Mercurial > hg > GearsTemplate
changeset 160:73c393f0dca3
fix main.c
author | mir3636 |
---|---|
date | Fri, 18 Nov 2016 18:16:30 +0900 |
parents | f2c77b0761fc |
children | efc68eca8463 |
files | src/parallel_execution/main.c src/parallel_execution/rb_tree.c src/parallel_execution/stack.cbc |
diffstat | 3 files changed, 32 insertions(+), 61 deletions(-) [+] |
line wrap: on
line diff
--- a/src/parallel_execution/main.c Wed Nov 16 21:29:01 2016 +0900 +++ b/src/parallel_execution/main.c Fri Nov 18 18:16:30 2016 +0900 @@ -87,7 +87,7 @@ goto createData1(context, &context->data[D_Allocate]->allocate, &context->data[D_LoopCounter]->loopCounter); } -__code createData2(struct Context* context, struct LoopCounter* loopCounter, struct Array* array, struct Node* node) { +__code createData2(struct Context* context, struct LoopCounter* loopCounter, struct Array* array, struct Node* node, Tree* tree) { int i = loopCounter->i; array->index = i; @@ -97,54 +97,21 @@ node->key = i; node->value = (union Data*)array; - context->next = CreateTask1; + tree->next = CreateTask1; + tree->node = node; - goto meta(context, C_put); + goto meta(context, loopCounter->tree->put); } __code createData2_stub(struct Context* context) { goto createData2(context, &context->data[D_LoopCounter]->loopCounter, &context->data[context->dataNum]->array, - &context->data[D_Node]->node); -} - -__code createTask1(struct Context* context, struct Allocate* allocate) { - allocate->size = sizeof(struct Task); - allocator(context); - goto meta(context, CreateTask2); -} - -__code createTask1_stub(struct Context* context) { - goto createTask1(context, &context->data[D_Allocate]->allocate); -} - -__code createTask2(struct Context* context, struct Allocate* allocate) { - allocate->size = sizeof(struct Queue); - allocator(context); - goto meta(context, CreateTask3); + &context->data[D_Node]->node, + Gearef(context, Tree)); } -__code createTask2_stub(struct Context* context) { - goto createTask2(context, &context->data[D_Allocate]->allocate); -} - -__code createTask3(struct Context* context, struct Allocate* allocate) { - allocate->size = sizeof(struct Queue); - allocator(context); - goto meta(context, CreateTask4); -} - -__code createTask3_stub(struct Context* context) { - goto createTask3(context, &context->data[D_Allocate]->allocate); -} - -__code meta_createTask4(struct Context* context, struct Queue* activeQueue, enum Code next) { - context->data[D_Queue] = (union Data *)activeQueue; - goto (context->code[next])(context); -} - -__code createTask4(struct Context* context, struct LoopCounter* loopCounter, struct Task* task, struct Queue* waitMe, struct Queue* waitI, struct Element* element, struct Queue* activeQueue) { +__code createTask1(struct Context* context, struct LoopCounter* loopCounter, struct Task* task, struct Queue* waitMe, struct Queue* waitI, struct Element* element, struct Queue* activeQueue) { int i = loopCounter->i; waitMe->first = 0; @@ -169,12 +136,15 @@ goto meta(context, SpawnTask); } -__code createTask4_stub(struct Context* context) { - goto createTask4(context, +__code createTask1_stub(struct Context* context) { + Task* task = &ALLOCATE(context, Task)->Task; + Queue* waitMe = &ALLOCATE(context, Queue)->Queue; + Queue* waitI = &ALLOCATE(context, Queue)->Queue; + goto createTask1(context, &context->data[D_LoopCounter]->loopCounter, - &context->data[context->dataNum-2]->task, - &context->data[context->dataNum-1]->queue, - &context->data[context->dataNum]->queue, + task, + waitMe, + waitI, &context->data[D_Element]->element, &context->data[D_ActiveQueue]->queue); }
--- a/src/parallel_execution/rb_tree.c Wed Nov 16 21:29:01 2016 +0900 +++ b/src/parallel_execution/rb_tree.c Fri Nov 18 18:16:30 2016 +0900 @@ -5,6 +5,18 @@ extern enum Relational compare(struct Node* node1, struct Node* node2); +union Data* createRedBlackTree(struct Context* context) { + struct Tree* tree = &ALLOCATE(context, Tree)->Tree; + struct RedBlackTree* redBlackTree = &ALLOCATE(context, RedBlackTree)->RedBlackTree; + tree->tree = (union Data*)redBlackTree; + redBlackTree->root = NULL; + tree->put = C_putRedBlackTree; + tree->get = C_getRedBlackTree; + tree->remove = C_removeRedBlackTree; + tree->clear = C_clearRedBlackTree; + return (union Data*)(tree); +} + void printTree1(union Data* data) { struct Node* node = &data->node; if (node == NULL) { @@ -23,7 +35,7 @@ printf("\n"); } -__code put(struct Context* context, struct Stack* nodeStack, struct Tree* tree, struct Node* node, struct Traverse* traverse, struct Node* root, struct Node* newNode) { +__code putRedBlackTree(struct Context* context, struct Stack* nodeStack, struct Tree* tree, struct Node* node, struct Traverse* traverse, struct Node* root, struct Node* newNode) { printTree((union Data*)(tree->root)); traverse->newNode = newNode; tree->root = newNode; // this should done at stackClear @@ -37,7 +49,7 @@ goto meta(context, C_insertNode); } -__code put_stub(struct Context* context) { +__code putRedBlackTree_stub(struct Context* context) { struct Node* newNode = &ALLOCATE(context, Node)->node; goto put(context, &context->data[D_Stack]->stack, @@ -332,7 +344,7 @@ } -__code get(struct Context* context, struct Tree* tree, struct Traverse* traverse) { +__code getRedBlackTree(struct Context* context, struct Tree* tree, struct Traverse* traverse) { if (tree->root) { traverse->current = tree->root; @@ -342,7 +354,7 @@ goto meta(context, traverse->next); } -__code get_stub(struct Context* context) { +__code getRedBlackTree_stub(struct Context* context) { goto get(context, &context->data[D_Tree]->tree, &context->data[D_Traverse]->Traverse); }
--- a/src/parallel_execution/stack.cbc Wed Nov 16 21:29:01 2016 +0900 +++ b/src/parallel_execution/stack.cbc Fri Nov 18 18:16:30 2016 +0900 @@ -90,18 +90,7 @@ union Data* data, *data1; if (stack->top) { - data = stack->top->data; - if (stack->top->next) { - data1 = stack->top->next->data; - } else { - data1 = NULL; - } - } else { - data = NULL; - data1 = NULL; - } - goto next(data, data1, ...); -} +zsh:1: command not found: nkf __code isEmptySingleLinkedStack(struct SingleLinkedStack* stack, __code next(...), __code whenEmpty(...)) { if (stack->top)