Mercurial > octave
diff libinterp/corefcn/help.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 | 14723784b9f2 |
children | b0e9c030f063 |
line wrap: on
line diff
--- a/libinterp/corefcn/help.cc Fri Jun 09 11:36:34 2017 -0400 +++ b/libinterp/corefcn/help.cc Fri Jun 09 02:21:28 2017 -0400 @@ -160,9 +160,11 @@ if (! curr_fcn) return retval; + symbol_table& symtab = octave::__get_symbol_table__ ("local_functions"); + // All subfunctions are listed in the top-level function of this file. while (curr_fcn->is_subfunction ()) - curr_fcn = symbol_table::get_curr_fcn (curr_fcn->parent_fcn_scope ()); + curr_fcn = symtab.get_curr_fcn (curr_fcn->parent_fcn_scope ()); // Get subfunctions. const std::list<std::string> names = curr_fcn->subfunction_names (); @@ -186,13 +188,15 @@ const static string_vector keywords = Fiskeyword ()(0).string_vector_value (); const static int key_len = keywords.numel (); - const string_vector bif = symbol_table::built_in_function_names (); + symbol_table& symtab = octave::__get_symbol_table__ ("make_name_list"); + + const string_vector bif = symtab.built_in_function_names (); const int bif_len = bif.numel (); - const string_vector cfl = symbol_table::cmdline_function_names (); + const string_vector cfl = symtab.cmdline_function_names (); const int cfl_len = cfl.numel (); - const string_vector lcl = symbol_table::variable_names (); + const string_vector lcl = symtab.variable_names (); const int lcl_len = lcl.numel (); octave::load_path& lp = octave::__get_load_path__ ("make_name_list"); @@ -272,7 +276,9 @@ { bool retval = false; - octave_value val = symbol_table::find_function (nm); + symbol_table& symtab = octave::__get_symbol_table__ ("raw_help_from_symbol_table"); + + octave_value val = symtab.find_function (nm); if (val.is_defined ()) { @@ -619,13 +625,15 @@ // Return a cell array of strings with the names of all builtin functions. -DEFUN (__builtins__, , , - doc: /* -*- texinfo -*- +DEFMETHOD (__builtins__, interp, , , + doc: /* -*- texinfo -*- @deftypefn {} {} __builtins__ () Undocumented internal function. @end deftypefn */) { - const string_vector bif = symbol_table::built_in_function_names (); + symbol_table& symtab = interp.get_symbol_table (); + + const string_vector bif = symtab.built_in_function_names (); return ovl (Cell (bif)); } @@ -706,7 +714,9 @@ type = ""; - octave_value val = symbol_table::find_function (name); + symbol_table& symtab = octave::__get_symbol_table__ ("do_which"); + + octave_value val = symtab.find_function (name); if (name.find_first_of ('.') == std::string::npos) {