diff options
author | John Wiegley <johnw@newartisans.com> | 2010-06-24 19:53:59 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2010-06-24 19:53:59 -0400 |
commit | 2f50e30b89a06e2f3c439f4a8440e4d35b4ebb27 (patch) | |
tree | 330f3ffd1e9ae74cebe642409ccc6c351efb8670 /src/scope.h | |
parent | bc51cd4651225ad95190880c4d6f71e3a069ebbc (diff) | |
download | fork-ledger-2f50e30b89a06e2f3c439f4a8440e4d35b4ebb27.tar.gz fork-ledger-2f50e30b89a06e2f3c439f4a8440e4d35b4ebb27.tar.bz2 fork-ledger-2f50e30b89a06e2f3c439f4a8440e4d35b4ebb27.zip |
Scopes can now provide a description of themselves
This isn't being used yet, but it likely will to improve the information
presented to users if their value expressions fail to compile or
evaluate.
Diffstat (limited to 'src/scope.h')
-rw-r--r-- | src/scope.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/scope.h b/src/scope.h index 8b4a9380..31b10f6b 100644 --- a/src/scope.h +++ b/src/scope.h @@ -109,6 +109,8 @@ public: TRACE_DTOR(scope_t); } + virtual string description() = 0; + virtual void define(const symbol_t::kind_t, const string&, expr_t::ptr_op_t) {} virtual expr_t::ptr_op_t lookup(const symbol_t::kind_t kind, @@ -191,6 +193,10 @@ public: TRACE_DTOR(bind_scope_t); } + virtual string description() { + return grandchild.description(); + } + virtual void define(const symbol_t::kind_t kind, const string& name, expr_t::ptr_op_t def) { parent->define(kind, name, def); @@ -262,6 +268,16 @@ public: TRACE_DTOR(symbol_scope_t); } + virtual string description() { + if (parent) + return parent->description(); +#if !defined(NO_ASSERTS) + else + assert(false); +#endif + return empty_string; + } + virtual void define(const symbol_t::kind_t kind, const string& name, expr_t::ptr_op_t def); @@ -299,6 +315,10 @@ public: TRACE_DTOR(context_scope_t); } + virtual string description() { + return parent->description(); + } + virtual value_t::type_t type_context() const { return value_type_context; } @@ -351,6 +371,10 @@ public: TRACE_DTOR(call_scope_t); } + virtual string description() { + return context_scope_t::description(); + } + void set_args(const value_t& _args) { args = _args; } @@ -617,6 +641,10 @@ public: value_scope_t(scope_t& _parent, const value_t& _value) : child_scope_t(_parent), value(_value) {} + virtual string description() { + return parent->description(); + } + virtual expr_t::ptr_op_t lookup(const symbol_t::kind_t kind, const string& name) { |