26 #if ! defined (octave_pt_eval_h)
27 #define octave_pt_eval_h 1
29 #include "octave-config.h"
51 class symbol_info_list;
54 class tree_expression;
87 void push (
const T& val) { m_stack.push (val); }
103 return m_stack.top ();
108 return m_stack.size ();
113 return m_stack.empty ();
118 while (! m_stack.empty ())
130 : m_interpreter (interp), m_statement_context (SC_OTHER),
131 m_lvalue_list (nullptr), m_autoload_map (), m_bp_table (*this),
132 m_call_stack (*this), m_profiler (), m_debug_frame (0),
133 m_debug_mode (false), m_quiet_breakpoint_flag (false),
134 m_debugger_stack (), m_max_recursion_depth (256),
135 m_whos_line_format (
" %a:4; %ln:6; %cs:16:6:1; %rb:12; %lc:-1;\n"),
136 m_silent_functions (false), m_string_fill_char (
' '),
137 m_PS4 (
"+ "), m_dbstep_flag (0), m_echo (ECHO_OFF),
138 m_echo_state (false), m_echo_file_name (), m_echo_file_pos (1),
139 m_echo_files (), m_in_loop_command (false),
140 m_breaking (0), m_continuing (0), m_returning (0),
141 m_indexed_object (), m_index_list (), m_index_type (),
142 m_index_position (0), m_num_indices (0)
153 bool at_top_level (
void)
const;
155 void eval (std::shared_ptr<tree_statement_list>& stmt_list,
158 std::string mfilename (
const std::string& opt =
"")
const;
161 int& parse_status,
int nargout);
167 int& parse_status,
int nargout);
172 const std::string& catch_code,
int nargout);
175 const std::string& try_code,
int nargout);
178 const std::string& try_code,
179 const std::string& catch_code,
int nargout);
279 bool statement_printing_enabled (
void);
281 void reset_debug_state (
void);
283 void reset_debug_state (
bool mode);
285 void enter_debugger (
const std::string& prompt =
"debug> ");
287 void keyboard (
const std::string& prompt =
"keyboard> ");
289 void dbupdown (
int n,
bool verbose =
false);
299 Matrix ignored_fcn_outputs (
void)
const;
305 void install_variable (
const std::string&
name,
312 void global_assign (
const std::string&
name,
317 void top_level_assign (
const std::string&
name,
320 bool is_variable (
const std::string&
name)
const;
322 bool is_local_variable (
const std::string&
name)
const;
332 bool is_global (
const std::string&
name)
const;
338 void assign (
const std::string&
name,
341 void assignin (
const std::string&
context,
const std::string&
name,
345 const std::string&
context =
"",
346 bool verbose =
false,
bool require_file =
true);
353 void define_parameter_list_from_arg_vector
361 convert_return_list_to_const_vector
363 const Matrix& ignored_outputs,
const Cell& varargout);
381 const std::shared_ptr<stack_frame>& closure_frames = std::shared_ptr<stack_frame> ());
390 void pop_stack_frame (
void);
394 return m_call_stack.get_current_stack_frame ();
399 return m_call_stack.current_user_frame ();
403 int current_line (
void)
const;
406 int current_column (
void)
const;
409 int debug_user_code_line (
void)
const;
412 int debug_user_code_column (
void)
const;
414 void debug_where (std::ostream& os)
const;
427 bool goto_frame (
size_t n = 0,
bool verbose =
false);
429 void goto_caller_frame (
void);
431 void goto_base_frame (
void);
433 void restore_frame (
size_t n);
435 std::string get_dispatch_class (
void)
const;
437 void set_dispatch_class (
const std::string& class_name);
439 bool is_class_method_executing (std::string& dispatch_class)
const;
441 bool is_class_constructor_executing (std::string& dispatch_class)
const;
443 std::list<std::shared_ptr<stack_frame>>
446 std::list<std::shared_ptr<stack_frame>> backtrace_frames ()
const;
448 std::list<frame_info> backtrace_info (
octave_idx_type& curr_user_frame,
449 bool print_subfn =
true)
const;
451 std::list<frame_info> backtrace_info (
void)
const;
454 bool print_subfn =
true)
const;
460 std::string backtrace_message (
void)
const;
462 void push_dummy_scope (
const std::string&
name);
463 void pop_scope (
void);
468 void mlock (
bool skip_first =
false)
const;
470 void munlock (
bool skip_first =
false)
const;
472 bool mislocked (
bool skip_first =
false)
const;
477 void display_call_stack (
void)
const;
481 void clear_objects (
void);
483 void clear_variable (
const std::string&
name);
485 void clear_variable_pattern (
const std::string& pattern);
487 void clear_variable_regexp (
const std::string& pattern);
489 void clear_variables (
void);
491 void clear_global_variable (
const std::string&
name);
493 void clear_global_variable_pattern (
const std::string& pattern);
495 void clear_global_variable_regexp (
const std::string& pattern);
497 void clear_global_variables (
void);
499 void clear_all (
bool force =
false);
501 void clear_symbol (
const std::string&
name);
503 void clear_symbol_pattern (
const std::string& pattern);
505 void clear_symbol_regexp (
const std::string& pattern);
507 std::list<std::string> global_variable_names (
void)
const;
509 std::list<std::string> top_level_variable_names (
void)
const;
511 std::list<std::string> variable_names (
void)
const;
514 const std::string& class_name =
"");
516 std::string current_function_name (
bool skip_first =
false)
const;
518 bool in_user_code (
void)
const;
530 std::string lookup_autoload (
const std::string& nm)
const;
532 std::list<std::string> autoloaded_functions (
void)
const;
534 std::list<std::string> reverse_lookup_autoload (
const std::string& nm)
const;
536 void add_autoload (
const std::string& fcn,
const std::string& nm);
538 void remove_autoload (
const std::string& fcn,
const std::string& nm);
544 int val = m_max_recursion_depth;
545 m_max_recursion_depth =
n;
556 int val = m_silent_functions;
557 m_silent_functions = b;
567 std::string val = m_whos_line_format;
568 m_whos_line_format = s;
579 size_t val = m_debug_frame;
586 return m_call_stack.current_frame ();
593 bool val = m_quiet_breakpoint_flag;
594 m_quiet_breakpoint_flag = flag;
602 int val = m_string_fill_char;
603 m_string_fill_char = c;
611 bool in_debug_repl (
void)
const;
615 void dbquit (
bool all =
false);
619 std::string
PS4 (
void)
const {
return m_PS4; }
621 std::string
PS4 (
const std::string& s)
623 std::string val = m_PS4;
630 return m_indexed_object;
635 m_indexed_object = obj;
644 const std::list<octave_value_list>& index_list)
646 m_index_type = index_type;
647 m_index_list = index_list;
653 m_index_list.clear ();
658 m_index_type +=
type;
659 m_index_list.push_back (idx);
675 return m_lvalue_list;
687 int val = m_breaking;
696 int val = m_continuing;
705 int val = m_returning;
714 int old_val = m_dbstep_flag;
723 int echo (
void)
const {
return m_echo; }
727 int old_val = m_echo;
738 bool return_list,
bool verbose =
false);
745 void push_echo_state (
int type,
const std::string& file_name,
750 void set_echo_state (
int type,
const std::string& file_name,
size_t pos);
752 void maybe_set_echo_state (
void);
756 bool maybe_push_echo_state_cleanup (
void);
760 void do_breakpoint (
bool is_breakpoint,
761 bool is_end_of_fcn_or_script =
false);
766 void uwp_set_echo_state (
bool state,
const std::string& file_name,
769 bool echo_this_file (
const std::string& file,
int type)
const;
771 void echo_code (
size_t line);
773 bool quit_loop_now (
void);
776 const Matrix& ignored_outputs,
int nargin,
777 int nargout,
bool takes_varargs,
780 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)
std::map< std::string, octave_value > local_vars_map
value_stack(const value_stack &)=default
value_stack(void)=default
~value_stack(void)=default
std::string whos_line_format(const std::string &s)
std::string PS4(const std::string &s)
size_t current_call_stack_frame_number(void) const
std::list< octave_value_list > m_index_list
void set_lvalue_list(const std::list< octave_lvalue > *lst)
void set_index_list(const std::string &index_type, const std::list< octave_value_list > &index_list)
const std::list< octave_lvalue > * lvalue_list(void) const
bool quiet_breakpoint_flag(void) const
int dbstep_flag(void) const
int continuing(void) const
std::map< std::string, std::string > m_autoload_map
std::string PS4(void) const
octave_value m_indexed_object
std::stack< debugger * > m_debugger_stack
bool silent_functions(void) const
void append_index_list(char type, const octave_value_list &idx)
bool silent_functions(bool b)
const std::list< octave_lvalue > * m_lvalue_list
bp_table & get_bp_table(void)
std::string m_echo_file_name
int m_max_recursion_depth
void set_indexed_object(const octave_value &obj=octave_value())
std::map< std::string, bool > m_echo_files
void clear_index_list(void)
bool m_quiet_breakpoint_flag
std::string m_whos_line_format
call_stack & get_call_stack(void)
bool quiet_breakpoint_flag(bool flag)
int num_indices(void) const
int max_recursion_depth(void) const
std::string whos_line_format(void) const
tree_evaluator(interpreter &interp)
interpreter & m_interpreter
std::shared_ptr< stack_frame > get_current_stack_frame(void) const
size_t debug_frame(size_t n)
const std::list< octave_value_list > & index_list(void) const
int returning(void) const
const std::string & index_type(void) const
size_t debug_frame(void) const
void set_dbstep_flag(int step)
stmt_list_type m_statement_context
octave_value indexed_object(void) const
char string_fill_char(char c)
char string_fill_char(void) const
std::shared_ptr< stack_frame > current_user_frame(void) const
~tree_evaluator(void)=default
tree_evaluator(const tree_evaluator &)=delete
interpreter & get_interpreter(void)
int max_recursion_depth(int n)
int index_position(void) const
profiler & get_profiler(void)
static octave_idx_type find(octave_idx_type i, octave_idx_type *pp)
static uint32_t state[624]
octave_value_list eval_string(const std::string &eval_str, bool silent, int &parse_status, int nargout)
static llvm::LLVMContext & context
octave_user_code * get_user_code(const std::string &fname)
void source_file(const std::string &file_name, const std::string &context, bool verbose, bool require_file)
static octave_value make_fcn_handle(const octave_value &fcn, const std::string &meth_name, const std::string &class_name)
octave_value::octave_value(const Array< char > &chm, char type) return retval
static octave::unwind_protect * curr_fcn_unwind_protect_frame(void)