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