annotate paper/src/SingleLinkedStack.c @ 72:951cb9681030

add source code
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Thu, 04 Feb 2021 14:54:44 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
72
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 #include "../context.h"
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 #include <stdio.h>
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 Stack* createSingleLinkedStack(struct Context* context) {
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 struct Stack* stack = &ALLOCATE(context, Stack)->Stack;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 struct SingleLinkedStack* single_linked_stack = &ALLOCATE(context, SingleLinkedStack)->SingleLinkedStack;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 stack->stack = (union Data*)single_linked_stack;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 stack->data = NULL;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 stack->data1 = NULL;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 single_linked_stack->top = NULL;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 stack->clear = C_clearSingleLinkedStack;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 stack->push = C_pushSingleLinkedStack;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 stack->pop = C_popSingleLinkedStack;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 stack->pop2 = C_pop2SingleLinkedStack;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 stack->isEmpty = C_isEmptySingleLinkedStack;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 stack->get = C_getSingleLinkedStack;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 stack->get2 = C_get2SingleLinkedStack;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 return stack;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 }
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 // include "Node.h"
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 void printStack1(union Data* data) {
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 struct Node* node = &data->Element.data->Node;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 if (node == NULL) {
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 printf("NULL");
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 } else {
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 printf("key = %d ,", node->key);
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 printStack1((union Data*)data->Element.next);
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 }
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 }
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
32
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 void printStack(union Data* data) {
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 printStack1(data);
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 printf("\n");
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 }
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
37
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 __code clearSingleLinkedStack(struct Context *context,struct SingleLinkedStack* stack,enum Code next) {
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 stack->top = NULL;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 goto meta(context, next);
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 }
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
42
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 __code clearSingleLinkedStack_stub(struct Context* context) {
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 SingleLinkedStack* stack = (SingleLinkedStack*)GearImpl(context, Stack, stack);
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 enum Code next = Gearef(context, Stack)->next;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 goto clearSingleLinkedStack(context, stack, next);
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 }
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
48
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 __code pushSingleLinkedStack(struct Context *context,struct SingleLinkedStack* stack, union Data* data, enum Code next) {
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 Element* element = &ALLOCATE(context, Element)->Element;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 element->next = stack->top;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 element->data = data;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 stack->top = element;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 goto meta(context, next);
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 }
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
56
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 __code pushSingleLinkedStack_stub(struct Context* context) {
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 SingleLinkedStack* stack = (SingleLinkedStack*)GearImpl(context, Stack, stack);
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 Data* data = Gearef(context, Stack)->data;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 enum Code next = Gearef(context, Stack)->next;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 goto pushSingleLinkedStack(context, stack, data, next);
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 }
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
63
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 __code popSingleLinkedStack(struct Context *context,struct SingleLinkedStack* stack, enum Code next,union Data **O_data) {
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 Data* data __attribute__((unused)) = *O_data;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
66 if (stack->top) {
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 data = stack->top->data;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 stack->top = stack->top->next;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 } else {
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 data = NULL;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 }
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 *O_data = data;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 goto meta(context, next);
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 }
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
75
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 __code popSingleLinkedStack_stub(struct Context* context) {
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 SingleLinkedStack* stack = (SingleLinkedStack*)GearImpl(context, Stack, stack);
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 enum Code next = Gearef(context, Stack)->next;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 Data** O_data = &Gearef(context, Stack)->data;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 goto popSingleLinkedStack(context, stack, next, O_data);
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
81 }
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
82
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
83 __code pop2SingleLinkedStack(struct Context *context,struct SingleLinkedStack* stack, enum Code next,union Data **O_data,union Data **O_data1) {
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
84 Data* data __attribute__((unused)) = *O_data;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
85 Data* data1 __attribute__((unused)) = *O_data1;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
86 if (stack->top) {
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
87 data = stack->top->data;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
88 stack->top = stack->top->next;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
89 } else {
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
90 data = NULL;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
91 }
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
92 if (stack->top) {
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
93 data1 = stack->top->data;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
94 stack->top = stack->top->next;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
95 } else {
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
96 data1 = NULL;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
97 }
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
98 *O_data = data;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
99 *O_data1 = data1;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
100 goto meta(context, next);
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
101 }
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
102
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
103
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
104 __code pop2SingleLinkedStack_stub(struct Context* context) {
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
105 SingleLinkedStack* stack = (SingleLinkedStack*)GearImpl(context, Stack, stack);
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
106 enum Code next = Gearef(context, Stack)->next;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
107 Data** O_data = &Gearef(context, Stack)->data;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
108 Data** O_data1 = &Gearef(context, Stack)->data1;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
109 goto pop2SingleLinkedStack(context, stack, next, O_data, O_data1);
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
110 }
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
111
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
112 __code getSingleLinkedStack(struct Context *context,struct SingleLinkedStack* stack, enum Code next,union Data **O_data) {
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
113 Data* data __attribute__((unused)) = *O_data;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
114 if (stack->top) {
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
115 data = stack->top->data;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
116 } else {
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
117 data = NULL;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
118 }
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
119 *O_data = data;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
120 goto meta(context, next);
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
121 }
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
122
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
123 __code getSingleLinkedStack_stub(struct Context* context) {
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
124 SingleLinkedStack* stack = (SingleLinkedStack*)GearImpl(context, Stack, stack);
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
125 enum Code next = Gearef(context, Stack)->next;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
126 Data** O_data = &Gearef(context, Stack)->data;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
127 goto getSingleLinkedStack(context, stack, next, O_data);
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
128 }
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
129
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
130 __code get2SingleLinkedStack(struct Context *context,struct SingleLinkedStack* stack, enum Code next,union Data **O_data,union Data **O_data1) {
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
131 Data* data __attribute__((unused)) = *O_data;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
132 Data* data1 __attribute__((unused)) = *O_data1;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
133 if (stack->top) {
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
134 data = stack->top->data;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
135 if (stack->top->next) {
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
136 data1 = stack->top->next->data;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
137 } else {
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
138 data1 = NULL;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
139 }
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
140 } else {
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
141 data = NULL;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
142 data1 = NULL;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
143 }
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
144 *O_data = data;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
145 *O_data1 = data1;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
146 goto meta(context, next);
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
147 }
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
148
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
149 __code get2SingleLinkedStack_stub(struct Context* context) {
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
150 SingleLinkedStack* stack = (SingleLinkedStack*)GearImpl(context, Stack, stack);
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
151 enum Code next = Gearef(context, Stack)->next;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
152 Data** O_data = &Gearef(context, Stack)->data;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
153 Data** O_data1 = &Gearef(context, Stack)->data1;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
154 goto get2SingleLinkedStack(context, stack, next, O_data, O_data1);
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
155 }
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
156
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
157 __code isEmptySingleLinkedStack(struct Context *context,struct SingleLinkedStack* stack, enum Code next, enum Code whenEmpty) {
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
158 if (stack->top) {
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
159 goto meta(context, next);
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
160 } else {
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
161 goto meta(context, whenEmpty);
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
162 }
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
163 }
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
164
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
165
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
166 __code isEmptySingleLinkedStack_stub(struct Context* context) {
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
167 SingleLinkedStack* stack = (SingleLinkedStack*)GearImpl(context, Stack, stack);
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
168 enum Code next = Gearef(context, Stack)->next;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
169 enum Code whenEmpty = Gearef(context, Stack)->whenEmpty;
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
170 goto isEmptySingleLinkedStack(context, stack, next, whenEmpty);
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
171 }
951cb9681030 add source code
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
172