changeset 343:5065d1e4adbb

Merge
author Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
date Thu, 25 May 2017 22:52:54 +0900
parents de1e315379c6 (current diff) 54bfd016ad88 (diff)
children b8be1d51f002
files
diffstat 1 files changed, 38 insertions(+), 56 deletions(-) [+]
line wrap: on
line diff
--- a/src/parallel_execution/RedBlackTree.cbc	Thu May 25 22:49:40 2017 +0900
+++ b/src/parallel_execution/RedBlackTree.cbc	Thu May 25 22:52:54 2017 +0900
@@ -93,7 +93,7 @@
     tree->current = newNode;
     nodeStack->stack = (union Data*)tree->nodeStack;
     nodeStack->next = C_insertCase1;
-    goto meta(context, traverse->nodeStack->get2);
+    goto meta(context, tree->nodeStack->get2);
 }
 
 __code insertCase1(struct RedBlackTree* tree, struct Node *parent, struct Node *grandparent) {
@@ -148,7 +148,7 @@
         tree->current = tree->current->left;
         tree->parent = tree->grandparent;
 
-        rotateTree->tree = tree;
+        rotateTree->traverse = tree;
         rotateTree->next = C_insertCase5;
 
         nodeStack->stack = (union Data*)tree->nodeStack;
@@ -158,7 +158,7 @@
         tree->parent = tree->grandparent;
         tree->current = tree->current->right;
 
-        rotateTree->tree = tree;
+        rotateTree->traverse = tree;
         rotateTree->next = C_insertCase5;
 
         nodeStack->stack = (union Data*)tree->nodeStack;
@@ -169,26 +169,23 @@
     goto meta(context, C_insertCase5);
 }
 
-__code insertCase5(struct RedBlackTree* traverse,struct Stack *nodeStack) {
-    nodeStack->stack = (union Data*)traverse->nodeStack;
+__code insertCase5(struct RedBlackTree* tree, struct Stack* nodeStack) {
+    nodeStack->stack = (union Data*)tree->nodeStack;
     nodeStack->next = C_insertCase51;
-    goto meta(context, traverse->nodeStack->pop2);
+    goto meta(context, tree->nodeStack->pop2);
 }
 
-__code insertCase5_stub(struct Context* context) {
-    goto insertCase5(context, &Gearef(context, Tree)->tree->Tree.tree->RedBlackTree, Gearef(context, Stack));
-}
-
-__code insertCase51(struct RedBlackTree* traverse, struct RotateTree *rotateTree, struct Node* current, struct Node* parent, struct Node* grandparent) {
-    traverse->parent = parent;
-    traverse->grandparent = grandparent;
+__code insertCase51(struct RedBlackTree* tree, struct RotateTree* rotateTree, struct Node* parent, struct Node* grandparent) {
+    struct Node* current = tree->current;
+    tree->parent = parent;
+    tree->grandparent = grandparent;
 
     parent->color = Black;
     grandparent->color = Red;
 
-    traverse->current = grandparent;
+    tree->current = grandparent;
 
-    rotateTree->traverse = traverse;
+    rotateTree->traverse = tree;
     rotateTree->next = C_stackClear;
 
     if ((current == parent->left) && (parent == grandparent->left))
@@ -203,23 +200,22 @@
     goto insertCase51(context,
                       &Gearef(context, Tree)->tree->Tree.tree->RedBlackTree,
                       Gearef(context, RotateTree),
-                      Gearef(context, Tree)->tree->Tree.tree->RedBlackTree.current,
                       parent,
                       grandparent);
 }
 
-__code rotateLeft(struct RedBlackTree* traverse,struct Stack* nodeStack) {
-    nodeStack->stack = (union Data*)traverse->nodeStack;
+__code rotateLeft(struct RedBlackTree* tree, struct Stack* nodeStack) {
+    nodeStack->stack = (union Data*)tree->nodeStack;
     nodeStack->next = C_rotateLeft1;
-    goto meta(context, traverse->nodeStack->get);
+    goto meta(context, tree->nodeStack->get);
 }
 
 __code rotateLeft_stub(struct Context* context) {
     struct RedBlackTree* traverse = context->data[D_RotateTree]->RotateTree.traverse;
     goto rotateLeft(context, traverse, Gearef(context, Stack));
 }
-
-__code rotateLeft1(struct Node* node, struct RedBlackTree* traverse, struct Node *parent,struct RotateTree *rotateTree) {
+    
+__code rotateLeft1(struct Node* node, struct RedBlackTree* tree, struct Node* parent, struct RotateTree* rotateTree) {
     struct Node* tmp = node->right;
 
     if (parent) {
@@ -228,16 +224,16 @@
         else
             parent->right = tmp;
     } else {
-        traverse->root = tmp;
+        tree->root = tmp;
     }
 
     node->right = tmp->left;
     tmp->left = node;
-    traverse->current = tmp;
+    tree->current = tmp;
     
     goto meta(context, rotateTree->next);
 }
-    
+
 __code rotateLeft1_stub(struct Context* context) {
     struct RedBlackTree* traverse = context->data[D_RotateTree]->RotateTree.traverse;
     struct Node* parent = &context->data[D_Stack]->Stack.data->Node;
@@ -248,10 +244,10 @@
                     Gearef(context, RotateTree));
 }
 
-__code rotateRight(struct RedBlackTree* traverse,struct Stack *nodeStack) {
-    nodeStack->stack = (union Data*)traverse->nodeStack;
+__code rotateRight(struct RedBlackTree* tree, struct Stack* nodeStack) {
+    nodeStack->stack = (union Data*)tree->nodeStack;
     nodeStack->next = C_rotateRight1;
-    goto meta(context, traverse->nodeStack->get);
+    goto meta(context, tree->nodeStack->get);
 }
 
 __code rotateRight_stub(struct Context* context) {
@@ -288,22 +284,16 @@
                      Gearef(context, RotateTree));
 }
 
-__code stackClear(struct RedBlackTree* traverse,struct Stack *nodeStack, __code next(...)) {
-    traverse->current = 0;
-    nodeStack->stack = (union Data*)traverse->nodeStack;
+__code stackClear(struct RedBlackTree* tree, struct Stack* nodeStack, __code next(...)) {
+    tree->current = 0;
+    nodeStack->stack = (union Data*)tree->nodeStack;
     nodeStack->next = next;
-    goto meta(context, traverse->nodeStack->clear);
+    goto meta(context, tree->nodeStack->clear);
 }
 
-__code stackClear_stub(struct Context* context) {
-    goto stackClear(context, &Gearef(context, Tree)->tree->Tree.tree->RedBlackTree, Gearef(context, Stack),
-        Gearef(context, Tree)->next);
-}
-    
-
-__code getRedBlackTree(struct RedBlackTree* traverse, __code next(...)) {
-    if (traverse->root) {
-        traverse->current = traverse->root;
+__code getRedBlackTree(struct RedBlackTree* tree, __code next(...)) {
+    if (tree->root) {
+        tree->current = tree->root;
 
         goto meta(context, C_search);
     }
@@ -311,33 +301,25 @@
     goto next(...);
 }
 
-__code getRedBlackTree_stub(struct Context* context) {
-    goto getRedBlackTree(context, &Gearef(context, Tree)->tree->Tree.tree->RedBlackTree, Gearef(context, Tree)->next);
-}
-
-__code search(struct RedBlackTree* traverse, struct Node* node, __code next(...)) {
+__code search(struct RedBlackTree* tree, struct Node* node, __code next(...)) {
     // compare(context, traverse, traverse->current->key, node->key);
-    traverse->result = compare(traverse->current, node);
-    if (traverse->result == EQ) {
-        *node = *traverse->current;
+    tree->result = compare(tree->current, node);
+    if (tree->result == EQ) {
+        *node = *tree->current;
         
         goto meta(context, next);
-    } else if (traverse->result == GT) {
-        traverse->current = traverse->current->right;
+    } else if (tree->result == GT) {
+        tree->current = tree->current->right;
     } else {
-        traverse->current = traverse->current->left;
+        tree->current = tree->current->left;
     }
         
-    if (traverse->current)
+    if (tree->current)
         goto meta(context, C_search);
 
     goto next(...);
 }
 
-__code search_stub(struct Context* context) {
-    goto search(context, &Gearef(context, Tree)->tree->Tree.tree->RedBlackTree, Gearef(context, Node), Gearef(context, Tree)->next);
-}
-
 /* /\* __code delete(struct Context* context, struct Tree* tree) { *\/ */
 /* /\*     if (tree->root) { *\/ */
 /* /\*         stack_push(context->code_stack, &context->next); *\/ */