26#if defined (HAVE_CONFIG_H)
32#include <condition_variable>
78OCTAVE_NORETURN
static void
79error_unexpected (
const char *name)
81 error (
"unexpected call to %s - please report this bug", name);
86class quit_debug_exception
90 quit_debug_exception (
bool all =
false) : m_all (all) { }
92 quit_debug_exception (
const quit_debug_exception&) =
default;
94 quit_debug_exception& operator = (
const quit_debug_exception&) =
default;
96 ~quit_debug_exception () =
default;
98 bool all ()
const {
return m_all; }
118 : m_interpreter (interp), m_level (level),
119 m_execution_mode (EX_NORMAL), m_in_debug_repl (false)
124 void repl (
const std::string& prompt =
"debug> ");
126 bool in_debug_repl ()
const {
return m_in_debug_repl; }
128 void dbcont () { m_execution_mode = EX_CONTINUE; }
130 void dbquit (
bool all =
false)
133 m_execution_mode = EX_QUIT_ALL;
135 m_execution_mode = EX_QUIT;
138 bool quitting_debugger ()
const;
145 execution_mode m_execution_mode;
146 bool m_in_debug_repl;
154debugger::server_loop ()
168 if (m_execution_mode == EX_CONTINUE || tw.
dbstep_flag ())
171 if (quitting_debugger ())
204 catch (
const interrupt_exception&)
207 m_interpreter.recover_from_exception ();
210 if (m_interpreter.interactive ())
215 m_interpreter.recover_from_exception ();
217 std::cerr <<
"error: unhandled index exception: "
218 << e.message () <<
" -- trying to return to prompt"
228 if (m_interpreter.interactive ())
230 m_interpreter.recover_from_exception ();
239 catch (
const quit_debug_exception& qde)
246 catch (
const std::bad_alloc&)
248 m_interpreter.recover_from_exception ();
250 std::cerr <<
"error: out of memory -- trying to return to prompt"
254 while (exit_status == 0);
256 if (exit_status == EOF)
258 if (m_interpreter.interactive ())
268debugger::repl (
const std::string& prompt_arg)
275 m_in_debug_repl =
true;
287 std::string fcn_file_nm, fcn_nm;
292 fcn_nm = fcn_file_nm.empty () ? caller->
name () : fcn_file_nm;
297 std::ostringstream buf;
299 input_system& input_sys = m_interpreter.get_input_system ();
303 if (! fcn_nm.empty ())
307 static char ctrl_z =
'Z' & 0x1f;
309 buf << ctrl_z << ctrl_z << fcn_nm <<
':' << curr_debug_line;
321 frm->display_stopped_in_message (buf);
329 fcn_nm, curr_debug_line);
333 std::string line_buf;
338 if (! line_buf.empty ())
339 buf << curr_debug_line <<
": " << line_buf;
341 buf <<
"[End of function]";
349 std::string stopped_in_msg = buf.str ();
351 if (m_interpreter.server_mode ())
353 if (! stopped_in_msg.empty ())
362 std::shared_ptr<push_parser>
371 if (! stopped_in_msg.empty ())
372 std::cerr << stopped_in_msg << std::endl;
374 std::string tmp_prompt = prompt_arg;
376 tmp_prompt =
"[" + std::to_string (m_level) +
"]" + prompt_arg;
379 m_interpreter.PS1 (tmp_prompt);
381 if (! m_interpreter.interactive ())
385 frame.
add (interactive_fptr, &m_interpreter,
386 m_interpreter.interactive ());
388 m_interpreter.interactive (
true);
399 frame.
add (forced_interactive_fptr, app,
406#if defined (OCTAVE_ENABLE_COMMAND_LINE_PUSH_PARSER)
414 parser debug_parser (m_interpreter);
420 while (m_in_debug_repl)
422 if (m_execution_mode == EX_CONTINUE || tw.
dbstep_flag ())
425 if (quitting_debugger ())
430 debug_parser.reset ();
432#if defined (OCTAVE_ENABLE_COMMAND_LINE_PUSH_PARSER)
445 std::string input_line = reader.get_input (prompt, eof);
453 retval = debug_parser.run (input_line,
false);
462 int retval = debug_parser.run ();
469 quitting_debugger ();
477 std::shared_ptr<tree_statement_list> stmt_list
478 = debug_parser.statement_list ();
481 stmt_list->accept (tw);
507 m_interpreter.recover_from_exception ();
509 catch (
const quit_debug_exception& qde)
521debugger::quitting_debugger ()
const
523 if (m_execution_mode == EX_QUIT)
528 if (m_level > 0 || m_interpreter.server_mode ()
529 || m_interpreter.in_top_level_repl ())
530 throw quit_debug_exception ();
535 if (m_execution_mode == EX_QUIT_ALL)
540 if (m_interpreter.server_mode () || m_interpreter.in_top_level_repl ())
541 throw quit_debug_exception (
true);
567 fname = fcn->
name ();
570 if (opt ==
"fullpathext")
573 std::size_t dpos = fname.rfind (sys::file_ops::dir_sep_char ());
574 std::size_t epos = fname.rfind (
'.');
577 epos = std::string::npos;
579 if (epos != std::string::npos)
580 fname = fname.substr (0, epos);
582 if (opt ==
"fullpath")
585 if (dpos != std::string::npos)
586 fname = fname.substr (dpos+1);
593 bool& incomplete_parse)
595 incomplete_parse =
false;
623 m_exit_status = m_parser->run (input, eof);
625 if (m_exit_status == 0)
627 std::shared_ptr<tree_statement_list>
628 stmt_list = m_parser->statement_list ();
638 else if (m_parser->at_end_of_input ())
642 incomplete_parse =
true;
648 if (m_exit_status == -1)
660 std::unique_lock<std::mutex> lock (mtx);
661 std::condition_variable cv;
662 bool incomplete_parse =
false;
663 bool evaluation_pending =
false;
664 bool exiting =
false;
675 = incomplete_parse ? m_interpreter.
PS2 () : m_interpreter.
PS1 ();
680 std::getline (std::cin, input);
685 incomplete_parse =
false;
686 evaluation_pending =
true;
690 ([
this, input, &mtx, &incomplete_parse, &evaluation_pending, &cv, &exiting] (
interpreter& interp)
694 std::lock_guard<std::mutex> local_lock (mtx);
700 catch (
const exit_exception&)
702 evaluation_pending =
false;
718 evaluation_pending =
false;
723 evaluation_pending =
false;
725 throw exit_exception (1);
730 evaluation_pending =
false;
735 evaluation_pending =
false;
742 cv.wait (lock, [&evaluation_pending] {
return ! evaluation_pending; });
763#if defined (OCTAVE_ENABLE_COMMAND_LINE_PUSH_PARSER)
764 static bool use_command_line_push_parser =
true;
766 static bool use_command_line_push_parser =
false;
774 std::shared_ptr<base_parser> repl_parser;
778 if (use_command_line_push_parser)
784 repl_parser = std::shared_ptr<base_parser> (pp);
789 repl_parser = std::shared_ptr<base_parser> (pp);
795 repl_parser = std::shared_ptr<base_parser> (pp);
804 repl_parser->reset ();
812 exit_status = repl_parser->run ();
814 if (exit_status == 0)
816 std::shared_ptr<tree_statement_list>
817 stmt_list = repl_parser->statement_list ();
825 else if (repl_parser->at_end_of_input ())
832 catch (
const interrupt_exception&)
844 std::cerr <<
"error: unhandled index exception: "
845 << ie.message () <<
" -- trying to return to prompt"
864 catch (
const quit_debug_exception&)
870 catch (
const std::bad_alloc&)
874 std::cerr <<
"error: out of memory -- trying to return to prompt"
878 while (exit_status == 0);
880 if (exit_status == EOF)
929 catch (
const interrupt_exception&)
944 std::cerr <<
"error: unhandled index exception: "
945 << e.message () <<
" -- trying to return to prompt"
967 catch (
const quit_debug_exception&)
973 catch (
const exit_exception& xe)
975 m_exit_status = xe.exit_status ();
978 catch (
const std::bad_alloc&)
983 std::cerr <<
"error: out of memory -- trying to return to prompt"
987 while (m_exit_status == 0);
989 if (m_exit_status == EOF)
997 return m_exit_status;
1006 stmt_list->accept (*
this);
1012 bool quit = (m_returning || m_breaking);
1027 catch (
const quit_debug_exception&)
1035 int& parse_status,
int nargout)
1039 parser eval_parser (eval_str, m_interpreter);
1043 eval_parser.
reset ();
1054 parse_status = eval_parser.
run ();
1056 if (parse_status == 0)
1058 std::shared_ptr<tree_statement_list> stmt_list
1065 if (stmt_list->size () == 1
1066 && (stmt = stmt_list->front ())
1076 bool do_bind_ans =
false;
1083 if (nargout == 0 && do_bind_ans && ! retval.
empty ())
1089 else if (nargout == 0)
1090 stmt_list->accept (*
this);
1092 error (
"eval: invalid use of statement list");
1101 while (parse_status == 0);
1108 bool silent,
int& parse_status)
1122 bool silent,
int& parse_status,
1125 std::string s = arg.
xstring_value (
"eval: expecting string argument");
1127 return eval_string (s, silent, parse_status, nargout);
1134 int parse_status = 0;
1136 return eval_string (try_code, nargout > 0, parse_status, nargout);
1141 const std::string& catch_code,
1148 int parse_status = 0;
1150 bool execution_error =
false;
1156 tmp =
eval_string (try_code, nargout > 0, parse_status, nargout);
1163 execution_error =
true;
1166 if (parse_status != 0 || execution_error)
1168 tmp =
eval_string (catch_code, nargout > 0, parse_status, nargout);
1180 if (execution_error)
1189 const std::string& try_code,
1197 if (context ==
"caller")
1199 else if (context ==
"base")
1202 error (R
"(evalin: CONTEXT must be "caller" or "base")");
1204 int parse_status = 0;
1206 return eval_string (try_code, nargout > 0, parse_status, nargout);
1211 const std::string& try_code,
1212 const std::string& catch_code,
1222 if (context ==
"caller")
1224 else if (context ==
"base")
1227 error (R
"(evalin: CONTEXT must be "caller" or "base")");
1231 int parse_status = 0;
1233 bool execution_error =
false;
1239 tmp =
eval_string (try_code, nargout > 0, parse_status, nargout);
1246 execution_error =
true;
1249 if (parse_status != 0 || execution_error)
1251 tmp =
eval_string (catch_code, nargout > 0, parse_status, nargout);
1263 if (execution_error)
1273 error_unexpected (
"tree_evaluator::visit_anon_fcn_handle");
1279 error_unexpected (
"tree_evaluator::visit_argument_list");
1285 warning (
"function arguments validation blocks are not supported; INCORRECT RESULTS ARE POSSIBLE");
1291 error_unexpected (
"tree_evaluator::visit_args_block_attribute_list");
1297 error_unexpected (
"tree_evaluator::visit_args_block_validation_list");
1303 error_unexpected (
"tree_evaluator::visit_arg_validation");
1309 error_unexpected (
"tree_evaluator::visit_arg_size_spec");
1315 error_unexpected (
"tree_evaluator::visit_arg_validation_fcns");
1321 error_unexpected (
"tree_evaluator::visit_binary_expression");
1327 error_unexpected (
"tree_evaluator::visit_boolean_expression");
1333 error_unexpected (
"tree_evaluator::visit_compound_binary_expression");
1341 int line = cmd.
line ();
1345 m_echo_file_pos = line + 1;
1351 if (m_in_loop_command)
1354 error (
"break must appear in a loop in the same file as loop command");
1360 error_unexpected (
"tree_evaluator::visit_colon_expression");
1368 int line = cmd.
line ();
1372 m_echo_file_pos = line + 1;
1378 if (m_in_loop_command)
1385 return ! (m_silent_functions && (m_statement_context ==
SC_FUNCTION
1393 || m_dbstep_flag != 0
1394 || m_break_on_next_stmt
1401 m_debug_mode = mode;
1434 frame.
add ([&tw, saved_frame = m_debug_frame] ()
1440 m_debug_frame = m_call_stack.
dbupdown (0);
1448 debugger *dbgr =
new debugger (m_interpreter, m_debugger_stack.size ());
1450 m_debugger_stack.push (dbgr);
1452 frame.
add ([
this] ()
1454 delete m_debugger_stack.top ();
1455 m_debugger_stack.pop ();
1459 dbgr->repl (prompt);
1471 m_debug_frame = m_call_stack.
dbupdown (n, verbose);
1478 return frame->inputname (n, ids_only);
1486 const std::list<octave_lvalue> *lvalues = m_lvalue_list;
1493 for (
const auto& lval : *lvalues)
1494 nbh += lval.is_black_hole ();
1503 for (
const auto& lval : *lvalues)
1505 if (lval.is_black_hole ())
1519get_operator_function_name (
const std::string& name)
1528 std::size_t
len = name.length ();
1555 else if (name[1] ==
'=')
1586 return "ctranspose";
1639 std::string fcn_name = get_operator_function_name (name);
1646 bool name_is_operator = fcn_name != name;
1648 std::size_t pos = fcn_name.find (
'.');
1650 if (pos != std::string::npos)
1669 std::string meth_nm = fcn_name.substr (pos+1);
1671 if (meth_nm.find (
'.') == std::string::npos)
1673 std::string obj_nm = fcn_name.substr (0, pos);
1680 if (
object.
is_defined () &&
object.is_classdef_object ())
1703 fcn_name = class_nm +
'.' + meth_nm;
1752 bool skip_first = name_is_operator;
1761 if (! name_is_operator)
1766 std::shared_ptr<stack_frame> frame
1782 && (fcn_name == curr_fcn->
name ()
1784 frame = frame->access_link ();
1889 std::shared_ptr<stack_frame> frame
1892 return frame->is_variable (name);
1898 std::shared_ptr<stack_frame> frame
1901 return frame->is_local_variable (name);
1938 std::shared_ptr<stack_frame> frame
1941 return frame->is_variable (sym);
1947 std::shared_ptr<stack_frame> frame
1950 return frame->is_defined (sym);
1956 std::shared_ptr<stack_frame> frame
1959 return frame->is_global (name);
1965 std::shared_ptr<stack_frame> frame
1968 return frame->varval (sym);
1974 std::shared_ptr<stack_frame> frame
1977 return frame->varval (name);
1985 std::shared_ptr<stack_frame> frame
1988 return frame->install_variable (name, value, global);
2026 std::shared_ptr<stack_frame> frame
2029 frame->assign (name, val);
2045 if (context ==
"caller")
2047 else if (context ==
"base")
2050 error (R
"(assignin: CONTEXT must be "caller" or "base")");
2059 error (
"assignin: invalid assignment to keyword '%s'",
2065 error (
"assignin: invalid variable name '%s'", name.c_str ());
2070 const std::string& context,
2071 bool verbose,
bool require_file)
2106 static std::map<std::string, int> source_call_depth;
2108 std::string file_full_name
2109 = sys::file_ops::tilde_expand (file_name);
2112 = file_full_name.find_last_of (sys::file_ops::dir_sep_str ());
2114 std::string dir_name = file_full_name.substr (0, pos);
2116 file_full_name = sys::env::make_absolute (file_full_name);
2120 if (source_call_depth.find (file_full_name) == source_call_depth.end ())
2121 source_call_depth[file_full_name] = -1;
2123 frame.
protect_var (source_call_depth[file_full_name]);
2125 source_call_depth[file_full_name]++;
2128 error (
"max_recursion_depth exceeded");
2130 if (! context.empty ())
2135 if (context ==
"caller")
2137 else if (context ==
"base")
2140 error (R
"(source: CONTEXT must be "caller" or "base")");
2145 = file_name.find_last_of (sys::file_ops::dir_sep_chars ());
2146 dir_end = (dir_end == std::string::npos) ? 0 : dir_end + 1;
2148 std::size_t extension = file_name.find_last_of (
'.');
2149 if (extension == std::string::npos)
2150 extension = file_name.length ();
2152 std::string symbol = file_name.substr (dir_end, extension - dir_end);
2153 std::string full_name = sys::canonicalize_file_name (file_name);
2188 file_name, dir_name,
"",
"",
2189 require_file,
true,
false,
false);
2193 std::string error_message = ee.message ();
2194 if (error_message.empty ())
2195 error (ee,
"source: error sourcing file '%s'",
2196 file_full_name.c_str ());
2198 error (ee,
"%s", error_message.c_str ());
2208 error (
"source: %s is not a script", full_name.c_str ());
2212 octave_stdout <<
"executing commands from " << full_name <<
" ... ";
2269 if (args(i).is_defined () && args(i).is_magic_colon ())
2272 error (
"no default value for argument %d", i+1);
2365 std::list<octave_value> arg_vals;
2367 for (
auto elt : *args)
2382 arg_vals.push_back (tmp_ovl(i));
2385 arg_vals.push_back (tmp);
2396 int len = ret_list->size ();
2407 int nout = nargout > 0 ? nargout : 1;
2412 if (nargout == 0 && !
is_defined (elt->ident ()))
2439 retval(i++) = varargout(j);
2449 bool retval =
false;
2478 if (label_value.
iscell ())
2486 bool match = val.
is_equal (cell(i,j));
2503 m_call_stack.
push (scope);
2508 const std::shared_ptr<stack_frame>& closure_frames)
2510 m_call_stack.
push (fcn, closure_frames);
2516 const std::shared_ptr<stack_frame>& closure_frames)
2518 m_call_stack.
push (fcn, local_vars, closure_frames);
2524 m_call_stack.
push (script);
2530 m_call_stack.
push (fcn);
2536 m_call_stack.
pop ();
2539std::shared_ptr<stack_frame>
2574 frm->display_stopped_in_message (os);
2582 if (! (frm->is_user_script_frame () || frm->is_user_fcn_frame ()))
2583 error (
"dblist: must be inside a user function or script to use dblist\n");
2585 frm->debug_list (os, num_lines);
2593 if (! (frm->is_user_script_frame () || frm->is_user_fcn_frame ()))
2594 error (
"dbtype: must be inside a user function or script to use dbtype\n");
2596 frm->debug_type (os, start_line, end_line);
2677std::list<std::shared_ptr<stack_frame>>
2683std::list<std::shared_ptr<stack_frame>>
2689std::list<frame_info>
2691 bool print_subfn)
const
2693 return m_call_stack.
backtrace_info (curr_user_frame, print_subfn);
2696std::list<frame_info>
2704 bool print_subfn)
const
2706 return m_call_stack.
backtrace (curr_user_frame, print_subfn);
2726 std::ostringstream buf;
2728 for (
const auto& frm : frames)
2730 buf <<
" " << frm.fcn_name ();
2732 int line = frm.line ();
2736 buf <<
" at line " << line;
2738 int column = frm.column ();
2741 buf <<
" column " << column;
2755 m_call_stack.
push (dummy_scope);
2761 m_call_stack.
pop ();
2782 error (
"mlock: invalid use outside a function");
2786 warning (
"mlock: locking built-in function has no effect");
2799 error (
"munlock: invalid use outside a function");
2803 warning (
"munlock: unlocking built-in function has no effect");
2816 error (
"mislocked: invalid use outside a function");
2836 std::shared_ptr<stack_frame> frame
2861 std::shared_ptr<stack_frame> frame
2864 frame->clear_objects ();
2870 std::shared_ptr<stack_frame> frame
2873 frame->clear_variable (name);
2879 std::shared_ptr<stack_frame> frame
2882 frame->clear_variable_pattern (pattern);
2888 std::shared_ptr<stack_frame> frame
2891 frame->clear_variable_regexp (pattern);
2897 std::shared_ptr<stack_frame> frame
2900 frame->clear_variables ();
2976std::list<std::string>
2982std::list<std::string>
2988std::list<std::string>
3007 std::string name = fname;
3009 if (sys::file_ops::dir_sep_char () !=
'/' && name[0] ==
'@')
3011 auto beg = name.begin () + 2;
3012 auto end = name.end () - 1;
3013 std::replace (beg, end,
'/', sys::file_ops::dir_sep_char ());
3016 std::size_t name_len = name.length ();
3018 if (name_len > 2 && name.substr (name_len-2) ==
".m")
3019 name = name.substr (0, name_len-2);
3027 std::size_t p2 = std::string::npos;
3031 std::size_t p1 = name.find (sys::file_ops::dir_sep_char (), 1);
3033 if (p1 == std::string::npos)
3036 std::string dispatch_type = name.substr (1, p1-1);
3038 p2 = name.find (
'>', p1);
3040 std::string method = name.substr (p1+1, p2-1);
3048 if (cls.
ok () && cls.
get_name () == dispatch_type)
3050 if (! method.compare (0, 4,
"get."))
3053 std::string prop_name = method.substr (4);
3055 if (prop.
ok () && prop.
get_name () == prop_name)
3064 else if (! method.compare (0, 4,
"set."))
3067 std::string prop_name = method.substr (4);
3069 if (prop.
ok () && prop.
get_name () == prop_name)
3081 if (meth.
ok () && meth.
get_name () == method)
3094 p2 = name.find (
'>');
3096 std::string main_fcn = name.substr (0, p2);
3102 std::string subfuns;
3104 if (p2 != std::string::npos)
3105 subfuns = name.substr (p2+1);
3110 if (! user_code || subfuns.empty ())
3130 return curfcn->
name ();
3146 int line = cmd.
line ();
3150 m_echo_file_pos = line + 1;
3162 init_list->
accept (*
this);
3177 error (
"declaration list element not global or persistent");
3197template <
typename T>
3199tree_evaluator::execute_range_loop (
const range<T>& rng,
int line,
3205 if (math::isinf (rng.limit ()) || math::isinf (rng.base ()))
3207 "FOR loop limit is infinite, will stop after %"
3208 OCTAVE_IDX_TYPE_FORMAT
" steps", steps);
3213 m_echo_file_pos = line;
3220 loop_body->
accept (*
this);
3222 if (quit_loop_now ())
3230 int line = cmd.
line ();
3267 execute_range_loop (rhs.
range_value (), line, ult, loop_body);
3277 m_echo_file_pos = line;
3282 loop_body->
accept (*
this);
3305 if (rhs.
ndims () > 2)
3329 m_echo_file_pos = line;
3338 loop_body->
accept (*
this);
3340 if (quit_loop_now ())
3353 error (
"invalid type in for loop expression near line %d, column %d",
3360 int line = cmd.
line ();
3383 error (
"in statement 'for [X, Y] = VAL', VAL must be a structure");
3391 auto p = lhs->begin ();
3412 m_echo_file_pos = line;
3414 std::string key = keys[i];
3426 loop_body->
accept (*
this);
3428 if (quit_loop_now ())
3455 = param_list ? param_list->
dup (new_scope) :
nullptr;
3476 std::set<std::string> free_vars = anon_fcn_ctx.
free_variables ();
3480 std::shared_ptr<stack_frame> frame
3483 for (
auto& name : free_vars)
3488 local_vars[name] = val;
3495 bool is_nested =
false;
3544 error (
"invalid use of colon in function argument list");
3556 retval = (*fcn) (args, nargout);
3561 retval = (*meth) (m_interpreter, args, nargout);
3594 error (
"invalid use of colon in function argument list");
3603 retval =
call_mex (mex_function, args, nargout);
3617 if (args.
length () != 0 || nargout != 0)
3618 error (
"invalid call to script %s", file_name.c_str ());
3628 if (m_call_stack.
size () >=
static_cast<std::size_t
> (m_max_recursion_depth))
3629 error (
"max_recursion_depth exceeded");
3640 cmd_list->
accept (*
this);
3655 error_unexpected (
"tree_evaluator::visit_octave_user_script");
3678 m_lvalue_list =
nullptr;
3683 int nargin = args.
length ();
3694 ret_args = args.
slice (0, 1,
true);
3696 args = args.
slice (1, nargin,
true);
3699 error (
"invalid call to classdef constructor in tree_evaluator::execute_user_function - please report this bug");
3704 bool takes_varargs =
false;
3710 max_inputs = param_list->size ();
3713 if (! takes_varargs && nargin > max_inputs)
3715 std::string name = user_function.
name ();
3718 name =
"@<anonymous>";
3721 "%s: function called with too many inputs",
3731 int max_outputs = ret_list->size ();
3733 if (nargout > max_outputs)
3735 std::string name = user_function.
name ();
3738 "%s: function called with too many outputs",
3743 bind_auto_fcn_vars (xargs.
name_tags (), ignored_outputs, nargin,
3753 error (
"%s: invalid classdef constructor, no output argument defined",
3762 if (m_call_stack.
size () >=
static_cast<std::size_t
> (m_max_recursion_depth))
3763 error (
"max_recursion_depth exceeded");
3778 block (m_profiler, user_function);
3800 if (nargout <= 1 && retval.
length () == 1 && retval(0).is_cs_list ())
3801 retval = retval(0).list_value ();
3805 cmd_list->
accept (*
this);
3825 varargout = varargout_varval.
xcell_value (
"varargout must be a cell array object");
3838 error_unexpected (
"tree_evaluator::visit_octave_user_function");
3844 error_unexpected (
"tree_evaluator::visit_octave_user_function_header");
3850 error_unexpected (
"tree_evaluator::visit_octave_user_function_trailer");
3862 std::string nm =
f->
name ();
3878 error_unexpected (
"tree_evaluator::visit_identifier");
3884 error_unexpected (
"tree_evaluator::visit_if_clause");
3892 int line = cmd.
line ();
3896 m_echo_file_pos = line + 1;
3917 m_call_stack.
set_location (tic->line (), tic->column ());
3919 if (m_debug_mode && ! tic->is_else_clause ())
3920 do_breakpoint (tic->is_active_breakpoint (*
this));
3922 if (tic->is_else_clause () || is_logically_true (expr,
"if"))
3927 stmt_lst->
accept (*
this);
3937 error_unexpected (
"tree_evaluator::visit_index_expression");
3943 error_unexpected (
"tree_evaluator::visit_matrix");
3949 error_unexpected (
"tree_evaluator::visit_cell");
3955 error_unexpected (
"tree_evaluator::visit_multi_assignment");
3963 int line = cmd.
line ();
3967 m_echo_file_pos = line + 1;
3977 error_unexpected (
"tree_evaluator::visit_constant");
3983 error_unexpected (
"tree_evaluator::visit_fcn_handle");
3989 error_unexpected (
"tree_evaluator::visit_parameter_list");
3995 error_unexpected (
"tree_evaluator::visit_postfix_expression");
4001 error_unexpected (
"tree_evaluator::visit_prefix_expression");
4009 int line = cmd.
line ();
4013 m_echo_file_pos = line + 1;
4025 || m_in_loop_command)
4032 error_unexpected (
"tree_evaluator::visit_simple_assignment");
4052 upv (m_lvalue_list,
nullptr);
4060 int line = stmt.
line ();
4064 m_echo_file_pos = line + 1;
4083 bool do_bind_ans =
false;
4096 catch (
const std::bad_alloc&)
4104 "out of memory or dimension too large for Octave's index type");
4106 catch (
const interrupt_exception&)
4137 throw quit_debug_exception (
true);
4151 auto p = lst.begin ();
4153 if (p != lst.end ())
4160 error (
"invalid statement found in statement list!");
4166 if (m_breaking || m_continuing)
4172 if (p == lst.end ())
4198 error_unexpected (
"tree_evaluator::visit_switch_case");
4204 error_unexpected (
"tree_evaluator::visit_switch_case_list");
4212 int line = cmd.
line ();
4216 m_echo_file_pos = line + 1;
4225 error (
"missing value in switch command near line %d, column %d",
4241 stmt_lst->
accept (*
this);
4254 int line = cmd.
line ();
4258 m_echo_file_pos = line + 1;
4261 bool execution_error =
false;
4279 try_code->
accept (*
this);
4283 execution_error =
true;
4300 if (execution_error)
4316 catch_code->
accept (*
this);
4361 if (m_breaking || m_returning)
4398 if (m_breaking || m_returning)
4409 int line = cmd.
line ();
4413 m_echo_file_pos = line + 1;
4420 if (unwind_protect_code)
4424 unwind_protect_code->
accept (*
this);
4445 catch (
const interrupt_exception&)
4462 int line = cmd.
line ();
4477 error (
"unexpected: while condition is nullptr - please report this bug");
4482 m_echo_file_pos = line;
4487 if (is_logically_true (expr,
"while"))
4492 loop_body->
accept (*
this);
4494 if (quit_loop_now ())
4505 int line = cmd.
line ();
4520 error (
"unexpected: do-until condition is nullptr - please report this bug");
4525 m_echo_file_pos = line;
4530 loop_body->
accept (*
this);
4532 if (quit_loop_now ())
4538 if (is_logically_true (expr,
"do-until"))
4546 error_unexpected (
"tree_evaluator::visit_superclass_ref");
4552 error_unexpected (
"tree_evaluator::visit_metaclass_query");
4558 static std::string ans =
"ans";
4584 m_interpreter.
feval (
"display", args);
4598tree_evaluator::do_breakpoint (
bool is_breakpoint,
4599 bool is_end_of_fcn_or_script)
4601 bool break_on_this_statement =
false;
4604 break_on_this_statement =
true;
4605 else if (m_dbstep_flag > 0)
4609 if (m_dbstep_flag == 1 || is_end_of_fcn_or_script)
4617 break_on_this_statement =
true;
4627 else if (m_dbstep_flag == 1
4634 break_on_this_statement =
true;
4637 else if (m_dbstep_flag == -1)
4641 break_on_this_statement =
true;
4645 else if (m_dbstep_flag == -2)
4653 if (is_end_of_fcn_or_script
4658 if (! break_on_this_statement)
4659 break_on_this_statement = m_break_on_next_stmt;
4661 m_break_on_next_stmt =
false;
4663 if (break_on_this_statement)
4673 const char *warn_for)
4675 bool expr_value =
false;
4684 error (
"%s: undefined value used in conditional expression", warn_for);
4694 "max_recursion_depth", 0);
4728 for (
const auto& fcn_fname : m_autoload_map)
4730 fcn_names(i) = fcn_fname.first;
4731 file_names(i) = fcn_fname.second;
4738 m.
assign (
"function", fcn_names);
4739 m.
assign (
"file", file_names);
4749 auto p = m_autoload_map.find (nm);
4751 if (p != m_autoload_map.end ())
4761std::list<std::string>
4764 std::list<std::string> names;
4766 for (
const auto& fcn_fname : m_autoload_map)
4767 names.push_back (fcn_fname.first);
4772std::list<std::string>
4775 std::list<std::string> names;
4777 for (
const auto& fcn_fname : m_autoload_map)
4778 if (nm == fcn_fname.second)
4779 names.push_back (fcn_fname.first);
4786 const std::string& nm)
4788 m_autoload_map[fcn] = check_autoload_file (nm);
4793 const std::string& nm)
4795 check_autoload_file (nm);
4802 m_autoload_map.erase (fcn);
4809 "whos_line_format");
4816 "silent_functions");
4823 "string_fill_char");
4834 std::string extra_message;
4838 std::string var = expr->
name ();
4850 if (fp && fp->
name () == var)
4852 =
" (note: variable '" + var +
"' shadows function)";
4856 std::string msg = ie.message () + extra_message;
4863 bool return_list,
bool verbose)
4865 return m_call_stack.
do_who (argc, argv, return_list, verbose);
4877 upv (m_lvalue_list,
nullptr);
4879 int len = args->size ();
4884 m_num_indices =
len;
4886 std::list<octave_value> arg_vals;
4890 for (
auto elt : *args)
4897 m_index_position = k++;
4906 arg_vals.push_back (tmp_ovl(i));
4909 arg_vals.push_back (tmp);
4923std::list<octave_lvalue>
4926 std::list<octave_lvalue> retval;
4929 retval.push_back (elt->lvalue (*
this));
4942 push_echo_state_cleanup (*frame);
4944 set_echo_state (type, file_name, pos);
4949tree_evaluator::set_echo_state (
int type,
const std::string& file_name,
4952 m_echo_state = echo_this_file (file_name, type);
4954 m_echo_file_name = file_name;
4955 m_echo_file_pos = pos;
4959tree_evaluator::uwp_set_echo_state (
bool state,
const std::string& file_name,
4962 m_echo_state = state;
4964 m_echo_file_name = file_name;
4965 m_echo_file_pos = pos;
4969tree_evaluator::maybe_set_echo_state ()
4990 set_echo_state (type, file_name, pos);
4997 frame.
add (&tree_evaluator::uwp_set_echo_state,
this,
4998 m_echo_state, m_echo_file_name, m_echo_file_pos);
5002tree_evaluator::maybe_push_echo_state_cleanup ()
5013 push_echo_state_cleanup (*frame);
5024 bool cleanup_pushed = maybe_push_echo_state_cleanup ();
5034 m_echo_files.clear ();
5042 std::string arg0 = argv[0];
5046 else if (arg0 ==
"off")
5051 file = sys::env::make_absolute (file);
5054 error (
"echo: no such file %s", arg0.c_str ());
5061 m_echo_files[file] =
false;
5067 auto p = m_echo_files.find (file);
5069 if (p == m_echo_files.end ())
5074 m_echo_files[file] =
true;
5081 p->second = ! p->second;
5090 std::string arg0 = argv[0];
5091 std::string arg1 = argv[1];
5093 if (arg1 ==
"on" || arg1 ==
"off")
5094 std::swap (arg0, arg1);
5101 m_echo_files.clear ();
5106 file = sys::env::make_absolute (file);
5109 error (
"echo: no such file %s", arg1.c_str ());
5112 m_echo_files[file] =
true;
5115 else if (arg0 ==
"off")
5120 m_echo_files.clear ();
5125 file = sys::env::make_absolute (file);
5128 error (
"echo: no such file %s", arg1.c_str ());
5130 m_echo_files[file] =
false;
5144 maybe_set_echo_state ();
5152 return (m_debugger_stack.empty ()
5153 ?
false : m_debugger_stack.top()->in_debug_repl ());
5159 if (! m_debugger_stack.empty ())
5160 m_debugger_stack.top()->dbcont ();
5166 if (! m_debugger_stack.empty ())
5167 m_debugger_stack.top()->dbquit (all);
5173 int nargin = args.
length ();
5175 if (nargin != 0 && nargin != 3)
5181 = args(1).strict_idx_type_value (
"end: K must be integer value");
5184 error (
"end: K must be greater than zero");
5187 = args(2).strict_idx_type_value (
"end: N must be integer value");
5190 error (
"end: N must be greater than zero");
5202 error (
"invalid use of 'end': may only be used to index existing value");
5206 if (m_index_list.empty ())
5207 expr_result = m_indexed_object;
5234 = m_indexed_object.
subsref (m_index_type, m_index_list, 1);
5243 error (
"error evaluating partial expression for END");
5253 std::string dispatch_class = expr_result.
class_name ();
5260 return m_interpreter.
feval
5261 (meth,
ovl (expr_result, m_index_position+1, m_num_indices), 1);
5274tree_evaluator::echo_this_file (
const std::string& file,
int type)
const
5287 auto p = m_echo_files.find (file);
5294 return (p == m_echo_files.end () || p->second);
5300 return p != m_echo_files.end () && p->second;
5308tree_evaluator::echo_code (
int line)
5318 int num_lines = line - m_echo_file_pos + 1;
5320 std::deque<std::string> lines
5323 for (
auto& elt : lines)
5330tree_evaluator::quit_loop_now ()
5339 bool quit = (m_returning || m_breaking || m_continuing);
5348tree_evaluator::bind_auto_fcn_vars (
const string_vector& arg_names,
5349 const Matrix& ignored_outputs,
5350 int nargin,
int nargout,
5365tree_evaluator::check_autoload_file (
const std::string& nm)
const
5367 if (sys::env::absolute_pathname (nm))
5370 std::string full_name = nm;
5380 if (! fname.empty ())
5382 fname = sys::env::make_absolute (fname);
5383 fname = fname.substr (0, fname.find_last_of (sys::file_ops::dir_sep_str ()) + 1);
5385 sys::file_stat fs (fname + nm);
5389 full_name = fname + nm;
5397 "autoload: '%s' is not an absolute filename",
5403DEFMETHOD (max_recursion_depth, interp, args, nargout,
5438DEFMETHOD (whos_line_format, interp, args, nargout,
5519DEFMETHOD (silent_functions, interp, args, nargout,
5553DEFMETHOD (string_fill_char, interp, args, nargout,
5619 return interp.PS4 (args, nargout);
5667 return tw.
echo (args, nargout);
5715 int nargin = args.length ();
5722 error (
"inputname: N must be a scalar index");
5724 int n = args(0).strict_int_value (
"inputname: N must be a scalar index");
5727 error (
"inputname: N must be a scalar index");
5729 bool ids_only =
true;
5732 ids_only = args(1).strict_bool_value (
"inputname: IDS_ONLY must be a logical value");
5735 return ovl (interp.inputname (n-1, ids_only));
5792OCTAVE_END_NAMESPACE(octave)
octave_idx_type rows() const
octave_idx_type columns() const
octave_idx_type numel() const
Number of elements in the array.
void resize(octave_idx_type nr, octave_idx_type nc, double rfv=0)
void add(F &&fcn, Args &&... args)
void discard(std::size_t num)
void run(std::size_t num)
void forced_interactive(bool arg)
static application * app()
static bool forced_interactive()
void statement_list(std::shared_ptr< tree_statement_list > &lst)
void disallow_command_syntax()
bool at_end_of_input() const
bool debug_on_err(const std::string &id)
bool debug_on_caught(const std::string &id)
void set_dispatch_class(const std::string &class_name)
std::shared_ptr< stack_frame > get_current_stack_frame() const
octave_value do_who(int argc, const string_vector &argv, bool return_list, bool verbose=false)
octave_value get_top_level_value(const std::string &name) const
octave_value global_varval(const std::string &name) const
std::size_t find_current_user_frame() const
std::list< frame_info > backtrace_info(octave_idx_type &curr_user_frame, bool print_subfn=true) const
octave_map backtrace(octave_idx_type &curr_user_frame, bool print_subfn=true) const
octave_value & global_varref(const std::string &name)
void set_top_level_value(const std::string &name, const octave_value &value)
octave_value get_auto_fcn_var(stack_frame::auto_var_type avt) const
std::list< std::string > variable_names() const
symbol_info_list regexp_symbol_info(const std::string &pattern) const
void make_global(const symbol_record &sym)
std::shared_ptr< stack_frame > current_user_frame() const
std::shared_ptr< stack_frame > pop_return()
void clear_global_variables()
symbol_info_list glob_symbol_info(const std::string &pattern) const
void restore_frame(std::size_t n)
bool at_top_level() const
bool is_class_method_executing(std::string &dispatch_class) const
bool goto_frame(std::size_t n=0, bool verbose=false)
int debug_user_code_column() const
std::size_t current_frame() const
void set_auto_fcn_var(stack_frame::auto_var_type avt, const octave_value &val)
symbol_info_list get_symbol_info()
symbol_info_list top_scope_symbol_info() const
std::list< std::string > global_variable_names() const
std::list< std::shared_ptr< stack_frame > > backtrace_frames(octave_idx_type &curr_user_frame) const
void set_location(int l, int c)
bool is_class_constructor_executing(std::string &dispatch_class) const
symbol_scope current_scope() const
octave_map empty_backtrace() const
octave_function * current_function(bool skip_first=false) const
void clear_global_variable_pattern(const std::string &pattern)
unwind_protect * curr_fcn_unwind_protect_frame()
int debug_user_code_line() const
octave_user_code * debug_user_code() const
void push(const symbol_scope &scope)
std::list< std::string > top_level_variable_names() const
void set_nargin(int nargin)
void clear_global_variable(const std::string &name)
octave_user_code * current_user_code() const
symbol_scope top_scope() const
void set_nargout(int nargout)
int current_user_code_line() const
std::size_t dbupdown(std::size_t start, int n, bool verbose)
int current_column() const
std::string get_dispatch_class() const
void clear_global_variable_regexp(const std::string &pattern)
void make_persistent(const symbol_record &sym)
octave_value max_stack_depth(const octave_value_list &args, int nargout)
cdef_method find_method(const std::string &nm, bool local=false)
std::string get_name() const
cdef_property find_property(const std::string &nm)
cdef_class find_class(const std::string &name, bool error_if_not_found=true, bool load_if_not_found=true)
octave_value get_function() const
std::string get_name() const
cdef_class get_class() const
octave_value get(const std::string &pname) const
std::string get_name() const
static void run_event_hooks()
static void increment_current_command_number()
static bool interrupt(bool=true)
static bool erase_empty_line(bool flag)
static std::string decode_prompt_string(const std::string &s)
static bool ignoring_entries()
static bool add(const std::string &)
static void ignore_entries(bool=true)
Vector representing the dimensions (size) of an Array.
dim_vector redim(int n) const
Force certain dimensionality, preserving numel ().
octave_value last_error_id(const octave_value_list &args, int nargout)
octave_map last_error_stack() const
octave_value debug_on_warning(const octave_value_list &args, int nargout)
void set_debug_on_warning(bool flag)
octave_value debug_on_caught(const octave_value_list &args, int nargout)
void save_exception(const execution_exception &ee)
octave_value debug_on_error(const octave_value_list &args, int nargout)
octave_value last_error_message(const octave_value_list &args, int nargout)
void display_exception(const execution_exception &ee) const
void set_debug_on_error(bool flag)
Provides threadsafe access to octave.
void append_history(const std::string &hist_entry)
void enter_debugger_event(const std::string &fcn_name, const std::string &fcn_file_name, int line)
void post_event(const fcn_callback &fcn)
void execute_in_debugger_event(const std::string &file, int line)
void set_var(const std::string &var_arg="")
virtual const char * err_id() const =0
cdef_manager & get_cdef_manager()
error_system & get_error_system()
load_path & get_load_path()
void set_PS1(const std::string &s)
octave_value PS1(const octave_value_list &args, int nargout)
void parse_and_execute(const std::string &input, bool &incomplete_parse)
tree_evaluator & get_evaluator()
octave_value_list feval(const char *name, const octave_value_list &args=octave_value_list(), int nargout=0)
Evaluate an Octave function (built-in or interpreted) and return the list of result values.
void recover_from_exception()
octave_value PS2(const octave_value_list &args, int nargout)
event_manager & get_event_manager()
symbol_table & get_symbol_table()
std::string find_file(const std::string &file) const
virtual bool is_user_code() const
virtual bool is_user_function() const
virtual bool is_builtin_function() const
octave_value_list(* fcn)(const octave_value_list &, int)
octave_value_list(* meth)(octave::interpreter &, const octave_value_list &, int)
octave_classdef * classdef_object_value(bool=false)
octave::cdef_object get_object() const
std::string class_name() const
virtual bool is_nested_function() const
virtual bool is_subfunction() const
std::string dispatch_class() const
bool is_class_method(const std::string &cname="") const
bool is_class_constructor(const std::string &cname="") const
bool is_private_function() const
virtual std::string parent_fcn_name() const
void stash_dir_name(const std::string &dir)
virtual bool is_parent_function() const
virtual octave_value_list call(octave::tree_evaluator &tw, int nargout=0, const octave_value_list &args=octave_value_list())
virtual std::list< std::string > parent_fcn_names() const
void stash_dispatch_class(const std::string &nm)
virtual std::string fcn_file_name() const
std::string dir_name() const
bool is_undefined() const
void assign(octave_value::assign_op, const octave_value &)
void define(const octave_value &v)
string_vector keys() const
const Cell & contents(const_iterator p) const
void assign(const std::string &k, const Cell &val)
void assign(const std::string &k, const octave_value &val)
void stash_fcn_file_name(const std::string &nm)
std::string get_code_line(std::size_t line)
std::string fcn_file_name() const
std::deque< std::string > get_code_lines(std::size_t line, std::size_t num_lines)
virtual octave_value find_subfunction(const std::string &) const
octave::tree_statement_list * body()
octave_user_code * user_code_value(bool=false)
octave::tree_parameter_list * parameter_list()
bool takes_varargs() const
bool is_special_expr() const
octave_value_list all_va_args(const octave_value_list &args)
bool is_classdef_constructor(const std::string &cname="") const
octave::tree_parameter_list * return_list()
bool is_anonymous_function() const
void restore_warning_states()
void mark_as_anonymous_function()
void mark_as_nested_function()
void resize(octave_idx_type n, const octave_value &rfv=octave_value())
void stash_name_tags(const string_vector &nm)
bool has_magic_colon() const
octave_value & xelem(octave_idx_type i)
string_vector name_tags() const
octave_value_list slice(octave_idx_type offset, octave_idx_type len, bool tags=false) const
string_vector make_argv(const std::string &="") const
octave_idx_type length() const
void make_storable_values()
bool is_function_handle() const
octave_value_list list_value() const
bool is_undefined() const
Cell xcell_value(const char *fmt,...) const
std::string class_name() const
octave_value subsref(const std::string &type, const std::list< octave_value_list > &idx)
octave_function * function_value(bool silent=false) const
octave_value index_op(const octave_value_list &idx, bool resize_ok=false)
bool is_scalar_type() const
octave_idx_type end_index(octave_idx_type index_position, octave_idx_type num_indices) const
bool is_equal(const octave_value &) const
octave_value storable_value() const
octave_value reshape(const dim_vector &dv) const
octave_map map_value() const
bool is_matrix_type() const
bool is_double_type() const
octave_user_function * user_function_value(bool silent=false) const
bool is_user_code() const
std::string xstring_value(const char *fmt,...) const
octave_user_code * user_code_value(bool silent=false) const
octave::range< double > range_value() const
std::map< std::string, octave_value > local_vars_map
octave_idx_type numel() const
static symbol_scope invalid()
void set_parent(const symbol_scope &p)
void cache_fcn_file_name(const std::string &name)
void set_nesting_depth(std::size_t depth)
void set_primary_parent(const symbol_scope &p)
void cache_dir_name(const std::string &name)
std::size_t nesting_depth() const
octave_value find_scoped_function(const std::string &name, const symbol_scope &search_scope)
octave_value find_method(const std::string &name, const std::string &dispatch_type)
void clear_function(const std::string &name)
void clear_function_pattern(const std::string &pat)
void clear_functions(bool force=false)
void install_cmdline_function(const std::string &name, const octave_value &fcn)
octave_value find_function(const std::string &name, const symbol_scope &search_scope=symbol_scope::invalid())
void clear_dld_function(const std::string &name)
octave_value fcn_table_find(const std::string &name, const octave_value_list &args=ovl(), const symbol_scope &search_scope=symbol_scope::invalid())
octave_value find_user_function(const std::string &name)
void clear_function_regexp(const std::string &pat)
tree_parameter_list * parameter_list() const
symbol_scope scope() const
tree_expression * expression() const
std::set< std::string > free_variables() const
tree_argument_list * left_hand_side()
tree_statement_list * body()
tree_expression * control_expr()
tree_decl_init_list * initializer_list()
tree_expression * expression()
tree_identifier * ident()
bool is_persistent() const
void accept(tree_walker &tw)
tree_expression * condition()
tree_statement_list * body()
octave_value_list eval_string(const std::string &eval_str, bool silent, int &parse_status, int nargout)
bool switch_case_label_matches(tree_switch_case *expr, const octave_value &val)
octave_value_list execute_user_function(octave_user_function &user_function, int nargout, const octave_value_list &args)
void visit_break_command(tree_break_command &)
bool is_global(const std::string &name) const
void visit_octave_user_function(octave_user_function &)
void visit_unwind_protect_command(tree_unwind_protect_command &)
bool mislocked(bool skip_first=false) const
void bind_ans(const octave_value &val, bool print)
void visit_return_command(tree_return_command &)
octave_value_list execute_builtin_function(octave_builtin &builtin_function, int nargout, const octave_value_list &args)
void clear_all(bool force=false)
int max_recursion_depth() const
void visit_statement_list(tree_statement_list &)
octave_value evaluate(tree_decl_elt *)
void visit_anon_fcn_handle(tree_anon_fcn_handle &)
octave_user_code * current_user_code() const
void source_file(const std::string &file_name, const std::string &context="", bool verbose=false, bool require_file=true)
symbol_scope get_current_scope() const
void visit_cell(tree_cell &)
octave_value echo(const octave_value_list &args, int nargout)
octave_value_list evaluate_end_expression(const octave_value_list &args)
void add_autoload(const std::string &fcn, const std::string &nm)
std::list< frame_info > backtrace_info() const
void visit_constant(tree_constant &)
void display_call_stack() const
octave_map empty_backtrace() const
void visit_superclass_ref(tree_superclass_ref &)
void visit_simple_assignment(tree_simple_assignment &)
octave_value & global_varref(const std::string &name)
octave_map backtrace() const
void final_index_error(index_exception &ie, const tree_expression *expr)
void visit_args_block_validation_list(tree_args_block_validation_list &)
Matrix ignored_fcn_outputs() const
void debug_where(std::ostream &os) const
void clear_global_variables()
void clear_global_variable(const std::string &name)
std::string get_dispatch_class() const
octave_value_list execute_mex_function(octave_mex_function &mex_function, int nargout, const octave_value_list &args)
std::string inputname(int n, bool ids_only=true) const
void set_dispatch_class(const std::string &class_name)
void visit_boolean_expression(tree_boolean_expression &)
bool goto_frame(std::size_t n=0, bool verbose=false)
void visit_switch_case(tree_switch_case &)
void munlock(bool skip_first=false) const
void visit_arg_validation(tree_arg_validation &)
octave_value get_auto_fcn_var(stack_frame::auto_var_type avt) const
void remove_autoload(const std::string &fcn, const std::string &nm)
void debug_list(std::ostream &os, int num_lines) const
bool at_top_level() const
void visit_octave_user_function_header(octave_user_function &)
void visit_arg_size_spec(tree_arg_size_spec &)
void visit_multi_assignment(tree_multi_assignment &)
void visit_continue_command(tree_continue_command &)
octave_value find(const std::string &name)
symbol_info_list top_scope_symbol_info() const
void visit_while_command(tree_while_command &)
void visit_do_until_command(tree_do_until_command &)
octave_map get_autoload_map() const
void visit_index_expression(tree_index_expression &)
void visit_postfix_expression(tree_postfix_expression &)
std::list< std::shared_ptr< stack_frame > > backtrace_frames() const
std::list< std::string > variable_names() const
void define_parameter_list_from_arg_vector(tree_parameter_list *param_list, const octave_value_list &args)
bool is_local_variable(const std::string &name) const
void visit_decl_command(tree_decl_command &)
bool in_debug_repl() const
void visit_arg_validation_fcns(tree_arg_validation_fcns &)
void visit_function_def(tree_function_def &)
symbol_scope get_top_scope() const
void visit_switch_command(tree_switch_command &)
int index_position() const
void clear_symbol_pattern(const std::string &pattern)
void clear_symbol(const std::string &name)
bool in_user_code() const
void visit_arguments_block(tree_arguments_block &)
void dbquit(bool all=false)
void keyboard(const std::string &prompt="debug> ")
void restore_frame(std::size_t n)
void visit_if_command(tree_if_command &)
bool is_class_method_executing(std::string &dispatch_class) const
void visit_spmd_command(tree_spmd_command &)
octave_value_list convert_to_const_vector(tree_argument_list *arg_list)
void debug_type(std::ostream &os, int start_line, int end_line) const
unwind_protect * curr_fcn_unwind_protect_frame()
std::shared_ptr< stack_frame > pop_return_stack_frame()
void visit_try_catch_command(tree_try_catch_command &)
void visit_colon_expression(tree_colon_expression &)
int debug_user_code_line() const
void push_dummy_scope(const std::string &name)
void visit_simple_for_command(tree_simple_for_command &)
std::shared_ptr< push_parser > get_parser()
octave_value_list make_value_list(tree_argument_list *args, const string_vector &arg_nm)
std::string backtrace_message() const
void clear_variable(const std::string &name)
void visit_matrix(tree_matrix &)
bool is_variable(const std::string &name) const
bool is_class_constructor_executing(std::string &dispatch_class) const
void visit_octave_user_script(octave_user_script &)
std::string lookup_autoload(const std::string &nm) const
void visit_if_clause(tree_if_clause &)
std::list< std::string > reverse_lookup_autoload(const std::string &nm) const
std::size_t current_call_stack_frame_number() const
void visit_args_block_attribute_list(tree_args_block_attribute_list &)
std::size_t debug_frame() const
octave_function * caller_function() const
std::list< std::string > global_variable_names() const
octave_value do_who(int argc, const string_vector &argv, bool return_list, bool verbose=false)
void set_parser(const std::shared_ptr< push_parser > &parser)
symbol_info_list get_symbol_info()
symbol_info_list glob_symbol_info(const std::string &pattern) const
bool silent_functions() const
void clear_global_variable_pattern(const std::string &pattern)
void visit_argument_list(tree_argument_list &)
octave_value_list convert_return_list_to_const_vector(tree_parameter_list *ret_list, int nargout, const Cell &varargout)
void assign(const std::string &name, const octave_value &val=octave_value())
void assignin(const std::string &context, const std::string &name, const octave_value &val=octave_value())
void visit_statement(tree_statement &)
char string_fill_char() const
octave_value top_level_varval(const std::string &name) const
void dbupdown(int n, bool verbose=false)
std::shared_ptr< stack_frame > current_user_frame() const
octave_value evaluate_anon_fcn_handle(tree_anon_fcn_handle &afh)
void undefine_parameter_list(tree_parameter_list *param_list)
octave_value max_stack_depth(const octave_value_list &args, int nargout)
void visit_identifier(tree_identifier &)
void clear_symbol_regexp(const std::string &pattern)
std::list< std::string > autoloaded_functions() const
void visit_octave_user_function_trailer(octave_user_function &)
int debug_user_code_column() const
void push_echo_state(int type, const std::string &file_name, int pos=1)
void visit_fcn_handle(tree_fcn_handle &)
octave_value_list execute_user_script(octave_user_script &user_script, int nargout, const octave_value_list &args)
void eval(std::shared_ptr< tree_statement_list > &stmt_list, bool interactive)
std::string whos_line_format() const
octave_value_list evalin(const std::string &context, const std::string &try_code, int nargout)
bool is_defined(const tree_expression *expr) const
octave_value global_varval(const std::string &name) const
void top_level_assign(const std::string &name, const octave_value &val=octave_value())
void install_variable(const std::string &name, const octave_value &value, bool global)
void visit_binary_expression(tree_binary_expression &)
symbol_info_list regexp_symbol_info(const std::string &pattern) const
void set_auto_fcn_var(stack_frame::auto_var_type avt, const octave_value &val=octave_value())
octave_user_code * debug_user_code() const
bool eval_decl_elt(tree_decl_elt *elt)
bool quiet_breakpoint_flag() const
void clear_global_variable_regexp(const std::string &pattern)
void visit_decl_elt(tree_decl_elt &)
void parse_and_execute(const std::string &input, bool &incomplete_parse)
void visit_parameter_list(tree_parameter_list &)
std::list< std::string > top_level_variable_names() const
std::list< octave_lvalue > make_lvalue_list(tree_argument_list *)
int current_column() const
void enter_debugger(const std::string &prompt="debug> ")
void visit_complex_for_command(tree_complex_for_command &)
octave_value whos_line_format(const octave_value_list &args, int nargout)
octave_user_code * get_user_code(const std::string &fname="")
void global_assign(const std::string &name, const octave_value &val=octave_value())
octave_value make_fcn_handle(const std::string &nm)
void mlock(bool skip_first=false) const
void visit_metaclass_query(tree_metaclass_query &)
void visit_compound_binary_expression(tree_compound_binary_expression &)
void do_unwind_protect_cleanup_code(tree_statement_list *list)
octave_value varval(const symbol_record &sym) const
void visit_switch_case_list(tree_switch_case_list &)
void push_stack_frame(const symbol_scope &scope)
std::string mfilename(const std::string &opt="") const
void visit_prefix_expression(tree_prefix_expression &)
void clear_variable_regexp(const std::string &pattern)
void visit_no_op_command(tree_no_op_command &)
octave_function * current_function(bool skip_first=false) const
bool statement_printing_enabled()
void set_nargin(int nargin)
void clear_variable_pattern(const std::string &pattern)
std::string current_function_name(bool skip_first=false) const
void set_nargout(int nargout)
void visit_if_command_list(tree_if_command_list &)
virtual octave_value evaluate(tree_evaluator &tw, int nargout=1)=0
virtual bool is_identifier() const
bool print_result() const
tree_expression * set_print_flag(bool print)
virtual std::string name() const
virtual tree_expression * dup(symbol_scope &scope) const =0
virtual bool is_assignment_expression() const
virtual octave_lvalue lvalue(tree_evaluator &)
virtual octave_value_list evaluate_n(tree_evaluator &tw, int nargout=1)=0
virtual bool is_black_hole() const
symbol_record symbol() const
octave_lvalue lvalue(tree_evaluator &tw)
octave_value evaluate(tree_evaluator &tw, int nargout=1)
void accept(tree_walker &tw)
tree_if_command_list * cmd_list()
bool is_end_of_fcn_or_script() const
bool takes_varargs() const
tree_parameter_list * dup(symbol_scope &scope) const
tree_expression * left_hand_side()
tree_expression * control_expr()
tree_statement_list * body()
tree_statement_list * body()
void accept(tree_walker &tw)
bool is_active_breakpoint(tree_evaluator &tw) const
tree_expression * expression()
bool is_expression() const
void accept(tree_walker &tw)
bool is_end_of_fcn_or_script() const
tree_expression * case_label()
tree_switch_case_list * case_list()
tree_expression * switch_value()
tree_identifier * identifier()
tree_statement_list * cleanup()
tree_statement_list * body()
tree_statement_list * cleanup()
tree_statement_list * body()
tree_statement_list * body()
tree_expression * condition()
bool is_active_breakpoint(tree_evaluator &tw) const
virtual int column() const
virtual void accept(tree_walker &tw)=0
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
#define DEFMETHOD(name, interp_name, args_name, nargout_name, doc)
Macro to define a builtin method.
void interpreter_try(unwind_protect &frame)
void error_with_id(const char *id, const char *fmt,...)
void warning(const char *fmt,...)
void warning_with_id(const char *id, const char *fmt,...)
void error(const char *fmt,...)
void err_indexed_cs_list()
bool iskeyword(const std::string &s)
octave_value_list call_mex(octave_mex_function &mex_fcn, const octave_value_list &args, int nargout_arg)
octave_value parse_fcn_file(interpreter &interp, const std::string &full_file, const std::string &file, const std::string &dir_name, const std::string &dispatch_type, const std::string &package_name, bool require_file, bool force_script, bool autoload, bool relative_lookup)
int release_unreferenced_dynamic_libraries()
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.
std::atomic< int > octave_interrupt_state
F77_RET_T const F77_DBLE const F77_DBLE * f
bool valid_identifier(const char *s)
void sleep(double seconds, bool do_graphics_events)
std::string fcn_file_in_path(const std::string &name)
octave_value set_internal_variable(bool &var, const octave_value_list &args, int nargout, const char *nm)