26#if defined (HAVE_CONFIG_H)
37#include "builtin-defun-decls.h"
78 octave::event_manager& evmgr
96 warning (
"function file '%s' changed since it was parsed",
109std::deque<std::string>
126 warning (
"help text for function is newer than function");
131std::map<std::string, octave_value>
134 return std::map<std::string, octave_value> ();
140 std::map<std::string, octave_value> m
153 "user-defined script",
154 "user-defined script");
161 (
const std::string& fnm,
const std::string& nm,
163 const std::string& ds)
171 (
const std::string& fnm,
const std::string& nm,
185 tw.push_stack_frame (
this);
189 return execute (tw, nargout, args);
196 return tw.execute_user_script (*
this, nargout, args);
208 "user-defined function",
209 "user-defined function");
218 m_param_list (pl), m_ret_list (rl),
219 m_lead_comm (), m_trail_comm (),
220 m_location_line (0), m_location_column (0),
221 m_system_fcn_file (false),
222 m_num_named_args (m_param_list ? m_param_list->length () : 0),
223 m_subfunction (false), m_inline_function (false),
224 m_anonymous_function (false), m_nested_function (false),
225 m_class_constructor (none), m_class_method (none)
282 new_eof_line = next_to_last_stmt->
line ();
283 new_eof_col = next_to_last_stmt->
column ();
286 last_stmt->
set_location (new_eof_line + 1, new_eof_col);
294 std::map<std::string, octave_value> fcns =
subfunctions ();
298 for (
auto& nm_fnval : fcns)
303 f->maybe_relocate_end_internal ();
319 std::ostringstream result;
329 result <<
'@' <<
name ();
336 return result.str ();
355 static const std::string canonical_fcn_file_dir
360 : canonical_fcn_file_dir;
407std::map<std::string, octave_value>
420 std::string subfuns = subfuns_arg;
422 std::string first_fun = subfuns;
424 std::size_t pos = subfuns.find (
'>');
426 if (pos == std::string::npos)
430 first_fun = subfuns.substr (0, pos-1);
431 subfuns = subfuns.substr (pos+1);
436 if (subfuns.empty ())
456std::list<std::string>
484 tw.push_stack_frame (
this);
488 return execute (tw, nargout, args);
495 return tw.execute_user_function (*
this, nargout, args);
525 retval = par1->
name () == ret1->
name ();
551 retval =
"unrecognized enum value";
578 retval =
"unrecognized enum value";
588 std::map<std::string, octave_value> m
625 octave::interpreter& interp
628 octave::tree_evaluator& tw = interp.get_evaluator ();
651OCTAVE_NAMESPACE_BEGIN
686 int nargin = args.length ();
704 error (
"nargin: invalid function name: %s",
name.c_str ());
709 error (
"nargin: FCN must be a string or function handle");
718 std::string type = fcn_val->
type_name ();
719 error (
"nargin: number of input arguments unavailable for %s objects",
725 retval = (m_param_list ? m_param_list->length () : 0);
727 retval = -1 - retval;
797 int nargin = args.length ();
815 error (
"nargout: invalid function name: %s",
name.c_str ());
831 error (
"nargout: FCN must be a string or function handle");
840 std::string type = fcn_val->
type_name ();
841 error (
"nargout: number of output arguments unavailable for %s objects",
845 tree_parameter_list *m_ret_list = fcn->
return_list ();
847 retval = (m_ret_list ? m_ret_list->length () : 0);
850 retval = -1 - retval;
854 if (interp.at_top_level ())
855 error (
"nargout: invalid call at top level");
868DEFUN (optimize_subsasgn_calls, args, nargout,
886 "optimize_subsasgn_calls");
895 return (i > 0 && table(i-1) == val);
901 error (
"isargout: K must be a positive integer");
903 return (k == 1 || k <= nargout) && !
val_in_table (ignored, k);
924 if (args.length () != 1)
927 if (interp.at_top_level ())
928 error (
"isargout: invalid call at top level");
944 if (args(0).is_scalar_type ())
946 double k = args(0).double_value ();
950 else if (args(0).isnumeric ())
952 const NDArray ka = args(0).array_value ();
956 r(i) =
isargout1 (nargout1, ignored, ka(i));
octave_idx_type numel(void) const
Number of elements in the array.
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
bool isempty(void) const
Size of the specified dimension.
OCTARRAY_API octave_idx_type lookup(const T &value, sortmode mode=UNSORTED) const
Do a binary lookup in a sorted array.
std::size_t length(void) const
std::list< tree_statement * >::reverse_iterator reverse_iterator
reverse_iterator rend(void)
reverse_iterator rbegin(void)
OCTAVE_API std::string get_line(std::size_t line) const
OCTAVE_API std::deque< std::string > get_lines(std::size_t line, std::size_t num_lines) const
void set_user_code(octave_user_code *code)
octave_value find_subfunction(const std::string &name) const
void erase_subfunctions(void)
void unlock_subfunctions(void)
std::map< std::string, octave_value > subfunctions(void) const
void set_parent(const symbol_scope &p)
void mark_subfunctions_in_scope_as_private(const std::string &class_name)
std::list< std::string > subfunction_names(void) const
void stash_subfunction_names(const std::list< std::string > &names)
void lock_subfunctions(void)
bool has_subfunctions(void) const
octave_value dump(void) const
sys::time mtime(void) const
tree_identifier * ident(void)
std::string name(void) const
bool takes_varargs(void) const
void visit_octave_user_function_trailer(octave_user_function &)
void visit_octave_user_function_header(octave_user_function &)
void mark_as_script_body(void)
void mark_as_function_body(void)
bp_table::bp_lines remove_all_breakpoints(event_manager &evmgr, const std::string &file)
bool is_end_of_fcn_or_script(void) const
bool is_end_of_file(void) const
tree_expression * expression(void)
void set_location(int l, int c)
virtual void visit_octave_user_script(octave_user_script &)
virtual void visit_octave_user_function(octave_user_function &)
virtual octave_user_function * user_function_value(bool silent=false)
virtual std::string type_name(void) const
friend class octave_value
bool is_anonymous(void) const
std::string dispatch_class(void) const
bool is_class_method(const std::string &cname="") const
bool is_class_constructor(const std::string &cname="") const
virtual void mark_as_private_function(const std::string &cname="")
std::string name(void) const
const Cell & contents(const_iterator p) const
octave_idx_type numel(void) const
octave_value dump(void) const
std::string fcn_file_name(void) const
std::string get_code_line(std::size_t line)
octave::sys::time m_t_checked
std::deque< std::string > get_code_lines(std::size_t line, std::size_t num_lines)
octave::tree_statement_list * m_cmd_list
octave::sys::time m_t_parsed
octave::file_info * m_file_info
octave::sys::time time_parsed(void) const
void cache_function_text(const std::string &text, const octave::sys::time ×tamp)
virtual std::map< std::string, octave_value > subfunctions(void) const
octave::symbol_scope m_scope
std::string parent_fcn_name(void) const
void restore_warning_states(void)
octave::tree_expression * special_expr(void)
void unlock_subfunctions(void)
void erase_subfunctions(void)
void mark_as_system_fcn_file(void)
octave_value_list call(octave::tree_evaluator &tw, int nargout=0, const octave_value_list &args=octave_value_list())
bool is_special_expr(void) const
octave::comment_list * m_trail_comm
octave::tree_parameter_list * m_param_list
void stash_parent_fcn_scope(const octave::symbol_scope &ps)
void maybe_relocate_end(void)
int m_end_location_column
octave_user_function * define_ret_list(octave::tree_parameter_list *t)
octave_value_list all_va_args(const octave_value_list &args)
void stash_subfunction_names(const std::list< std::string > &names)
std::string profiler_name(void) const
bool is_classdef_constructor(const std::string &cname="") const
bool takes_varargs(void) const
octave_value_list execute(octave::tree_evaluator &tw, int nargout=0, const octave_value_list &args=octave_value_list())
bool takes_var_return(void) const
void mark_as_private_function(const std::string &cname="")
std::list< std::string > subfunction_names(void) const
int beginning_column(void) const
class_method_type m_class_method
void print_code_function_header(const std::string &prefix)
octave::tree_parameter_list * m_ret_list
void accept(octave::tree_walker &tw)
octave::tree_parameter_list * parameter_list(void)
bool is_inline_function(void) const
void print_code_function_trailer(const std::string &prefix)
std::map< std::string, octave_value > subfunctions(void) const
bool has_subfunctions(void) const
~octave_user_function(void)
octave_value find_subfunction(const std::string &subfuns) const
octave_user_function(const octave::symbol_scope &scope=octave::symbol_scope(), octave::tree_parameter_list *pl=nullptr, octave::tree_parameter_list *rl=nullptr, octave::tree_statement_list *cl=nullptr)
class_method_type m_class_constructor
bool is_subfunction(void) const
bool subsasgn_optimization_ok(void)
int beginning_line(void) const
octave::tree_parameter_list * return_list(void)
void lock_subfunctions(void)
std::string method_type_str(void) const
bool m_anonymous_function
octave::comment_list * m_lead_comm
std::string ctor_type_str(void) const
octave_value dump(void) const
bool is_anonymous_function(void) const
void maybe_relocate_end_internal(void)
void accept(octave::tree_walker &tw)
octave_value_list call(octave::tree_evaluator &tw, int nargout=0, const octave_value_list &args=octave_value_list())
octave_value_list execute(octave::tree_evaluator &tw, int nargout=0, const octave_value_list &args=octave_value_list())
octave_idx_type length(void) const
octave_value_list slice(octave_idx_type offset, octave_idx_type len, bool tags=false) const
OCTINTERP_API octave_function * function_value(bool silent=false) const
int int_value(bool req_int=false, bool frc_str_conv=false) const
OCTINTERP_API octave_fcn_handle * fcn_handle_value(bool silent=false) const
OCTINTERP_API octave_user_function * user_function_value(bool silent=false) const
bool is_string(void) const
bool is_defined(void) const
bool is_function_handle(void) const
bool isstruct(void) const
std::string string_value(bool force=false) const
OCTINTERP_API octave_map map_value(void) const
bool is_undefined(void) const
bool is_inline_function(void) const
Matrix matrix_value(bool frc_str_conv=false) const
octave_value find_function(const std::string &name, const symbol_scope &search_scope=symbol_scope())
octave_value get_auto_fcn_var(stack_frame::auto_var_type avt) const
OCTINTERP_API void print_usage(void)
#define DEFMETHOD(name, interp_name, args_name, nargout_name, doc)
Macro to define a builtin method.
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
void warning(const char *fmt,...)
OCTAVE_EXPORT octave_value_list Fwarning(octave::interpreter &interp, const octave_value_list &args, int nargout)
void error(const char *fmt,...)
#define panic_impossible()
void err_wrong_type_arg(const char *name, const char *s)
F77_RET_T const F77_DBLE const F77_DBLE * f
std::string fcn_file_dir(void)
std::string canonicalize_file_name(const std::string &name)
event_manager & __get_event_manager__(const std::string &who)
interpreter & __get_interpreter__(const std::string &who)
#define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n, c)
static bool Voptimize_subsasgn_calls
static bool val_in_table(const Matrix &table, double val)
static bool isargout1(int nargout, const Matrix &ignored, double k)
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.
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)