Mercurial > octave
diff libinterp/corefcn/interpreter-private.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 | 214cb58ccc1c |
line wrap: on
line diff
--- a/libinterp/corefcn/interpreter-private.cc Fri Jun 09 11:36:34 2017 -0400 +++ b/libinterp/corefcn/interpreter-private.cc Fri Jun 09 02:21:28 2017 -0400 @@ -31,6 +31,7 @@ #include "load-path.h" #include "interpreter-private.h" #include "interpreter.h" +#include "symtab.h" namespace octave { @@ -39,7 +40,10 @@ interpreter *interp = interpreter::the_interpreter (); if (! interp) - error ("%s: interpreter context missing", who.c_str ()); + { + abort (); + error ("%s: interpreter context missing", who.c_str ()); + } return *interp; } @@ -51,6 +55,20 @@ return interp.get_load_path (); } + symbol_table& __get_symbol_table__ (const std::string& who) + { + interpreter& interp = __get_interpreter__ (who); + + return interp.get_symbol_table (); + } + + symbol_table::scope_id __get_current_scope__ (const std::string& who) + { + symbol_table& symtab = __get_symbol_table__ (who); + + return symtab.current_scope (); + } + tree_evaluator& __get_evaluator__ (const std::string& who) { interpreter& interp = __get_interpreter__ (who);