Mercurial > hg > Gears > Gears
changeset 987:5480387d4c8d
fix: gearsDirectory mkdir cd2Child
author | matac42 <matac@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 27 Nov 2021 17:29:54 +0900 |
parents | 3c9f6fda000d |
children | a7d1288cf58e |
files | src/parallel_execution/examples/gearsDirectory/GearsDirectory.h src/parallel_execution/examples/gearsDirectory/GearsDirectoryImpl.cbc src/parallel_execution/examples/gearsDirectory/GearsDirectory_test.cbc |
diffstat | 3 files changed, 36 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/src/parallel_execution/examples/gearsDirectory/GearsDirectory.h Sat Nov 20 17:23:16 2021 +0900 +++ b/src/parallel_execution/examples/gearsDirectory/GearsDirectory.h Sat Nov 27 17:29:54 2021 +0900 @@ -2,7 +2,7 @@ union Data* gearsDirectory; struct Integer* name; __code mkdir(Impl* gearsDirectory, struct Integer* name, __code next(...)); - __code cd2Child(Impl* gearsDirectory, __code next(...)); + __code cd2Child(Impl* gearsDirectory, struct Integer* name, __code next(...)); __code cd2Parent(Impl* gearsDirectory, __code next(...)); __code next(...); } GearsDirectory; \ No newline at end of file
--- a/src/parallel_execution/examples/gearsDirectory/GearsDirectoryImpl.cbc Sat Nov 20 17:23:16 2021 +0900 +++ b/src/parallel_execution/examples/gearsDirectory/GearsDirectoryImpl.cbc Sat Nov 27 17:29:54 2021 +0900 @@ -17,7 +17,7 @@ struct GearsDirectoryImpl* gears_directory_impl = new GearsDirectoryImpl(); gearsDirectory->gearsDirectory = (union Data*)gears_directory_impl; - struct Tree* firstTree = new RedBlackTree(); + struct Tree* firstTree = createRedBlackTree(context); gears_directory_impl->currentDirectory = firstTree; gears_directory_impl->directoryStack = createSingleLinkedStack(context); gearsDirectory->mkdir = C_mkdirGearsDirectoryImpl; @@ -27,22 +27,44 @@ } __code mkdir(struct GearsDirectoryImpl* gearsDirectory, struct Integer* name, __code next(...)) { - struct Tree* newDirectory = new RedBlackTree(); + struct Tree* newDirectory = createRedBlackTree(context); Node* node = new Node(); node->value = newDirectory; node->key = name->value; - goto next(...); + struct Tree* cDirectory = new Tree(); + 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(); + cDirectory = gearsDirectory->currentDirectory; + struct Node* node = new Node(); + node->key = name->value; + goto cDirectory->get(node, cd2Child2); } -__code cd2Child(struct GearsDirectoryImpl* gearsDirectory, __code next(...)) { +__code cd2Child2(struct GearsDirectoryImpl* gearsDirectory, struct Node* node0, __code next(...)) { // treeを作る - struct Tree* tree = new RedBlackTree(); + // struct Tree* tree = new RedBlackTree(); // currentDirectoryを作ったtreeに変更する - struct Tree* parentDirectory = gearsDirectory->currentDirectory; - gearsDirectory->currentDirectory = tree; + // struct Tree* parentDirectory = gearsDirectory->currentDirectory; + // gearsDirectory->currentDirectory = tree; // current treeをstackにpushする - struct Stack* ds = gearsDirectory->directoryStack; - goto ds->push(parentDirectory, next(...)); + // struct Stack* ds = gearsDirectory->directoryStack; + + // searchの結果,存在すればcurrentDirectoryにsearchしたtreeをsetする + gearsDirectory->currentDirectory = node0->value; + goto next(...); + // gato ds->push(parentDirectory, next(...)); +} + +__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; + goto cd2Child2(context, gearsDirectory, node0, next); } @@ -58,7 +80,7 @@ __code cd2Parent2_stub(struct Context* context) { GearsDirectoryImpl* gearsDirectory = (GearsDirectoryImpl*)GearImpl(context, GearsDirectory, gearsDirectory); - Tree* tree = Gearef(context, Stack)->data; + 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 Sat Nov 20 17:23:16 2021 +0900 +++ b/src/parallel_execution/examples/gearsDirectory/GearsDirectory_test.cbc Sat Nov 27 17:29:54 2021 +0900 @@ -15,7 +15,9 @@ } __code task2(GearsDirectory* gearsDirectory){ - // goto gearsDirectory->cd2Parent(task3); + Integer* name = new Integer(); + name->value = 1; + goto gearsDirectory->cd2Child(name, task3); } __code task2_stub(struct Context* context){