comparison src/parallel_execution/trans_impl.pl @ 557:1eb2a22ec1e3

tweak
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Mon, 18 Nov 2019 21:22:34 +0900
parents a0b7eb5e58c0
children 8a825fc15817
comparison
equal deleted inserted replaced
556:a0b7eb5e58c0 557:1eb2a22ec1e3
1 #!/usr/bin/env perl 1 #!/usr/bin/env perl
2 use strict; 2 use strict;
3 use warnings; 3 use warnings;
4
5 use FindBin;
6 use lib "$FindBin::Bin/lib";
7 use Gears::Util;
8
4 use DDP { deparse => 1}; 9 use DDP { deparse => 1};
5 use CbC::Util;
6 10
7 #my $impl_file = shift or die 'require impl file'; 11 my $impl_file = shift or die 'require impl file';
8 #my $impl = parse_impl($impl_file); 12 my $ir = Gears::Util->parse_impl($impl_file);
9 13 my $hoge = Gears::Util->find_interface($ir->{isa});
10 my $hoge = CbC::Util->parse_impl(shift); 14 my $foo = Gears::Util->slup($hoge);
11 p $hoge;
12
13 sub slup {
14 my $file = shift;
15 open my $fh, '<', $file;
16 local $/;
17 my $f = <$fh>;
18 return $f;
19 }
20
21
22 sub parse_impl {
23 my $file = shift;
24
25 unless (-f $file) {
26 die "invlid file path: $file\n";
27 }
28
29 open my $fh, '<', $file;
30 my $impl = {
31 impl => undef,
32 isa => undef,
33 codes => [],
34 deta => [],
35 };
36
37 while (my $line = <$fh>) {
38 if ($line =~ m|^/\*|) {
39 while ( $line !~ m|\*/|) {
40 $line = <$fh>;
41 next;
42 }
43 next;
44 }
45
46 if ($line =~ m|typedef struct ([\w]+)\s*<Type,\s*Isa>\s*impl\s*([\w+]+)\s*{|) {
47 $impl->{impl} = $1;
48 $impl->{isa} = $2;
49 next;
50 }
51
52 next if ($line =~ /^\s+$/);
53 next if ($line =~ m[//|}]);
54
55 if ($line =~ /__code (\w+)\(.*/) {
56 push(@{$impl->{codes}},$1);
57 next;
58 }
59
60 $line =~ s/\s*([\w\s\*]+);\s*/$1/;
61 push(@{$impl->{deta}},$1);
62 }
63 return $impl;
64 }
65