comparison src/parallel_execution/RedBlackTree.cbc @ 280:2c2e4e597eb0

generate no compile errors
author mir3636
date Fri, 03 Feb 2017 17:47:27 +0900
parents b5e8fce400a5
children 5bca0ff563e6
comparison
equal deleted inserted replaced
279:b5e8fce400a5 280:2c2e4e597eb0
1 #include <stdio.h> 1 #include <stdio.h>
2 2
3 #include "../context.h" 3 #include "../context.h"
4 #include "../origin_cs.h"
5 4
6 extern enum Relational compare(struct Node* node1, struct Node* node2); 5 extern enum Relational compare(struct Node* node1, struct Node* node2);
7 6
8 Tree* createRedBlackTree(struct Context* context) { 7 Tree* createRedBlackTree(struct Context* context) {
9 struct Tree* tree = new Tree(); 8 struct Tree* tree = new Tree();
42 traverse->root = newNode; // this should done at stackClear 41 traverse->root = newNode; // this should done at stackClear
43 traverse->parent = NULL; 42 traverse->parent = NULL;
44 if (root) { 43 if (root) {
45 traverse->current = root; 44 traverse->current = root;
46 traverse->result = compare(traverse->current, node); 45 traverse->result = compare(traverse->current, node);
47 goto C_replaceNode(...); 46 goto meta(context, C_replaceNode);
48 } 47 }
49 48
50 goto C_insertNode(...); 49 goto meta(context, C_insertNode);
51 } 50 }
52 51
53 __code putRedBlackTree_stub(struct Context* context) { 52 __code putRedBlackTree_stub(struct Context* context) {
54 struct Node* newNode = &ALLOCATE(context, Node)->Node; 53 struct Node* newNode = &ALLOCATE(context, Node)->Node;
55 goto putRedBlackTree(context, 54 goto putRedBlackTree(context,
91 newNode->left = newnewNode; 90 newNode->left = newnewNode;
92 } 91 }
93 traverse->newNode = newnewNode; 92 traverse->newNode = newnewNode;
94 if (traverse->current) { 93 if (traverse->current) {
95 traverse->result = compare(traverse->current, node); 94 traverse->result = compare(traverse->current, node);
96 goto C_replaceNode(...); 95 goto meta(context, C_replaceNode);
97 } 96 }
98 goto C_insertNode(...); 97 goto meta(context, C_insertNode);
99 98
100 } 99 }
101 100
102 __code replaceNode1_stub(struct Context* context) { 101 __code replaceNode1_stub(struct Context* context) {
103 struct Node* newnewNode = &ALLOCATE(context, Node)->Node; 102 struct Node* newnewNode = &ALLOCATE(context, Node)->Node;
130 129
131 __code insertCase1(struct RedBlackTree* traverse, struct Node *parent, struct Node *grandparent) { 130 __code insertCase1(struct RedBlackTree* traverse, struct Node *parent, struct Node *grandparent) {
132 if (parent != NULL) { 131 if (parent != NULL) {
133 traverse->parent = parent; 132 traverse->parent = parent;
134 traverse->grandparent = grandparent; 133 traverse->grandparent = grandparent;
135 goto C_insertCase2(...); 134 goto meta(context, C_insertCase2);
136 } 135 }
137 traverse->root->color = Black; 136 traverse->root->color = Black;
138 goto C_stackClear(...); 137 goto meta(context, C_stackClear);
139 } 138 }
140 139
141 __code insertCase1_stub(struct Context* context) { 140 __code insertCase1_stub(struct Context* context) {
142 goto insertCase1(context, 141 goto insertCase1(context,
143 &Gearef(context, Tree)->tree->Tree.tree->RedBlackTree, 142 &Gearef(context, Tree)->tree->Tree.tree->RedBlackTree,
145 &context->data[D_Stack]->Stack.data1->Node); 144 &context->data[D_Stack]->Stack.data1->Node);
146 } 145 }
147 146
148 __code insertCase2(struct RedBlackTree* traverse) { 147 __code insertCase2(struct RedBlackTree* traverse) {
149 if (traverse->parent->color == Black) { 148 if (traverse->parent->color == Black) {
150 goto C_stackClear(...); 149 goto meta(context, C_stackClear);
151 } 150 }
152 goto C_insertCase3(...); 151 goto meta(context, C_insertCase3);
153 } 152 }
154 153
155 __code insertCase2_stub(struct Context* context) { 154 __code insertCase2_stub(struct Context* context) {
156 goto insertCase2(context, &Gearef(context, Tree)->tree->Tree.tree->RedBlackTree); 155 goto insertCase2(context, &Gearef(context, Tree)->tree->Tree.tree->RedBlackTree);
157 } 156 }
172 traverse->current = traverse->grandparent; 171 traverse->current = traverse->grandparent;
173 nodeStack->stack = (union Data*)traverse->nodeStack; 172 nodeStack->stack = (union Data*)traverse->nodeStack;
174 nodeStack->next = C_insertCase1; 173 nodeStack->next = C_insertCase1;
175 goto meta(context, traverse->nodeStack->pop2); 174 goto meta(context, traverse->nodeStack->pop2);
176 } 175 }
177 goto C_insertCase4(...); 176 goto meta(context, C_insertCase4);
178 } 177 }
179 178
180 __code insertCase3_stub(struct Context* context) { 179 __code insertCase3_stub(struct Context* context) {
181 goto insertCase3(context, &Gearef(context, Tree)->tree->Tree.tree->RedBlackTree, 180 goto insertCase3(context, &Gearef(context, Tree)->tree->Tree.tree->RedBlackTree,
182 Gearef(context, Stack)); 181 Gearef(context, Stack));
205 nodeStack->stack = (union Data*)traverse->nodeStack; 204 nodeStack->stack = (union Data*)traverse->nodeStack;
206 nodeStack->next = C_rotateRight; 205 nodeStack->next = C_rotateRight;
207 goto meta(context, nodeStack->pop); 206 goto meta(context, nodeStack->pop);
208 } 207 }
209 208
210 goto C_insertCase5(...); 209 goto meta(context, C_insertCase5);
211 } 210 }
212 211
213 __code insertCase4_stub(struct Context* context) { 212 __code insertCase4_stub(struct Context* context) {
214 goto insertCase4(context, &Gearef(context, Tree)->tree->Tree.tree->RedBlackTree, Gearef(context, RotateTree)); 213 goto insertCase4(context, &Gearef(context, Tree)->tree->Tree.tree->RedBlackTree, Gearef(context, RotateTree));
215 } 214 }
235 234
236 rotateTree->traverse = traverse; 235 rotateTree->traverse = traverse;
237 rotateTree->next = C_stackClear; 236 rotateTree->next = C_stackClear;
238 237
239 if ((current == parent->left) && (parent == grandparent->left)) 238 if ((current == parent->left) && (parent == grandparent->left))
240 goto C_rotateRight(...); 239 goto meta(context, C_rotateRight);
241 else 240 else
242 goto C_rotateLeft(...); 241 goto meta(context, C_rotateLeft);
243 } 242 }
244 243
245 __code insertCase51_stub(struct Context* context) { 244 __code insertCase51_stub(struct Context* context) {
246 struct Node* parent = &context->data[D_Stack]->Stack.data->Node; 245 struct Node* parent = &context->data[D_Stack]->Stack.data->Node;
247 struct Node* grandparent = &context->data[D_Stack]->Stack.data1->Node; 246 struct Node* grandparent = &context->data[D_Stack]->Stack.data1->Node;
348 347
349 __code getRedBlackTree(struct RedBlackTree* traverse, __code next(...)) { 348 __code getRedBlackTree(struct RedBlackTree* traverse, __code next(...)) {
350 if (traverse->root) { 349 if (traverse->root) {
351 traverse->current = traverse->root; 350 traverse->current = traverse->root;
352 351
353 goto C_search(...); 352 goto meta(context, C_search);
354 } 353 }
355 354
356 goto next(...); 355 goto next(...);
357 } 356 }
358 357
372 } else { 371 } else {
373 traverse->current = traverse->current->left; 372 traverse->current = traverse->current->left;
374 } 373 }
375 374
376 if (traverse->current) 375 if (traverse->current)
377 goto C_search(...); 376 goto meta(context, C_search);
378 377
379 goto next(...); 378 goto next(...);
380 } 379 }
381 380
382 __code search_stub(struct Context* context) { 381 __code search_stub(struct Context* context) {