changeset 27200:dc1edf932248

eliminate direct access to call_stack in input functions * pt-eval.h, pt-eval.cc (tree_evaluator::current_line, tree_evaluator::caller_user_code_line, tree_evaluator::current_column, tree_evaluator::caller_user_code, tree_evaluator::goto_frame, tree_evaluator::caller_user_code_column, tree_evaluator::restore_frame, tree_evaluator::goto_frame_relative): New functions. * input.cc (input_system::keyboard, input_system::get_debug_input, Fkeyboard): Eliminate direct access to call stack.
author John W. Eaton <jwe@octave.org>
date Mon, 01 Apr 2019 17:32:02 +0000
parents f27002104c5b
children bd49997051ef
files libinterp/corefcn/input.cc libinterp/parse-tree/pt-eval.cc libinterp/parse-tree/pt-eval.h
diffstat 3 files changed, 65 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/input.cc	Mon Apr 01 16:58:05 2019 +0000
+++ b/libinterp/corefcn/input.cc	Mon Apr 01 17:32:02 2019 +0000
@@ -44,7 +44,6 @@
 #include "uniconv-wrappers.h"
 
 #include "builtin-defun-decls.h"
-#include "call-stack.h"
 #include "defun.h"
 #include "dirfns.h"
 #include "error.h"
@@ -408,7 +407,7 @@
 
     void input_system::initialize (bool line_editing)
     {
-// Force default line editor if we don't want readline editing.
+      // Force default line editor if we don't want readline editing.
       if (! line_editing)
         {
           command_editor::force_default_editor ();
--- a/libinterp/parse-tree/pt-eval.cc	Mon Apr 01 16:58:05 2019 +0000
+++ b/libinterp/parse-tree/pt-eval.cc	Mon Apr 01 17:32:02 2019 +0000
@@ -137,16 +137,13 @@
 
     bool silent = tw.quiet_breakpoint_flag (false);
 
-    call_stack& cs = m_interpreter.get_call_stack ();
-
-    frame.add_method (cs, &call_stack::restore_frame,
-                      cs.current_frame ());
-
-    cs.goto_frame (tw.debug_frame ());
-
-    octave_user_code *caller = cs.current_user_code ();
+    frame.add_method (tw, &tree_evaluator::restore_frame,
+                      tw.current_call_stack_frame_number ());
+
+    tw.goto_frame (tw.debug_frame ());
+
+    octave_user_code *caller = tw.current_user_code ();
     std::string nm;
-    int curr_debug_line;
 
     if (caller)
       {
@@ -154,11 +151,9 @@
 
         if (nm.empty ())
           nm = caller->name ();
-
-        curr_debug_line = cs.current_user_code_line ();
       }
-    else
-      curr_debug_line = cs.current_line ();
+
+    int curr_debug_line = tw.current_line ();
 
     std::ostringstream buf;
 
@@ -180,7 +175,7 @@
 
             if (! silent)
               {
-                stack_frame *frm = cs.current_user_frame ();
+                stack_frame *frm = tw.current_user_frame ();
 
                 frm->display_stopped_in_message (buf);
               }
@@ -277,7 +272,7 @@
                     // something like "dbup; dbstack"?  Will the call to
                     // dbstack use the right frame?  If not, how can we
                     // fix this problem?
-                    cs.goto_frame (tw.debug_frame ());
+                    tw.goto_frame (tw.debug_frame ());
                   }
 
                 octave_quit ();
@@ -1869,6 +1864,33 @@
     return false;
   }
 
+  // Current line in current function.
+  int tree_evaluator::current_line (void) const
+  {
+    return m_call_stack.current_line ();
+  }
+
+  // Current column in current function.
+  int tree_evaluator::current_column (void) const
+  {
+    return m_call_stack.current_column ();
+  }
+
+  octave_user_code * tree_evaluator::current_user_code (void) const
+  {
+    return m_call_stack.current_user_code ();
+  }
+
+  bool tree_evaluator::goto_frame (size_t n, bool verbose)
+  {
+    return m_call_stack.goto_frame (n, verbose);
+  }
+
+  void tree_evaluator::restore_frame (size_t n)
+  {
+    return m_call_stack.restore_frame (n);
+  }
+
   std::list<stack_frame *>
   tree_evaluator::backtrace_frames (octave_idx_type& curr_user_frame) const
   {
--- a/libinterp/parse-tree/pt-eval.h	Mon Apr 01 16:58:05 2019 +0000
+++ b/libinterp/parse-tree/pt-eval.h	Mon Apr 01 17:32:02 2019 +0000
@@ -474,6 +474,33 @@
       return m_call_stack.get_current_stack_frame ();
     }
 
+    stack_frame * current_user_frame (void) const
+    {
+      return m_call_stack.current_user_frame ();
+    }
+
+    // Current line in current function.
+    int current_line (void) const;
+
+    // Current column in current function.
+    int current_column (void) const;
+
+    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;
+
+    bool goto_frame (size_t n = 0, bool verbose = false);
+
+    void restore_frame (size_t n);
+
+    bool goto_frame_relative (int n, bool verbose = false);
+
     std::list<stack_frame *>
     backtrace_frames (octave_idx_type& curr_user_frame) const;