diff options
author | Marius Kintel <marius@kintel.net> | 2013-10-04 22:13:26 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2013-10-04 22:13:26 (GMT) |
commit | b4e80581ca09068e07050a09802a0fc23fa6342b (patch) | |
tree | a0f6442ec2b34b37cd7ac7f88e11c86b8f07ffc9 /src/module.cc | |
parent | 793ee8eb8887be567a679a83fcaf3970ebf48d50 (diff) | |
parent | 400d28d753aa8af8de60a7f82851ffdc3cdae672 (diff) |
Merge branch 'bom-tree-std-stack' of git://github.com/steelman/openscad into steelman-bom-tree-std-stack
Conflicts:
src/module.cc
Diffstat (limited to 'src/module.cc')
-rw-r--r-- | src/module.cc | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/module.cc b/src/module.cc index f66c8ef..e3a992b 100644 --- a/src/module.cc +++ b/src/module.cc @@ -153,6 +153,8 @@ std::vector<AbstractNode*> IfElseModuleInstantiation::instantiateElseChildren(co return this->else_scope.instantiateChildren(evalctx); } +std::deque<std::string> Module::module_stack; + Module::~Module() { } @@ -183,6 +185,9 @@ AbstractNode *Module::instantiate(const Context *ctx, const ModuleInstantiation // set $children first since we might have variables depending on it c.set_variable("$children", Value(double(inst->scope.children.size()))); c.initializeModule(*this); + module_stack.push_back(inst->name()); + c.set_variable("$parent_modules", Value(double(module_stack.size()))); + c.initializeModule(*this); // FIXME: Set document path to the path of the module #if 0 && DEBUG c.dump(this, inst); @@ -191,6 +196,7 @@ AbstractNode *Module::instantiate(const Context *ctx, const ModuleInstantiation AbstractNode *node = new AbstractNode(inst); std::vector<AbstractNode *> instantiatednodes = this->scope.instantiateChildren(&c); node->children.insert(node->children.end(), instantiatednodes.begin(), instantiatednodes.end()); + module_stack.pop_back(); return node; } |