Mercurial > hg > Members > Moririn
annotate src/parallel_execution/test/stack_test.c @ 208:b6ffdd99e525
fix generate_context
author | mir3636 |
---|---|
date | Tue, 20 Dec 2016 19:39:51 +0900 |
parents | 7470b8382672 |
children | 50d0d1b468aa |
rev | line source |
---|---|
202 | 1 #include "../stack.h" |
182 | 2 #include "../context.h" |
3 #include "../origin_cs.h" | |
4 #include <assert.h> | |
207
7470b8382672
Fix compile error to stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
205
diff
changeset
|
5 extern __code initContext(struct Context* context); |
182 | 6 |
202 | 7 __code stack_test1(struct Context* context, struct Task* task, struct Stack* stack) { |
205 | 8 task->code = C_stack_test1; |
9 stack->next = C_stack_test2; | |
202 | 10 stack->data = (union Data*)task; |
205 | 11 goto meta(context, stack->push); |
182 | 12 } |
13 | |
202 | 14 __code stack_test1_stub(struct Context* context) { |
182 | 15 Task* task = &ALLOCATE(context, Task)->Task; |
205 | 16 struct Stack* stack = &(createSingleLinkedStack(context)->Stack); |
17 assert(stack->stack->SingleLinkedStack.top == NULL); | |
18 context->data[D_Stack]->Stack.stack = (union Data*)stack; | |
202 | 19 goto stack_test1(context, |
182 | 20 task, |
207
7470b8382672
Fix compile error to stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
205
diff
changeset
|
21 &context->data[D_Stack]->Stack.stack->Stack); |
182 | 22 } |
23 | |
202 | 24 __code stack_test2(struct Context* context, struct Task* task, struct Stack* stack) { |
205 | 25 task->code = C_stack_test2; |
26 stack->next = C_stack_test3; | |
202 | 27 stack->data = (union Data*)task; |
205 | 28 goto meta(context, stack->push); |
182 | 29 } |
30 | |
202 | 31 __code stack_test2_stub(struct Context* context) { |
207
7470b8382672
Fix compile error to stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
205
diff
changeset
|
32 assert(context->data[D_Stack]->Stack.stack->Stack.stack->SingleLinkedStack.top->data->Task.code == C_stack_test1); |
182 | 33 Task* task = &ALLOCATE(context, Task)->Task; |
202 | 34 goto stack_test2(context, |
182 | 35 task, |
207
7470b8382672
Fix compile error to stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
205
diff
changeset
|
36 &context->data[D_Stack]->Stack.stack->Stack); |
182 | 37 } |
38 | |
202 | 39 __code stack_test3(struct Context* context, struct Stack* stack) { |
205 | 40 stack->next = C_stack_test4; |
207
7470b8382672
Fix compile error to stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
205
diff
changeset
|
41 goto meta(context, stack->pop); |
182 | 42 } |
43 | |
202 | 44 __code stack_test3_stub(struct Context* context) { |
207
7470b8382672
Fix compile error to stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
205
diff
changeset
|
45 assert(context->data[D_Stack]->Stack.stack->Stack.stack->SingleLinkedStack.top->data->Task.code == C_stack_test2); |
7470b8382672
Fix compile error to stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
205
diff
changeset
|
46 assert(context->data[D_Stack]->Stack.stack->Stack.stack->SingleLinkedStack.top->data->Task.code == C_stack_test1); |
202 | 47 goto stack_test3(context, |
207
7470b8382672
Fix compile error to stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
205
diff
changeset
|
48 &context->data[D_Stack]->Stack.stack->Stack); |
182 | 49 } |
50 | |
202 | 51 __code stack_test4(struct Context* context) { |
208 | 52 goto meta(context, exit_code); |
182 | 53 } |
54 | |
202 | 55 __code stack_test4_stub(struct Context* context) { |
207
7470b8382672
Fix compile error to stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
205
diff
changeset
|
56 assert(context->data[D_Stack]->Stack.stack->Stack.data->Task.code == C_stack_test1); |
7470b8382672
Fix compile error to stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
205
diff
changeset
|
57 assert(context->data[D_Stack]->Stack.stack->Stack.stack->SingleLinkedStack.top->data->Task.code == C_stack_test1); |
205 | 58 goto stack_test4(context); |
182 | 59 } |
60 | |
61 int main(int argc, char const* argv[]) { | |
62 struct Context* main_context = NEW(struct Context); | |
63 initContext(main_context); | |
205 | 64 main_context->next = C_stack_test1; |
182 | 65 goto start_code(main_context); |
66 } |