Mercurial > hg > Members > Moririn
changeset 265:4ccf776db994
fix
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 28 Jan 2017 17:15:55 +0900 |
parents | cd6ea4c7f6a5 |
children | ffcd80cc3a83 |
files | src/parallel_execution/CMakeLists.txt src/parallel_execution/Todo src/parallel_execution/test/cbc_stack_test.c |
diffstat | 3 files changed, 67 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/parallel_execution/CMakeLists.txt Sat Jan 28 16:29:15 2017 +0900 +++ b/src/parallel_execution/CMakeLists.txt Sat Jan 28 17:15:55 2017 +0900 @@ -61,6 +61,6 @@ TARGET cbc_stack_test SOURCES - origin_cs.c test/stack_test.c SingleLinkedStack.cbc + origin_cs.c test/cbc_stack_test.c SingleLinkedStack.cbc )
--- a/src/parallel_execution/Todo Sat Jan 28 16:29:15 2017 +0900 +++ b/src/parallel_execution/Todo Sat Jan 28 17:15:55 2017 +0900 @@ -13,6 +13,8 @@ などをチェックする必要がある。これらの型チェックは CbC level では行われない。(CbCはmeta levelだから) + 戻り値の部分は interface に記述させるという手もあるな。 + Sun Jan 22 20:11:28 JST 2017
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/parallel_execution/test/cbc_stack_test.c Sat Jan 28 17:15:55 2017 +0900 @@ -0,0 +1,64 @@ +#include "../stack.h" +#include "../context.h" +#include "../origin_cs.h" +#include <assert.h> + +__code stack_test1(struct Context* context, struct Task* task, struct Stack* stack) { + task->code = C_stack_test1; + stack->next = C_stack_test2; + stack->data = (union Data*)task; + goto meta(context, stack->stack->Stack.push); +} + +__code stack_test1_stub(struct Context* context) { + Task* task = &ALLOCATE(context, Task)->Task; + struct Stack* stack = &(createSingleLinkedStack(context)->Stack); + assert(stack->stack->SingleLinkedStack.top == NULL); + context->data[D_Stack]->Stack.stack = (union Data*)stack; + goto stack_test1(context, + task, + &context->data[D_Stack]->Stack); +} + +__code stack_test2(struct Context* context, struct Task* task, struct Stack* stack) { + task->code = C_stack_test2; + stack->next = C_stack_test3; + stack->data = (union Data*)task; + goto meta(context, stack->stack->Stack.push); +} + +__code stack_test2_stub(struct Context* context) { + assert(context->data[D_Stack]->Stack.stack->Stack.stack->SingleLinkedStack.top->data->Task.code == C_stack_test1); + Task* task = &ALLOCATE(context, Task)->Task; + goto stack_test2(context, + task, + &context->data[D_Stack]->Stack); +} + +__code stack_test3(struct Context* context, struct Stack* stack) { + stack->next = C_stack_test4; + goto meta(context, stack->stack->Stack.pop); +} + +__code stack_test3_stub(struct Context* context) { + assert(context->data[D_Stack]->Stack.stack->Stack.stack->SingleLinkedStack.top->data->Task.code == C_stack_test2); + goto stack_test3(context, + &context->data[D_Stack]->Stack); +} + +__code stack_test4(struct Context* context) { + goto meta(context, C_exit_code); +} + +__code stack_test4_stub(struct Context* context) { + assert(context->data[D_Stack]->Stack.data->Task.code == C_stack_test2); + assert(context->data[D_Stack]->Stack.stack->Stack.stack->SingleLinkedStack.top->data->Task.code == C_stack_test1); + goto stack_test4(context); +} + +int main(int argc, char const* argv[]) { + struct Context* main_context = NEW(struct Context); + initContext(main_context); + main_context->next = C_stack_test1; + goto start_code(main_context); +}