diff --git a/src/context.cc b/src/context.cc index 567cdbca..c7903967 100644 --- a/src/context.cc +++ b/src/context.cc @@ -162,6 +162,14 @@ bool Context::has_local_variable(const std::string &name) const return variables.find(name) != variables.end(); } +/** + * This is separated because PRINTB uses quite a lot of stack space + * and the methods using it evaluate_function() and instantiate_module() + * are called often when recursive functions or modules are evaluated. + * + * @param what what is ignored + * @param name name of the ignored object + */ static void print_ignore_warning(const char *what, const char *name) { PRINTB("WARNING: Ignoring unknown %s '%s'.", what % name); diff --git a/src/evalcontext.cc b/src/evalcontext.cc index 223b4ce6..79f078b7 100644 --- a/src/evalcontext.cc +++ b/src/evalcontext.cc @@ -27,12 +27,7 @@ ValuePtr EvalContext::getArgValue(size_t i, const Context *ctx) const const Assignment &arg = this->eval_arguments[i]; ValuePtr v; if (arg.second) { - try { - v = arg.second->evaluate(ctx ? ctx : this); - } - catch (RecursionException &e) { - PRINT(e.what()); - } + v = arg.second->evaluate(ctx ? ctx : this); } return v; } diff --git a/src/module.cc b/src/module.cc index 2a85c6b7..8cf6498e 100644 --- a/src/module.cc +++ b/src/module.cc @@ -153,8 +153,13 @@ AbstractNode *ModuleInstantiation::evaluate(const Context *ctx) const PRINT("New eval ctx:"); c.dump(NULL, this); #endif - AbstractNode *node = ctx->instantiate_module(*this, &c); // Passes c as evalctx - return node; + try { + AbstractNode *node = ctx->instantiate_module(*this, &c); // Passes c as evalctx + return node; + } catch (RecursionException &e) { + PRINT(e.what()); + return NULL; + } } std::vector ModuleInstantiation::instantiateChildren(const Context *evalctx) const