26 #if ! defined (octave_pt_eval_h)
27 #define octave_pt_eval_h 1
29 #include "octave-config.h"
92 void push (
const T& val) { m_stack.push (val); }
101 T retval = m_stack.top ();
108 return m_stack.top ();
113 return m_stack.size ();
118 return m_stack.empty ();
123 while (! m_stack.empty ())
135 : m_interpreter (interp), m_parser (), m_statement_context (SC_OTHER),
136 m_lvalue_list (nullptr), m_autoload_map (), m_bp_table (*this),
137 m_call_stack (*this), m_profiler (), m_debug_frame (0),
138 m_debug_mode (false), m_quiet_breakpoint_flag (false),
139 m_debugger_stack (), m_exit_status (0), m_max_recursion_depth (256),
140 m_whos_line_format (
" %la:5; %ln:6; %cs:16:6:1; %rb:12; %lc:-1;\n"),
141 m_silent_functions (false), m_string_fill_char (
' '), m_PS4 (
"+ "),
142 m_dbstep_flag (0), m_break_on_next_stmt (false), m_echo (ECHO_OFF),
143 m_echo_state (false), m_echo_file_name (), m_echo_file_pos (1),
144 m_echo_files (), m_in_top_level_repl (false),
145 m_server_mode (false), m_in_loop_command (false),
146 m_breaking (0), m_continuing (0), m_returning (0),
147 m_indexed_object (), m_index_list (), m_index_type (),
148 m_index_position (0), m_num_indices (0)
169 bool at_top_level (
void)
const;
171 std::string mfilename (
const std::string& opt =
"")
const;
177 void parse_and_execute (
const std::string&
input,
bool& incomplete_parse);
179 void get_line_and_eval (
void);
185 int server_loop (
void);
191 void eval (std::shared_ptr<tree_statement_list>& stmt_list,
195 int& parse_status,
int nargout);
197 octave_value eval_string (
const std::string& eval_str,
bool silent,
201 int& parse_status,
int nargout);
206 const std::string& catch_code,
int nargout);
209 const std::string& try_code,
int nargout);
212 const std::string& try_code,
213 const std::string& catch_code,
int nargout);
256 execute_builtin_function (
octave_builtin& builtin_function,
int nargout,
336 bool statement_printing_enabled (
void);
338 void reset_debug_state (
void);
340 void reset_debug_state (
bool mode);
342 void enter_debugger (
const std::string& prompt =
"debug> ");
344 void keyboard (
const std::string& prompt =
"keyboard> ");
346 void dbupdown (
int n,
bool verbose =
false);
356 Matrix ignored_fcn_outputs (
void)
const;
362 void install_variable (
const std::string& name,
365 octave_value global_varval (
const std::string& name)
const;
369 void global_assign (
const std::string& name,
372 octave_value top_level_varval (
const std::string& name)
const;
374 void top_level_assign (
const std::string& name,
377 bool is_variable (
const std::string& name)
const;
379 bool is_local_variable (
const std::string& name)
const;
389 bool is_global (
const std::string& name)
const;
395 void assign (
const std::string& name,
398 void assignin (
const std::string& context,
const std::string& name,
402 const std::string& context =
"",
403 bool verbose =
false,
bool require_file =
true);
410 void define_parameter_list_from_arg_vector
418 convert_return_list_to_const_vector
420 const Matrix& ignored_outputs,
const Cell& varargout);
436 const std::shared_ptr<stack_frame>& closure_frames = std::shared_ptr<stack_frame> ());
440 const std::shared_ptr<stack_frame>& closure_frames = std::shared_ptr<stack_frame> ());
446 void pop_stack_frame (
void);
450 return m_call_stack.get_current_stack_frame ();
455 return m_call_stack.current_user_frame ();
459 int current_line (
void)
const;
462 int current_column (
void)
const;
465 int debug_user_code_line (
void)
const;
468 int debug_user_code_column (
void)
const;
470 void debug_where (std::ostream& os)
const;
483 bool goto_frame (std::size_t
n = 0,
bool verbose =
false);
485 void goto_caller_frame (
void);
487 void goto_base_frame (
void);
489 void restore_frame (std::size_t
n);
491 std::string get_dispatch_class (
void)
const;
493 void set_dispatch_class (
const std::string& class_name);
495 bool is_class_method_executing (std::string& dispatch_class)
const;
497 bool is_class_constructor_executing (std::string& dispatch_class)
const;
499 std::list<std::shared_ptr<stack_frame>>
502 std::list<std::shared_ptr<stack_frame>> backtrace_frames ()
const;
504 std::list<frame_info> backtrace_info (
octave_idx_type& curr_user_frame,
505 bool print_subfn =
true)
const;
507 std::list<frame_info> backtrace_info (
void)
const;
510 bool print_subfn =
true)
const;
516 std::string backtrace_message (
void)
const;
518 void push_dummy_scope (
const std::string& name);
519 void pop_scope (
void);
524 void mlock (
bool skip_first =
false)
const;
526 void munlock (
bool skip_first =
false)
const;
528 bool mislocked (
bool skip_first =
false)
const;
533 void display_call_stack (
void)
const;
537 void clear_objects (
void);
539 void clear_variable (
const std::string& name);
541 void clear_variable_pattern (
const std::string& pattern);
543 void clear_variable_regexp (
const std::string& pattern);
545 void clear_variables (
void);
547 void clear_global_variable (
const std::string& name);
549 void clear_global_variable_pattern (
const std::string& pattern);
551 void clear_global_variable_regexp (
const std::string& pattern);
553 void clear_global_variables (
void);
555 void clear_all (
bool force =
false);
557 void clear_symbol (
const std::string& name);
559 void clear_symbol_pattern (
const std::string& pattern);
561 void clear_symbol_regexp (
const std::string& pattern);
563 std::list<std::string> global_variable_names (
void)
const;
565 std::list<std::string> top_level_variable_names (
void)
const;
567 std::list<std::string> variable_names (
void)
const;
570 const std::string& class_name =
"");
572 std::string current_function_name (
bool skip_first =
false)
const;
574 bool in_user_code (
void)
const;
586 std::string lookup_autoload (
const std::string& nm)
const;
588 std::list<std::string> autoloaded_functions (
void)
const;
590 std::list<std::string> reverse_lookup_autoload (
const std::string& nm)
const;
592 void add_autoload (
const std::string& fcn,
const std::string& nm);
594 void remove_autoload (
const std::string& fcn,
const std::string& nm);
600 int val = m_max_recursion_depth;
601 m_max_recursion_depth =
n;
612 int val = m_silent_functions;
613 m_silent_functions = b;
623 std::string val = m_whos_line_format;
624 m_whos_line_format = s;
635 std::size_t val = m_debug_frame;
642 return m_call_stack.current_frame ();
649 bool val = m_quiet_breakpoint_flag;
650 m_quiet_breakpoint_flag = flag;
658 int val = m_string_fill_char;
659 m_string_fill_char = c;
667 bool in_debug_repl (
void)
const;
674 void dbquit (
bool all =
false);
680 m_debug_watch_expressions.insert (expr);
687 m_debug_watch_expressions.erase (expr);
694 m_debug_watch_expressions.clear ();
701 return m_debug_watch_expressions;
706 std::string
PS4 (
void)
const {
return m_PS4; }
708 std::string
PS4 (
const std::string& s)
710 std::string val = m_PS4;
717 return m_indexed_object;
722 m_indexed_object = obj;
731 const std::list<octave_value_list>& index_list)
733 m_index_type = index_type;
734 m_index_list = index_list;
740 m_index_list.clear ();
745 m_index_type += type;
746 m_index_list.push_back (idx);
762 return m_lvalue_list;
774 int val = m_breaking;
783 int val = m_continuing;
792 int val = m_returning;
801 int old_val = m_dbstep_flag;
810 return m_break_on_next_stmt;
815 bool old_val = m_break_on_next_stmt;
816 m_break_on_next_stmt = val;
822 m_break_on_next_stmt = val;
827 int echo (
void)
const {
return m_echo; }
831 int old_val = m_echo;
842 bool return_list,
bool verbose =
false);
849 void push_echo_state (
int type,
const std::string& file_name,
int pos = 1);
853 template <
typename T>
854 void execute_range_loop (
const range<T>& rng,
int line,
858 void set_echo_state (
int type,
const std::string& file_name,
int pos);
860 void maybe_set_echo_state (
void);
864 bool maybe_push_echo_state_cleanup (
void);
868 void do_breakpoint (
bool is_breakpoint,
869 bool is_end_of_fcn_or_script =
false);
874 void uwp_set_echo_state (
bool state,
const std::string& file_name,
int pos);
876 bool echo_this_file (
const std::string& file,
int type)
const;
878 void echo_code (
int line);
880 bool quit_loop_now (
void);
883 const Matrix& ignored_outputs,
int nargin,
884 int nargout,
bool takes_varargs,
887 std::string check_autoload_file (
const std::string& nm)
const;
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)
static octave_value make_fcn_handle(const octave_value &fcn, const std::string &meth_name, const std::string &class_name)
std::map< std::string, octave_value > local_vars_map
value_stack(const value_stack &)=default
value_stack(void)=default
std::size_t size(void) const
~value_stack(void)=default
bool in_top_level_repl(void) const
void set_indexed_object(const octave_value &obj=octave_value())
std::size_t m_debug_frame
std::stack< debugger * > m_debugger_stack
int dbstep_flag(void) const
std::list< octave_value_list > m_index_list
profiler & get_profiler(void)
std::size_t debug_frame(std::size_t n)
int max_recursion_depth(int n)
interpreter & m_interpreter
char string_fill_char(void) const
stmt_list_type m_statement_context
char string_fill_char(char c)
int max_recursion_depth(void) const
octave_value indexed_object(void) const
std::size_t debug_frame(void) const
std::string whos_line_format(const std::string &s)
const std::string & index_type(void) const
std::size_t current_call_stack_frame_number(void) const
bool silent_functions(bool b)
bool m_quiet_breakpoint_flag
void remove_debug_watch_expression(const std::string &expr)
std::map< std::string, std::string > m_autoload_map
int returning(void) const
octave_value m_indexed_object
bool quiet_breakpoint_flag(bool flag)
std::shared_ptr< stack_frame > get_current_stack_frame(void) const
int index_position(void) const
std::string PS4(void) const
const std::list< octave_lvalue > * lvalue_list(void) const
std::shared_ptr< push_parser > m_parser
int num_indices(void) const
void set_break_on_next_statement(bool val)
void add_debug_watch_expression(const std::string &expr)
bool quiet_breakpoint_flag(void) const
tree_evaluator(interpreter &interp)
void set_parser(const std::shared_ptr< push_parser > &parser)
bool m_break_on_next_stmt
void server_mode(bool arg)
interpreter & get_interpreter(void)
const std::list< octave_lvalue > * m_lvalue_list
void clear_index_list(void)
bool server_mode(void) const
void clear_debug_watch_expressions(void)
int m_max_recursion_depth
tree_evaluator(const tree_evaluator &)=delete
std::string PS4(const std::string &s)
std::string m_echo_file_name
bool break_on_next_statement(bool val)
std::set< std::string > m_debug_watch_expressions
bool break_on_next_statement(void) const
void set_lvalue_list(const std::list< octave_lvalue > *lst)
void set_dbstep_flag(int step)
std::shared_ptr< stack_frame > current_user_frame(void) const
void append_index_list(char type, const octave_value_list &idx)
std::string m_whos_line_format
std::shared_ptr< push_parser > get_parser(void)
~tree_evaluator(void)=default
std::set< std::string > debug_watch_expressions(void) const
void set_index_list(const std::string &index_type, const std::list< octave_value_list > &index_list)
bool silent_functions(void) const
std::string whos_line_format(void) const
int continuing(void) const
const std::list< octave_value_list > & index_list(void) const
std::map< std::string, bool > m_echo_files
bp_table & get_bp_table(void)
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 &)
tree_walker & operator=(const tree_walker &)=delete
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 &)
static octave_idx_type find(octave_idx_type i, octave_idx_type *pp)
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)
static int input(yyscan_t yyscanner)
static uint32_t state[624]
static octave::unwind_protect * curr_fcn_unwind_protect_frame(void)