Mercurial > hg > GearsTemplate
changeset 140:f31b4e4bf4bb
fixes
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 09 Nov 2016 13:26:53 +0900 |
parents | c13b07d15d86 |
children | 4f6a660c14a1 |
files | src/parallel_execution/context.c src/parallel_execution/origin_cs.c src/parallel_execution/rb_tree.c src/parallel_execution/stack.c src/parallel_execution/stack.h |
diffstat | 5 files changed, 48 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- a/src/parallel_execution/context.c Wed Nov 09 10:13:31 2016 +0900 +++ b/src/parallel_execution/context.c Wed Nov 09 13:26:53 2016 +0900 @@ -17,7 +17,9 @@ extern __code replaceNode1_stub(struct Context*); extern __code insertNode_stub(struct Context*); extern __code rotateLeft_stub(struct Context*); +extern __code rotateLeft1_stub(struct Context*); extern __code rotateRight_stub(struct Context*); +extern __code rotateRight1_stub(struct Context*); extern __code colorFlip_stub(struct Context*); extern __code fixUp_stub(struct Context*); extern __code changeReference_stub(struct Context*); @@ -87,7 +89,9 @@ context->code[Replace1] = replaceNode1_stub; context->code[Insert] = insertNode_stub; context->code[RotateL] = rotateLeft_stub; + context->code[RotateL1] = rotateLeft1_stub; context->code[RotateR] = rotateRight_stub; + context->code[RotateR1] = rotateRight1_stub; context->code[InsertCase1] = insert1_stub; context->code[InsertCase2] = insert2_stub; context->code[InsertCase3] = insert3_stub; @@ -97,6 +101,15 @@ context->code[StackClear] = stackClear_stub; context->code[Get] = get_stub; context->code[Search] = search_stub; + + context->code[Search] = search_stub; + context->code[ PushSingleLinkedStack] = pushSingleLinkedStack_stub; + context->code[ PopSingleLinkedStack] = popSingleLinkedStack_stub; + context->code[ Pop2SingleLinkedStack] = pop2SingleLinkedStack_stub; + context->code[ GetSingleLinkedStack] = getSingleLinkedStack_stub; + context->code[ Get2SingleLinkedStack] = get2SingleLinkedStack_stub; + context->code[ IsEmptySingleLinkedStack] = isEmptySingleLinkedStack_stub; + /* context->code[Delete] = delete_stub; */ /* context->code[Delete1] = delete1_stub; */ /* context->code[Delete2] = delete2_stub; */
--- a/src/parallel_execution/origin_cs.c Wed Nov 09 10:13:31 2016 +0900 +++ b/src/parallel_execution/origin_cs.c Wed Nov 09 13:26:53 2016 +0900 @@ -1,7 +1,9 @@ #include <stdlib.h> +#include <stdio.h> #include "context.h" __code meta(struct Context* context, enum Code next) { + printf("meta %d\n",next); goto (context->code[next])(context); }
--- a/src/parallel_execution/rb_tree.c Wed Nov 09 10:13:31 2016 +0900 +++ b/src/parallel_execution/rb_tree.c Wed Nov 09 13:26:53 2016 +0900 @@ -140,8 +140,7 @@ } __code insert2_stub(struct Context* context) { - struct SingleLinkedStack *nodeStack = (struct SingleLinkedStack*)context->data[Traverse]->traverse.nodeStack->stack; - goto insertCase2(context, &context->data[Traverse]->traverse, &context->data[Stack]->stack, &nodeStack->top->data->node); + goto insertCase2(context, &context->data[Traverse]->traverse, &context->data[Stack]->stack, &context->data[Stack]->stack.data->node); } __code insertCase3(struct Context* context, struct Traverse* traverse, struct Stack* nodeStack, struct Node* parent, struct Node* grandparent) { @@ -170,8 +169,8 @@ __code insert3_stub(struct Context* context) { goto insertCase3(context, &context->data[Traverse]->traverse, &context->data[Stack]->stack, - &context->data[Traverse]->traverse.nodeStack->data->node, - &context->data[Traverse]->traverse.nodeStack->data1->node + &context->data[Stack]->stack.data->node, + &context->data[Stack]->stack.data1->node ); } @@ -199,19 +198,18 @@ __code insert4_stub(struct Context* context) { goto insertCase4(context, &context->data[Traverse]->traverse, context->data[Traverse]->traverse.current, - &context->data[Traverse]->traverse.nodeStack->data->node, - &context->data[Traverse]->traverse.nodeStack->data1->node); + &context->data[Stack]->stack.data->node, + &context->data[Stack]->stack.data1->node); } -__code insertCase5(struct Context* context, struct Traverse* traverse) { - struct Stack* nodeStack = traverse->nodeStack; +__code insertCase5(struct Context* context, struct Traverse* traverse,struct Stack *nodeStack) { nodeStack->stack = (union Data*)traverse->nodeStack; nodeStack->next = InsertCase51; - goto meta(context, nodeStack->get2); + goto meta(context, traverse->nodeStack->get2); } __code insert5_stub(struct Context* context) { - goto insertCase5(context, &context->data[Traverse]->traverse); + goto insertCase5(context, &context->data[Traverse]->traverse, &context->data[Stack]->stack); } __code insertCase51(struct Context* context, struct Traverse* traverse, struct Node* current, struct Node* parent, struct Node* grandparent) { @@ -227,22 +225,20 @@ } __code insert51_stub(struct Context* context) { - struct Traverse* traverse = &context->data[Traverse]->traverse; - struct Node* parent = &traverse->nodeStack->data->node; - struct Node* grandparent = &traverse->nodeStack->data1->node; + struct Node* parent = &context->data[Stack]->stack.data->node; + struct Node* grandparent = &context->data[Stack]->stack.data1->node; goto insertCase51(context, &context->data[Traverse]->traverse, context->data[Traverse]->traverse.current, parent, grandparent); } // put rotateLeft's continuation as argument -__code rotateLeft(struct Context* context, struct Traverse* traverse) { - struct Stack* nodeStack = traverse->nodeStack; +__code rotateLeft(struct Context* context, struct Traverse* traverse,struct Stack* nodeStack) { nodeStack->stack = (union Data*)traverse->nodeStack; nodeStack->next = RotateL1; - goto meta(context, nodeStack->get); + goto meta(context, traverse->nodeStack->get); } __code rotateLeft_stub(struct Context* context) { - goto rotateLeft(context, &context->data[Traverse]->traverse); + goto rotateLeft(context, &context->data[Traverse]->traverse, &context->data[Stack]->stack); } __code rotateLeft1(struct Context* context, struct Node* node, struct Tree* tree, struct Traverse* traverse, struct Node* parent) { @@ -265,8 +261,7 @@ } __code rotateLeft1_stub(struct Context* context) { - struct Traverse* traverse = &context->data[Traverse]->traverse; - struct Node* parent = &traverse->nodeStack->data->node; + struct Node* parent = &context->data[Stack]->stack.data->node; goto rotateLeft1(context, context->data[Traverse]->traverse.current, &context->data[Tree]->tree, @@ -274,14 +269,14 @@ parent); } -__code rotateRight(struct Context* context, struct Traverse* traverse) { - struct Stack* nodeStack = traverse->nodeStack; +__code rotateRight(struct Context* context, struct Traverse* traverse,struct Stack *nodeStack) { + nodeStack->stack = (union Data*)traverse->nodeStack; nodeStack->next = RotateR1; - goto meta(context, nodeStack->get); + goto meta(context, traverse->nodeStack->get); } __code rotateRight_stub(struct Context* context) { - goto rotateRight(context, &context->data[Traverse]->traverse); + goto rotateLeft(context, &context->data[Traverse]->traverse, &context->data[Stack]->stack); } __code rotateRight1(struct Context* context, struct Node* node, struct Tree* tree, struct Traverse* traverse, struct Node* parent) { @@ -304,8 +299,7 @@ } __code rotateRight1_stub(struct Context* context) { - struct Traverse* traverse = &context->data[Traverse]->traverse; - struct Node* parent = &traverse->nodeStack->data->node; + struct Node* parent = &context->data[Stack]->stack.data->node; goto rotateRight1(context, context->data[Traverse]->traverse.current, &context->data[Tree]->tree,
--- a/src/parallel_execution/stack.c Wed Nov 09 10:13:31 2016 +0900 +++ b/src/parallel_execution/stack.c Wed Nov 09 13:26:53 2016 +0900 @@ -42,7 +42,7 @@ __code pushSingleLinkedStack_stub(struct Context* context) { struct Element* element = &ALLOCATE(context, Element)->element; goto pushSingleLinkedStack(context, - (struct SingleLinkedStack *)&context->data[Stack]->stack.stack, + (struct SingleLinkedStack *)context->data[Stack]->stack.stack->stack.stack, element, context->data[Stack]->stack.data, context->data[Stack]->stack.next); @@ -60,7 +60,7 @@ __code popSingleLinkedStack_stub(struct Context* context) { goto popSingleLinkedStack(context, - (struct SingleLinkedStack *)context->data[Stack]->stack.stack, + (struct SingleLinkedStack *)context->data[Stack]->stack.stack->stack.stack, &context->data[Stack]->stack.data, context->data[Stack]->stack.next); } @@ -83,7 +83,7 @@ __code pop2SingleLinkedStack_stub(struct Context* context) { goto pop2SingleLinkedStack(context, - (struct SingleLinkedStack *)context->data[Stack]->stack.stack, + (struct SingleLinkedStack *)context->data[Stack]->stack.stack->stack.stack, &context->data[Stack]->stack.data, &context->data[Stack]->stack.data1, context->data[Stack]->stack.next); @@ -96,7 +96,7 @@ __code getSingleLinkedStack_stub(struct Context* context) { goto getSingleLinkedStack(context, - (struct SingleLinkedStack *)context->data[Stack]->stack.stack, + (struct SingleLinkedStack *)context->data[Stack]->stack.stack->stack.stack, &context->data[Stack]->stack.data, context->data[Stack]->stack.next); } @@ -111,13 +111,14 @@ } } else { *data = NULL; + *data1 = NULL; } goto meta(context, next); } __code get2SingleLinkedStack_stub(struct Context* context) { goto get2SingleLinkedStack(context, - (struct SingleLinkedStack *)context->data[Stack]->stack.stack, + (struct SingleLinkedStack *)context->data[Stack]->stack.stack->stack.stack, &context->data[Stack]->stack.data, &context->data[Stack]->stack.data1, context->data[Stack]->stack.next); @@ -132,7 +133,7 @@ __code isEmptySingleLinkedStack_stub(struct Context* context) { goto isEmptySingleLinkedStack(context, - (struct SingleLinkedStack *)context->data[Stack]->stack.stack, + (struct SingleLinkedStack *)context->data[Stack]->stack.stack->stack.stack, context->data[Stack]->stack.next, context->data[Stack]->stack.whenEmpty); }
--- a/src/parallel_execution/stack.h Wed Nov 09 10:13:31 2016 +0900 +++ b/src/parallel_execution/stack.h Wed Nov 09 13:26:53 2016 +0900 @@ -1,1 +1,8 @@ extern union Data* createSingleLinkedStack(struct Context* context); + +extern __code pushSingleLinkedStack_stub(struct Context* context) ; +extern __code popSingleLinkedStack_stub(struct Context* context) ; +extern __code pop2SingleLinkedStack_stub(struct Context* context) ; +extern __code getSingleLinkedStack_stub(struct Context* context) ; +extern __code get2SingleLinkedStack_stub(struct Context* context) ; +extern __code isEmptySingleLinkedStack_stub(struct Context* context) ;