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