changeset 718:7c79694229d3

check impl interface CodeGear
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Tue, 01 Sep 2020 20:32:46 +0900
parents 1595fc808041
children 2316193f7999
files src/parallel_execution/CMakeLists.txt src/parallel_execution/examples/pop_and_push/StackTestImpl3.cbc src/parallel_execution/examples/pop_and_push/main.cbc src/parallel_execution/generate_stub.pl src/parallel_execution/lib/Gears/Stub.pm
diffstat 5 files changed, 35 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/src/parallel_execution/CMakeLists.txt	Tue Sep 01 15:59:32 2020 +0900
+++ b/src/parallel_execution/CMakeLists.txt	Tue Sep 01 20:32:46 2020 +0900
@@ -146,7 +146,7 @@
   TARGET
   pop_and_push
   SOURCES
-  examples/pop_and_push/main.cbc  examples/pop_and_push/StackTestImpl.cbc TaskManagerImpl.cbc CPUWorker.cbc SynchronizedQueue.cbc AtomicReference.cbc SingleLinkedStack.cbc examples/pop_and_push/StackTest2Impl.cbc
+  examples/pop_and_push/main.cbc  examples/pop_and_push/StackTestImpl.cbc TaskManagerImpl.cbc CPUWorker.cbc SynchronizedQueue.cbc AtomicReference.cbc SingleLinkedStack.cbc examples/pop_and_push/StackTest2Impl.cbc examples/pop_and_push/StackTestImpl3.cbc
 )
 
 
--- a/src/parallel_execution/examples/pop_and_push/StackTestImpl3.cbc	Tue Sep 01 15:59:32 2020 +0900
+++ b/src/parallel_execution/examples/pop_and_push/StackTestImpl3.cbc	Tue Sep 01 20:32:46 2020 +0900
@@ -23,18 +23,18 @@
 
 
 __code pop2Test(struct StackTestImpl3* stackTest, struct Stack* stack, __code next(...)) {
-  goto stack->pop2(pop2Test1);
+    goto stack->pop2(pop2Test1);
 }
 
 __code pop2Test3(struct StackTestImpl3* stackTest, struct Stack* stack, __code next(union Data* data, union Data* data1, ...)) {
-  String* str = NEW(String);
-  str->size = 200;
-  String* str1 = NEW(String);
-  str1->size = 300;
-  data = (union Data*)str;
-  data1 = (union Data*)str1;
+    String* str = NEW(String);
+    str->size = 200;
+    String* str1 = NEW(String);
+    str1->size = 300;
+    data = (union Data*)str;
+    data1 = (union Data*)str1;
 
-  goto pop2Test1(stackTest, data, data1);
+    goto pop2Test1(stackTest, data, data1);
 }
 
 
--- a/src/parallel_execution/examples/pop_and_push/main.cbc	Tue Sep 01 15:59:32 2020 +0900
+++ b/src/parallel_execution/examples/pop_and_push/main.cbc	Tue Sep 01 20:32:46 2020 +0900
@@ -39,7 +39,7 @@
 
 __code createTask1(struct LoopCounter* loopCounter, struct TaskManager* taskManager) {
     Stack* stack = createSingleLinkedStack(context);
-    StackTest* stackTest = createStackTestImpl(context);
+    StackTest* stackTest = createStackTestImpl3(context);
     goto stackTest->insertTest1(stack, code2);
 }
 
--- a/src/parallel_execution/generate_stub.pl	Tue Sep 01 15:59:32 2020 +0900
+++ b/src/parallel_execution/generate_stub.pl	Tue Sep 01 20:32:46 2020 +0900
@@ -309,8 +309,23 @@
         }
     }
 
+
+    if ($implInterfaceInfo->{isImpl}) {
+      for my $shouldImplCode (map { $_->{name} } @{$implInterfaceInfo->{parsedInterfaceInfo}->{codes}}) {
+        my $isDefine = $shouldImplCode;
+        for my $implCode (keys %{$codeGearInfo}) {
+          if ($implCode =~  /$shouldImplCode/) {
+            $isDefine = 1;
+            next;
+          }
+        }
+
+        if ($isDefine ne 1) {
+          die "[ERROR] Not define $isDefine at $filename\n";
+        }
+      }
+    }
     $filename2EachCodeGearArgs{$filename} = $codeGearInfo;
-
 }
 
 sub includeInterface {
--- a/src/parallel_execution/lib/Gears/Stub.pm	Tue Sep 01 15:59:32 2020 +0900
+++ b/src/parallel_execution/lib/Gears/Stub.pm	Tue Sep 01 20:32:46 2020 +0900
@@ -29,11 +29,14 @@
 
   my $constructor;
 
+    #  struct StackTest2* stackTest2  = &ALLOCATE(context, StackTest2)->StackTest2;
+    #struct StackTest2Impl* stack_test2impl = &ALLOCATE(context, StackTest2Impl)->StackTest2Impl;
+
   $constructor .=  <<"EOF";
 $impl_ir->{isa}* create$impl_ir->{name}(struct Context* context) {
-    struct $impl_ir->{isa}* $interface_name  = new $impl_ir->{isa}();
-    struct $impl_ir->{name}* $impl_name = new $impl_ir->{name}();
-    $interface_name->$interface_name = (union Data*)$impl_name;
+    struct $impl_ir->{isa}* $interface_var_name  = &ALLOCATE(context, $impl_ir->{isa})->$impl_ir->{isa};
+    struct $impl_ir->{name}* $impl_name = &ALLOCATE(context, $impl_ir->{name})->$impl_ir->{name};
+    $interface_var_name->$interface_var_name = (union Data*)$impl_name;
 EOF
 
   $constructor .= _generate_variable_initialization($interface_ir->{data}, $interface_var_name);
@@ -44,16 +47,16 @@
   for my $code (@{$impl_ir->{codes}}) {
       my $code_gear = $code->{name};
       next if $code_gear eq 'next';
-      $constructor .= "    ${impl_name}->$code_gear = C_$code_gear;\n"
+      $constructor .= "    ${impl_var_name}->$code_gear = C_$code_gear;\n"
   }
 
   for my $code (@{$interface_ir->{codes}}) {
       my $code_gear = $code->{name};
       next if $code_gear eq 'next';
-      $constructor .= "    ${interface_name}->$code_gear = C_${code_gear}$impl_ir->{name};\n"
+      $constructor .= "    ${interface_var_name}->$code_gear = C_${code_gear}$impl_ir->{name};\n"
   }
 
-  $constructor .= "    return $interface_name;\n";
+  $constructor .= "    return $interface_var_name;\n";
   $constructor .= "}\n";
 
   return $constructor;