diff libinterp/corefcn/call-stack.h @ 27873:020d0e8f7ac6

reafactor mlock, munlock, and mislocked functions * interpreter.h, interpreter.cc (interpreter::mlock, interpreter::munlock, interpreter::mislocked): Revamp. Provide versions that act on current function in the call stack (possibly skipping the first found) and versions of munlock and mislocked that accept function names. * call-stack.h, call-stack.cc (call_stack::current): Delete. (call_stack::current_function): New function. Change all uses of call_stack::current to use this function instead. (call_stack::caller): Delete. (call_stack::caller_function): New function, define in terms of current_function. Change all uses of call_stack::caller to use this function instead. (call_stack::mlock): Delete. * ov-fcn.h (octave_function::islocked): Now const. * pt-eval.h, pt-eval.cc (tree_evaluator::current_function, tree_evaluator::current_function_name, tree_evaluator::mlock): New argument, SKIP_FIRST. (tree_evaluator::munlock, tree_evaluator::mislocked): New functions. * variables.cc (Fmlock, Fmunlock, Fmislocked): Simplify. Decode arguments and call interpreter fucntions.
author John W. Eaton <jwe@octave.org>
date Tue, 17 Dec 2019 12:26:09 -0500
parents e06ce39f78ad
children b442ec6dda5c
line wrap: on
line diff
--- a/libinterp/corefcn/call-stack.h	Thu Dec 26 08:11:00 2019 -0800
+++ b/libinterp/corefcn/call-stack.h	Tue Dec 17 12:26:09 2019 -0500
@@ -62,18 +62,16 @@
 
     call_stack (tree_evaluator& evaluator);
 
-    // Current function (top of stack).
-    octave_function * current (void) const
-    {
-      octave_function *retval = nullptr;
+    // Lock current function.  Look for the first stack frame that is
+    // a function.  If SKIP_FIST is true, then skip the first frame.
+    // That allows functions like Fmlock to find and lock the calling
+    // function instead of locking Fmlock itself.
 
-      if (! m_cs.empty ())
-        {
-          const stack_frame *elt = m_cs[m_curr_frame];
-          retval = elt->function ();
-        }
+    octave_function * current_function (bool skip_first = false) const;
 
-      return retval;
+    octave_function * caller_function (void) const
+    {
+      return current_function (true);
     }
 
     // Current line in current function.
@@ -82,14 +80,6 @@
     // Current column in current function.
     int current_column (void) const;
 
-    // Caller function, may be built-in.
-
-    octave_function * caller (void) const
-    {
-      return (m_curr_frame > 1
-              ? m_cs[m_curr_frame-1]->function () : m_cs[0]->function ());
-    }
-
     size_t current_frame (void) const { return m_curr_frame; }
 
     size_t size (void) const { return m_cs.size (); }
@@ -255,14 +245,6 @@
 
     void clear (void);
 
-    // Lock current function.  Skip built-in functions (mlock is skipped
-    // silently; warn for others) and look for the first caller that is
-    // a user-defined (m-file) or dynamically loaded (.oct or .mex)
-    // function.  That allows the built-in Fmlock function to lock the
-    // calling function instead of locking istelf.
-
-    void mlock (void) const;
-
     symbol_info_list all_variables (void);
 
     std::list<symbol_record> glob (const std::string& pattern) const;