mirror of https://github.com/vitalif/openscad
access method for parent context
parent
19de4c9d15
commit
d2eecc4e06
|
@ -13,6 +13,7 @@ public:
|
||||||
Context(const Context *parent = NULL);
|
Context(const Context *parent = NULL);
|
||||||
virtual ~Context();
|
virtual ~Context();
|
||||||
|
|
||||||
|
const Context *getParent() const { return this->parent; }
|
||||||
virtual Value evaluate_function(const std::string &name, const class EvalContext *evalctx) const;
|
virtual Value evaluate_function(const std::string &name, const class EvalContext *evalctx) const;
|
||||||
virtual class AbstractNode *instantiate_module(const class ModuleInstantiation &inst, const EvalContext *evalctx) const;
|
virtual class AbstractNode *instantiate_module(const class ModuleInstantiation &inst, const EvalContext *evalctx) const;
|
||||||
|
|
||||||
|
@ -29,11 +30,11 @@ public:
|
||||||
std::string getAbsolutePath(const std::string &filename) const;
|
std::string getAbsolutePath(const std::string &filename) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const Context *parent;
|
|
||||||
|
|
||||||
static std::vector<const Context*> ctx_stack;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
const Context *parent;
|
||||||
|
static std::vector<const Context*> ctx_stack;
|
||||||
|
|
||||||
typedef boost::unordered_map<std::string, Value> ValueMap;
|
typedef boost::unordered_map<std::string, Value> ValueMap;
|
||||||
ValueMap constants;
|
ValueMap constants;
|
||||||
ValueMap variables;
|
ValueMap variables;
|
||||||
|
|
|
@ -109,8 +109,8 @@ const EvalContext* ControlModule::getLastModuleCtx(const EvalContext *evalctx)
|
||||||
// Find the last custom module invocation, which will contain
|
// Find the last custom module invocation, which will contain
|
||||||
// an eval context with the children of the module invokation
|
// an eval context with the children of the module invokation
|
||||||
const Context *tmpc = evalctx;
|
const Context *tmpc = evalctx;
|
||||||
while (tmpc->parent) {
|
while (tmpc->getParent()) {
|
||||||
const ModuleContext *modulectx = dynamic_cast<const ModuleContext*>(tmpc->parent);
|
const ModuleContext *modulectx = dynamic_cast<const ModuleContext*>(tmpc->getParent());
|
||||||
if (modulectx) {
|
if (modulectx) {
|
||||||
// This will trigger if trying to invoke child from the root of any file
|
// This will trigger if trying to invoke child from the root of any file
|
||||||
// assert(filectx->evalctx);
|
// assert(filectx->evalctx);
|
||||||
|
@ -119,7 +119,7 @@ const EvalContext* ControlModule::getLastModuleCtx(const EvalContext *evalctx)
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
tmpc = tmpc->parent;
|
tmpc = tmpc->getParent();
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue