summaryrefslogtreecommitdiff
path: root/src/module.cc
diff options
context:
space:
mode:
authorMarius Kintel <marius@kintel.net>2013-10-04 22:13:26 (GMT)
committerMarius Kintel <marius@kintel.net>2013-10-04 22:13:26 (GMT)
commitb4e80581ca09068e07050a09802a0fc23fa6342b (patch)
treea0f6442ec2b34b37cd7ac7f88e11c86b8f07ffc9 /src/module.cc
parent793ee8eb8887be567a679a83fcaf3970ebf48d50 (diff)
parent400d28d753aa8af8de60a7f82851ffdc3cdae672 (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.cc6
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;
}
contact: Jan Huwald // Impressum