Mercurial > octave
changeset 27204:9a3e92d02a03
eliminate direct access to call stack in variables functions
* pt-eval.h, pt-eval.cc (tree_evaluator::caller_function,
tree_evaluator::curr_fcn_unwind_protect_frame): New functions.
* variables.cc (curr_fcn_unwind_protect_frame, Fmlock, Fmunlock,
Fmislocked, F__varval__): Eliminate direct access to call stack.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 01 Apr 2019 18:21:27 +0000 |
parents | 79065f9d5553 |
children | 6648d1ae05fe |
files | libinterp/corefcn/variables.cc libinterp/parse-tree/pt-eval.cc libinterp/parse-tree/pt-eval.h |
diffstat | 3 files changed, 24 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/variables.cc Mon Apr 01 18:00:15 2019 +0000 +++ b/libinterp/corefcn/variables.cc Mon Apr 01 18:21:27 2019 +0000 @@ -40,7 +40,6 @@ #include "lo-regexp.h" #include "str-vec.h" -#include "call-stack.h" #include "Cell.h" #include "defun.h" #include "dirfns.h" @@ -537,10 +536,10 @@ static octave::unwind_protect * curr_fcn_unwind_protect_frame (void) { - octave::call_stack& cs - = octave::__get_call_stack__ ("curr_fcn_unwind_protect_frame"); + octave::tree_evaluator& tw + = octave::__get_evaluator__ ("curr_fcn_unwind_protect_frame"); - return cs.curr_fcn_unwind_protect_frame (); + return tw.curr_fcn_unwind_protect_frame (); } template <typename T> @@ -835,9 +834,9 @@ if (args.length () != 0) print_usage (); - octave::call_stack& cs = interp.get_call_stack (); + octave::tree_evaluator& tw = interp.get_evaluator (); - octave_function *fcn = cs.caller (); + octave_function *fcn = tw.caller_function (); if (! fcn) error ("mlock: invalid use outside a function"); @@ -871,9 +870,9 @@ } else { - octave::call_stack& cs = interp.get_call_stack (); + octave::tree_evaluator& tw = interp.get_evaluator (); - octave_function *fcn = cs.caller (); + octave_function *fcn = tw.caller_function (); if (! fcn) error ("munlock: invalid use outside a function"); @@ -909,9 +908,9 @@ } else { - octave::call_stack& cs = interp.get_call_stack (); + octave::tree_evaluator& tw = interp.get_evaluator (); - octave_function *fcn = cs.caller (); + octave_function *fcn = tw.caller_function (); if (! fcn) error ("mislocked: invalid use outside a function"); @@ -1441,9 +1440,9 @@ if (nm == ".argn.") { - octave::call_stack& cs = interp.get_call_stack (); + octave::tree_evaluator& tw = interp.get_evaluator (); - return cs.get_auto_fcn_var (octave::stack_frame::ARG_NAMES); + return tw.get_auto_fcn_var (octave::stack_frame::ARG_NAMES); } return interp.varval (nm);
--- a/libinterp/parse-tree/pt-eval.cc Mon Apr 01 18:00:15 2019 +0000 +++ b/libinterp/parse-tree/pt-eval.cc Mon Apr 01 18:21:27 2019 +0000 @@ -1881,6 +1881,11 @@ return m_call_stack.current_user_code (); } + unwind_protect * tree_evaluator::curr_fcn_unwind_protect_frame (void) const + { + return m_call_stack.curr_fcn_unwind_protect_frame (); + } + octave_user_code * tree_evaluator::debug_user_code (void) const { return m_call_stack.debug_user_code (); @@ -1891,6 +1896,11 @@ return m_call_stack.current (); } + octave_function * tree_evaluator::caller_function (void) const + { + return m_call_stack.caller (); + } + bool tree_evaluator::goto_frame (size_t n, bool verbose) { return m_call_stack.goto_frame (n, verbose);
--- a/libinterp/parse-tree/pt-eval.h Mon Apr 01 18:00:15 2019 +0000 +++ b/libinterp/parse-tree/pt-eval.h Mon Apr 01 18:21:27 2019 +0000 @@ -488,19 +488,15 @@ octave_user_code * current_user_code (void) const; - // Line in user code caller. - int caller_user_code_line (void) const; - - // Column in user code caller. - int caller_user_code_column (void) const; - - octave_user_code * caller_user_code (size_t nskip = 0) const; + unwind_protect * curr_fcn_unwind_protect_frame (void) const; // Current function that we are debugging. octave_user_code * debug_user_code (void) const; octave_function * current_function (void) const; + octave_function * caller_function (void) const; + bool goto_frame (size_t n = 0, bool verbose = false); void restore_frame (size_t n);