26 #if ! defined (octave_pt_eval_h)
27 #define octave_pt_eval_h 1
29 #include "octave-config.h"
84 OCTAVE_DEFAULT_CONSTRUCT_COPY_MOVE_DELETE (
value_stack)
86 void push (const T& val) { m_stack.
push (val); }
95 T retval = m_stack.top ();
102 return m_stack.top ();
107 return m_stack.size ();
112 return m_stack.empty ();
117 while (! m_stack.empty ())
123 std::stack<T> m_stack;
129 : m_interpreter (interp), m_parser (), m_statement_context (SC_OTHER),
130 m_lvalue_list (nullptr), m_autoload_map (), m_bp_table (*this),
131 m_call_stack (*this), m_profiler (), m_debug_frame (0),
132 m_debug_mode (false), m_quiet_breakpoint_flag (false),
133 m_debugger_stack (), m_exit_status (0), m_max_recursion_depth (256),
134 m_whos_line_format (
" %la:5; %ln:6; %cs:16:6:1; %rb:12; %lc:-1;\n"),
135 m_silent_functions (false), m_string_fill_char (
' '), m_PS4 (
"+ "),
136 m_dbstep_flag (0), m_break_on_next_stmt (false), m_echo (ECHO_OFF),
137 m_echo_state (false), m_echo_file_name (),
139 m_echo_files (), m_in_top_level_repl (false),
140 m_server_mode (false), m_in_loop_command (false),
141 m_breaking (0), m_continuing (0), m_returning (0),
142 m_indexed_object (), m_index_list (), m_index_type (),
143 m_index_position (0), m_num_indices (0)
160 bool at_top_level ()
const;
162 std::string mfilename (
const std::string& opt =
"")
const;
168 void parse_and_execute (
const std::string& input,
bool& incomplete_parse);
170 void get_line_and_eval ();
182 void eval (std::shared_ptr<tree_statement_list>& stmt_list,
186 int& parse_status,
int nargout);
188 octave_value eval_string (
const std::string& eval_str,
bool silent,
192 int& parse_status,
int nargout);
197 const std::string& catch_code,
int nargout);
200 const std::string& try_code,
int nargout);
203 const std::string& try_code,
204 const std::string& catch_code,
int nargout);
247 execute_builtin_function (
octave_builtin& builtin_function,
int nargout,
327 bool statement_printing_enabled ();
329 void reset_debug_state ();
331 void reset_debug_state (
bool mode);
333 void enter_debugger (
const std::string& prompt =
"debug> ");
335 void keyboard (
const std::string& prompt =
"keyboard> ");
337 void dbupdown (
int n,
bool verbose =
false);
347 Matrix ignored_fcn_outputs ()
const;
353 void install_variable (
const std::string& name,
356 octave_value global_varval (
const std::string& name)
const;
360 void global_assign (
const std::string& name,
363 octave_value top_level_varval (
const std::string& name)
const;
365 void top_level_assign (
const std::string& name,
368 bool is_variable (
const std::string& name)
const;
370 bool is_local_variable (
const std::string& name)
const;
380 bool is_global (
const std::string& name)
const;
386 void assign (
const std::string& name,
389 void assignin (
const std::string& context,
const std::string& name,
393 const std::string& context =
"",
394 bool verbose =
false,
bool require_file =
true);
399 void set_nargin (
int nargin);
400 void set_nargout (
int nargout);
404 void define_parameter_list_from_arg_vector
412 convert_return_list_to_const_vector
429 const std::shared_ptr<stack_frame>& closure_frames = std::shared_ptr<stack_frame> ());
433 const std::shared_ptr<stack_frame>& closure_frames = std::shared_ptr<stack_frame> ());
439 void pop_stack_frame ();
441 std::shared_ptr<stack_frame> pop_return_stack_frame ();
445 return m_call_stack.get_current_stack_frame ();
450 return m_call_stack.current_user_frame ();
454 int current_line ()
const;
457 int current_column ()
const;
460 int debug_user_code_line ()
const;
463 int debug_user_code_column ()
const;
465 void debug_where (std::ostream& os)
const;
478 bool goto_frame (std::size_t
n = 0,
bool verbose =
false);
480 void goto_caller_frame ();
482 void goto_base_frame ();
484 void restore_frame (std::size_t
n);
486 std::string get_dispatch_class ()
const;
488 void set_dispatch_class (
const std::string& class_name);
490 bool is_class_method_executing (std::string& dispatch_class)
const;
492 bool is_class_constructor_executing (std::string& dispatch_class)
const;
494 std::list<std::shared_ptr<stack_frame>>
497 std::list<std::shared_ptr<stack_frame>> backtrace_frames ()
const;
499 std::list<frame_info> backtrace_info (
octave_idx_type& curr_user_frame,
500 bool print_subfn =
true)
const;
502 std::list<frame_info> backtrace_info ()
const;
505 bool print_subfn =
true)
const;
511 std::string backtrace_message ()
const;
513 void push_dummy_scope (
const std::string& name);
519 void mlock (
bool skip_first =
false)
const;
521 void munlock (
bool skip_first =
false)
const;
523 bool mislocked (
bool skip_first =
false)
const;
528 void display_call_stack ()
const;
532 void clear_objects ();
534 void clear_variable (
const std::string& name);
536 void clear_variable_pattern (
const std::string& pattern);
538 void clear_variable_regexp (
const std::string& pattern);
540 void clear_variables ();
542 void clear_global_variable (
const std::string& name);
544 void clear_global_variable_pattern (
const std::string& pattern);
546 void clear_global_variable_regexp (
const std::string& pattern);
548 void clear_global_variables ();
550 void clear_all (
bool force =
false);
552 void clear_symbol (
const std::string& name);
554 void clear_symbol_pattern (
const std::string& pattern);
556 void clear_symbol_regexp (
const std::string& pattern);
558 std::list<std::string> global_variable_names ()
const;
560 std::list<std::string> top_level_variable_names ()
const;
562 std::list<std::string> variable_names ()
const;
566 std::string current_function_name (
bool skip_first =
false)
const;
568 bool in_user_code ()
const;
580 std::string lookup_autoload (
const std::string& nm)
const;
582 std::list<std::string> autoloaded_functions ()
const;
584 std::list<std::string> reverse_lookup_autoload (
const std::string& nm)
const;
586 void add_autoload (
const std::string& fcn,
const std::string& nm);
588 void remove_autoload (
const std::string& fcn,
const std::string& nm);
594 int val = m_max_recursion_depth;
595 m_max_recursion_depth =
n;
606 int val = m_silent_functions;
607 m_silent_functions = b;
617 std::string val = m_whos_line_format;
618 m_whos_line_format = s;
629 std::size_t val = m_debug_frame;
636 return m_call_stack.current_frame ();
643 bool val = m_quiet_breakpoint_flag;
644 m_quiet_breakpoint_flag = flag;
652 int val = m_string_fill_char;
653 m_string_fill_char = c;
661 bool in_debug_repl ()
const;
668 void dbquit (
bool all =
false);
674 m_debug_watch_expressions.insert (expr);
681 m_debug_watch_expressions.erase (expr);
688 m_debug_watch_expressions.clear ();
695 return m_debug_watch_expressions;
700 std::string
PS4 ()
const {
return m_PS4; }
702 std::string
PS4 (
const std::string& s)
704 std::string val = m_PS4;
709 void set_PS4 (
const std::string& s) { m_PS4 = s; }
713 return m_indexed_object;
718 m_indexed_object = obj;
727 const std::list<octave_value_list>& index_list)
729 m_index_type = index_type;
730 m_index_list = index_list;
736 m_index_list.clear ();
741 m_index_type += type;
742 m_index_list.push_back (idx);
758 return m_lvalue_list;
770 int val = m_breaking;
779 int val = m_continuing;
788 int val = m_returning;
797 int old_val = m_dbstep_flag;
806 return m_break_on_next_stmt;
811 bool old_val = m_break_on_next_stmt;
812 m_break_on_next_stmt = val;
818 m_break_on_next_stmt = val;
823 int echo ()
const {
return m_echo; }
827 int old_val = m_echo;
839 bool return_list,
bool verbose =
false);
846 void push_echo_state (
int type,
const std::string& file_name,
int pos = 1);
854 m_echo_file_pos = pos;
859 template <
typename T>
864 void set_echo_state (
int type,
const std::string& file_name,
int pos);
866 void maybe_set_echo_state ();
870 bool maybe_push_echo_state_cleanup ();
874 void do_breakpoint (
bool is_breakpoint,
875 bool is_end_of_fcn_or_script =
false);
880 void uwp_set_echo_state (
bool state,
const std::string& file_name,
int pos);
882 bool echo_this_file (
const std::string& file,
int type)
const;
884 void echo_code (
int line);
886 bool quit_loop_now ();
889 const Matrix& ignored_outputs,
int nargin,
890 int nargout,
bool takes_varargs,
893 std::string check_autoload_file (
const std::string& nm)
const;
897 std::shared_ptr<push_parser> m_parser;
900 stmt_list_type m_statement_context;
902 const std::list<octave_lvalue> *m_lvalue_list;
905 std::map<std::string, std::string> m_autoload_map;
914 std::size_t m_debug_frame;
918 bool m_quiet_breakpoint_flag;
925 std::stack<debugger *> m_debugger_stack;
927 std::set<std::string> m_debug_watch_expressions;
933 int m_max_recursion_depth;
936 std::string m_whos_line_format;
940 bool m_silent_functions;
943 char m_string_fill_char;
956 bool m_break_on_next_stmt;
970 std::string m_echo_file_name;
982 std::map<std::string, bool> m_echo_files;
985 bool m_in_top_level_repl;
991 bool m_in_loop_command;
1005 std::list<octave_value_list> m_index_list;
1006 std::string m_index_type;
1007 int m_index_position;
1011 OCTAVE_END_NAMESPACE(
octave)
std::map< std::string, octave_value > local_vars_map
void set_indexed_object(const octave_value &obj=octave_value())
std::set< std::string > debug_watch_expressions() const
int max_recursion_depth() const
std::size_t debug_frame(std::size_t n)
int max_recursion_depth(int n)
void set_PS4(const std::string &s)
void set_echo_file_pos(int pos)
bool break_on_next_statement() const
char string_fill_char(char c)
std::string whos_line_format(const std::string &s)
bool silent_functions(bool b)
bool in_top_level_repl() const
int index_position() const
void remove_debug_watch_expression(const std::string &expr)
interpreter & get_interpreter()
bool quiet_breakpoint_flag(bool flag)
octave_value indexed_object() const
void set_break_on_next_statement(bool val)
std::size_t current_call_stack_frame_number() const
std::size_t debug_frame() const
void add_debug_watch_expression(const std::string &expr)
tree_evaluator(interpreter &interp)
std::shared_ptr< push_parser > get_parser()
void set_parser(const std::shared_ptr< push_parser > &parser)
bool silent_functions() const
void server_mode(bool arg)
std::shared_ptr< stack_frame > current_user_frame() const
char string_fill_char() const
std::shared_ptr< stack_frame > get_current_stack_frame() const
const std::list< octave_lvalue > * lvalue_list() const
std::string whos_line_format() const
bp_table & get_bp_table()
std::string PS4(const std::string &s)
bool break_on_next_statement(bool val)
const std::list< octave_value_list > & index_list() const
const std::string & index_type() const
~tree_evaluator()=default
bool quiet_breakpoint_flag() const
void set_lvalue_list(const std::list< octave_lvalue > *lst)
void set_dbstep_flag(int step)
void clear_debug_watch_expressions()
void append_index_list(char type, const octave_value_list &idx)
void set_index_list(const std::string &index_type, const std::list< octave_value_list > &index_list)
profiler & get_profiler()
virtual void visit_compound_binary_expression(tree_compound_binary_expression &)
virtual void visit_boolean_expression(tree_boolean_expression &)
virtual void visit_unwind_protect_command(tree_unwind_protect_command &)
virtual void visit_try_catch_command(tree_try_catch_command &)
virtual void visit_if_command_list(tree_if_command_list &)
virtual void visit_multi_assignment(tree_multi_assignment &)
virtual void visit_return_command(tree_return_command &)
virtual void visit_continue_command(tree_continue_command &)
virtual void visit_switch_case_list(tree_switch_case_list &)
virtual void visit_complex_for_command(tree_complex_for_command &)
virtual void visit_break_command(tree_break_command &)
virtual void visit_matrix(tree_matrix &)
virtual void visit_args_block_validation_list(tree_args_block_validation_list &)
virtual void visit_fcn_handle(tree_fcn_handle &)
virtual void visit_colon_expression(tree_colon_expression &)
virtual void visit_arg_size_spec(tree_arg_size_spec &)
virtual void visit_spmd_command(tree_spmd_command &)
virtual void visit_do_until_command(tree_do_until_command &)
virtual void visit_no_op_command(tree_no_op_command &)
virtual void visit_binary_expression(tree_binary_expression &)
virtual void visit_simple_for_command(tree_simple_for_command &)
virtual void visit_postfix_expression(tree_postfix_expression &)
virtual void visit_prefix_expression(tree_prefix_expression &)
virtual void visit_anon_fcn_handle(tree_anon_fcn_handle &)
virtual void visit_args_block_attribute_list(tree_args_block_attribute_list &)
virtual void visit_parameter_list(tree_parameter_list &)
virtual void visit_arguments_block(tree_arguments_block &)
virtual void visit_statement(tree_statement &)
virtual void visit_index_expression(tree_index_expression &)
virtual void visit_decl_command(tree_decl_command &)
virtual void visit_switch_case(tree_switch_case &)
virtual void visit_cell(tree_cell &)
virtual void visit_identifier(tree_identifier &)
virtual void visit_if_clause(tree_if_clause &)
virtual void visit_statement_list(tree_statement_list &)
virtual void visit_arg_validation_fcns(tree_arg_validation_fcns &)
virtual void visit_if_command(tree_if_command &)
virtual void visit_argument_list(tree_argument_list &)
virtual void visit_decl_elt(tree_decl_elt &)
virtual void visit_constant(tree_constant &)
virtual void visit_simple_assignment(tree_simple_assignment &)
virtual void visit_superclass_ref(tree_superclass_ref &)
virtual void visit_octave_user_script(octave_user_script &)
virtual void visit_arg_validation(tree_arg_validation &)
virtual void visit_octave_user_function(octave_user_function &)
virtual void visit_function_def(tree_function_def &)
virtual void visit_metaclass_query(tree_metaclass_query &)
virtual void visit_while_command(tree_while_command &)
virtual void visit_switch_command(tree_switch_command &)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
void source_file(const std::string &file_name, const std::string &context="", bool verbose=false, bool require_file=true)