Mercurial > hg > Members > Moririn
diff src/parallel_execution/generate_stub.pl @ 278:23767f714f4a
fix generate_stub
author | mir3636 |
---|---|
date | Thu, 02 Feb 2017 20:27:56 +0900 |
parents | d14eb393023d |
children | 2c2e4e597eb0 |
line wrap: on
line diff
--- a/src/parallel_execution/generate_stub.pl Thu Feb 02 18:29:50 2017 +0900 +++ b/src/parallel_execution/generate_stub.pl Thu Feb 02 20:27:56 2017 +0900 @@ -149,11 +149,12 @@ my $prevCodeGearName; my $inTypedef = 0; + my $inStub = 0; my %stub; my $codeGearName; while (<$in>) { - if (! $inTypedef) { + if (! $inTypedef && ! $inStub) { if (/^typedef struct (\w+) {/) { $inTypedef = 1; } elsif (/^\_\_code (\w+)\((.*)\)(.*)/) { @@ -162,6 +163,7 @@ my $tail = $3; if ($codeGearName =~ /_stub$/) { # don't touch already existing stub + $inStub = 1; $stub{$codeGearName} = 1; print $fd $_; next; @@ -170,10 +172,10 @@ # stub is generated just before next CodeGear if (defined $stub{$prevCodeGearName."_stub"}) { undef $prevCodeGearName; - print $fd $_; - next; + } else { + &generateStub($fd,$prevCodeGearName,$dataGearName{$prevCodeGearName}); + $stub{$prevCodeGearName."_stub"} = 1; } - $stub{$prevCodeGearName."_stub"} = &generateStub($fd,$prevCodeGearName,$dataGearName{$prevCodeGearName}); } # analyzing CodeGear argument # these arguments are extract from current context's arugment DataGear Interface @@ -239,24 +241,27 @@ } next; } elsif (/^(.*)goto (\w+)\((.*)\);/) { - # handling got statement + # 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 @args = split(/,/,$3); - # write continuation's arguments into the interface arguments - # we may need a commit for a shared DataGear - for my $arg ( @{$outputArgs{$codeGearName}->{$next}} ) { - my $v = shift(@args); - print $fd "\t*O_$arg = $v;\n"; + if (defined $code{$interface}->{$next}) { + # write continuation's arguments into the interface arguments + # we may need a commit for a shared DataGear + for my $arg ( @{$outputArgs{$codeGearName}->{$next}} ) { + my $v = shift(@args); + print $fd "\t*O_$arg = $v;\n"; + } + print $fd "${prev}goto meta(context, $next);\n"; + next; } - print $fd "${prev}goto meta(context, $next);\n"; - next; } else { s/new\s+(\w+)\(\)/\&ALLOCATE(context, \1)->\1/g; # replacing new } # gather type name and type } elsif (/^}/) { + $inStub = 0; $inTypedef = 0; } print $fd $_;