Mercurial > hg > Members > Moririn
diff src/parallel_execution/generate_stub.pl @ 418:a74bec89c198
generate main
author | mir3636 |
---|---|
date | Fri, 06 Oct 2017 14:39:36 +0900 |
parents | eec6553a2aa6 |
children | d839c9cb7c83 |
line wrap: on
line diff
--- a/src/parallel_execution/generate_stub.pl Thu Oct 05 17:00:48 2017 +0900 +++ b/src/parallel_execution/generate_stub.pl Fri Oct 06 14:39:36 2017 +0900 @@ -278,13 +278,16 @@ my $inTypedef = 0; my $inStub = 0; my $inParGoto = 0; + my $inMain = 0 ; my %stub; my $codeGearName; while (<$in>) { - if (! $inTypedef && ! $inStub) { + if (! $inTypedef && ! $inStub && ! $inMain) { if (/^typedef struct (\w+) {/) { $inTypedef = 1; + } elsif (/^int main\((.*)\) {/) { + $inMain = 1; } elsif (/^\_\_code (\w+)\((.*)\)(.*)/) { $codeGearName = $1; my $args = $2; @@ -513,9 +516,23 @@ s/new\s+(\w+)\(\)/\&ALLOCATE(context, \1)->\1/g; # replacing new } # gather type name and type - } elsif (/^}/) { + } elsif ($inMain) { + if (/^(.*)goto start_code\(main_context\);/) { + next; + } elsif (/^(.*)goto (\w+)\((.*)\);/) { + my $prev = $1; + my $next = $2; + print $fd "${prev}struct Context* main_context = NEW(struct Context);\n"; + print $fd "${prev}initContext(main_context);\n"; + print $fd "${prev}main_context->next = C_$next;\n"; + print $fd "${prev}goto start_code(main_context);\n"; + next; + } + } + if (/^}/) { $inStub = 0; $inTypedef = 0; + $inMain = 0; } print $fd $_; }