Mercurial > hg > Gears > GearsAgda
changeset 262:2c56a9536c0d
add comments
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 28 Jan 2017 16:04:38 +0900 |
parents | 0cd43e22aee1 |
children | 18b43cdc8ee5 |
files | src/parallel_execution/generate_stub.pl |
diffstat | 1 files changed, 16 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/parallel_execution/generate_stub.pl Sat Jan 28 15:48:54 2017 +0900 +++ b/src/parallel_execution/generate_stub.pl Sat Jan 28 16:04:38 2017 +0900 @@ -161,11 +161,13 @@ my $args = $2; my $tail = $3; if ($codeGearName =~ /_stub$/) { + # don't touch already existing stub $stub{$codeGearName} = 1; print $fd $_; next; } if (defined $prevCodeGearName) { + # stub is generated just before next CodeGear if (defined $stub{$prevCodeGearName."_stub"}) { undef $prevCodeGearName; print $fd $_; @@ -173,6 +175,11 @@ } $stub{$prevCodeGearName."_stub"} = &generateStub($fd,$prevCodeGearName,$dataGearName{$prevCodeGearName}); } + # analyzing CodeGear argument + # these arguments are extract from current context's arugment DataGear Interface + # and passed to the CodeGear + # struct Implementaion needs special handling + # __code next(...) ---> enum Code next $prevCodeGearName = $codeGearName; $dataGearVar{$codeGearName} = []; $outputVar{$codeGearName} = ""; @@ -182,13 +189,16 @@ if ($args =~ s/(^\s*,\s*)//) { $newArgs .= $1; } - # replace __code next + # continuation case if ($args =~ s/^\_\_code\s+(\w+)\(([^)]*)\)//) { my $next = $1; my @args = split(/,/,$2); if ( &generateStubArgs($codeGearName, $next, "Code", $next, $interface,0) ) { $newArgs .= "enum Code $next"; } + # analyze continuation arguments + # output arguments are defined in the Interface take the pointer of these + # output arguments are put into the Interface DataGear just before the goto for my $arg (@args) { $arg =~ s/^\s*//; last if ($arg =~ /\.\.\./); @@ -216,21 +226,25 @@ last; } } + # generate goto statement from stub to the CodeGear in the buffer $dataGearName{$codeGearName} .= "\tgoto $codeGearName(context"; for my $arg ( @{$dataGearVar{$codeGearName}}) { $dataGearName{$codeGearName} .= ", $arg"; } $dataGearName{$codeGearName} .= ");"; + # generate CodeGear header with new arguments print $fd "__code $codeGearName($newArgs)$tail\n"; if ($outputVar{$codeGearName} ne "") { print $fd $outputVar{$codeGearName}; } next; } elsif (/^(.*)goto (\w+)\((.*)\);/) { + # handling got 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 + # 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);