comparison src/parallel_execution/context.c @ 132:7c309e1aea73

Code Gears stack api
author one
date Thu, 27 Oct 2016 18:54:11 +0900
parents a4507906938c
children a747dc9d4da6
comparison
equal deleted inserted replaced
131:a4507906938c 132:7c309e1aea73
1 #include <stdlib.h> 1 #include <stdlib.h>
2 2
3 #include "context.h" 3 #include "context.h"
4 #include "stack.h"
4 5
5 extern __code code1_stub(struct Context*); 6 extern __code code1_stub(struct Context*);
6 extern __code code2_stub(struct Context*); 7 extern __code code2_stub(struct Context*);
7 extern __code code3_stub(struct Context*); 8 extern __code code3_stub(struct Context*);
8 extern __code code4(struct Context*); 9 extern __code code4(struct Context*);
145 146
146 struct Allocate* allocate = ALLOC_DATA(context, Allocate); 147 struct Allocate* allocate = ALLOC_DATA(context, Allocate);
147 allocate->size = 0; 148 allocate->size = 0;
148 149
149 150
150 struct SingleLinkedStack* singleLinkedStack = ALLOC_DATA(context, SingleLinkedStack); 151 ALLOC_DATA(context, Stack);
151 singleLinkedStack->top = NULL;
152 singleLinkedStack->i.push = PushSingleLinkedStack;
153 singleLinkedStack->i.pop = PopSingleLinkedStack;
154 singleLinkedStack->i.isEmpty = NULL;
155 singleLinkedStack->i.stack = (union StackSelf*)singleLinkedStack;
156
157 context->data[Stack] = (union Data*)&singleLinkedStack->i;
158 152
159 struct Tree* tree = ALLOC_DATA(context, Tree); 153 struct Tree* tree = ALLOC_DATA(context, Tree);
160 tree->root = 0; 154 tree->root = 0;
161 155
162 struct Traverse* traverse = ALLOC_DATA(context, Traverse); 156 struct Traverse* traverse = ALLOC_DATA(context, Traverse);
163 traverse->nodeStack = NULL; 157 traverse->nodeStack = &createSingleLinkedStack(context)->stack;
164 158
165 struct Node* node = ALLOC_DATA(context, Node); 159 struct Node* node = ALLOC_DATA(context, Node);
166 node->key = 0; 160 node->key = 0;
167 node->value = 0; 161 node->value = 0;
168 node->left = 0; 162 node->left = 0;