Mercurial > hg > Gears > Gears
changeset 895:9fe2d98d0684
replace meta
author | anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 26 Jan 2021 15:04:48 +0900 |
parents | ff670811f17a |
children | f978f88ada11 |
files | src/parallel_execution/examples/DPPMC/meta.pm src/parallel_execution/generate_stub.pl |
diffstat | 2 files changed, 16 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/src/parallel_execution/examples/DPPMC/meta.pm Tue Jan 26 14:52:06 2021 +0900 +++ b/src/parallel_execution/examples/DPPMC/meta.pm Tue Jan 26 15:04:48 2021 +0900 @@ -9,9 +9,10 @@ ); } +#my ($currentCodeGearName, $context, $next) = @_; sub generateMcMeta { - my ($currentCodeGear, $context, $next) = @_; + my ($context, $next) = @_; return "goto mcMeta($context, $next);\n"; }
--- a/src/parallel_execution/generate_stub.pl Tue Jan 26 14:52:06 2021 +0900 +++ b/src/parallel_execution/generate_stub.pl Tue Jan 26 15:04:48 2021 +0900 @@ -604,7 +604,7 @@ my ($filename, $inputCbCFile) = @_; open my $in,"<",$filename or die("can't open $filename $!"); - my $generateMeta = findAndLoadMetaPM($filename); + my $generateMeta = createGotoMetaFunction($filename); my $fn; if ($opt_o) { @@ -1335,24 +1335,29 @@ } #my $goto_meta = "${prev}goto meta(${context_name}, $next->$method);\n"; -sub generateMeta { - my ($currentCodeGear, $context, $next) = @_; +sub generateDefaultgotoMeta { + my (undef, $context, $next) = @_; return "goto meta($context, $next);\n"; } -sub findAndLoadMetaPM { +sub createGotoMetaFunction { my $filename = shift; my $project_dir_name = dirname $filename; my $metapm = "$FindBin::Bin/$project_dir_name/meta.pm"; unless (-f $metapm) { #default case - return sub { - my (undef, $context, $next) = @_; - return "goto meta($context, $next);\n"; - }; + return \&generateDefaultgotoMeta; } load $metapm; print "[info] load $metapm\n"; - print STDERR meta->hello(); + my @replaceMeta = meta->replaceMeta(); + return sub { + my ($currentCodeGearName, $context, $next) = @_; + my $generator = shift @{[ map { $_->[1] } grep { $currentCodeGearName =~ $_->[0] } @replaceMeta ] }; + unless ($generator) { + return generateDefaultgotoMeta(undef, $context, $next); + } + return $generator->($context, $next); + }; }