# HG changeset patch # User anatofuz # Date 1597815792 -32400 # Node ID 17822e599e3f874ecf24e556d5e50787ed2b03c7 # Parent 2092dd29cc96db45e7a998ee444d0e06ece716b2 ... diff -r 2092dd29cc96 -r 17822e599e3f src/parallel_execution/generate_stub.pl --- a/src/parallel_execution/generate_stub.pl Wed Aug 19 12:45:04 2020 +0900 +++ b/src/parallel_execution/generate_stub.pl Wed Aug 19 14:43:12 2020 +0900 @@ -112,10 +112,11 @@ sub getDataGear { my ($filename) = @_; - my ($codeGearName, $name, $inTypedef,$described_data_gear); + my ($codeGearName, $name, $inTypedef,$described_data_gear, $codeGearName2Args); open my $fd,"<",$filename or die("can't open $filename $!"); while (<$fd>) { if (! $inTypedef) { + #this scope is usually parsing cbc file if (/^typedef struct (\w+)\s*<(.*)>/) { $inTypedef = 1; $name = $1; @@ -136,13 +137,15 @@ } $interface = $1; $implementation = $3; - if ($search_cbc_from_code_gear_and_filename->($interface, $filename)) { - &getDataGear($search_cbc_from_code_gear_and_filename->($interface, $filename)); + my $cbc_source_path = $search_cbc_from_code_gear_and_filename->($interface, $filename); + if ($cbc_source_path) { + &getDataGear($cbc_source_path); } } elsif(/^(.*)par goto (\w+)\((.*)\)/) { my $codeGearName = $2; - if ($search_cbc_from_code_gear_and_filename->($codeGearName, $filename)) { - &getCodeGear($search_cbc_from_code_gear_and_filename->($codeGearName, $filename)); + my $cbc_source_path = $search_cbc_from_code_gear_and_filename->($codeGearName, $filename); + if ($cbc_source_path) { + &getCodeGear($cbc_source_path); } } elsif(/^#interface "(.*)"/) { # use interface @@ -151,15 +154,29 @@ $interfaceHeader =~ m|(\w+)\.\w+$|; #remove filename extention my $interfaceName = $1; $call_interfaces{$filename}->{$interfaceName} = 1; - if (exists $interface_name_to_header_path->{$interfaceName}) { - &getDataGear($interface_name_to_header_path->{$interfaceName}); - &getCodeGear($interface_name_to_header_path->{$interfaceName}); + my $interface_path = $interface_name_to_header_path->{$interfaceName}; + if ($interface_path) { + &getDataGear($interface_path); + &getCodeGear($interface_path); } } elsif (/^\_\_code (\w+)\((.*)\)(.*)/) { my $codeGearName = $1; - if ($search_cbc_from_code_gear_and_filename->($codeGearName, $filename)) { - &getCodeGear($search_cbc_from_code_gear_and_filename->($codeGearName, $filename)); + my $args = $2; + my $cbc_source_path = $search_cbc_from_code_gear_and_filename->($codeGearName, $filename); + if ($cbc_source_path) { + &getCodeGear($cbc_source_path); } + my $tname2type = parseCodeGearDeclarationArg($args); + for my $tname (keys %$tname2type) { + $codeGearName2Args->{$codeGearName}->{$tname} = $tname2type->{$tname}; + } + } elsif (/^(.*)goto (\w+)\-\>(\w+)\((.*)\);/) { + # handling goto statement + # convert it to the meta call form with two arugments, that is context and enum Code + my $prev = $1; + my $next = $2; + my $method = $3; + my $tmpArgs = $4; } next; } @@ -187,17 +204,9 @@ if (/__code (\w+)/) { next if $described_data_gear; my $args = $'; - while ($args =~ /\s*(struct|union|const|enum)?\s*([\w\[\]_]+)\*?\s*(\w+),?/g) { - #$args eq (Impl* vm, pde_t* pgdir, char* init, uint sz, __code next(...)); - my $const_type = $1; - my $ttype = $2; - my $tname = $3; - - $ttype =~ s/(Impl|Isa|Type)/Data/; - if ($const_type && ($const_type =~ /(const|enum)/)) { - $ttype = "$1 $ttype"; - } - $var{$name}->{$tname} = $ttype; + my $tname2type = parseCodeGearDeclarationArg($args); + for my $tname (keys %$tname2type) { + $var{$name}->{$tname} = $tname2type->{$tname}; } } if (/^}/) { @@ -207,6 +216,24 @@ } +sub parseCodeGearDeclarationArg { + my ($args) = @_; + my %tname2type; + while ($args =~ /\s*(struct|union|const|enum)?\s*([\w\[\]_]+)\*?\s*(\w+),?/g) { + #$args eq (Impl* vm, pde_t* pgdir, char* init, uint sz, __code next(...)); + my $const_type = $1; + my $ttype = $2; + my $tname = $3; + + $ttype =~ s/(Impl|Isa|Type)/Data/; + if ($const_type && ($const_type =~ /(const|enum)/)) { + $ttype = "$1 $ttype"; + } + $tname2type{$tname} = $ttype; + } + return \%tname2type; +} + sub getCodeGear { my ($filename) = @_; open my $fd,"<",$filename or die("can't open $filename $!");