comparison src/parallel_execution/stack.c @ 136:a747dc9d4da6

stack refactering no compile error
author mir3636
date Tue, 08 Nov 2016 15:01:08 +0900
parents 77a7ccb0d84d
children 04a2f486a30d
comparison
equal deleted inserted replaced
135:77a7ccb0d84d 136:a747dc9d4da6
24 } 24 }
25 25
26 __code pushSingleLinkedStack_stub(struct Context* context) { 26 __code pushSingleLinkedStack_stub(struct Context* context) {
27 struct Element* element = &ALLOCATE(context, Element)->element; 27 struct Element* element = &ALLOCATE(context, Element)->element;
28 goto pushSingleLinkedStack(context, 28 goto pushSingleLinkedStack(context,
29 (struct SignleLinkedStack *)&context->data[Stack]->stack.stack, 29 (struct SingleLinkedStack *)&context->data[Stack]->stack.stack,
30 element, 30 element,
31 &context->data[Stack]->stack.data, 31 context->data[Stack]->stack.data,
32 &context->data[Stack]->stack.next); 32 context->data[Stack]->stack.next);
33 } 33 }
34 34
35 __code popSingleLinkedStack(struct Context* context, struct SingleLinkedStack* stack, union Data** data, enum Code next) { 35 __code popSingleLinkedStack(struct Context* context, struct SingleLinkedStack* stack, union Data** data, enum Code next) {
36 *data = stack->top; 36 if (stack->top) {
37 stack->top = stack->top->next; 37 *data = stack->top->data;
38 stack->top = stack->top->next;
39 } else {
40 *data = NULL;
41 }
38 goto meta(context, next); 42 goto meta(context, next);
39 } 43 }
40 44
41 __code popSingleLinkedStack_stub(struct Context* context) { 45 __code popSingleLinkedStack_stub(struct Context* context) {
42 goto popSingleLinkedStack(context, 46 goto popSingleLinkedStack(context,
43 (struct SignleLinkedStack *)context->data[Stack]->stack.stack, 47 (struct SingleLinkedStack *)context->data[Stack]->stack.stack,
44 &context->data[Stack]->stack.data, 48 &context->data[Stack]->stack.data,
45 context->data[Stack]->stack.next); 49 context->data[Stack]->stack.next);
46 } 50 }
47 51
48 __code pop2SingleLinkedStack(struct Context* context, struct SingleLinkedStack* stack, union Data** data, union Data** data1, enum Code next) { 52 __code pop2SingleLinkedStack(struct Context* context, struct SingleLinkedStack* stack, union Data** data, union Data** data1, enum Code next) {
49 *data = stack->top; 53 if (stack->top) {
50 *data1 = stack->top->next; 54 *data = stack->top->data;
51 stack->top = data1->next; 55 stack->top = stack->top->next;
56 } else {
57 *data = NULL;
58 }
59 if (stack->top) {
60 *data1 = stack->top->data;
61 stack->top = stack->top->next;
62 } else {
63 *data1 = NULL;
64 }
52 goto meta(context, next); 65 goto meta(context, next);
53 } 66 }
54 67
55 __code pop2SingleLinkedStack_stub(struct Context* context) { 68 __code pop2SingleLinkedStack_stub(struct Context* context) {
56 goto popSingleLinkedStack(context, 69 goto pop2SingleLinkedStack(context,
57 (struct SignleLinkedStack *)context->data[Stack]->stack.stack, 70 (struct SingleLinkedStack *)context->data[Stack]->stack.stack,
58 &context->data[Stack]->stack.data, 71 &context->data[Stack]->stack.data,
59 &context->data[Stack]->stack.data1, 72 &context->data[Stack]->stack.data1,
60 context->data[Stack]->stack.next); 73 context->data[Stack]->stack.next);
61 } 74 }
62 75
63 __code getSingleLinkedStack(struct Context* context, struct SingleLinkedStack* stack, union Data** data, union Data** data1, enum Code next) { 76 __code getSingleLinkedStack(struct Context* context, struct SingleLinkedStack* stack, union Data** data, enum Code next) {
64 *data = stack->top; 77 *data = stack->top->data;
65 goto meta(context, next); 78 goto meta(context, next);
66 } 79 }
67 80
68 __code getSingleLinkedStack_stub(struct Context* context) { 81 __code getSingleLinkedStack_stub(struct Context* context) {
69 goto popSingleLinkedStack(context, 82 goto getSingleLinkedStack(context,
70 (struct SignleLinkedStack *)context->data[Stack]->stack.stack, 83 (struct SingleLinkedStack *)context->data[Stack]->stack.stack,
71 &context->data[Stack]->stack.data, 84 &context->data[Stack]->stack.data,
72 context->data[Stack]->stack.next); 85 context->data[Stack]->stack.next);
73 } 86 }
74 87
75 __code get2SingleLinkedStack(struct Context* context, struct SingleLinkedStack* stack, union Data** data, union Data** data1, enum Code next) { 88 __code get2SingleLinkedStack(struct Context* context, struct SingleLinkedStack* stack, union Data** data, union Data** data1, enum Code next) {
76 *data = stack->top; 89 if (stack->top) {
77 *data1 = stack->top->next; 90 *data = stack->top->data;
91 if (stack->top->next) {
92 *data1 = stack->top->next->data;
93 } else {
94 *data1 = NULL;
95 }
96 } else {
97 *data = NULL;
98 }
78 goto meta(context, next); 99 goto meta(context, next);
79 } 100 }
80 101
81 __code get2SingleLinkedStack_stub(struct Context* context) { 102 __code get2SingleLinkedStack_stub(struct Context* context) {
82 goto popSingleLinkedStack(context, 103 goto get2SingleLinkedStack(context,
83 (struct SignleLinkedStack *)context->data[Stack]->stack.stack, 104 (struct SingleLinkedStack *)context->data[Stack]->stack.stack,
84 &context->data[Stack]->stack.data, 105 &context->data[Stack]->stack.data,
85 &context->data[Stack]->stack.data1, 106 &context->data[Stack]->stack.data1,
86 context->data[Stack]->stack.next); 107 context->data[Stack]->stack.next);
87 } 108 }
88 109
93 goto meta(context, whenEmpty); 114 goto meta(context, whenEmpty);
94 } 115 }
95 116
96 __code isEmptySingleLinkedStack_stub(struct Context* context) { 117 __code isEmptySingleLinkedStack_stub(struct Context* context) {
97 goto isEmptySingleLinkedStack(context, 118 goto isEmptySingleLinkedStack(context,
98 (struct SignleLinkedStack *)context->data[Stack]->stack.stack, 119 (struct SingleLinkedStack *)context->data[Stack]->stack.stack,
99 context->data[Stack]->stack.next, 120 context->data[Stack]->stack.next,
100 context->data[Stack]->stack.whenEmpty); 121 context->data[Stack]->stack.whenEmpty);
101 } 122 }
102 123