Mercurial > hg > GearsTemplate
changeset 442:481fce540daf
Fix goto implement method of generate_stub
author | Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 21 Nov 2017 09:16:12 +0900 |
parents | 5a737c3df91c |
children | ff2764cb5edb |
files | src/parallel_execution/Atomic.cbc src/parallel_execution/SingleLinkedStack.cbc src/parallel_execution/generate_stub.pl src/parallel_execution/test/queue_test.cbc src/parallel_execution/test/stack_test.c src/parallel_execution/test/stack_test.cbc |
diffstat | 6 files changed, 23 insertions(+), 85 deletions(-) [+] |
line wrap: on
line diff
--- a/src/parallel_execution/Atomic.cbc Tue Nov 21 04:28:36 2017 +0900 +++ b/src/parallel_execution/Atomic.cbc Tue Nov 21 09:16:12 2017 +0900 @@ -1,6 +1,6 @@ typedef struct Atomic<Type, Impl>{ - Type* atomic; - Type* data; + union Data* atomic; + union Data* data; __code checkAndSet(Impl* atomic, Type* data, __code next(...)); __code next(...); } Atomic;
--- a/src/parallel_execution/SingleLinkedStack.cbc Tue Nov 21 04:28:36 2017 +0900 +++ b/src/parallel_execution/SingleLinkedStack.cbc Tue Nov 21 09:16:12 2017 +0900 @@ -40,7 +40,7 @@ goto next(...); } -__code pushSingleLinkedStack(struct SingleLinkedStack* stack,union Data* data, __code next(...)) { +__code pushSingleLinkedStack(struct SingleLinkedStack* stack, union Data* data, __code next(...)) { Element* element = new Element(); element->next = stack->top; element->data = data;
--- a/src/parallel_execution/generate_stub.pl Tue Nov 21 04:28:36 2017 +0900 +++ b/src/parallel_execution/generate_stub.pl Tue Nov 21 09:16:12 2017 +0900 @@ -68,7 +68,7 @@ # # generated meta level code # -# Gearef(context, Stack)->stack = nodeStack->stack; +# Gearef(context, Stack)->stack = (union Data*)nodeStack; # Gearef(context, Stack)->data = (union Data*)node; # Gearef(context, Stack)->next = C_stackTest3; # goto meta(context, nodeStack->push); @@ -102,9 +102,9 @@ if ( -f "$interface.cbc") { &getDataGear("$interface.cbc"); } - } elsif (/^(\s)*(\w+)\-\>(\w+)\s\=\s\((.*)\)create(\w+)\((.*)\);$/) { + } elsif (/\s*\=\s*(.*)create(\w+)\((.*)\);$/) { #my $intfn = ucfirst($2); - my $impln = $5; + my $impln = $2; if ( -f "$impln.cbc") { &getCodeGear("$impln.cbc"); } @@ -393,7 +393,7 @@ $ftype = lcfirst($ntype); } } - print $fd "\tGearef(context, $ntype)->$ftype = $next->$ftype;\n"; + print $fd "\tGearef(context, $ntype)->$ftype = (union Data*) $next;\n"; # Put interface argument my $prot = $code{$ntype}->{$method}; my $i = 1; @@ -415,7 +415,7 @@ } $i++; } - print $fd "${prev}goto meta(context, $next->$ftype->$ntype.$method);\n"; + print $fd "${prev}goto meta(context, $next->$method);\n"; next; } elsif(/^(.*)par goto (\w+)\((.*)\);/) { # handling par goto statement
--- a/src/parallel_execution/test/queue_test.cbc Tue Nov 21 04:28:36 2017 +0900 +++ b/src/parallel_execution/test/queue_test.cbc Tue Nov 21 09:16:12 2017 +0900 @@ -2,12 +2,16 @@ #include <assert.h> __code queueTest1(struct Queue* queue) { - queue->queue = (union Data*)createSingleLinkedQueue(context); Node* node = new Node(); node->color = Red; goto queue->put(node, queueTest2); } +__code queueTest1_stub(struct Context* context) { + Queue* queue = createSingleLinkedQueue(context); + goto queueTest1(context, queue); +} + __code queueTest2(struct Queue* queue) { Node* node = new Node(); node->color = Black; @@ -18,7 +22,7 @@ SingleLinkedQueue* singleLinkedQueue = (SingleLinkedQueue*)GearImpl(context, Queue, queue); assert(singleLinkedQueue->top->next->data->Node.color == Red); assert(singleLinkedQueue->last->data->Node.color == Red); - Queue* queue = Gearef(context, Queue); + Queue* queue = (struct Queue*)Gearef(context, Queue)->queue; goto queueTest2(context, queue); } @@ -30,7 +34,7 @@ SingleLinkedQueue* singleLinkedQueue = (SingleLinkedQueue*)GearImpl(context, Queue, queue); assert(singleLinkedQueue->top->next->data->Node.color == Red); assert(singleLinkedQueue->last->data->Node.color == Black); - Queue* queue = Gearef(context, Queue); + Queue* queue = (struct Queue*)Gearef(context, Queue)->queue; goto queueTest3(context, queue); } @@ -42,8 +46,5 @@ } int main(int argc, char const* argv[]) { - struct Context* main_context = NEW(struct Context); - initContext(main_context); - main_context->next = C_queueTest1; - goto start_code(main_context); + goto queueTest1(); }
--- a/src/parallel_execution/test/stack_test.c Tue Nov 21 04:28:36 2017 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -#include "../../context.h" -#include <assert.h> - -__code stackTest1(struct Context *context,struct Stack* stack) { - stack->stack = (union Data*)createSingleLinkedStack(context); - Node* node = &ALLOCATE(context, Node)->Node; - node->color = Red; - Gearef(context, Stack)->stack = stack->stack; - Gearef(context, Stack)->data = node; - Gearef(context, Stack)->next = stackTest2; - goto meta(context, stack->stack->Stack.push); -} - -__code stackTest1_stub(struct Context* context) { - Stack* stack = Gearef(context, Stack); - goto stackTest1(context, stack); -} - -__code stackTest2(struct Context *context,struct Stack* stack) { - Node* node = &ALLOCATE(context, Node)->Node; - node->color = Black; - Gearef(context, Stack)->stack = stack->stack; - Gearef(context, Stack)->data = node; - Gearef(context, Stack)->next = stackTest3; - goto meta(context, stack->stack->Stack.push); -} - -__code stackTest2_stub(struct Context* context) { - SingleLinkedStack* singleLinkedStack = &stack->stack->Stack.stack->SingleLinkedStack; - assert(singleLinkedStack->top->data->Node.color == Red); - Stack* stack = Gearef(context, Stack); - goto stackTest2(context, stack); -} - -__code stackTest3(struct Context *context,struct Stack* stack) { - Gearef(context, Stack)->stack = stack->stack; - Gearef(context, Stack)->next = assert3; - goto meta(context, stack->stack->Stack.pop); -} - -__code stackTest3_stub(struct Context* context) { - /* - assert on stack implementation - */ - SingleLinkedStack* singleLinkedStack = &stack->stack->Stack.stack->SingleLinkedStack; - assert(singleLinkedStack->top->data->Node.color == Black); - Stack* stack = Gearef(context, Stack); - goto stackTest3(context, stack); -} - -__code assert3(struct Context *context,struct Node* node, struct Stack* stack) { - /* - assert in normal level - */ - assert(node->color == Red); - goto exit_code(0); -} - -int main(int argc, char const* argv[]) { - goto stackTest1(); -} -__code assert3_stub(struct Context* context) { - Node* node = Gearef(context, Node); - Stack* stack = Gearef(context, Stack); - goto assert3(context, node, stack); -} -
--- a/src/parallel_execution/test/stack_test.cbc Tue Nov 21 04:28:36 2017 +0900 +++ b/src/parallel_execution/test/stack_test.cbc Tue Nov 21 09:16:12 2017 +0900 @@ -2,12 +2,16 @@ #include <assert.h> __code stackTest1(struct Stack* stack) { - stack->stack = (union Data*)createSingleLinkedStack(context); Node* node = new Node(); node->color = Red; goto stack->push(node, stackTest2); } +__code stackTest1_stub(struct Context* context) { + Stack* stack = createSingleLinkedStack(context); + goto stackTest1(context, stack); +} + __code stackTest2(struct Stack* stack) { Node* node = new Node(); node->color = Black; @@ -17,7 +21,7 @@ __code stackTest2_stub(struct Context* context) { SingleLinkedStack* singleLinkedStack = (SingleLinkedStack*)GearImpl(context, Stack, stack); assert(singleLinkedStack->top->data->Node.color == Red); - Stack* stack = Gearef(context, Stack); + Stack* stack = (struct Stack*)Gearef(context, Stack)->stack; goto stackTest2(context, stack); } @@ -31,7 +35,7 @@ */ SingleLinkedStack* singleLinkedStack = (SingleLinkedStack*)GearImpl(context, Stack, stack); assert(singleLinkedStack->top->data->Node.color == Black); - Stack* stack = Gearef(context, Stack); + Stack* stack = (struct Stack*)Gearef(context, Stack)->stack; goto stackTest3(context, stack); }