diff libinterp/octave-value/ov-fcn.h @ 28429:8eb8ba8aff9a stable

refactor octave_function call method This change is a step toward keeping stack frames for closures (handles to nested functions) separate from the functions themselves. * call-stack.h, call-stack.cc (call_stack::curr_fcn_unwind_protect_frame: No longer const. Update all uses. (call_stack::push): Dliminate unwind protect frame argument. Change all uses. * stack-frame.h, stack-frame.cc (script_stack_frame, user_fcn_stack_frame): Create uniwnd_protect_frame only if needed. * ov-builtin.h, ov-builtin.cc (octave_builtin::execute): New function that executes function without pushing stack frame. (octave_builtin::call): Delete. * ov-class.h, ov-class.cc (octave_inline_fcn::execute): New function. (octave_inline_fcn::call): Call execute. * ov-classdef.h, ov-classdef.cc (octave_classdef_meta::execute): New function. (octave_classdef_meta::call): Call execute. (octave_classdef_superclass_ref::execute): New function. (octave_classdef_superclass_ref::call): Call execute. * ov-fcn-handle.cc (octave_fcn_handle::call): When calling a function that has closure_frames, push stack frame here instead of inside octave_user_function object. * ov-fcn.h (octave_function::execute): New pure virtual function. * ov-fcn.h, ov-fcn.cc (octave_function::call): Define only one variant, without closure frames as an argument. Default version simply pushes stack frame and calls execute. * ov-mex-fcn.h, ov-mex-fcn.cc (octave_mex_function::execute): Rename from call. Don't push stack frame here. * ov-usr-fcn.h, ov-usr-fcn.cc (octave_user_script::call, octave_user_function::call): Push stack frame and call execute. (octave_user_script::execute, octave_user_function::execute): New function. * pt-eval.h, pt-eval.cc (tree_evaluator::push_stack_frame): Eliminate unwind protect frame argument. Change all uses. (tree_evaluator::execute_user_script): Update. (tree_evaluator::execute_user_function): Update. Don't push stack frame here.
author John W. Eaton <jwe@octave.org>
date Mon, 30 Mar 2020 10:43:47 -0400
parents 9a3deb17b4ea
children 71c34141cc2d
line wrap: on
line diff
--- a/libinterp/octave-value/ov-fcn.h	Mon Mar 23 15:44:30 2020 -0400
+++ b/libinterp/octave-value/ov-fcn.h	Mon Mar 30 10:43:47 2020 -0400
@@ -223,14 +223,16 @@
   virtual bool accepts_postfix_index (char type) const
   { return (type == '('); }
 
+  // Push new stack frame (if necessary) and execute function.
   virtual octave_value_list
   call (octave::tree_evaluator& tw, int nargout = 0,
-        const octave_value_list& args = octave_value_list ()) = 0;
+        const octave_value_list& args = octave_value_list ());
 
+  // Execute function without pushing new stack frame (assumes that has
+  // already been done).
   virtual octave_value_list
-  call (octave::tree_evaluator& tw, int nargout,
-        const octave_value_list& args,
-        const std::shared_ptr<octave::stack_frame>& closure_context);
+  execute (octave::tree_evaluator& tw, int nargout = 0,
+           const octave_value_list& args = octave_value_list ()) = 0;
 
 protected: