diff options
author | Łukasz Stelmach <stlman@poczta.fm> | 2013-08-18 15:18:43 (GMT) |
---|---|---|
committer | Łukasz Stelmach <stlman@poczta.fm> | 2013-08-18 15:19:49 (GMT) |
commit | 400d28d753aa8af8de60a7f82851ffdc3cdae672 (patch) | |
tree | 3e76d4c4449556c26d48073200956045bc092111 /src/module.h | |
parent | d67e0129161a98f852ed2685f43e7eb7c7538bf0 (diff) |
Enable module stack introspection from within an SCAD script
The _current_module and _parent_module variables have been replaced
by a built-in function parent_module(n). It takes one numeric parameter n,
and returns n-th element from the module stack. If no argument provided,
n defaults to 1 and the function returns the name of the direct parent
module. If n is equal 0 current module name is returned.
Diffstat (limited to 'src/module.h')
-rw-r--r-- | src/module.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/module.h b/src/module.h index fca88e3..8414706 100644 --- a/src/module.h +++ b/src/module.h @@ -4,7 +4,7 @@ #include <string> #include <vector> #include <list> -#include <stack> +#include <deque> #include <boost/unordered_map.hpp> #include <boost/unordered_set.hpp> #include <time.h> @@ -74,12 +74,15 @@ public: virtual AbstractNode *instantiate(const Context *ctx, const ModuleInstantiation *inst, const EvalContext *evalctx = NULL) const; virtual std::string dump(const std::string &indent, const std::string &name) const; + static const std::string& stack_element(int n) { return module_stack[n]; }; + static int stack_size() { return module_stack.size(); }; AssignmentList definition_arguments; LocalScope scope; + private: - static std::stack<std::string> stack; + static std::deque<std::string> module_stack; }; // FIXME: A FileModule doesn't have definition arguments, so we shouldn't really |