Mercurial > hg > Gears > Gears
view src/parallel_execution/examples/gearsDirectory/GearsDirectoryImpl.cbc @ 985:33d7b8a86f69
fix gearsDirectory
author | matac42 <matac@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 20 Nov 2021 03:13:21 +0900 |
parents | f86f3496f5fd |
children | 3c9f6fda000d |
line wrap: on
line source
#include "../../../context.h" #interface "GearsDirectory.h" #interface "Stack.h" #interface "Tree.h" #impl "GearsDirectory.h" as "GearsDirectoryImpl.h" // ---- // typedef struct GearsDirectoryImpl <> impl GearsDirectory { // struct Tree* currentDirectory; // struct Stack* directoryStack; // } GearsDirectoryImpl; // ---- GearsDirectory* createGearsDirectoryImpl(struct Context* context) { struct GearsDirectory* gearsDirectory = new GearsDirectory(); struct GearsDirectoryImpl* gears_directory_impl = new GearsDirectoryImpl(); gearsDirectory->gearsDirectory = (union Data*)gears_directory_impl; struct Tree* firstTree = new RedBlackTree(); gears_directory_impl->currentDirectory = firstTree; gears_directory_impl->directoryStack = createSingleLinkedStack(context); gearsDirectory->cd2Child = C_cd2ChildGearsDirectoryImpl; gearsDirectory->cd2Parent = C_cd2ParentGearsDirectoryImpl; return gearsDirectory; } __code cd2Child(struct GearsDirectoryImpl* gearsDirectory, __code next(...)) { // treeを作る struct Tree* tree = new RedBlackTree(); // currentDirectoryを作ったtreeに変更する struct Tree* parentDirectory = gearsDirectory->currentDirectory; gearsDirectory->currentDirectory = tree; // current treeをstackにpushする struct Stack* ds = gearsDirectory->directoryStack; goto ds->push(parentDirectory, 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; goto next(...); } __code cd2Parent2_stub(struct Context* context) { GearsDirectoryImpl* gearsDirectory = (GearsDirectoryImpl*)GearImpl(context, GearsDirectory, gearsDirectory); Tree* tree = Gearef(context, Stack)->data; enum Code next = Gearef(context, GearsDirectory)->next; goto cd2Parent2(context, gearsDirectory, tree, next); }