Mercurial > octave
diff libinterp/octave-value/ov-class.cc @ 23599:5cb3a2bb5e1e
don't use singleton for symbol_table
This is the first of a series of changes to make the symbol table a
part of the interpreter instead of a global object. These changes
also aim to simplify the implementation of symbol table so that it is
easier to understand and modify.
* Functions now own their scope (workspace) data.
* The list of subfunctions is contained in the scope rather than a
global list.
* symtab.h, symtab.cc (class symbol_table): Don't use singleton
pattern.
* interpreter.h, interpreter.cc (interpreter::m_symbol_table): New
data member.
(interpreter::~interpreter): Don't set instance to 0.
* interpreter-private.h, interpreter-private.cc
(__get_symbol_table__): New function.
Change all uses of call_stack to access call_stack object from the
interpreter.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 09 Jun 2017 02:21:28 -0400 |
parents | 80e3bfb7bd5a |
children | b9378eff6d13 |
line wrap: on
line diff
--- a/libinterp/octave-value/ov-class.cc Fri Jun 09 11:36:34 2017 -0400 +++ b/libinterp/octave-value/ov-class.cc Fri Jun 09 02:21:28 2017 -0400 @@ -197,7 +197,9 @@ } } - symbol_table::add_to_parent_map (id, parent_list); + symbol_table& symtab = octave::__get_symbol_table__ ("octave_class"); + + symtab.add_to_parent_map (id, parent_list); } octave_base_value * @@ -295,7 +297,10 @@ return octave_base_value::size (); Matrix retval (1, 2, 1.0); - octave_value meth = symbol_table::find_method ("size", class_name ()); + + symbol_table& symtab = octave::__get_symbol_table__ ("octave_class::size"); + + octave_value meth = symtab.find_method ("size", class_name ()); if (meth.is_defined ()) { @@ -333,7 +338,9 @@ octave_idx_type retval = -1; const std::string cn = class_name (); - octave_value meth = symbol_table::find_method ("numel", cn); + symbol_table& symtab = octave::__get_symbol_table__ ("octave_class::numel"); + + octave_value meth = symtab.find_method ("numel", cn); if (meth.is_defined ()) { @@ -426,7 +433,9 @@ } else { - octave_value meth = symbol_table::find_method ("subsref", class_name ()); + symbol_table& symtab = octave::__get_symbol_table__ ("octave_class::subsref"); + + octave_value meth = symtab.find_method ("subsref", class_name ()); if (meth.is_defined ()) { @@ -524,7 +533,10 @@ if (! (in_class_method () || called_from_builtin ())) { - octave_value meth = symbol_table::find_method ("subsasgn", class_name ()); + symbol_table& symtab + = octave::__get_symbol_table__ ("octave_class::subsasgn_common"); + + octave_value meth = symtab.find_method ("subsasgn", class_name ()); if (meth.is_defined ()) { @@ -799,7 +811,9 @@ idx_vector octave_class::index_vector (bool require_integers) const { - octave_value meth = symbol_table::find_method ("subsindex", class_name ()); + symbol_table& symtab = octave::__get_symbol_table__ ("octave_class::index_vector"); + + octave_value meth = symtab.find_method ("subsindex", class_name ()); if (! meth.is_defined ()) error ("no subsindex method defined for class %s", @@ -845,7 +859,9 @@ { bool retval = false; - octave_value meth = symbol_table::find_method ("logical", class_name ()); + symbol_table& symtab = octave::__get_symbol_table__ ("octave_class::is_true"); + + octave_value meth = symtab.find_method ("logical", class_name ()); if (meth.is_defined ()) { @@ -961,7 +977,10 @@ { string_vector retval; - octave_value meth = symbol_table::find_method ("char", class_name ()); + symbol_table& symtab + = octave::__get_symbol_table__ ("octave_class::string_vector_value"); + + octave_value meth = symtab.find_method ("char", class_name ()); if (! meth.is_defined ()) error ("no char method defined for class %s", class_name ().c_str ()); @@ -1026,7 +1045,10 @@ retval = true; else { - octave_value ctor = symbol_table::find_method (c_name, c_name); + symbol_table& symtab + = octave::__get_symbol_table__ ("octave_class::reconstruct_exemplar"); + + octave_value ctor = symtab.find_method (c_name, c_name); bool have_ctor = false; @@ -2023,8 +2045,10 @@ if (is_built_in_class (inf_class)) break; + symbol_table& symtab = interp.get_symbol_table (); + std::string sup_class = fcn->name (); - if (! symbol_table::set_class_relationship (sup_class, inf_class)) + if (! symtab.set_class_relationship (sup_class, inf_class)) error ("superiorto: opposite precedence already set for %s and %s", sup_class.c_str (), inf_class.c_str ()); } @@ -2058,8 +2082,10 @@ error ("inferiorto: cannot give user-defined class lower " "precedence than built-in class"); + symbol_table& symtab = interp.get_symbol_table (); + std::string inf_class = fcn->name (); - if (! symbol_table::set_class_relationship (sup_class, inf_class)) + if (! symtab.set_class_relationship (sup_class, inf_class)) error ("inferiorto: opposite precedence already set for %s and %s", inf_class.c_str (), sup_class.c_str ()); }