diff src/parallel_execution/generate_stub.pl @ 715:fd9b9fa4ec98

fix pop_and_push test
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Fri, 28 Aug 2020 16:43:39 +0900
parents d5bd1c640db0
children 284fa7d7326e
line wrap: on
line diff
--- a/src/parallel_execution/generate_stub.pl	Fri Aug 28 12:24:42 2020 +0900
+++ b/src/parallel_execution/generate_stub.pl	Fri Aug 28 16:43:39 2020 +0900
@@ -135,9 +135,9 @@
                 $code{$name} = {};
                 $generic{$name} = [];
             } elsif (/^(\w+)(\*)+ create(\w+)\(/) { # this case implementation constructor
-                if (defined $implInterfaceInfo->{interface} ) {
-                   die "duplicate interface $implInterfaceInfo->{interface}\n";
-                }
+              #if (defined $implInterfaceInfo->{interface} ) {
+              #     die "duplicate interface $implInterfaceInfo->{interface}\n";
+              #  }
                 my $interfaceName = $1;
                 $implInterfaceInfo->{isImpl} = 1;
                 $implInterfaceInfo->{interface} = $interfaceName;
@@ -567,6 +567,8 @@
                 $inTypedef = 1;
             } elsif (/^int main\((.*)\) \{/) {
                 $inMain = 1;
+            } elsif(/^#impl "(.*)"/) {
+              next;
             } elsif(/^#interface "(.*)"/) {
                 my $interfaceHeader = $1;
                 # #interface not write
@@ -656,9 +658,9 @@
                             my $typeName = $2;
                             my $ptrType = $3;
                             my $varName = $4;
-                        if ($structType =~ /(const|enum)/) {
-                            $typeName = "$structType $typeName";
-                        }
+                            if ($structType =~ /(const|enum)/) {
+                                $typeName = "$structType $typeName";
+                            }
                             my $typeField = lcfirst($typeName);
                             push(@{$outputArgs{$codeGearName}->{$next}}, $varName);
                             if (generateStubArgs($codeGearName, $varName, $typeName, $ptrType, $typeField, $implInterfaceInfo,1)) {
@@ -877,6 +879,13 @@
                     # continuation arguments
                     $v = 1  if ( $n eq $next);
                 }
+
+                if (exists_codegear_in_interface({codeGearName => $next, parsedInfo => $implInterfaceInfo->{parsedInterfaceInfo}})) {
+                    my $replaceCodeGear = "${next}$implInterfaceInfo->{implementation}"; #${pop}SingleLinkedStack
+                    if ($replaceCodeGearNames->{$next}) {
+                      $next = $replaceCodeGear;
+                    }
+                }
                 if ($v || ($implInterfaceInfo->{isImpl} && defined $code{$implInterfaceInfo->{interface}}->{$next})) {
                     # write continuation's arguments into the interface arguments
                     # we may need a commit for a shared DataGear
@@ -940,7 +949,7 @@
     }
     if (defined $prevCodeGearName) {
         if (!defined $stub{$prevCodeGearName."_stub"}->{wrote}) {
-            $stub{$prevCodeGearName."_stub"} = &generateStub($fd,$prevCodeGearName,$dataGearName{$codeGearName});
+            $stub{$prevCodeGearName."_stub"}->{wrote} = &generateStub($fd,$prevCodeGearName,$dataGearName{$codeGearName});
         }
     }