GNU Octave  8.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
pt-eval.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2009-2023 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if ! defined (octave_pt_eval_h)
27 #define octave_pt_eval_h 1
28 
29 #include "octave-config.h"
30 
31 #include <iosfwd>
32 #include <list>
33 #include <memory>
34 #include <set>
35 #include <stack>
36 #include <string>
37 
38 #include "bp-table.h"
39 #include "call-stack.h"
40 #include "oct-lvalue.h"
41 #include "ov.h"
42 #include "ovl.h"
43 #include "profiler.h"
44 #include "pt-walk.h"
45 #include "stack-frame.h"
46 
47 class octave_builtin;
49 class octave_user_code;
51 class octave_user_script;
52 
54 
55 class symbol_info_list;
56 class symbol_scope;
57 class tree_decl_elt;
58 class tree_expression;
59 
60 class debugger;
61 class interpreter;
62 class push_parser;
63 class unwind_protect;
64 
65 // How to evaluate the code that the parse trees represent.
66 
67 class OCTINTERP_API tree_evaluator : public tree_walker
68 {
69 public:
70 
72  {
73  ECHO_OFF = 0,
74  ECHO_SCRIPTS = 1,
75  ECHO_FUNCTIONS = 2,
76  ECHO_ALL = 4
77  };
78 
79  template <typename T>
81  {
82  public:
83 
84  value_stack (void) = default;
85 
86  value_stack (const value_stack&) = default;
87 
88  value_stack& operator = (const value_stack&) = default;
89 
90  ~value_stack (void) = default;
91 
92  void push (const T& val) { m_stack.push (val); }
93 
94  void pop (void)
95  {
96  m_stack.pop ();
97  }
98 
99  T val_pop (void)
100  {
101  T retval = m_stack.top ();
102  m_stack.pop ();
103  return retval;
104  }
105 
106  T top (void) const
107  {
108  return m_stack.top ();
109  }
110 
111  std::size_t size (void) const
112  {
113  return m_stack.size ();
114  }
115 
116  bool empty (void) const
117  {
118  return m_stack.empty ();
119  }
120 
121  void clear (void)
122  {
123  while (! m_stack.empty ())
124  m_stack.pop ();
125  }
126 
127  private:
128 
129  std::stack<T> m_stack;
130  };
131 
132  typedef void (*decl_elt_init_fcn) (tree_decl_elt&);
133 
135  : m_interpreter (interp), m_parser (), m_statement_context (SC_OTHER),
136  m_lvalue_list (nullptr), m_autoload_map (), m_bp_table (*this),
137  m_call_stack (*this), m_profiler (), m_debug_frame (0),
138  m_debug_mode (false), m_quiet_breakpoint_flag (false),
139  m_debugger_stack (), m_exit_status (0), m_max_recursion_depth (256),
140  m_whos_line_format (" %la:5; %ln:6; %cs:16:6:1; %rb:12; %lc:-1;\n"),
141  m_silent_functions (false), m_string_fill_char (' '), m_PS4 ("+ "),
142  m_dbstep_flag (0), m_break_on_next_stmt (false), m_echo (ECHO_OFF),
143  m_echo_state (false), m_echo_file_name (), m_echo_file_pos (1),
144  m_echo_files (), m_in_top_level_repl (false),
145  m_server_mode (false), m_in_loop_command (false),
146  m_breaking (0), m_continuing (0), m_returning (0),
147  m_indexed_object (), m_index_list (), m_index_type (),
148  m_index_position (0), m_num_indices (0)
149  { }
150 
151  // No copying!
152 
153  tree_evaluator (const tree_evaluator&) = delete;
154 
156 
157  ~tree_evaluator (void) = default;
158 
159  std::shared_ptr<push_parser> get_parser (void)
160  {
161  return m_parser;
162  }
163 
164  void set_parser (const std::shared_ptr<push_parser>& parser)
165  {
166  m_parser = parser;
167  }
168 
169  bool at_top_level (void) const;
170 
171  std::string mfilename (const std::string& opt = "") const;
172 
173  // Parse a line of input. If input ends at a complete statement
174  // boundary, execute the resulting parse tree. Useful to handle
175  // parsing user input when running in server mode.
176 
177  void parse_and_execute (const std::string& input, bool& incomplete_parse);
178 
179  void get_line_and_eval (void);
180 
181  int repl (void);
182 
183  bool in_top_level_repl (void) const { return m_in_top_level_repl; }
184 
185  int server_loop (void);
186 
187  bool server_mode (void) const { return m_server_mode; }
188 
189  void server_mode (bool arg) { m_server_mode = arg; }
190 
191  void eval (std::shared_ptr<tree_statement_list>& stmt_list,
192  bool interactive);
193 
194  octave_value_list eval_string (const std::string& eval_str, bool silent,
195  int& parse_status, int nargout);
196 
197  octave_value eval_string (const std::string& eval_str, bool silent,
198  int& parse_status);
199 
200  octave_value_list eval_string (const octave_value& arg, bool silent,
201  int& parse_status, int nargout);
202 
203  octave_value_list eval (const std::string& try_code, int nargout);
204 
205  octave_value_list eval (const std::string& try_code,
206  const std::string& catch_code, int nargout);
207 
208  octave_value_list evalin (const std::string& context,
209  const std::string& try_code, int nargout);
210 
211  octave_value_list evalin (const std::string& context,
212  const std::string& try_code,
213  const std::string& catch_code, int nargout);
214 
216 
218 
220 
222 
224 
226 
228 
230 
232 
234 
236 
238 
240 
242 
244 
246 
248 
250 
252 
253  octave_value evaluate_anon_fcn_handle (tree_anon_fcn_handle& afh);
254 
256  execute_builtin_function (octave_builtin& builtin_function, int nargout,
257  const octave_value_list& args);
259  execute_mex_function (octave_mex_function& mex_function, int nargout,
260  const octave_value_list& args);
261 
263 
265  execute_user_script (octave_user_script& user_script, int nargout,
266  const octave_value_list& args);
267 
269 
271  execute_user_function (octave_user_function& user_function,
272  int nargout, const octave_value_list& args);
273 
274  void visit_octave_user_function_header (octave_user_function&);
275 
276  void visit_octave_user_function_trailer (octave_user_function&);
277 
279 
281 
283 
285 
287 
289 
290  void visit_matrix (tree_matrix&);
291 
292  void visit_cell (tree_cell&);
293 
295 
297 
299 
301 
303 
305 
307 
309 
311 
313 
315 
317 
319 
321 
323 
324  void do_unwind_protect_cleanup_code (tree_statement_list *list);
325 
327 
330 
333 
334  void bind_ans (const octave_value& val, bool print);
335 
336  bool statement_printing_enabled (void);
337 
338  void reset_debug_state (void);
339 
340  void reset_debug_state (bool mode);
341 
342  void enter_debugger (const std::string& prompt = "debug> ");
343 
344  void keyboard (const std::string& prompt = "keyboard> ");
345 
346  void dbupdown (int n, bool verbose = false);
347 
348  // Possible types of evaluation contexts.
350  {
351  SC_FUNCTION, // function body
352  SC_SCRIPT, // script file
353  SC_OTHER // command-line input or eval string
354  };
355 
356  Matrix ignored_fcn_outputs (void) const;
357 
358  octave_value make_fcn_handle (const std::string& nm);
359 
360  octave_value evaluate (tree_decl_elt *);
361 
362  void install_variable (const std::string& name,
363  const octave_value& value, bool global);
364 
365  octave_value global_varval (const std::string& name) const;
366 
367  octave_value& global_varref (const std::string& name);
368 
369  void global_assign (const std::string& name,
370  const octave_value& val = octave_value ());
371 
372  octave_value top_level_varval (const std::string& name) const;
373 
374  void top_level_assign (const std::string& name,
375  const octave_value& val = octave_value ());
376 
377  bool is_variable (const std::string& name) const;
378 
379  bool is_local_variable (const std::string& name) const;
380 
381  bool is_variable (const tree_expression *expr) const;
382 
383  bool is_defined (const tree_expression *expr) const;
384 
385  bool is_variable (const symbol_record& sym) const;
386 
387  bool is_defined (const symbol_record& sym) const;
388 
389  bool is_global (const std::string& name) const;
390 
391  octave_value varval (const symbol_record& sym) const;
392 
393  octave_value varval (const std::string& name) const;
394 
395  void assign (const std::string& name,
396  const octave_value& val = octave_value ());
397 
398  void assignin (const std::string& context, const std::string& name,
399  const octave_value& val = octave_value ());
400 
401  void source_file (const std::string& file_name,
402  const std::string& context = "",
403  bool verbose = false, bool require_file = true);
404 
405  void set_auto_fcn_var (stack_frame::auto_var_type avt,
406  const octave_value& val = octave_value ());
407 
408  octave_value get_auto_fcn_var (stack_frame::auto_var_type avt) const;
409 
410  void define_parameter_list_from_arg_vector
411  (tree_parameter_list *param_list, const octave_value_list& args);
412 
413  void undefine_parameter_list (tree_parameter_list *param_list);
414 
415  octave_value_list convert_to_const_vector (tree_argument_list *arg_list);
416 
418  convert_return_list_to_const_vector
419  (tree_parameter_list *ret_list, int nargout,
420  const Matrix& ignored_outputs, const Cell& varargout);
421 
422  bool eval_decl_elt (tree_decl_elt *elt);
423 
424  bool switch_case_label_matches (tree_switch_case *expr,
425  const octave_value& val);
426 
427  interpreter& get_interpreter (void) { return m_interpreter; }
428 
429  bp_table& get_bp_table (void) { return m_bp_table; }
430 
431  profiler& get_profiler (void) { return m_profiler; }
432 
433  void push_stack_frame (const symbol_scope& scope);
434 
435  void push_stack_frame (octave_user_function *fcn,
436  const std::shared_ptr<stack_frame>& closure_frames = std::shared_ptr<stack_frame> ());
437 
438  void push_stack_frame (octave_user_function *fcn,
439  const stack_frame::local_vars_map& local_vars,
440  const std::shared_ptr<stack_frame>& closure_frames = std::shared_ptr<stack_frame> ());
441 
442  void push_stack_frame (octave_user_script *script);
443 
444  void push_stack_frame (octave_function *fcn);
445 
446  void pop_stack_frame (void);
447 
448  std::shared_ptr<stack_frame> get_current_stack_frame (void) const
449  {
450  return m_call_stack.get_current_stack_frame ();
451  }
452 
453  std::shared_ptr<stack_frame> current_user_frame (void) const
454  {
455  return m_call_stack.current_user_frame ();
456  }
457 
458  // Current line in current function.
459  int current_line (void) const;
460 
461  // Current column in current function.
462  int current_column (void) const;
463 
464  // Line number in current function that we are debugging.
465  int debug_user_code_line (void) const;
466 
467  // Column number in current function that we are debugging.
468  int debug_user_code_column (void) const;
469 
470  void debug_where (std::ostream& os) const;
471 
472  octave_user_code * current_user_code (void) const;
473 
475 
476  // Current function that we are debugging.
477  octave_user_code * debug_user_code (void) const;
478 
479  octave_function * current_function (bool skip_first = false) const;
480 
481  octave_function * caller_function (void) const;
482 
483  bool goto_frame (std::size_t n = 0, bool verbose = false);
484 
485  void goto_caller_frame (void);
486 
487  void goto_base_frame (void);
488 
489  void restore_frame (std::size_t n);
490 
491  std::string get_dispatch_class (void) const;
492 
493  void set_dispatch_class (const std::string& class_name);
494 
495  bool is_class_method_executing (std::string& dispatch_class) const;
496 
497  bool is_class_constructor_executing (std::string& dispatch_class) const;
498 
499  std::list<std::shared_ptr<stack_frame>>
500  backtrace_frames (octave_idx_type& curr_user_frame) const;
501 
502  std::list<std::shared_ptr<stack_frame>> backtrace_frames () const;
503 
504  std::list<frame_info> backtrace_info (octave_idx_type& curr_user_frame,
505  bool print_subfn = true) const;
506 
507  std::list<frame_info> backtrace_info (void) const;
508 
509  octave_map backtrace (octave_idx_type& curr_user_frame,
510  bool print_subfn = true) const;
511 
512  octave_map backtrace (void) const;
513 
514  octave_map empty_backtrace (void) const;
515 
516  std::string backtrace_message (void) const;
517 
518  void push_dummy_scope (const std::string& name);
519  void pop_scope (void);
520 
521  symbol_scope get_top_scope (void) const;
522  symbol_scope get_current_scope (void) const;
523 
524  void mlock (bool skip_first = false) const;
525 
526  void munlock (bool skip_first = false) const;
527 
528  bool mislocked (bool skip_first = false) const;
529 
530  octave_value max_stack_depth (const octave_value_list& args, int nargout);
531 
532  // Useful for debugging
533  void display_call_stack (void) const;
534 
535  octave_value find (const std::string& name);
536 
537  void clear_objects (void);
538 
539  void clear_variable (const std::string& name);
540 
541  void clear_variable_pattern (const std::string& pattern);
542 
543  void clear_variable_regexp (const std::string& pattern);
544 
545  void clear_variables (void);
546 
547  void clear_global_variable (const std::string& name);
548 
549  void clear_global_variable_pattern (const std::string& pattern);
550 
551  void clear_global_variable_regexp (const std::string& pattern);
552 
553  void clear_global_variables (void);
554 
555  void clear_all (bool force = false);
556 
557  void clear_symbol (const std::string& name);
558 
559  void clear_symbol_pattern (const std::string& pattern);
560 
561  void clear_symbol_regexp (const std::string& pattern);
562 
563  std::list<std::string> global_variable_names (void) const;
564 
565  std::list<std::string> top_level_variable_names (void) const;
566 
567  std::list<std::string> variable_names (void) const;
568 
569  octave_user_code * get_user_code (const std::string& fname = "",
570  const std::string& class_name = "");
571 
572  std::string current_function_name (bool skip_first = false) const;
573 
574  bool in_user_code (void) const;
575 
576  symbol_info_list glob_symbol_info (const std::string& pattern) const;
577 
578  symbol_info_list regexp_symbol_info (const std::string& pattern) const;
579 
580  symbol_info_list get_symbol_info (void);
581 
582  symbol_info_list top_scope_symbol_info (void) const;
583 
584  octave_map get_autoload_map (void) const;
585 
586  std::string lookup_autoload (const std::string& nm) const;
587 
588  std::list<std::string> autoloaded_functions (void) const;
589 
590  std::list<std::string> reverse_lookup_autoload (const std::string& nm) const;
591 
592  void add_autoload (const std::string& fcn, const std::string& nm);
593 
594  void remove_autoload (const std::string& fcn, const std::string& nm);
595 
596  int max_recursion_depth (void) const { return m_max_recursion_depth; }
597 
599  {
600  int val = m_max_recursion_depth;
601  m_max_recursion_depth = n;
602  return val;
603  }
604 
606  max_recursion_depth (const octave_value_list& args, int nargout);
607 
608  bool silent_functions (void) const { return m_silent_functions; }
609 
610  bool silent_functions (bool b)
611  {
612  int val = m_silent_functions;
613  m_silent_functions = b;
614  return val;
615  }
616 
617  octave_value whos_line_format (const octave_value_list& args, int nargout);
618 
619  std::string whos_line_format (void) const { return m_whos_line_format; }
620 
621  std::string whos_line_format (const std::string& s)
622  {
623  std::string val = m_whos_line_format;
624  m_whos_line_format = s;
625  return val;
626  }
627 
629  silent_functions (const octave_value_list& args, int nargout);
630 
631  std::size_t debug_frame (void) const { return m_debug_frame; }
632 
633  std::size_t debug_frame (std::size_t n)
634  {
635  std::size_t val = m_debug_frame;
636  m_debug_frame = n;
637  return val;
638  }
639 
640  std::size_t current_call_stack_frame_number (void) const
641  {
642  return m_call_stack.current_frame ();
643  }
644 
645  bool quiet_breakpoint_flag (void) const { return m_quiet_breakpoint_flag; }
646 
647  bool quiet_breakpoint_flag (bool flag)
648  {
649  bool val = m_quiet_breakpoint_flag;
650  m_quiet_breakpoint_flag = flag;
651  return val;
652  }
653 
654  char string_fill_char (void) const { return m_string_fill_char; }
655 
656  char string_fill_char (char c)
657  {
658  int val = m_string_fill_char;
659  m_string_fill_char = c;
660  return val;
661  }
662 
663  // The following functions are provided for convenience. They
664  // call the corresponding functions in the debugger class for the
665  // current debugger (if any).
666 
667  bool in_debug_repl (void) const;
668 
669  void dbcont (void);
670 
671  // Return true if we are in the debug repl and m_execution_mode is
672  // set to exit the debugger. Otherwise, do nothing.
673 
674  void dbquit (bool all = false);
675 
676  // Add EXPR to the set of expressions that may be evaluated when the
677  // debugger stops at a breakpoint.
678  void add_debug_watch_expression (const std::string& expr)
679  {
680  m_debug_watch_expressions.insert (expr);
681  }
682 
683  // Remove EXPR from the set of expressions that may be evaluated
684  // when the debugger stops at a breakpoint.
685  void remove_debug_watch_expression (const std::string& expr)
686  {
687  m_debug_watch_expressions.erase (expr);
688  }
689 
690  // Clear the set of expressions that may be evaluated when the
691  // debugger stops at a breakpoint.
693  {
694  m_debug_watch_expressions.clear ();
695  }
696 
697  // Return the set of expressions that may be evaluated when the
698  // debugger stops at a breakpoint.
699  std::set<std::string> debug_watch_expressions (void) const
700  {
701  return m_debug_watch_expressions;
702  }
703 
704  octave_value PS4 (const octave_value_list& args, int nargout);
705 
706  std::string PS4 (void) const { return m_PS4; }
707 
708  std::string PS4 (const std::string& s)
709  {
710  std::string val = m_PS4;
711  m_PS4 = s;
712  return val;
713  }
714 
716  {
717  return m_indexed_object;
718  }
719 
721  {
722  m_indexed_object = obj;
723  }
724 
725  const std::list<octave_value_list>& index_list (void) const
726  {
727  return m_index_list;
728  }
729 
730  void set_index_list (const std::string& index_type,
731  const std::list<octave_value_list>& index_list)
732  {
733  m_index_type = index_type;
734  m_index_list = index_list;
735  }
736 
737  void clear_index_list (void)
738  {
739  m_index_type = "";
740  m_index_list.clear ();
741  }
742 
743  void append_index_list (char type, const octave_value_list& idx)
744  {
745  m_index_type += type;
746  m_index_list.push_back (idx);
747  }
748 
749  const std::string& index_type (void) const
750  {
751  return m_index_type;
752  }
753 
754  int index_position (void) const { return m_index_position; }
755 
756  int num_indices (void) const { return m_num_indices; }
757 
758  octave_value_list evaluate_end_expression (const octave_value_list& args);
759 
760  const std::list<octave_lvalue> * lvalue_list (void) const
761  {
762  return m_lvalue_list;
763  }
764 
765  void set_lvalue_list (const std::list<octave_lvalue> *lst)
766  {
767  m_lvalue_list = lst;
768  }
769 
770  int breaking (void) const { return m_breaking; }
771 
772  int breaking (int n)
773  {
774  int val = m_breaking;
775  m_breaking = n;
776  return val;
777  }
778 
779  int continuing (void) const { return m_continuing; }
780 
781  int continuing (int n)
782  {
783  int val = m_continuing;
784  m_continuing = n;
785  return val;
786  }
787 
788  int returning (void) const { return m_returning; }
789 
790  int returning (int n)
791  {
792  int val = m_returning;
793  m_returning = n;
794  return val;
795  }
796 
797  int dbstep_flag (void) const { return m_dbstep_flag; }
798 
799  int dbstep_flag (int val)
800  {
801  int old_val = m_dbstep_flag;
802  m_dbstep_flag = val;
803  return old_val;
804  }
805 
806  void set_dbstep_flag (int step) { m_dbstep_flag = step; }
807 
808  bool break_on_next_statement (void) const
809  {
810  return m_break_on_next_stmt;
811  }
812 
813  bool break_on_next_statement (bool val)
814  {
815  bool old_val = m_break_on_next_stmt;
816  m_break_on_next_stmt = val;
817  return old_val;
818  }
819 
821  {
822  m_break_on_next_stmt = val;
823  }
824 
825  octave_value echo (const octave_value_list& args, int nargout);
826 
827  int echo (void) const { return m_echo; }
828 
829  int echo (int val)
830  {
831  int old_val = m_echo;
832  m_echo = val;
833  return old_val;
834  }
835 
837  string_fill_char (const octave_value_list& args, int nargout);
838 
839  void final_index_error (index_exception& ie, const tree_expression *expr);
840 
841  octave_value do_who (int argc, const string_vector& argv,
842  bool return_list, bool verbose = false);
843 
845  make_value_list (tree_argument_list *args, const string_vector& arg_nm);
846 
847  std::list<octave_lvalue> make_lvalue_list (tree_argument_list *);
848 
849  void push_echo_state (int type, const std::string& file_name, int pos = 1);
850 
851 private:
852 
853  template <typename T>
854  void execute_range_loop (const range<T>& rng, int line,
855  octave_lvalue& ult,
856  tree_statement_list *loop_body);
857 
858  void set_echo_state (int type, const std::string& file_name, int pos);
859 
860  void maybe_set_echo_state (void);
861 
862  void push_echo_state_cleanup (unwind_protect& frame);
863 
864  bool maybe_push_echo_state_cleanup (void);
865 
866  void do_breakpoint (tree_statement& stmt);
867 
868  void do_breakpoint (bool is_breakpoint,
869  bool is_end_of_fcn_or_script = false);
870 
871  bool is_logically_true (tree_expression *expr, const char *warn_for);
872 
873  // For unwind-protect.
874  void uwp_set_echo_state (bool state, const std::string& file_name, int pos);
875 
876  bool echo_this_file (const std::string& file, int type) const;
877 
878  void echo_code (int line);
879 
880  bool quit_loop_now (void);
881 
882  void bind_auto_fcn_vars (const string_vector& arg_names,
883  const Matrix& ignored_outputs, int nargin,
884  int nargout, bool takes_varargs,
885  const octave_value_list& va_args);
886 
887  std::string check_autoload_file (const std::string& nm) const;
888 
890 
891  std::shared_ptr<push_parser> m_parser;
892 
893  // The context for the current evaluation.
895 
896  const std::list<octave_lvalue> *m_lvalue_list;
897 
898  // List of autoloads (function -> file mapping).
899  std::map<std::string, std::string> m_autoload_map;
900 
902 
904 
906 
907  // The number of the stack frame we are currently debugging.
908  std::size_t m_debug_frame;
909 
911 
913 
914  // When entering the debugger we push it on this stack. Managing
915  // debugger invocations this way allows us to handle recursive
916  // debugger calls. When we exit a debugger the object is popped
917  // from the stack and deleted and we resume working with the
918  // previous debugger (if any) that is now at the top of the stack.
919  std::stack<debugger *> m_debugger_stack;
920 
921  std::set<std::string> m_debug_watch_expressions;
922 
924 
925  // Maximum nesting level for functions, scripts, or sourced files
926  // called recursively.
928 
929  // Defines layout for the whos/who -long command
930  std::string m_whos_line_format;
931 
932  // If TRUE, turn off printing of results in functions (as if a
933  // semicolon has been appended to each statement).
935 
936  // The character to fill with when creating string arrays.
938 
939  // String printed before echoed commands (enabled by --echo-commands).
940  std::string m_PS4;
941 
942  // If > 0, stop executing at the (N-1)th stopping point, counting
943  // from the the current execution point in the current frame.
944  //
945  // If < 0, stop executing at the next possible stopping point.
947 
948  // If TRUE, and we are not stopping for another reason (dbstep or a
949  // breakpoint) then stop at next statement and enter the debugger.
951 
952  // Echo commands as they are executed?
953  //
954  // 1 ==> echo commands read from script files
955  // 2 ==> echo commands from functions
956  //
957  // more than one state can be active at once.
958  int m_echo;
959 
960  // Are we currently echoing commands? This state is set by the
961  // functions that execute functions and scripts.
963 
964  std::string m_echo_file_name;
965 
966  // Next line to echo, counting from 1. We use int here because the
967  // parser does. It also initializes line and column numbers to the
968  // invalid value -1 and that can cause trouble if cast to an
969  // unsigned value. When updating this value and echoing ranges of
970  // code, we also check to ensure that the line numbers stored in the
971  // parse tree are valid. It would be better to ensure that the
972  // parser always stores valid position info, but that's more
973  // difficult to always do correctly.
975 
976  std::map<std::string, bool> m_echo_files;
977 
978  // TRUE if we are in the top level interactive read eval print loop.
980 
981  // TRUE means we are executing in the server_loop function.
983 
984  // TRUE means we are evaluating some kind of looping construct.
986 
987  // Nonzero means we're breaking out of a loop or function body.
989 
990  // Nonzero means we're jumping to the end of a loop.
992 
993  // Nonzero means we're returning from a function.
995 
996  // The following are all used by the END function. Maybe they
997  // should be kept together in a separate object?
999  std::list<octave_value_list> m_index_list;
1000  std::string m_index_type;
1003 };
1004 
1006 
1007 #endif
OCTAVE_END_NAMESPACE(octave)
F77_RET_T const F77_DBLE const F77_DBLE const F77_INT const F77_DBLE const F77_DBLE const F77_DBLE F77_DBLE F77_DBLE F77_INT F77_INT const F77_INT const F77_INT F77_INT F77_INT F77_DBLE *F77_RET_T const F77_DBLE const F77_INT const F77_DBLE const F77_DBLE F77_DBLE F77_DBLE F77_INT F77_INT const F77_INT const F77_INT F77_INT F77_INT F77_DBLE *F77_RET_T const F77_REAL const F77_REAL const F77_INT const F77_REAL const F77_REAL const F77_REAL F77_REAL F77_REAL F77_INT F77_INT const F77_INT const F77_INT F77_INT F77_INT F77_REAL *F77_RET_T const F77_REAL const F77_INT const F77_REAL const F77_REAL F77_REAL F77_REAL F77_INT F77_INT const F77_INT const F77_INT F77_INT F77_INT F77_REAL *static F77_INT user_function(const double &x, int &, double &result)
Definition: Quad.cc:80
static octave_value make_fcn_handle(const octave_value &fcn, const std::string &meth_name, const std::string &class_name)
Definition: cdef-class.cc:66
Definition: Cell.h:43
Definition: dMatrix.h:42
Definition: parse.h:829
std::map< std::string, octave_value > local_vars_map
Definition: stack-frame.h:112
void push(const T &val)
Definition: pt-eval.h:92
bool empty(void) const
Definition: pt-eval.h:116
value_stack(const value_stack &)=default
std::size_t size(void) const
Definition: pt-eval.h:111
std::stack< T > m_stack
Definition: pt-eval.h:129
bool m_in_loop_command
Definition: pt-eval.h:985
bool in_top_level_repl(void) const
Definition: pt-eval.h:183
void set_indexed_object(const octave_value &obj=octave_value())
Definition: pt-eval.h:720
int dbstep_flag(int val)
Definition: pt-eval.h:799
std::size_t m_debug_frame
Definition: pt-eval.h:908
std::stack< debugger * > m_debugger_stack
Definition: pt-eval.h:919
int returning(int n)
Definition: pt-eval.h:790
bool m_server_mode
Definition: pt-eval.h:982
int dbstep_flag(void) const
Definition: pt-eval.h:797
std::list< octave_value_list > m_index_list
Definition: pt-eval.h:999
profiler & get_profiler(void)
Definition: pt-eval.h:431
std::size_t debug_frame(std::size_t n)
Definition: pt-eval.h:633
int max_recursion_depth(int n)
Definition: pt-eval.h:598
interpreter & m_interpreter
Definition: pt-eval.h:889
int breaking(int n)
Definition: pt-eval.h:772
char string_fill_char(void) const
Definition: pt-eval.h:654
bool m_silent_functions
Definition: pt-eval.h:934
int m_continuing
Definition: pt-eval.h:991
int m_index_position
Definition: pt-eval.h:1001
bool m_in_top_level_repl
Definition: pt-eval.h:979
int echo(int val)
Definition: pt-eval.h:829
stmt_list_type m_statement_context
Definition: pt-eval.h:894
char string_fill_char(char c)
Definition: pt-eval.h:656
int max_recursion_depth(void) const
Definition: pt-eval.h:596
octave_value indexed_object(void) const
Definition: pt-eval.h:715
std::size_t debug_frame(void) const
Definition: pt-eval.h:631
std::string whos_line_format(const std::string &s)
Definition: pt-eval.h:621
char m_string_fill_char
Definition: pt-eval.h:937
const std::string & index_type(void) const
Definition: pt-eval.h:749
std::size_t current_call_stack_frame_number(void) const
Definition: pt-eval.h:640
int m_num_indices
Definition: pt-eval.h:1002
bool silent_functions(bool b)
Definition: pt-eval.h:610
bool m_quiet_breakpoint_flag
Definition: pt-eval.h:912
void remove_debug_watch_expression(const std::string &expr)
Definition: pt-eval.h:685
std::map< std::string, std::string > m_autoload_map
Definition: pt-eval.h:899
int returning(void) const
Definition: pt-eval.h:788
octave_value m_indexed_object
Definition: pt-eval.h:998
bool quiet_breakpoint_flag(bool flag)
Definition: pt-eval.h:647
std::shared_ptr< stack_frame > get_current_stack_frame(void) const
Definition: pt-eval.h:448
int index_position(void) const
Definition: pt-eval.h:754
bool m_echo_state
Definition: pt-eval.h:962
std::string PS4(void) const
Definition: pt-eval.h:706
int m_exit_status
Definition: pt-eval.h:923
const std::list< octave_lvalue > * lvalue_list(void) const
Definition: pt-eval.h:760
std::shared_ptr< push_parser > m_parser
Definition: pt-eval.h:891
int num_indices(void) const
Definition: pt-eval.h:756
void set_break_on_next_statement(bool val)
Definition: pt-eval.h:820
void add_debug_watch_expression(const std::string &expr)
Definition: pt-eval.h:678
bool quiet_breakpoint_flag(void) const
Definition: pt-eval.h:645
tree_evaluator(interpreter &interp)
Definition: pt-eval.h:134
void set_parser(const std::shared_ptr< push_parser > &parser)
Definition: pt-eval.h:164
bool m_break_on_next_stmt
Definition: pt-eval.h:950
void server_mode(bool arg)
Definition: pt-eval.h:189
interpreter & get_interpreter(void)
Definition: pt-eval.h:427
int m_breaking
Definition: pt-eval.h:988
const std::list< octave_lvalue > * m_lvalue_list
Definition: pt-eval.h:896
int m_dbstep_flag
Definition: pt-eval.h:946
void clear_index_list(void)
Definition: pt-eval.h:737
bool server_mode(void) const
Definition: pt-eval.h:187
void clear_debug_watch_expressions(void)
Definition: pt-eval.h:692
int m_max_recursion_depth
Definition: pt-eval.h:927
int m_returning
Definition: pt-eval.h:994
tree_evaluator(const tree_evaluator &)=delete
std::string PS4(const std::string &s)
Definition: pt-eval.h:708
std::string m_echo_file_name
Definition: pt-eval.h:964
int continuing(int n)
Definition: pt-eval.h:781
bool break_on_next_statement(bool val)
Definition: pt-eval.h:813
int m_echo_file_pos
Definition: pt-eval.h:974
std::set< std::string > m_debug_watch_expressions
Definition: pt-eval.h:921
bool break_on_next_statement(void) const
Definition: pt-eval.h:808
call_stack m_call_stack
Definition: pt-eval.h:903
void set_lvalue_list(const std::list< octave_lvalue > *lst)
Definition: pt-eval.h:765
void set_dbstep_flag(int step)
Definition: pt-eval.h:806
std::shared_ptr< stack_frame > current_user_frame(void) const
Definition: pt-eval.h:453
void append_index_list(char type, const octave_value_list &idx)
Definition: pt-eval.h:743
std::string m_whos_line_format
Definition: pt-eval.h:930
std::shared_ptr< push_parser > get_parser(void)
Definition: pt-eval.h:159
~tree_evaluator(void)=default
std::set< std::string > debug_watch_expressions(void) const
Definition: pt-eval.h:699
int echo(void) const
Definition: pt-eval.h:827
bp_table m_bp_table
Definition: pt-eval.h:901
std::string m_PS4
Definition: pt-eval.h:940
void set_index_list(const std::string &index_type, const std::list< octave_value_list > &index_list)
Definition: pt-eval.h:730
bool m_debug_mode
Definition: pt-eval.h:910
bool silent_functions(void) const
Definition: pt-eval.h:608
std::string whos_line_format(void) const
Definition: pt-eval.h:619
int continuing(void) const
Definition: pt-eval.h:779
profiler m_profiler
Definition: pt-eval.h:905
int breaking(void) const
Definition: pt-eval.h:770
const std::list< octave_value_list > & index_list(void) const
Definition: pt-eval.h:725
std::string m_index_type
Definition: pt-eval.h:1000
std::map< std::string, bool > m_echo_files
Definition: pt-eval.h:976
bp_table & get_bp_table(void)
Definition: pt-eval.h:429
virtual void visit_compound_binary_expression(tree_compound_binary_expression &)
Definition: pt-walk.cc:152
virtual void visit_boolean_expression(tree_boolean_expression &)
Definition: pt-walk.cc:147
virtual void visit_unwind_protect_command(tree_unwind_protect_command &)
Definition: pt-walk.cc:567
virtual void visit_try_catch_command(tree_try_catch_command &)
Definition: pt-walk.cc:549
virtual void visit_if_command_list(tree_if_command_list &)
Definition: pt-walk.cc:319
virtual void visit_multi_assignment(tree_multi_assignment &)
Definition: pt-walk.cc:450
virtual void visit_return_command(tree_return_command &)
Definition: pt-walk.cc:507
virtual void visit_continue_command(tree_continue_command &)
Definition: pt-walk.cc:180
virtual void visit_switch_case_list(tree_switch_case_list &)
Definition: pt-walk.cc:345
virtual void visit_complex_for_command(tree_complex_for_command &)
Definition: pt-walk.cc:241
virtual void visit_break_command(tree_break_command &)
Definition: pt-walk.cc:157
virtual void visit_matrix(tree_matrix &)
Definition: pt-walk.cc:424
virtual void visit_args_block_validation_list(tree_args_block_validation_list &)
Definition: pt-walk.cc:81
virtual void visit_fcn_handle(tree_fcn_handle &)
Definition: pt-walk.cc:473
virtual void visit_colon_expression(tree_colon_expression &)
Definition: pt-walk.cc:162
virtual void visit_arg_size_spec(tree_arg_size_spec &)
Definition: pt-walk.cc:118
virtual void visit_spmd_command(tree_spmd_command &)
Definition: pt-walk.cc:259
virtual void visit_do_until_command(tree_do_until_command &)
Definition: pt-walk.cc:593
virtual void visit_no_op_command(tree_no_op_command &)
Definition: pt-walk.cc:463
virtual void visit_binary_expression(tree_binary_expression &)
Definition: pt-walk.cc:134
virtual void visit_simple_for_command(tree_simple_for_command &)
Definition: pt-walk.cc:218
virtual void visit_postfix_expression(tree_postfix_expression &)
Definition: pt-walk.cc:491
virtual void visit_prefix_expression(tree_prefix_expression &)
Definition: pt-walk.cc:499
virtual void visit_anon_fcn_handle(tree_anon_fcn_handle &)
Definition: pt-walk.cc:34
virtual void visit_args_block_attribute_list(tree_args_block_attribute_list &)
Definition: pt-walk.cc:73
virtual void visit_parameter_list(tree_parameter_list &)
Definition: pt-walk.cc:478
virtual void visit_arguments_block(tree_arguments_block &)
Definition: pt-walk.cc:60
virtual void visit_statement(tree_statement &)
Definition: pt-walk.cc:525
virtual void visit_index_expression(tree_index_expression &)
Definition: pt-walk.cc:371
virtual void visit_decl_command(tree_decl_command &)
Definition: pt-walk.cc:185
virtual void visit_switch_case(tree_switch_case &)
Definition: pt-walk.cc:332
virtual void visit_cell(tree_cell &)
Definition: pt-walk.cc:437
virtual void visit_identifier(tree_identifier &)
Definition: pt-walk.cc:293
virtual void visit_if_clause(tree_if_clause &)
Definition: pt-walk.cc:298
virtual void visit_statement_list(tree_statement_list &)
Definition: pt-walk.cc:540
virtual void visit_arg_validation_fcns(tree_arg_validation_fcns &)
Definition: pt-walk.cc:126
virtual void visit_if_command(tree_if_command &)
Definition: pt-walk.cc:311
virtual void visit_argument_list(tree_argument_list &)
Definition: pt-walk.cc:47
virtual void visit_decl_elt(tree_decl_elt &)
Definition: pt-walk.cc:193
virtual void visit_constant(tree_constant &)
Definition: pt-walk.cc:468
virtual void visit_simple_assignment(tree_simple_assignment &)
Definition: pt-walk.cc:512
virtual void visit_superclass_ref(tree_superclass_ref &)
Definition: pt-walk.cc:606
virtual void visit_octave_user_script(octave_user_script &)
Definition: pt-walk.cc:267
tree_walker & operator=(const tree_walker &)=delete
virtual void visit_arg_validation(tree_arg_validation &)
Definition: pt-walk.cc:90
virtual void visit_octave_user_function(octave_user_function &)
Definition: pt-walk.cc:275
virtual void visit_function_def(tree_function_def &)
Definition: pt-walk.cc:283
virtual void visit_metaclass_query(tree_metaclass_query &)
Definition: pt-walk.cc:611
virtual void visit_while_command(tree_while_command &)
Definition: pt-walk.cc:580
virtual void visit_switch_command(tree_switch_command &)
Definition: pt-walk.cc:358
static octave_idx_type find(octave_idx_type i, octave_idx_type *pp)
Definition: colamd.cc:106
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
octave_idx_type n
Definition: mx-inlines.cc:753
void source_file(const std::string &file_name, const std::string &context, bool verbose, bool require_file)
Definition: oct-parse.cc:10319
static int input(yyscan_t yyscanner)
static uint32_t state[624]
Definition: randmtzig.cc:193
static octave::unwind_protect * curr_fcn_unwind_protect_frame(void)
Definition: variables.cc:561