Mercurial > octave
changeset 25401:6f6479125d80
eliminate some globals from tree_evaluator class
* pt-eval.cc (tree_evaluator::m_statement_context): New member
variable, replaces static data member statement_context. Change all uses.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 22 May 2018 00:53:15 -0400 |
parents | d423ce60f5c8 |
children | ef2b9d4abf4a |
files | libinterp/parse-tree/pt-eval.cc libinterp/parse-tree/pt-eval.h |
diffstat | 2 files changed, 24 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/parse-tree/pt-eval.cc Mon May 21 22:06:20 2018 -0400 +++ b/libinterp/parse-tree/pt-eval.cc Tue May 22 00:53:15 2018 -0400 @@ -67,14 +67,12 @@ bool tree_evaluator::quiet_breakpoint_flag = false; - tree_evaluator::stmt_list_type tree_evaluator::statement_context - = tree_evaluator::other; - // Normal evaluator. void tree_evaluator::reset (void) { + m_statement_context = SC_OTHER; m_result_type = RT_UNDEFINED; m_expr_result_value = octave_value (); m_expr_result_value_list = octave_value_list (); @@ -428,8 +426,8 @@ bool tree_evaluator::statement_printing_enabled (void) { - return ! (m_silent_functions && (statement_context == function - || statement_context == script)); + return ! (m_silent_functions && (m_statement_context == SC_FUNCTION + || m_statement_context == SC_SCRIPT)); } void @@ -1203,7 +1201,7 @@ tree_statement_list *cmd_list = user_script.body (); - if (cmd_list) + if (! cmd_list) return retval; unwind_protect frame; @@ -1228,8 +1226,8 @@ frame.protect_var (Vtrack_line_num); Vtrack_line_num = true; - frame.protect_var (tree_evaluator::statement_context); - tree_evaluator::statement_context = tree_evaluator::script; + frame.protect_var (m_statement_context); + m_statement_context = SC_SCRIPT; profiler::enter<octave_user_script> block (m_profiler, user_script); @@ -1398,8 +1396,8 @@ // Evaluate the commands that make up the function. - frame.protect_var (tree_evaluator::statement_context); - tree_evaluator::statement_context = tree_evaluator::function; + frame.protect_var (m_statement_context); + m_statement_context = SC_FUNCTION; { profiler::enter<octave_user_function> block (m_profiler, user_function); @@ -1580,7 +1578,8 @@ { tree_expression *expr = tic->condition (); - if (statement_context == function || statement_context == script) + if (m_statement_context == SC_FUNCTION + || m_statement_context == SC_SCRIPT) m_call_stack.set_location (tic->line (), tic->column ()); if (debug_mode && ! tic->is_else_clause ()) @@ -2368,7 +2367,8 @@ reset_debug_state (); } - else if (statement_context == function || statement_context == script + else if (m_statement_context == SC_FUNCTION + || m_statement_context == SC_SCRIPT || m_in_loop_command) tree_return_command::returning = 1; } @@ -2467,7 +2467,8 @@ if (cmd || expr) { - if (statement_context == function || statement_context == script) + if (m_statement_context == SC_FUNCTION + || m_statement_context == SC_SCRIPT) { // Skip commands issued at a debug> prompt to avoid disturbing // the state of the program we are debugging.
--- a/libinterp/parse-tree/pt-eval.h Mon May 21 22:06:20 2018 -0400 +++ b/libinterp/parse-tree/pt-eval.h Tue May 22 00:53:15 2018 -0400 @@ -126,10 +126,10 @@ typedef void (*decl_elt_init_fcn) (tree_decl_elt&); tree_evaluator (interpreter& interp) - : m_interpreter (interp), m_result_type (RT_UNDEFINED), - m_expr_result_value (), m_expr_result_value_list (), - m_lvalue_list_stack (), m_nargout_stack (), - m_bp_table (*this), m_call_stack (interp), + : m_interpreter (interp), m_statement_context (SC_OTHER), + m_result_type (RT_UNDEFINED), m_expr_result_value (), + m_expr_result_value_list (), m_lvalue_list_stack (), + m_nargout_stack (), m_bp_table (*this), m_call_stack (interp), m_profiler (), m_max_recursion_depth (256), m_silent_functions (false), m_string_fill_char (' '), m_PS4 ("+ "), m_dbstep_flag (0), m_echo (ECHO_OFF), @@ -267,14 +267,11 @@ // Possible types of evaluation contexts. enum stmt_list_type { - function, // function body - script, // script file - other // command-line input or eval string + SC_FUNCTION, // function body + SC_SCRIPT, // script file + SC_OTHER // command-line input or eval string }; - // The context for the current evaluation. - static stmt_list_type statement_context; - Matrix ignored_fcn_outputs (void) const; bool isargout (int nargout, int iout) const; @@ -512,6 +509,9 @@ interpreter& m_interpreter; + // The context for the current evaluation. + stmt_list_type m_statement_context; + result_type m_result_type; octave_value m_expr_result_value; octave_value_list m_expr_result_value_list;