Mercurial > octave
diff libinterp/corefcn/symtab.h @ 21574:ae4d7dfea337
maint: merge stable to default.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 01 Apr 2016 12:57:49 -0400 |
parents | dfce76507f4b f3f8e1d3e399 |
children | b571fc85953f |
line wrap: on
line diff
--- a/libinterp/corefcn/symtab.h Thu Mar 31 14:12:13 2016 -0700 +++ b/libinterp/corefcn/symtab.h Fri Apr 01 12:57:49 2016 -0400 @@ -49,6 +49,8 @@ { public: + static octave_value dummy_octave_value; + typedef int scope_id; typedef size_t context_id; @@ -262,12 +264,10 @@ } else if (is_persistent ()) { - static octave_value foobar; - symbol_table *inst = symbol_table::get_instance (symbol_table::current_scope ()); - return inst ? inst->do_persistent_varref (name) : foobar; + return inst ? inst->do_persistent_varref (name) : dummy_octave_value; } else { @@ -654,6 +654,8 @@ symbol_record (symbol_record_rep *new_rep) : rep (new_rep) { } }; + static symbol_record dummy_symbol_record; + // Always access a symbol from the current scope. // Useful for scripts, as they may be executed in more than one scope. class @@ -1310,11 +1312,9 @@ static symbol_record& insert (const std::string& name, scope_id scope = xcurrent_scope) { - static symbol_record foobar; - symbol_table *inst = get_instance (scope); - return inst ? inst->do_insert (name) : foobar; + return inst ? inst->do_insert (name) : symbol_table::dummy_symbol_record; } static void rename (const std::string& old_name, @@ -1333,8 +1333,6 @@ context_id context = xdefault_context, bool force_add = false) { - static octave_value foobar; - symbol_table *inst = get_instance (scope); if (inst) @@ -1346,11 +1344,9 @@ varref (const std::string& name, scope_id scope = xcurrent_scope, context_id context = xdefault_context, bool force_add = false) { - static octave_value foobar; - symbol_table *inst = get_instance (scope); - return inst ? inst->do_varref (name, context, force_add) : foobar; + return inst ? inst->do_varref (name, context, force_add) : dummy_octave_value; } // Convenience function to simplify @@ -1369,11 +1365,9 @@ force_varref (const std::string& name, scope_id scope = xcurrent_scope, context_id context = xdefault_context) { - static octave_value foobar; - symbol_table *inst = get_instance (scope); - return inst ? inst->do_varref (name, context, true) : foobar; + return inst ? inst->do_varref (name, context, true) : dummy_octave_value; } static octave_value varval (const std::string& name, @@ -1427,11 +1421,9 @@ static octave_value& top_level_varref (const std::string& name) { - static octave_value foobar; - symbol_table *inst = get_instance (top_scope ()); - return inst ? inst->do_varref (name, 0, true) : foobar; + return inst ? inst->do_varref (name, 0, true) : dummy_octave_value; } static octave_value @@ -1454,11 +1446,9 @@ static octave_value& persistent_varref (const std::string& name) { - static octave_value foobar; - symbol_table *inst = get_instance (xcurrent_scope); - return inst ? inst->do_persistent_varref (name) : foobar; + return inst ? inst->do_persistent_varref (name) : dummy_octave_value; } static octave_value persistent_varval (const std::string& name)