From 2f50e30b89a06e2f3c439f4a8440e4d35b4ebb27 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 24 Jun 2010 19:53:59 -0400 Subject: 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. --- src/scope.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/scope.h') 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) { -- cgit v1.2.3