Mercurial > hg > Gears > Gears
changeset 994:bb9cc6115890
feat: FileSystemTree
author | matac42 <matac@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 04 Dec 2021 13:48:32 +0900 |
parents | 762bd4cea38b |
children | 74d7ff2c658a |
files | src/parallel_execution/CMakeLists.txt src/parallel_execution/FTree.h src/parallel_execution/FileSystemTree.cbc src/parallel_execution/examples/gearsDirectory/GearsDirectoryImpl.cbc src/parallel_execution/examples/gearsDirectory/GearsDirectory_test.cbc src/parallel_execution/plautogen/impl/FileSystemTree.h src/parallel_execution/test/fsTree_test.cbc |
diffstat | 7 files changed, 738 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/src/parallel_execution/CMakeLists.txt Fri Dec 03 21:07:30 2021 +0900 +++ b/src/parallel_execution/CMakeLists.txt Sat Dec 04 13:48:32 2021 +0900 @@ -235,11 +235,17 @@ SOURCES examples/socket_test/socket_test.cbc examples/socket_test/ServerImpl.cbc ) -) GearsCommand( TARGET gearsDirectory SOURCES - TaskManagerImpl.cbc CPUWorker.cbc SingleLinkedQueue.cbc SingleLinkedStack.cbc AtomicReference.cbc SynchronizedQueue.cbc RedBlackTree.cbc examples/gearsDirectory/GearsDirectoryImpl.cbc examples/gearsDirectory/GearsDirectory_test.cbc compare.c + TaskManagerImpl.cbc CPUWorker.cbc SingleLinkedQueue.cbc SingleLinkedStack.cbc AtomicReference.cbc SynchronizedQueue.cbc FileSystemTree.cbc examples/gearsDirectory/GearsDirectoryImpl.cbc examples/gearsDirectory/GearsDirectory_test.cbc compare.c +) + +GearsCommand( + TARGET + fstree + SOURCES + SingleLinkedQueue.cbc test/fsTree_test.cbc FileSystemTree.cbc SingleLinkedStack.cbc compare.c ) \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/parallel_execution/FTree.h Sat Dec 04 13:48:32 2021 +0900 @@ -0,0 +1,13 @@ +typedef struct FTree<>{ + /* future Code */ + /* Type* tree; */ + /* Type* node; */ + union Data* fTree; + struct Node* node; + struct FTree* treeParent; + __code put(Impl* fTree,Type* node, __code next(...)); + __code get(Impl* fTree, Type* node, __code next(...)); + __code remove(Impl* fTree,Type* node, __code next(...)); + // __code clearRedBlackTree(); + __code next(...); +} FTree;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/parallel_execution/FileSystemTree.cbc Sat Dec 04 13:48:32 2021 +0900 @@ -0,0 +1,604 @@ +#include <stdio.h> + +#include "../context.h" +#interface "FTree.h" +#interface "Stack.h" + +extern enum Relational compare(struct Node* node1, struct Node* node2); + +FTree* createFileSystemTree(struct Context* context, struct FTree* cDirectory) { + struct FTree* fTree = new FTree(); + struct FileSystemTree* fileSystemTree = new FileSystemTree(); + fTree->fTree = (union Data*)fileSystemTree; + fileSystemTree->root = NULL; + fileSystemTree->nodeStack = createSingleLinkedStack(context); + fTree->treeParent = cDirectory; + fTree->put = C_putFileSystemTree; + fTree->get = C_getFileSystemTree; + fTree->remove = C_removeFileSystemTree; + // fTree->clear = C_clearFileSystemTree; + return fTree; +} + +void printTree1(union Data* data) { + struct Node* node = &data->Node; + if (node == NULL) { + printf("NULL"); + } else { + printf("key = %d (", node->key); + printTree1((union Data*)(node->right)); + printf("), ("); + printTree1((union Data*)(node->left)); + printf(")"); + } +} + +void printTree(union Data* data) { + printTree1(data); + printf("\n"); +} + +__code putFileSystemTree(struct FileSystemTree* fTree, struct Node* node) { + struct Node* newNode = &ALLOCATE(context, Node)->Node; + struct Node* root = fTree->root; + //printTree((union Data*)(fTree->root)); + fTree->newNode = newNode; + fTree->root = newNode; // this should done at stackClear + fTree->parent = NULL; + if (root) { + fTree->current = root; + fTree->result = compare(fTree->current, node); + fTree->findNodeNext = C_insertNode; + goto findNode(fTree); + } + goto insertNode(fTree, node); +} + +__code findNode(struct FileSystemTree* fTree) { + struct Stack* nodeStack = fTree->nodeStack; + struct Node* oldNode = fTree->current; + struct Node* newNode = fTree->newNode; + fTree->previous = newNode; + *newNode = *oldNode; + goto nodeStack->push((union Data*)newNode, findNode1); +} + +__code findNode1(struct FileSystemTree* fTree, struct Node* node, __code next(...)) { + struct Node* oldNode = fTree->current; + struct Node* newNode = fTree->previous; + struct Node* newnewNode = &ALLOCATE(context, Node)->Node; + int result = fTree->result; + if (result == EQ) { + newNode->value = node->value; + // go to stack clear + goto next(...); + } else if (result == GT) { + fTree->current = oldNode->right; + newNode->right = newnewNode; + } else { + fTree->current = oldNode->left; + newNode->left = newnewNode; + } + fTree->newNode = newnewNode; + if (fTree->current) { + fTree->result = compare(fTree->current, node); + goto findNode(fTree); + } + goto meta(context, fTree->findNodeNext); + // gato fTree->findNodeNext(fTree, node); + +} + +__code insertNode(struct FileSystemTree* fTree, struct Node* node) { + struct Stack* nodeStack = fTree->nodeStack; + struct Node* newNode = fTree->newNode; + *newNode = *node; + newNode->color = Red; + fTree->current = newNode; + goto nodeStack->get2(insertCase1); +} + +__code insertCase1(struct FileSystemTree* fTree, struct Node *parent, struct Node *grandparent) { + if (parent != NULL) { + fTree->parent = parent; + fTree->grandparent = grandparent; + goto insertCase2(fTree); + } + fTree->root->color = Black; + goto stackClear(); +} + +__code insertCase1_stub(struct Context* context) { + goto insertCase1(context, + &Gearef(context, FTree)->fTree->FTree.fTree->FileSystemTree, + &context->data[D_Stack]->Stack.data->Node, + &context->data[D_Stack]->Stack.data1->Node); +} + +__code insertCase2(struct FileSystemTree* fTree) { + if (fTree->parent->color == Black) { + goto stackClear(); + } + goto insertCase3(fTree); +} + +__code insertCase3(struct FileSystemTree* fTree) { + struct Stack* nodeStack = fTree->nodeStack; + struct Node* uncle; + + if (fTree->grandparent->left == fTree->parent) { + uncle = fTree->grandparent->right; + } else { + uncle = fTree->grandparent->left; + } + + if (uncle && (uncle->color == Red)) { + // do insertcase1 on grandparent, stack must be pop by two + fTree->parent->color = Black; + uncle->color = Black; + fTree->grandparent->color = Red; + fTree->current = fTree->grandparent; + goto nodeStack->pop2(insertCase1); + } + goto insertCase4(); +} + +__code insertCase4(struct FileSystemTree* fTree, struct RotateTree* rotateTree) { + struct Stack* nodeStack = fTree->nodeStack; + + if ((fTree->current == fTree->parent->right) && (fTree->parent == fTree->grandparent->left)) { + fTree->current = fTree->current->left; + fTree->parent = fTree->grandparent; + + rotateTree->traverse = fTree; + rotateTree->next = C_insertCase5; + + goto nodeStack->pop(rotateLeft); + } else if ((fTree->current == fTree->parent->left) && (fTree->parent == fTree->grandparent->right)) { + fTree->parent = fTree->grandparent; + fTree->current = fTree->current->right; + + rotateTree->traverse = fTree; + rotateTree->next = C_insertCase5; + + goto nodeStack->pop(rotateRight); + } + + goto insertCase5(); +} + +__code insertCase5(struct FileSystemTree* fTree) { + struct Stack* nodeStack = fTree->nodeStack; + goto nodeStack->pop2(insertCase51); +} + +__code insertCase51(struct FileSystemTree* fTree, struct RotateTree* rotateTree, struct Node* parent, struct Node* grandparent) { + struct Node* current = fTree->current; + fTree->parent = parent; + fTree->grandparent = grandparent; + + parent->color = Black; + grandparent->color = Red; + + fTree->current = grandparent; + + rotateTree->traverse = fTree; + rotateTree->next = C_stackClear; + + if ((current == parent->left) && (parent == grandparent->left)){ + goto rotateRight(); + } else { + goto rotateLeft(); + } +} + +__code insertCase51_stub(struct Context* context) { + struct Node* parent = &context->data[D_Stack]->Stack.data->Node; + struct Node* grandparent = &context->data[D_Stack]->Stack.data1->Node; + goto insertCase51(context, + &Gearef(context, FTree)->fTree->FTree.fTree->FileSystemTree, + Gearef(context, RotateTree), + parent, + grandparent); +} + +__code rotateLeft(struct FileSystemTree* fTree) { + struct Stack* nodeStack = fTree->nodeStack; + goto nodeStack->get(rotateLeft1); +} + +__code rotateLeft_stub(struct Context* context) { + struct FileSystemTree* traverse = context->data[D_RotateTree]->RotateTree.traverse; + goto rotateLeft(context, traverse); +} + +__code rotateLeft1(struct Node* node, struct FileSystemTree* fTree, struct Node* parent, struct RotateTree* rotateTree) { + struct Node* tmp = node->right; + + if (parent) { + if (node == parent->left) + parent->left = tmp; + else + parent->right = tmp; + } else { + fTree->root = tmp; + } + + node->right = tmp->left; + tmp->left = node; + fTree->current = tmp; + + goto meta(context, rotateTree->next); +} + +__code rotateLeft1_stub(struct Context* context) { + struct FileSystemTree* traverse = context->data[D_RotateTree]->RotateTree.traverse; + struct Node* parent = &context->data[D_Stack]->Stack.data->Node; + goto rotateLeft1(context, + traverse->current, + traverse, + parent, + Gearef(context, RotateTree)); +} + +__code rotateRight(struct FileSystemTree* fTree) { + struct Stack* nodeStack = fTree->nodeStack; + goto nodeStack->get(rotateRight1); +} + +__code rotateRight_stub(struct Context* context) { + struct FileSystemTree* traverse = context->data[D_RotateTree]->RotateTree.traverse; + goto rotateLeft(context, traverse); +} + +__code rotateRight1(struct Node* node, struct FileSystemTree* traverse,struct Node *parent,struct RotateTree *rotateTree) { + struct Node* tmp = node->left; + + if (parent) { + if (node == parent->left) + parent->left = tmp; + else + parent->right = tmp; + } else { + traverse->root = tmp; + } + + node->left = tmp->right; + tmp->right = node; + traverse->current = tmp; + + goto meta(context, rotateTree->next); +} + +__code rotateRight1_stub(struct Context* context) { + struct FileSystemTree* traverse = context->data[D_RotateTree]->RotateTree.traverse; + struct Node* parent = &context->data[D_Stack]->Stack.data->Node; + goto rotateRight1(context, + traverse->current, + traverse, + parent, + Gearef(context, RotateTree)); +} + +__code stackClear(struct FileSystemTree* fTree, struct Stack* nodeStack, __code next(...)) { + fTree->current = 0; + nodeStack->stack = (union Data*)fTree->nodeStack; + nodeStack->next = next; + goto meta(context, fTree->nodeStack->clear); +} + +__code getFileSystemTree(struct FileSystemTree* fTree, struct Node* node, __code next(...)) { + if (fTree->root) { + fTree->current = fTree->root; + + goto search(node); + } + + goto next(...); +} + +__code search(struct FileSystemTree* fTree, struct Node* node, __code next(...)) { + // compare(context, traverse, traverse->current->key, node->key); + fTree->result = compare(fTree->current, node); + if (fTree->result == EQ) { + *node = *fTree->current; + Gearef(context, FTree)->node = node; + goto next(node, ...); + // goto meta(context, next); + } else if (fTree->result == GT) { + fTree->current = fTree->current->right; + } else { + fTree->current = fTree->current->left; + } + + if (fTree->current) { + goto meta(context, C_search); + } + + goto next(...); +} + + +__code removeFileSystemTree(struct FileSystemTree* fTree, struct Node* node, __code next(...)) { + struct Node* newNode = &ALLOCATE(context, Node)->Node; + struct Node* root = fTree->root; + printTree((union Data*)(fTree->root)); + fTree->newNode = newNode; + fTree->root = newNode; // this should done at stackClear + fTree->parent = NULL; + if (root) { + fTree->current = root; + fTree->result = compare(fTree->current, node); + fTree->findNodeNext = C_replaceNodeForDelete2; + goto findNode(fTree); + } + goto next(...); +} + + + +__code delete2(struct Node* current) { + if (current->color == Black) { + struct Node* child = current->right == NULL ? current->left : current->right; + current->color = child == NULL ? Black : child->color; + + goto deleteCase1(current); + } + + goto delete3(fTree, current); +} + + + +__code delete3(struct FileSystemTree* fTree, struct Node* current, __code next(...)) { + struct Node* tmp = current->right == NULL ? current->left : current->right; + struct Stack* nodeStack = fTree->nodeStack; + + if (fTree->parent) { + if (current == fTree->parent->left) + fTree->parent->left = tmp; + else + fTree->parent->right = tmp; + } else { + fTree->root = tmp; + } + + + if (fTree->parent == NULL && tmp) { + tmp->color = Black; + } + + current == fTree->parent->left ? (fTree->parent->left = NULL) : (fTree->parent->right = NULL); + + Gearef(context, Stack)->stack = (union Data*) nodeStack; + Gearef(context, Stack)->next = next; + goto meta(context, nodeStack->pop); + +// gato nodeStack->pop(next); +} + + + +__code replaceNodeForDelete2(struct FileSystemTree* fTree, struct Node* newNode) { + if (fTree->current->left && fTree->current->right) { + fTree->parent = newNode; + fTree->current = newNode->left; + newNode->left = context->heap; + + + fTree->parent = newNode; + + goto findMax1(fTree,oldNode, newNode); + } + + goto delete2(current); +} + + +__code findMax1(struct FileSystemTree* fTree, struct Node* oldNode, struct Node* newNode) { + *newNode = *oldNode; + + if (newNode->right) { + goto findMax2(fTree, oldNode, newNode); + } + + fTree->current = newNode; + + goto delete2(current); +} + + + + +__code findMax2(struct FileSystemTree* fTree, struct Node* oldNode, struct Node* newNode) { + *newNode = *oldNode; + + if (newNode->right->right) { + fTree->current = newNode->right; + newNode->right = context->heap; + + fTree->parent = newNode; + + goto findMax2(fTree, oldNode, newNode); + } + + fTree->current = newNode; + + goto delete2(fTree,current); +} + + +__code deleteCase1(struct FileSystemTree* fTree, struct Node* current) { + if (fTree->parent) { + goto deleteCase2(fTree,current); + } + + goto delete3(fTree, current); +} + + + +__code deleteCase2(struct FileSystemTree* fTree, struct Node* current, struct RotateTree* rotateTree) { + struct Node* sibling = current == fTree->parent->left ? fTree->parent->right : fTree->parent->left; + struct Stack* nodeStack = fTree->nodeStack; + + if ((sibling == NULL ? Black : sibling->color) == Red) { + fTree->parent->color = Red; + sibling->color = Black; + + current == fTree->parent->left ? (fTree->parent->left = context->heap) : (fTree->parent->right = context->heap); + + struct Node* node = sibling; + + fTree->current = fTree->parent; + + rotateTree->traverse = fTree; + rotateTree->next = C_deleteCase3; + + if (current == fTree->parent->left) { + goto nodeStack->push((union Data*)node,rotateLeft); + } else { + goto nodeStack->push((union Data*)node,rotateRight); + } + + goto deleteCase3(fTree,current); + } +} + + + +__code deleteCase3(struct FileSystemTree* fTree, struct Node* current) { + struct Node* sibling = current == fTree->parent->left ? fTree->parent->right : fTree->parent->left; + + if (fTree->parent->color == Black && + (sibling == NULL ? Black : sibling->color) == Black && + (sibling->left == NULL ? Black : sibling->left->color) == Black && + (sibling->right == NULL ? Black : sibling->right->color) == Black) { + sibling->color = Red; + + fTree->current = fTree->parent; + goto deleteCase1(current); + } + + goto deleteCase4(current); +} + + + +__code deleteCase4(struct FileSystemTree* fTree,struct Node* current) { + struct Node* sibling = current == fTree->parent->left ? fTree->parent->right : fTree->parent->left; + + if (fTree->parent->color == Red && + (sibling == NULL ? Black : sibling->color) == Black && + (sibling->left == NULL ? Black : sibling->left->color) == Black && + (sibling->right == NULL ? Black : sibling->right->color) == Black) { + sibling->color = Red; + fTree->parent->color = Black; + + goto delete3(fTree,current); + } + + goto deleteCase5(fTree,current); +} + + + +__code deleteCase5(struct FileSystemTree* fTree, struct Node* current, struct RotateTree* rotateTree) { + struct Node* sibling = current == fTree->parent->left ? fTree->parent->right : fTree->parent->left; + struct Stack* nodeStack = fTree->nodeStack; + // sibling->parent = fTree->parent; + + if (current == fTree->parent->left && + (sibling == NULL ? Black : sibling->color) == Black && + (sibling->left == NULL ? Black : sibling->left->color) == Red && + (sibling->right == NULL ? Black : sibling->right->color) == Black) { + sibling->color = Red; + sibling->left->color = Black; + + // sibling == sibling->parent->left ? (sibling->parent->left = context->heap) : (sibling->parent->right = context->heap); + sibling == fTree->parent->left ? (fTree->parent->left = context->heap) : (fTree->parent->right = context->heap); + + struct Node* node = new Node(); + node = sibling->left; + + struct Node* tmp = node; + *tmp = *sibling; + fTree->parent = current; + + tmp->left = context->heap; +/* struct Node* node = new Node(); */ +/* node = *sibling->left; */ + fTree->parent = tmp; + + fTree->current = tmp; + + + rotateTree->traverse = fTree; + rotateTree->next = C_deleteCase6; + + goto nodeStack->push((union Data*)node,rotateRight); + } else if (current == fTree->parent->right && + (sibling == NULL ? Black : sibling->color) == Black && + (sibling->left == NULL ? Black : sibling->left->color) == Black && + (sibling->right == NULL ? Black : sibling->right->color) == Red) { + sibling->color = Red; + sibling->right->color = Black; + + sibling == fTree->parent->left ? (fTree->parent->left = context->heap) : (fTree->parent->right = context->heap); + + struct Node* node = new Node(); + node = sibling->right; + + struct Node* tmp = node; + *tmp = *sibling; + // tmp->parent = current; + + tmp->right = context->heap; +/* struct Node* node = new Node(); */ +/* node = *sibling->right; */ + //node->parent = tmp; + + fTree->current = tmp; + + + rotateTree->traverse = fTree; + rotateTree->next = C_deleteCase6; + + goto nodeStack->push((union Data*)node,rotateLeft); + } + + goto deleteCase6(fTree,current); +} + + +__code deleteCase6(struct FileSystemTree* fTree, struct Node* current, struct RotateTree* rotateTree) { + struct Node* sibling = current == fTree->parent->left ? fTree->parent->right : fTree->parent->left; + struct Stack* nodeStack = fTree->nodeStack; + sibling == fTree->parent->left ? (fTree->parent->left = context->heap) : (fTree->parent->right = context->heap); + + struct Node* tmp = sibling; + // *tmp = *sibling; + fTree->parent = current; + + tmp->color = fTree->parent->color; + fTree->parent->color = Black; + + + if (current == fTree->parent->left) { + tmp->right->color = Black; + fTree->current = fTree->parent; + + rotateTree->traverse = fTree; + rotateTree->next = C_delete3; + + goto nodeStack->push((union Data*)tmp,rotateLeft); + } else { + tmp->left->color = Black; + fTree->current = fTree->parent; + + rotateTree->traverse = fTree; + rotateTree->next = C_delete3; + + goto nodeStack->push((union Data*)tmp,rotateLeft); + } +}
--- a/src/parallel_execution/examples/gearsDirectory/GearsDirectoryImpl.cbc Fri Dec 03 21:07:30 2021 +0900 +++ b/src/parallel_execution/examples/gearsDirectory/GearsDirectoryImpl.cbc Sat Dec 04 13:48:32 2021 +0900 @@ -1,13 +1,13 @@ #include "../../../context.h" #interface "GearsDirectory.h" #interface "Stack.h" -#interface "Tree.h" +#interface "FTree.h" #interface "Integer.h" #impl "GearsDirectory.h" as "GearsDirectoryImpl.h" // ---- // typedef struct GearsDirectoryImpl <> impl GearsDirectory { -// struct Tree* currentDirectory; +// struct FTree* currentDirectory; // struct Stack* directoryStack; // } GearsDirectoryImpl; // ---- @@ -17,7 +17,7 @@ struct GearsDirectoryImpl* gears_directory_impl = new GearsDirectoryImpl(); gearsDirectory->gearsDirectory = (union Data*)gears_directory_impl; - struct Tree* firstTree = createRedBlackTree(context); + struct FTree* firstTree = createFileSystemTree(context, NULL); gears_directory_impl->currentDirectory = firstTree; gears_directory_impl->directoryStack = createSingleLinkedStack(context); gearsDirectory->mkdir = C_mkdirGearsDirectoryImpl; @@ -27,18 +27,18 @@ } __code mkdir(struct GearsDirectoryImpl* gearsDirectory, struct Integer* name, __code next(...)) { - struct Tree* newDirectory = createRedBlackTree(context); + struct FTree* newDirectory = createFileSystemTree(context, gearsDirectory->currentDirectory); Node* node = new Node(); node->value = newDirectory; node->key = name->value; - struct Tree* cDirectory = new Tree(); + struct FTree* cDirectory = new FTree(); cDirectory = gearsDirectory->currentDirectory; goto cDirectory->put(node, next(...)); } __code cd2Child(struct GearsDirectoryImpl* gearsDirectory, struct Integer* name, __code next(...)) { // 現在のtreeからnode->keyがnameと一致するものをsearch - struct Tree* cDirectory = new Tree(); + struct FTree* cDirectory = new FTree(); cDirectory = gearsDirectory->currentDirectory; struct Node* node = new Node(); node->key = name->value; @@ -47,9 +47,9 @@ __code cd2Child2(struct GearsDirectoryImpl* gearsDirectory, struct Node* node0, __code next(...)) { // treeを作る - // struct Tree* tree = new RedBlackTree(); + // struct FTree* tree = new FileSystemTree(); // currentDirectoryを作ったtreeに変更する - // struct Tree* parentDirectory = gearsDirectory->currentDirectory; + // struct FTree* parentDirectory = gearsDirectory->currentDirectory; // gearsDirectory->currentDirectory = tree; // current treeをstackにpushする // struct Stack* ds = gearsDirectory->directoryStack; @@ -63,24 +63,14 @@ __code cd2Child2_stub(struct Context* context) { GearsDirectoryImpl* gearsDirectory = (GearsDirectoryImpl*)GearImpl(context, GearsDirectory, gearsDirectory); enum Code next = Gearef(context, GearsDirectory)->next; - Node* node0 = Gearef(context, Tree)->node; + Node* node0 = Gearef(context, FTree)->node; goto cd2Child2(context, gearsDirectory, node0, next); } __code cd2Parent(struct GearsDirectoryImpl* gearsDirectory, __code next(...)) { - struct Stack* ds = gearsDirectory->directoryStack; - goto ds->pop(cd2Parent2); -} - -__code cd2Parent2(struct GearsDirectoryImpl* gearsDirectory, struct Tree* tree, __code next(...)) { - gearsDirectory->currentDirectory = tree; + // struct Stack* ds = gearsDirectory->directoryStack; + // gato ds->pop(cd2Parent2); + gearsDirectory->currentDirectory = gearsDirectory->currentDirectory->treeParent; goto next(...); } - -__code cd2Parent2_stub(struct Context* context) { - GearsDirectoryImpl* gearsDirectory = (GearsDirectoryImpl*)GearImpl(context, GearsDirectory, gearsDirectory); - Tree* tree = Gearef(context, Tree); - enum Code next = Gearef(context, GearsDirectory)->next; - goto cd2Parent2(context, gearsDirectory, tree, next); -}
--- a/src/parallel_execution/examples/gearsDirectory/GearsDirectory_test.cbc Fri Dec 03 21:07:30 2021 +0900 +++ b/src/parallel_execution/examples/gearsDirectory/GearsDirectory_test.cbc Sat Dec 04 13:48:32 2021 +0900 @@ -26,7 +26,7 @@ } __code task3(GearsDirectory* gearsDirectory){ - + goto gearsDirectory->cd2Parent(exit_code); } __code task3_stub(struct Context* context){
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/parallel_execution/plautogen/impl/FileSystemTree.h Sat Dec 04 13:48:32 2021 +0900 @@ -0,0 +1,11 @@ +typedef struct FileSystemTree <> impl FTree { + struct Node* root; + struct Node* current; // reading node of original tree; + struct Node* previous; // parent of reading node of original tree; + struct Node* newNode; // writing node of new tree; + struct Node* parent; + struct Node* grandparent; + struct Stack* nodeStack; + __code findNodeNext(...); + int result; +} FileSystemTree;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/parallel_execution/test/fsTree_test.cbc Sat Dec 04 13:48:32 2021 +0900 @@ -0,0 +1,89 @@ +#include <stdio.h> +#include "../../context.h" +#interface "Tree.h" + +/* #include <assert.h> */ + +__code fsTreeTest1(struct Tree* tree) { + printf("Test1\n"); + Node* node = new Node(); + node->value = (union Data*)new Integer(); + ((Integer*)node->value)->value = 3; + node->key = 3; + printf("value->%d,key->%d\n",((Integer*)node->value)->value,node->key); + goto tree->put(node, fsTreeTest2); +} + +__code fsTreeTest1_stub(struct Context* context) { + printf("test1_stub\n"); + Tree* tree = createFileSystemTree(context); + goto fsTreeTest1(context,tree); +} + + +__code fsTreeTest2(struct Tree* tree) { + printf("Test2\n"); + Node* node = new Node(); + node->value = (union Data*)new Integer(); + // ((Integer*)(node->value))->value= 4; + node->key = 3; + goto tree->get(node, fsTreeTest3); +} + +__code fsTreeTest2_stub(struct Context* context) { + printf("test2_stub\n"); + Tree* tree = (struct Tree*)Gearef(context, Tree)->tree; + goto fsTreeTest2(context,tree); +} + + +__code fsTreeTest3(struct Tree* tree, struct Node* node0) { + printf("test3\n"); + printf("value=%d key=%d\n", ((Integer*)node0->value)->value, node0->key); + Node* node = new Node(); + node->value = (union Data*)new Integer(); + ((Integer*)(node->value))->value = 2; + node->key = 2; + goto tree->put(node, fsTreeTest4); +} + +__code fsTreeTest3_stub(struct Context* context) { + Tree* tree = (struct Tree*)Gearef(context, Tree)->tree; + Node* node0 = Gearef(context, Tree)->node; + goto fsTreeTest3(context,tree,node0); +} + +__code fsTreeTest4(struct Tree* tree) { + printf("test4\n"); + Node* node = new Node(); + node->value = (union Data*)new Integer(); + ((Integer*)(node->value))->value = 8; + node->key = 8; + goto tree->put(node, fsTreeTest5); +} + +__code fsTreeTest4_stub(struct Context* context) { + Tree* tree = (struct Tree*)Gearef(context, Tree)->tree; + goto fsTreeTest4(context,tree); +} + +__code fsTreeTest5(struct Tree* tree) { + printf("test5\n"); + Node* node = new Node(); + node->value = (union Data*)new Integer(); + ((Integer*)node->value)->value = 8; + node->key = 8; + goto tree->remove(node,exit_code); +} + +__code fsTreeTest5_stub(struct Context* context) { + Tree* tree = (struct Tree*)Gearef(context, Tree)->tree; + goto fsTreeTest5(context,tree); +} + + + +int main(int argc, char const* argv[]) { + printf("test_main\n"); + goto fsTreeTest1(); +}