# HG changeset patch # User John W. Eaton # Date 1554151124 0 # Node ID 5b40cf4896f0c1bce9529e449a145ab5d90264b8 # Parent 242e66e014d9784267efbed58867bbf1e56778e2 eliminate some direct access to call stack in classdef and inline objects * pt-eval.h, pt-eval.cc (tree_evaluator::get_dispatch_class, tree_evaluator::set_dispatch_class): New functions. * cdef-property.cc (is_method_executing): Eliminate direct access to call stack. * cdef-utils.cc (get_class_context): Likewise. * ov-fcn-inline.cc (octave_fcn_inline::octave_fcn_inline): Likewise. * ov-classdef.cc (octave_classdef_superclass_ref::is_constructed_object): Likewise. diff -r 242e66e014d9 -r 5b40cf4896f0 libinterp/octave-value/cdef-property.cc --- a/libinterp/octave-value/cdef-property.cc Mon Apr 01 20:28:53 2019 +0000 +++ b/libinterp/octave-value/cdef-property.cc Mon Apr 01 20:38:44 2019 +0000 @@ -54,9 +54,7 @@ { tree_evaluator& tw = __get_evaluator__ ("is_method_executing"); - call_stack& cs = __get_call_stack__ ("is_method_executing"); - - octave_function *stack_fcn = cs.current (); + octave_function *stack_fcn = tw.current_function (); octave_function *method_fcn = ov.function_value (true); diff -r 242e66e014d9 -r 5b40cf4896f0 libinterp/octave-value/cdef-utils.cc --- a/libinterp/octave-value/cdef-utils.cc Mon Apr 01 20:28:53 2019 +0000 +++ b/libinterp/octave-value/cdef-utils.cc Mon Apr 01 20:38:44 2019 +0000 @@ -24,7 +24,6 @@ # include "config.h" #endif -#include "call-stack.h" #include "cdef-class.h" #include "cdef-manager.h" #include "cdef-method.h" @@ -34,6 +33,7 @@ #include "interpreter-private.h" #include "ov-classdef.h" #include "ov-usr-fcn.h" +#include "pt-eval.h" namespace octave { @@ -252,14 +252,14 @@ // methods will use the dispatch class of the class in which they // are defined instead of the class in which they are executing. - call_stack& cs = __get_call_stack__ ("get_class_context"); + tree_evaluator& tw = __get_evaluator__ ("get_class_context"); - std::string dispatch_class = cs.get_dispatch_class (); + std::string dispatch_class = tw.get_dispatch_class (); if (! dispatch_class.empty ()) return lookup_class (dispatch_class); - octave_function *fcn = cs.current (); + octave_function *fcn = tw.current_function (); if (fcn && (fcn->is_class_method () || fcn->is_classdef_constructor () diff -r 242e66e014d9 -r 5b40cf4896f0 libinterp/octave-value/ov-classdef.cc --- a/libinterp/octave-value/ov-classdef.cc Mon Apr 01 20:28:53 2019 +0000 +++ b/libinterp/octave-value/ov-classdef.cc Mon Apr 01 20:38:44 2019 +0000 @@ -27,7 +27,6 @@ #include #include -#include "call-stack.h" #include "cdef-class.h" #include "cdef-method.h" #include "cdef-package.h" @@ -490,9 +489,7 @@ bool octave_classdef_superclass_ref::is_constructed_object (octave::tree_evaluator& tw, const std::string& nm) { - octave::call_stack& cs = tw.get_call_stack (); - - octave_function *of = cs.current (); + octave_function *of = tw.current_function (); if (of->is_classdef_constructor ()) { diff -r 242e66e014d9 -r 5b40cf4896f0 libinterp/octave-value/ov-fcn-inline.cc --- a/libinterp/octave-value/ov-fcn-inline.cc Mon Apr 01 20:28:53 2019 +0000 +++ b/libinterp/octave-value/ov-fcn-inline.cc Mon Apr 01 20:38:44 2019 +0000 @@ -35,7 +35,6 @@ #include "oct-locbuf.h" -#include "call-stack.h" #include "defun.h" #include "error.h" #include "errwarn.h" @@ -101,9 +100,9 @@ if (uf) { - octave::call_stack& cs = interp.get_call_stack (); + octave::tree_evaluator& tw = interp.get_evaluator (); - octave_function *curr_fcn = cs.current (); + octave_function *curr_fcn = tw.current_function (); if (curr_fcn) { diff -r 242e66e014d9 -r 5b40cf4896f0 libinterp/parse-tree/pt-eval.cc --- a/libinterp/parse-tree/pt-eval.cc Mon Apr 01 20:28:53 2019 +0000 +++ b/libinterp/parse-tree/pt-eval.cc Mon Apr 01 20:38:44 2019 +0000 @@ -1936,6 +1936,16 @@ return m_call_stack.restore_frame (n); } + std::string tree_evaluator::get_dispatch_class (void) const + { + return m_call_stack.get_dispatch_class (); + } + + void tree_evaluator::set_dispatch_class (const std::string& class_name) + { + m_call_stack.set_dispatch_class (class_name); + } + std::list tree_evaluator::backtrace_frames (octave_idx_type& curr_user_frame) const { diff -r 242e66e014d9 -r 5b40cf4896f0 libinterp/parse-tree/pt-eval.h --- a/libinterp/parse-tree/pt-eval.h Mon Apr 01 20:28:53 2019 +0000 +++ b/libinterp/parse-tree/pt-eval.h Mon Apr 01 20:38:44 2019 +0000 @@ -521,6 +521,10 @@ std::list backtrace_frames () const; + std::string get_dispatch_class (void) const; + + void set_dispatch_class (const std::string& class_name); + octave_map backtrace (octave_idx_type& curr_user_frame, bool print_subfn = true) const;