Mercurial > octave
changeset 27206:4e4a9d7b436e
eliminate direct access to call stack in mex functions
* mex.cc (mex::function_name, mexGetVariable, mexPutVariable):
Eliminate direct access to call stack.
* pt-eval.h, pt-eval.cc (tree_evaluator::goto_caller_frame,
tree_evaluator::goto_base_frame): New functions.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 01 Apr 2019 20:25:34 +0000 |
parents | 6648d1ae05fe |
children | 242e66e014d9 |
files | libinterp/corefcn/mex.cc libinterp/parse-tree/pt-eval.cc libinterp/parse-tree/pt-eval.h |
diffstat | 3 files changed, 30 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/mex.cc Mon Apr 01 18:28:44 2019 +0000 +++ b/libinterp/corefcn/mex.cc Mon Apr 01 20:25:34 2019 +0000 @@ -40,7 +40,6 @@ #include "quit.h" #include "Cell.h" -#include "call-stack.h" #include "error.h" #include "interpreter-private.h" #include "interpreter.h" @@ -2163,10 +2162,10 @@ { if (! fname) { - octave::call_stack& cs - = octave::__get_call_stack__ ("mex::function_name"); - - octave_function *fcn = cs.current (); + octave::tree_evaluator& tw + = octave::__get_evaluator__ ("mex::function_name"); + + octave_function *fcn = tw.current_function (); if (fcn) { @@ -3512,12 +3511,12 @@ if (base) { - octave::call_stack& cs = interp.get_call_stack (); - - frame.add_method (cs, &octave::call_stack::restore_frame, - cs.current_frame ()); - - cs.goto_base_frame (); + octave::tree_evaluator& tw = interp.get_evaluator (); + + frame.add_method (tw, &octave::tree_evaluator::restore_frame, + tw.current_call_stack_frame_number ()); + + tw.goto_base_frame (); } val = interp.varval (name); @@ -3577,12 +3576,12 @@ if (base) { - octave::call_stack& cs = interp.get_call_stack (); - - frame.add_method (cs, &octave::call_stack::restore_frame, - cs.current_frame ()); - - cs.goto_base_frame (); + octave::tree_evaluator& tw = interp.get_evaluator (); + + frame.add_method (tw, &octave::tree_evaluator::restore_frame, + tw.current_call_stack_frame_number ()); + + tw.goto_base_frame (); } interp.assign (name, mxArray::as_octave_value (ptr));
--- a/libinterp/parse-tree/pt-eval.cc Mon Apr 01 18:28:44 2019 +0000 +++ b/libinterp/parse-tree/pt-eval.cc Mon Apr 01 20:25:34 2019 +0000 @@ -1921,6 +1921,16 @@ return m_call_stack.goto_frame (n, verbose); } + void tree_evaluator::goto_caller_frame (void) + { + m_call_stack.goto_caller_frame (); + } + + void tree_evaluator::goto_base_frame (void) + { + m_call_stack.goto_base_frame (); + } + void tree_evaluator::restore_frame (size_t n) { return m_call_stack.restore_frame (n);
--- a/libinterp/parse-tree/pt-eval.h Mon Apr 01 18:28:44 2019 +0000 +++ b/libinterp/parse-tree/pt-eval.h Mon Apr 01 20:25:34 2019 +0000 @@ -508,6 +508,10 @@ bool goto_frame (size_t n = 0, bool verbose = false); + void goto_caller_frame (void); + + void goto_base_frame (void); + void restore_frame (size_t n); bool goto_frame_relative (int n, bool verbose = false);