1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2009-2021 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_user_code;
48 
49 namespace octave
50 {
51   class symbol_info_list;
52   class symbol_scope;
53   class tree_decl_elt;
54   class tree_expression;
55 
56   class debugger;
57   class interpreter;
58   class unwind_protect;
59 
60   // How to evaluate the code that the parse trees represent.
61 
62   class OCTINTERP_API tree_evaluator : public tree_walker
63   {
64   public:
65 
66     enum echo_state
67     {
68       ECHO_OFF = 0,
69       ECHO_SCRIPTS = 1,
70       ECHO_FUNCTIONS = 2,
71       ECHO_ALL = 4
72     };
73 
74     template <typename T>
75     class value_stack
76     {
77     public:
78 
79       value_stack (void) = default;
80 
81       value_stack (const value_stack&) = default;
82 
83       value_stack& operator = (const value_stack&) = default;
84 
85       ~value_stack (void) = default;
86 
push(const T & val)87       void push (const T& val) { m_stack.push (val); }
88 
pop(void)89       void pop (void)
90       {
91         m_stack.pop ();
92       }
93 
val_pop(void)94       T val_pop (void)
95       {
96         T retval = m_stack.top ();
97         m_stack.pop ();
98         return retval;
99       }
100 
top(void)101       T top (void) const
102       {
103         return m_stack.top ();
104       }
105 
size(void)106       std::size_t size (void) const
107       {
108         return m_stack.size ();
109       }
110 
empty(void)111       bool empty (void) const
112       {
113         return m_stack.empty ();
114       }
115 
clear(void)116       void clear (void)
117       {
118         while (! m_stack.empty ())
119           m_stack.pop ();
120       }
121 
122     private:
123 
124       std::stack<T> m_stack;
125     };
126 
127     typedef void (*decl_elt_init_fcn) (tree_decl_elt&);
128 
tree_evaluator(interpreter & interp)129     tree_evaluator (interpreter& interp)
130       : m_interpreter (interp), m_statement_context (SC_OTHER),
131         m_lvalue_list (nullptr), m_autoload_map (), m_bp_table (*this),
132         m_call_stack (*this), m_profiler (), m_debug_frame (0),
133         m_debug_mode (false), m_quiet_breakpoint_flag (false),
134         m_debugger_stack (), m_max_recursion_depth (256),
135         m_whos_line_format ("  %a:4; %ln:6; %cs:16:6:1;  %rb:12;  %lc:-1;\n"),
136         m_silent_functions (false), m_string_fill_char (' '),
137         m_PS4 ("+ "), m_dbstep_flag (0), m_echo (ECHO_OFF),
138         m_echo_state (false), m_echo_file_name (), m_echo_file_pos (1),
139         m_echo_files (), m_in_top_level_repl (false),
140         m_in_loop_command (false), m_breaking (0), m_continuing (0),
141         m_returning (0), m_indexed_object (), m_index_list (),
142         m_index_type (), m_index_position (0), m_num_indices (0)
143     { }
144 
145     // No copying!
146 
147     tree_evaluator (const tree_evaluator&) = delete;
148 
149     tree_evaluator& operator = (const tree_evaluator&) = delete;
150 
151     ~tree_evaluator (void) = default;
152 
153     bool at_top_level (void) const;
154 
155     int repl (void);
156 
in_top_level_repl(void)157     bool in_top_level_repl (void) const { return m_in_top_level_repl; }
158 
159     void eval (std::shared_ptr<tree_statement_list>& stmt_list,
160                bool interactive);
161 
162     std::string mfilename (const std::string& opt = "") const;
163 
164     octave_value_list eval_string (const std::string& eval_str, bool silent,
165                                    int& parse_status, int nargout);
166 
167     octave_value eval_string (const std::string& eval_str, bool silent,
168                               int& parse_status);
169 
170     octave_value_list eval_string (const octave_value& arg, bool silent,
171                                    int& parse_status, int nargout);
172 
173     octave_value_list eval (const std::string& try_code, int nargout);
174 
175     octave_value_list eval (const std::string& try_code,
176                             const std::string& catch_code, int nargout);
177 
178     octave_value_list evalin (const std::string& context,
179                               const std::string& try_code, int nargout);
180 
181     octave_value_list evalin (const std::string& context,
182                               const std::string& try_code,
183                               const std::string& catch_code, int nargout);
184 
185     void visit_anon_fcn_handle (tree_anon_fcn_handle&);
186 
187     void visit_argument_list (tree_argument_list&);
188 
189     void visit_binary_expression (tree_binary_expression&);
190 
191     void visit_boolean_expression (tree_boolean_expression&);
192 
193     void visit_compound_binary_expression (tree_compound_binary_expression&);
194 
195     void visit_break_command (tree_break_command&);
196 
197     void visit_colon_expression (tree_colon_expression&);
198 
199     void visit_continue_command (tree_continue_command&);
200 
201     void visit_decl_command (tree_decl_command&);
202 
203     void visit_decl_elt (tree_decl_elt&);
204 
205     void visit_simple_for_command (tree_simple_for_command&);
206 
207     void visit_complex_for_command (tree_complex_for_command&);
208 
209     void visit_octave_user_script (octave_user_script&);
210 
211     octave_value_list
212     execute_user_script (octave_user_script& user_script, int nargout,
213                          const octave_value_list& args);
214 
215     void visit_octave_user_function (octave_user_function&);
216 
217     octave_value_list
218     execute_user_function (octave_user_function& user_function,
219                            int nargout, const octave_value_list& args);
220 
221     void visit_octave_user_function_header (octave_user_function&);
222 
223     void visit_octave_user_function_trailer (octave_user_function&);
224 
225     void visit_function_def (tree_function_def&);
226 
227     void visit_identifier (tree_identifier&);
228 
229     void visit_if_clause (tree_if_clause&);
230 
231     void visit_if_command (tree_if_command&);
232 
233     void visit_if_command_list (tree_if_command_list&);
234 
235     void visit_index_expression (tree_index_expression&);
236 
237     void visit_matrix (tree_matrix&);
238 
239     void visit_cell (tree_cell&);
240 
241     void visit_multi_assignment (tree_multi_assignment&);
242 
243     void visit_no_op_command (tree_no_op_command&);
244 
245     void visit_constant (tree_constant&);
246 
247     void visit_fcn_handle (tree_fcn_handle&);
248 
249     void visit_parameter_list (tree_parameter_list&);
250 
251     void visit_postfix_expression (tree_postfix_expression&);
252 
253     void visit_prefix_expression (tree_prefix_expression&);
254 
255     void visit_return_command (tree_return_command&);
256 
257     void visit_simple_assignment (tree_simple_assignment&);
258 
259     void visit_statement (tree_statement&);
260 
261     void visit_statement_list (tree_statement_list&);
262 
263     void visit_switch_case (tree_switch_case&);
264 
265     void visit_switch_case_list (tree_switch_case_list&);
266 
267     void visit_switch_command (tree_switch_command&);
268 
269     void visit_try_catch_command (tree_try_catch_command&);
270 
271     void do_unwind_protect_cleanup_code (tree_statement_list *list);
272 
273     void visit_unwind_protect_command (tree_unwind_protect_command&);
274 
275     void visit_while_command (tree_while_command&);
276     void visit_do_until_command (tree_do_until_command&);
277 
278     void visit_superclass_ref (tree_superclass_ref&);
279     void visit_metaclass_query (tree_metaclass_query&);
280 
281     void bind_ans (const octave_value& val, bool print);
282 
283     bool statement_printing_enabled (void);
284 
285     void reset_debug_state (void);
286 
287     void reset_debug_state (bool mode);
288 
289     void enter_debugger (const std::string& prompt = "debug> ");
290 
291     void keyboard (const std::string& prompt = "keyboard> ");
292 
293     void dbupdown (int n, bool verbose = false);
294 
295     // Possible types of evaluation contexts.
296     enum stmt_list_type
297     {
298       SC_FUNCTION,  // function body
299       SC_SCRIPT,    // script file
300       SC_OTHER      // command-line input or eval string
301     };
302 
303     Matrix ignored_fcn_outputs (void) const;
304 
305     octave_value make_fcn_handle (const std::string& nm);
306 
307     octave_value evaluate (tree_decl_elt *);
308 
309     void install_variable (const std::string& name,
310                            const octave_value& value, bool global);
311 
312     octave_value global_varval (const std::string& name) const;
313 
314     octave_value& global_varref (const std::string& name);
315 
316     void global_assign (const std::string& name,
317                         const octave_value& val = octave_value ());
318 
319     octave_value top_level_varval (const std::string& name) const;
320 
321     void top_level_assign (const std::string& name,
322                            const octave_value& val = octave_value ());
323 
324     bool is_variable (const std::string& name) const;
325 
326     bool is_local_variable (const std::string& name) const;
327 
328     bool is_variable (const tree_expression *expr) const;
329 
330     bool is_defined (const tree_expression *expr) const;
331 
332     bool is_variable (const symbol_record& sym) const;
333 
334     bool is_defined (const symbol_record& sym) const;
335 
336     bool is_global (const std::string& name) const;
337 
338     octave_value varval (const symbol_record& sym) const;
339 
340     octave_value varval (const std::string& name) const;
341 
342     void assign (const std::string& name,
343                  const octave_value& val = octave_value ());
344 
345     void assignin (const std::string& context, const std::string& name,
346                    const octave_value& val = octave_value ());
347 
348     void source_file (const std::string& file_name,
349                       const std::string& context = "",
350                       bool verbose = false, bool require_file = true);
351 
352     void set_auto_fcn_var (stack_frame::auto_var_type avt,
353                            const octave_value& val = octave_value ());
354 
355     octave_value get_auto_fcn_var (stack_frame::auto_var_type avt) const;
356 
357     void define_parameter_list_from_arg_vector
358       (tree_parameter_list *param_list, const octave_value_list& args);
359 
360     void undefine_parameter_list (tree_parameter_list *param_list);
361 
362     octave_value_list convert_to_const_vector (tree_argument_list *arg_list);
363 
364     octave_value_list
365     convert_return_list_to_const_vector
366       (tree_parameter_list *ret_list, int nargout,
367        const Matrix& ignored_outputs, const Cell& varargout);
368 
369     bool eval_decl_elt (tree_decl_elt *elt);
370 
371     bool switch_case_label_matches (tree_switch_case *expr,
372                                     const octave_value& val);
373 
get_interpreter(void)374     interpreter& get_interpreter (void) { return m_interpreter; }
375 
get_bp_table(void)376     bp_table& get_bp_table (void) { return m_bp_table; }
377 
get_profiler(void)378     profiler& get_profiler (void) { return m_profiler; }
379 
get_call_stack(void)380     call_stack& get_call_stack (void) { return m_call_stack; }
381 
382     void push_stack_frame (const symbol_scope& scope);
383 
384     void push_stack_frame (octave_user_function *fcn,
385                            const std::shared_ptr<stack_frame>& closure_frames = std::shared_ptr<stack_frame> ());
386 
387     void push_stack_frame (octave_user_function *fcn,
388                            const stack_frame::local_vars_map& local_vars,
389                            const std::shared_ptr<stack_frame>& closure_frames = std::shared_ptr<stack_frame> ());
390 
391     void push_stack_frame (octave_user_script *script);
392 
393     void push_stack_frame (octave_function *fcn);
394 
395     void pop_stack_frame (void);
396 
get_current_stack_frame(void)397     std::shared_ptr<stack_frame> get_current_stack_frame (void) const
398     {
399       return m_call_stack.get_current_stack_frame ();
400     }
401 
current_user_frame(void)402     std::shared_ptr<stack_frame> current_user_frame (void) const
403     {
404       return m_call_stack.current_user_frame ();
405     }
406 
407     // Current line in current function.
408     int current_line (void) const;
409 
410     // Current column in current function.
411     int current_column (void) const;
412 
413     // Line number in current function that we are debugging.
414     int debug_user_code_line (void) const;
415 
416     // Column number in current function that we are debugging.
417     int debug_user_code_column (void) const;
418 
419     void debug_where (std::ostream& os) const;
420 
421     octave_user_code * current_user_code (void) const;
422 
423     unwind_protect * curr_fcn_unwind_protect_frame (void);
424 
425     // Current function that we are debugging.
426     octave_user_code * debug_user_code (void) const;
427 
428     octave_function * current_function (bool skip_first = false) const;
429 
430     octave_function * caller_function (void) const;
431 
432     bool goto_frame (std::size_t n = 0, bool verbose = false);
433 
434     void goto_caller_frame (void);
435 
436     void goto_base_frame (void);
437 
438     void restore_frame (std::size_t n);
439 
440     std::string get_dispatch_class (void) const;
441 
442     void set_dispatch_class (const std::string& class_name);
443 
444     bool is_class_method_executing (std::string& dispatch_class) const;
445 
446     bool is_class_constructor_executing (std::string& dispatch_class) const;
447 
448     std::list<std::shared_ptr<stack_frame>>
449     backtrace_frames (octave_idx_type& curr_user_frame) const;
450 
451     std::list<std::shared_ptr<stack_frame>> backtrace_frames () const;
452 
453     std::list<frame_info> backtrace_info (octave_idx_type& curr_user_frame,
454                                           bool print_subfn = true) const;
455 
456     std::list<frame_info> backtrace_info (void) const;
457 
458     octave_map backtrace (octave_idx_type& curr_user_frame,
459                           bool print_subfn = true) const;
460 
461     octave_map backtrace (void) const;
462 
463     octave_map empty_backtrace (void) const;
464 
465     std::string backtrace_message (void) const;
466 
467     void push_dummy_scope (const std::string& name);
468     void pop_scope (void);
469 
470     symbol_scope get_top_scope (void) const;
471     symbol_scope get_current_scope (void) const;
472 
473     void mlock (bool skip_first = false) const;
474 
475     void munlock (bool skip_first = false) const;
476 
477     bool mislocked (bool skip_first = false) const;
478 
479     octave_value max_stack_depth (const octave_value_list& args, int nargout);
480 
481     // Useful for debugging
482     void display_call_stack (void) const;
483 
484     octave_value find (const std::string& name);
485 
486     void clear_objects (void);
487 
488     void clear_variable (const std::string& name);
489 
490     void clear_variable_pattern (const std::string& pattern);
491 
492     void clear_variable_regexp (const std::string& pattern);
493 
494     void clear_variables (void);
495 
496     void clear_global_variable (const std::string& name);
497 
498     void clear_global_variable_pattern (const std::string& pattern);
499 
500     void clear_global_variable_regexp (const std::string& pattern);
501 
502     void clear_global_variables (void);
503 
504     void clear_all (bool force = false);
505 
506     void clear_symbol (const std::string& name);
507 
508     void clear_symbol_pattern (const std::string& pattern);
509 
510     void clear_symbol_regexp (const std::string& pattern);
511 
512     std::list<std::string> global_variable_names (void) const;
513 
514     std::list<std::string> top_level_variable_names (void) const;
515 
516     std::list<std::string> variable_names (void) const;
517 
518     octave_user_code * get_user_code (const std::string& fname = "",
519                                       const std::string& class_name = "");
520 
521     std::string current_function_name (bool skip_first = false) const;
522 
523     bool in_user_code (void) const;
524 
525     symbol_info_list glob_symbol_info (const std::string& pattern) const;
526 
527     symbol_info_list regexp_symbol_info (const std::string& pattern) const;
528 
529     symbol_info_list get_symbol_info (void);
530 
531     symbol_info_list top_scope_symbol_info (void) const;
532 
533     octave_map get_autoload_map (void) const;
534 
535     std::string lookup_autoload (const std::string& nm) const;
536 
537     std::list<std::string> autoloaded_functions (void) const;
538 
539     std::list<std::string> reverse_lookup_autoload (const std::string& nm) const;
540 
541     void add_autoload (const std::string& fcn, const std::string& nm);
542 
543     void remove_autoload (const std::string& fcn, const std::string& nm);
544 
max_recursion_depth(void)545     int max_recursion_depth (void) const { return m_max_recursion_depth; }
546 
max_recursion_depth(int n)547     int max_recursion_depth (int n)
548     {
549       int val = m_max_recursion_depth;
550       m_max_recursion_depth = n;
551       return val;
552     }
553 
554     octave_value
555     max_recursion_depth (const octave_value_list& args, int nargout);
556 
silent_functions(void)557     bool silent_functions (void) const { return m_silent_functions; }
558 
silent_functions(bool b)559     bool silent_functions (bool b)
560     {
561       int val = m_silent_functions;
562       m_silent_functions = b;
563       return val;
564     }
565 
566     octave_value whos_line_format (const octave_value_list& args, int nargout);
567 
whos_line_format(void)568     std::string whos_line_format (void) const { return m_whos_line_format; }
569 
whos_line_format(const std::string & s)570     std::string whos_line_format (const std::string& s)
571     {
572       std::string val = m_whos_line_format;
573       m_whos_line_format = s;
574       return val;
575     }
576 
577     octave_value
578     silent_functions (const octave_value_list& args, int nargout);
579 
debug_frame(void)580     std::size_t debug_frame (void) const { return m_debug_frame; }
581 
debug_frame(std::size_t n)582     std::size_t debug_frame (std::size_t n)
583     {
584       std::size_t val = m_debug_frame;
585       m_debug_frame = n;
586       return val;
587     }
588 
current_call_stack_frame_number(void)589     std::size_t current_call_stack_frame_number (void) const
590     {
591       return m_call_stack.current_frame ();
592     }
593 
quiet_breakpoint_flag(void)594     bool quiet_breakpoint_flag (void) const { return m_quiet_breakpoint_flag; }
595 
quiet_breakpoint_flag(bool flag)596     bool quiet_breakpoint_flag (bool flag)
597     {
598       bool val = m_quiet_breakpoint_flag;
599       m_quiet_breakpoint_flag = flag;
600       return val;
601     }
602 
string_fill_char(void)603     char string_fill_char (void) const { return m_string_fill_char; }
604 
string_fill_char(char c)605     char string_fill_char (char c)
606     {
607       int val = m_string_fill_char;
608       m_string_fill_char = c;
609       return val;
610     }
611 
612     // The following functions are provided for convenience.  They
613     // call the corresponding functions in the debugger class for the
614     // current debugger (if any).
615 
616     bool in_debug_repl (void) const;
617 
618     void dbcont (void);
619 
620     void dbquit (bool all = false);
621 
622     octave_value PS4 (const octave_value_list& args, int nargout);
623 
PS4(void)624     std::string PS4 (void) const { return m_PS4; }
625 
PS4(const std::string & s)626     std::string PS4 (const std::string& s)
627     {
628       std::string val = m_PS4;
629       m_PS4 = s;
630       return val;
631     }
632 
indexed_object(void)633     octave_value indexed_object (void) const
634     {
635       return m_indexed_object;
636     }
637 
638     void set_indexed_object (const octave_value& obj = octave_value ())
639     {
640       m_indexed_object = obj;
641     }
642 
index_list(void)643     const std::list<octave_value_list>& index_list (void) const
644     {
645       return m_index_list;
646     }
647 
set_index_list(const std::string & index_type,const std::list<octave_value_list> & index_list)648     void set_index_list (const std::string& index_type,
649                          const std::list<octave_value_list>& index_list)
650     {
651       m_index_type = index_type;
652       m_index_list = index_list;
653     }
654 
clear_index_list(void)655     void clear_index_list (void)
656     {
657       m_index_type = "";
658       m_index_list.clear ();
659     }
660 
append_index_list(char type,const octave_value_list & idx)661     void append_index_list (char type, const octave_value_list& idx)
662     {
663       m_index_type += type;
664       m_index_list.push_back (idx);
665     }
666 
index_type(void)667     const std::string& index_type (void) const
668     {
669       return m_index_type;
670     }
671 
index_position(void)672     int index_position (void) const { return m_index_position; }
673 
num_indices(void)674     int num_indices (void) const { return m_num_indices; }
675 
676     octave_value_list evaluate_end_expression (const octave_value_list& args);
677 
lvalue_list(void)678     const std::list<octave_lvalue> * lvalue_list (void) const
679     {
680       return m_lvalue_list;
681     }
682 
set_lvalue_list(const std::list<octave_lvalue> * lst)683     void set_lvalue_list (const std::list<octave_lvalue> *lst)
684     {
685       m_lvalue_list = lst;
686     }
687 
breaking(void)688     int breaking (void) const { return m_breaking; }
689 
breaking(int n)690     int breaking (int n)
691     {
692       int val = m_breaking;
693       m_breaking = n;
694       return val;
695     }
696 
continuing(void)697     int continuing (void) const { return m_continuing; }
698 
continuing(int n)699     int continuing (int n)
700     {
701       int val = m_continuing;
702       m_continuing = n;
703       return val;
704     }
705 
returning(void)706     int returning (void) const { return m_returning; }
707 
returning(int n)708     int returning (int n)
709     {
710       int val = m_returning;
711       m_returning = n;
712       return val;
713     }
714 
dbstep_flag(void)715     int dbstep_flag (void) const { return m_dbstep_flag; }
716 
dbstep_flag(int val)717     int dbstep_flag (int val)
718     {
719       int old_val = m_dbstep_flag;
720       m_dbstep_flag = val;
721       return old_val;
722     }
723 
set_dbstep_flag(int step)724     void set_dbstep_flag (int step) { m_dbstep_flag = step; }
725 
726     octave_value echo (const octave_value_list& args, int nargout);
727 
echo(void)728     int echo (void) const { return m_echo; }
729 
echo(int val)730     int echo (int val)
731     {
732       int old_val = m_echo;
733       m_echo = val;
734       return old_val;
735     }
736 
737     octave_value
738     string_fill_char (const octave_value_list& args, int nargout);
739 
740     void final_index_error (index_exception& e, const tree_expression *expr);
741 
742     octave_value do_who (int argc, const string_vector& argv,
743                          bool return_list, bool verbose = false);
744 
745     octave_value_list
746     make_value_list (tree_argument_list *args, const string_vector& arg_nm);
747 
748     std::list<octave_lvalue> make_lvalue_list (tree_argument_list *);
749 
750     void push_echo_state (int type, const std::string& file_name,
751                           std::size_t pos = 1);
752 
753   private:
754 
755     void set_echo_state (int type, const std::string& file_name, std::size_t pos);
756 
757     void maybe_set_echo_state (void);
758 
759     void push_echo_state_cleanup (unwind_protect& frame);
760 
761     bool maybe_push_echo_state_cleanup (void);
762 
763     void do_breakpoint (tree_statement& stmt);
764 
765     void do_breakpoint (bool is_breakpoint,
766                         bool is_end_of_fcn_or_script = false);
767 
768     bool is_logically_true (tree_expression *expr, const char *warn_for);
769 
770     // For unwind-protect.
771     void uwp_set_echo_state (bool state, const std::string& file_name,
772                              std::size_t pos);
773 
774     bool echo_this_file (const std::string& file, int type) const;
775 
776     void echo_code (std::size_t line);
777 
778     bool quit_loop_now (void);
779 
780     void bind_auto_fcn_vars (const string_vector& arg_names,
781                              const Matrix& ignored_outputs, int nargin,
782                              int nargout, bool takes_varargs,
783                              const octave_value_list& va_args);
784 
785     std::string check_autoload_file (const std::string& nm) const;
786 
787     interpreter& m_interpreter;
788 
789     // The context for the current evaluation.
790     stmt_list_type m_statement_context;
791 
792     const std::list<octave_lvalue> *m_lvalue_list;
793 
794     // List of autoloads (function -> file mapping).
795     std::map<std::string, std::string> m_autoload_map;
796 
797     bp_table m_bp_table;
798 
799     call_stack m_call_stack;
800 
801     profiler m_profiler;
802 
803     // The number of the stack frame we are currently debugging.
804     std::size_t m_debug_frame;
805 
806     bool m_debug_mode;
807 
808     bool m_quiet_breakpoint_flag;
809 
810     // When entering the debugger we push it on this stack.  Managing
811     // debugger invocations this way allows us to handle recursive
812     // debugger calls.  When we exit a debugger the object is popped
813     // from the stack and deleted and we resume working with the
814     // previous debugger (if any) that is now at the top of the stack.
815     std::stack<debugger *> m_debugger_stack;
816 
817     // Maximum nesting level for functions, scripts, or sourced files
818     // called recursively.
819     int m_max_recursion_depth;
820 
821     // Defines layout for the whos/who -long command
822     std::string m_whos_line_format;
823 
824     // If TRUE, turn off printing of results in functions (as if a
825     // semicolon has been appended to each statement).
826     bool m_silent_functions;
827 
828     // The character to fill with when creating string arrays.
829     char m_string_fill_char;
830 
831     // String printed before echoed commands (enabled by --echo-commands).
832     std::string m_PS4;
833 
834     // If > 0, stop executing at the (N-1)th stopping point, counting
835     //         from the the current execution point in the current frame.
836     //
837     // If < 0, stop executing at the next possible stopping point.
838     int m_dbstep_flag;
839 
840     // Echo commands as they are executed?
841     //
842     //   1  ==>  echo commands read from script files
843     //   2  ==>  echo commands from functions
844     //
845     // more than one state can be active at once.
846     int m_echo;
847 
848     // Are we currently echoing commands?  This state is set by the
849     // functions that execute functions and scripts.
850     bool m_echo_state;
851 
852     std::string m_echo_file_name;
853 
854     // Next line to echo, counting from 1.
855     std::size_t m_echo_file_pos;
856 
857     std::map<std::string, bool> m_echo_files;
858 
859     // TRUE if we are in the top level interactive read eval print loop.
860     bool m_in_top_level_repl;
861 
862     // TRUE means we are evaluating some kind of looping construct.
863     bool m_in_loop_command;
864 
865     // Nonzero means we're breaking out of a loop or function body.
866     int m_breaking;
867 
868     // Nonzero means we're jumping to the end of a loop.
869     int m_continuing;
870 
871     // Nonzero means we're returning from a function.
872     int m_returning;
873 
874     // The following are all used by the END function.  Maybe they
875     // should be kept together in a separate object?
876     octave_value m_indexed_object;
877     std::list<octave_value_list> m_index_list;
878     std::string m_index_type;
879     int m_index_position;
880     int m_num_indices;
881   };
882 }
883 
884 #endif
885