Mercurial > hg > Members > menikon > CbC_xv6
diff src/gearsTools/lib/Gears/Util.pm @ 112:b9df8ea87b42
fix trans_impl.pl
author | anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 28 Nov 2019 16:58:04 +0900 |
parents | 8c7c1ea49f21 |
children | efff86f375ed |
line wrap: on
line diff
--- a/src/gearsTools/lib/Gears/Util.pm Thu Nov 28 12:17:05 2019 +0900 +++ b/src/gearsTools/lib/Gears/Util.pm Thu Nov 28 16:58:04 2019 +0900 @@ -63,7 +63,7 @@ next; } next if ($line =~ /^\s+$/); - next if ($line =~ m[^//]); + next if ($line =~ m[^\s*//]); next if ($line =~ m[^\}\s*$ir->{name};]); if ($line =~ m|__code (\w+)\(([()\.\*\s\w,_]+)\)|) { @@ -76,6 +76,32 @@ return $ir; } +sub parse_with_rewrite { + my ($class, $file) = @_; + my $ir = _parse_base($file); + + my @data_gears; + my @code_gears; + map { push (@data_gears, $_) unless ($_ =~ /enum Code/);} @{$ir->{content}}; + map { push (@code_gears, $1) if ($_ =~ /enum Code (\w+);/);} @{$ir->{content}}; + + open my $fh , '<', $file; + my $i = 0; + while (($i < scalar @code_gears) && (my $line = <$fh>)) { + my $cg = $code_gears[$i]; + if ($line =~ m|__code $cg\(([()\.\*\s\w,_]+)\)|) { + $code_gears[$i] = { + name => $cg, + args => $1, + }; + $i++; + } + } + $ir->{codes} = \@code_gears; + $ir->{data} = \@data_gears; + return $ir; +} + sub file_checking { my ($class, $file_name) = @_; unless (-f $file_name) { @@ -116,7 +142,7 @@ my $find_path = shift // "."; my @files; - find( { wanted => sub { push @files, $_ if /\.h/ }, no_chdir => 1 }, $find_path); + find( { wanted => sub { push @files, $_ if /\.(?:h|dg)/ }, no_chdir => 1 }, $find_path); return \@files; } @@ -148,4 +174,5 @@ return $context; } + 1;