Mercurial > hg > GearsTemplate
changeset 136:a747dc9d4da6
stack refactering no compile error
author | mir3636 |
---|---|
date | Tue, 08 Nov 2016 15:01:08 +0900 |
parents | 77a7ccb0d84d |
children | 909d0548284f |
files | src/parallel_execution/allocate.c src/parallel_execution/context.c src/parallel_execution/context.h src/parallel_execution/stack.c |
diffstat | 4 files changed, 45 insertions(+), 48 deletions(-) [+] |
line wrap: on
line diff
--- a/src/parallel_execution/allocate.c Tue Nov 08 14:29:31 2016 +0900 +++ b/src/parallel_execution/allocate.c Tue Nov 08 15:01:08 2016 +0900 @@ -1,4 +1,5 @@ #include "context.h" +#include "origin_cs.h" union Data* allocator(struct Context* context) { context->data[++context->dataNum] = context->heap;
--- a/src/parallel_execution/context.c Tue Nov 08 14:29:31 2016 +0900 +++ b/src/parallel_execution/context.c Tue Nov 08 15:01:08 2016 +0900 @@ -24,13 +24,9 @@ extern __code insert1_stub(struct Context*); extern __code insert2_stub(struct Context*); extern __code insert3_stub(struct Context*); -extern __code insert31_stub(struct Context*); extern __code insert4_stub(struct Context*); -extern __code insert4_01_stub(struct Context*); -extern __code insert4_02_stub(struct Context*); -extern __code insert4_1_stub(struct Context*); -extern __code insert4_2_stub(struct Context*); extern __code insert5_stub(struct Context*); +extern __code insert51_stub(struct Context*); extern __code stackClear_stub(struct Context*); extern __code get_stub(struct Context*); extern __code search_stub(struct Context*); @@ -95,13 +91,9 @@ context->code[InsertCase1] = insert1_stub; context->code[InsertCase2] = insert2_stub; context->code[InsertCase3] = insert3_stub; - context->code[InsertCase31] = insert31_stub; context->code[InsertCase4] = insert4_stub; - context->code[InsertCase4_01]= insert4_01_stub; - context->code[InsertCase4_02]= insert4_02_stub; - context->code[InsertCase4_1] = insert4_1_stub; - context->code[InsertCase4_2] = insert4_2_stub; context->code[InsertCase5] = insert5_stub; + context->code[InsertCase51] = insert51_stub; context->code[StackClear] = stackClear_stub; context->code[Get] = get_stub; context->code[Search] = search_stub;
--- a/src/parallel_execution/context.h Tue Nov 08 14:29:31 2016 +0900 +++ b/src/parallel_execution/context.h Tue Nov 08 15:01:08 2016 +0900 @@ -57,12 +57,7 @@ InsertCase1, InsertCase2, InsertCase3, - InsertCase31, InsertCase4, - InsertCase4_01, - InsertCase4_02, - InsertCase4_1, - InsertCase4_2, InsertCase5, InsertCase51, StackClear, @@ -143,18 +138,6 @@ union Data **data; }; -struct QueueInterface { - enum Code put; - enum Code get; - enum Code isEmpty; -}; - -struct StackInterface { - enum Code push; - enum Code pop; - enum Code isEmpty; -}; - union Data { struct Meta { enum DataType type; @@ -190,7 +173,7 @@ struct Element* first; struct Element* last; int count; - struct QueueInterface* i; + union Data* queue; enum Code next; } queue; // Stack Interface
--- a/src/parallel_execution/stack.c Tue Nov 08 14:29:31 2016 +0900 +++ b/src/parallel_execution/stack.c Tue Nov 08 15:01:08 2016 +0900 @@ -26,61 +26,82 @@ __code pushSingleLinkedStack_stub(struct Context* context) { struct Element* element = &ALLOCATE(context, Element)->element; goto pushSingleLinkedStack(context, - (struct SignleLinkedStack *)&context->data[Stack]->stack.stack, + (struct SingleLinkedStack *)&context->data[Stack]->stack.stack, element, - &context->data[Stack]->stack.data, - &context->data[Stack]->stack.next); + context->data[Stack]->stack.data, + context->data[Stack]->stack.next); } __code popSingleLinkedStack(struct Context* context, struct SingleLinkedStack* stack, union Data** data, enum Code next) { - *data = stack->top; - stack->top = stack->top->next; + if (stack->top) { + *data = stack->top->data; + stack->top = stack->top->next; + } else { + *data = NULL; + } goto meta(context, next); } __code popSingleLinkedStack_stub(struct Context* context) { goto popSingleLinkedStack(context, - (struct SignleLinkedStack *)context->data[Stack]->stack.stack, + (struct SingleLinkedStack *)context->data[Stack]->stack.stack, &context->data[Stack]->stack.data, context->data[Stack]->stack.next); } __code pop2SingleLinkedStack(struct Context* context, struct SingleLinkedStack* stack, union Data** data, union Data** data1, enum Code next) { - *data = stack->top; - *data1 = stack->top->next; - stack->top = data1->next; + if (stack->top) { + *data = stack->top->data; + stack->top = stack->top->next; + } else { + *data = NULL; + } + if (stack->top) { + *data1 = stack->top->data; + stack->top = stack->top->next; + } else { + *data1 = NULL; + } goto meta(context, next); } __code pop2SingleLinkedStack_stub(struct Context* context) { - goto popSingleLinkedStack(context, - (struct SignleLinkedStack *)context->data[Stack]->stack.stack, + goto pop2SingleLinkedStack(context, + (struct SingleLinkedStack *)context->data[Stack]->stack.stack, &context->data[Stack]->stack.data, &context->data[Stack]->stack.data1, context->data[Stack]->stack.next); } -__code getSingleLinkedStack(struct Context* context, struct SingleLinkedStack* stack, union Data** data, union Data** data1, enum Code next) { - *data = stack->top; +__code getSingleLinkedStack(struct Context* context, struct SingleLinkedStack* stack, union Data** data, enum Code next) { + *data = stack->top->data; goto meta(context, next); } __code getSingleLinkedStack_stub(struct Context* context) { - goto popSingleLinkedStack(context, - (struct SignleLinkedStack *)context->data[Stack]->stack.stack, + goto getSingleLinkedStack(context, + (struct SingleLinkedStack *)context->data[Stack]->stack.stack, &context->data[Stack]->stack.data, context->data[Stack]->stack.next); } __code get2SingleLinkedStack(struct Context* context, struct SingleLinkedStack* stack, union Data** data, union Data** data1, enum Code next) { - *data = stack->top; - *data1 = stack->top->next; + if (stack->top) { + *data = stack->top->data; + if (stack->top->next) { + *data1 = stack->top->next->data; + } else { + *data1 = NULL; + } + } else { + *data = NULL; + } goto meta(context, next); } __code get2SingleLinkedStack_stub(struct Context* context) { - goto popSingleLinkedStack(context, - (struct SignleLinkedStack *)context->data[Stack]->stack.stack, + goto get2SingleLinkedStack(context, + (struct SingleLinkedStack *)context->data[Stack]->stack.stack, &context->data[Stack]->stack.data, &context->data[Stack]->stack.data1, context->data[Stack]->stack.next); @@ -95,7 +116,7 @@ __code isEmptySingleLinkedStack_stub(struct Context* context) { goto isEmptySingleLinkedStack(context, - (struct SignleLinkedStack *)context->data[Stack]->stack.stack, + (struct SingleLinkedStack *)context->data[Stack]->stack.stack, context->data[Stack]->stack.next, context->data[Stack]->stack.whenEmpty); }