comparison libinterp/parse-tree/pt-eval.cc @ 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
comparison
equal deleted inserted replaced
27199:f27002104c5b 27200:dc1edf932248
135 135
136 tree_evaluator& tw = m_interpreter.get_evaluator (); 136 tree_evaluator& tw = m_interpreter.get_evaluator ();
137 137
138 bool silent = tw.quiet_breakpoint_flag (false); 138 bool silent = tw.quiet_breakpoint_flag (false);
139 139
140 call_stack& cs = m_interpreter.get_call_stack (); 140 frame.add_method (tw, &tree_evaluator::restore_frame,
141 141 tw.current_call_stack_frame_number ());
142 frame.add_method (cs, &call_stack::restore_frame, 142
143 cs.current_frame ()); 143 tw.goto_frame (tw.debug_frame ());
144 144
145 cs.goto_frame (tw.debug_frame ()); 145 octave_user_code *caller = tw.current_user_code ();
146
147 octave_user_code *caller = cs.current_user_code ();
148 std::string nm; 146 std::string nm;
149 int curr_debug_line;
150 147
151 if (caller) 148 if (caller)
152 { 149 {
153 nm = caller->fcn_file_name (); 150 nm = caller->fcn_file_name ();
154 151
155 if (nm.empty ()) 152 if (nm.empty ())
156 nm = caller->name (); 153 nm = caller->name ();
157 154 }
158 curr_debug_line = cs.current_user_code_line (); 155
159 } 156 int curr_debug_line = tw.current_line ();
160 else
161 curr_debug_line = cs.current_line ();
162 157
163 std::ostringstream buf; 158 std::ostringstream buf;
164 159
165 input_system& input_sys = m_interpreter.get_input_system (); 160 input_system& input_sys = m_interpreter.get_input_system ();
166 161
178 // that we are stopped on the no-op command that marks the 173 // that we are stopped on the no-op command that marks the
179 // end of a function or script. 174 // end of a function or script.
180 175
181 if (! silent) 176 if (! silent)
182 { 177 {
183 stack_frame *frm = cs.current_user_frame (); 178 stack_frame *frm = tw.current_user_frame ();
184 179
185 frm->display_stopped_in_message (buf); 180 frm->display_stopped_in_message (buf);
186 } 181 }
187 182
188 octave_link::enter_debugger_event (nm, curr_debug_line); 183 octave_link::enter_debugger_event (nm, curr_debug_line);
275 // for the call stack. But is this right way to do 270 // for the call stack. But is this right way to do
276 // this job? What if the statement list was 271 // this job? What if the statement list was
277 // something like "dbup; dbstack"? Will the call to 272 // something like "dbup; dbstack"? Will the call to
278 // dbstack use the right frame? If not, how can we 273 // dbstack use the right frame? If not, how can we
279 // fix this problem? 274 // fix this problem?
280 cs.goto_frame (tw.debug_frame ()); 275 tw.goto_frame (tw.debug_frame ());
281 } 276 }
282 277
283 octave_quit (); 278 octave_quit ();
284 } 279 }
285 } 280 }
1865 else 1860 else
1866 return val.is_equal (label_value); 1861 return val.is_equal (label_value);
1867 } 1862 }
1868 1863
1869 return false; 1864 return false;
1865 }
1866
1867 // Current line in current function.
1868 int tree_evaluator::current_line (void) const
1869 {
1870 return m_call_stack.current_line ();
1871 }
1872
1873 // Current column in current function.
1874 int tree_evaluator::current_column (void) const
1875 {
1876 return m_call_stack.current_column ();
1877 }
1878
1879 octave_user_code * tree_evaluator::current_user_code (void) const
1880 {
1881 return m_call_stack.current_user_code ();
1882 }
1883
1884 bool tree_evaluator::goto_frame (size_t n, bool verbose)
1885 {
1886 return m_call_stack.goto_frame (n, verbose);
1887 }
1888
1889 void tree_evaluator::restore_frame (size_t n)
1890 {
1891 return m_call_stack.restore_frame (n);
1870 } 1892 }
1871 1893
1872 std::list<stack_frame *> 1894 std::list<stack_frame *>
1873 tree_evaluator::backtrace_frames (octave_idx_type& curr_user_frame) const 1895 tree_evaluator::backtrace_frames (octave_idx_type& curr_user_frame) const
1874 { 1896 {