23 #if defined (HAVE_CONFIG_H) 33 #include "builtin-defun-decls.h" 80 warning (
"function file '%s' changed since it was parsed",
93 std::deque<std::string>
110 warning (
"help text for function is newer than function");
115 std::map<std::string, octave_value>
118 return std::map<std::string, octave_value> ();
124 "user-defined script",
125 "user-defined script");
129 t_parsed (static_cast<time_t> (0)),
130 t_checked (static_cast<time_t> (0)),
139 t_parsed (static_cast<time_t> (0)),
140 t_checked (static_cast<time_t> (0)),
144 cmd_list->mark_as_script_body ();
151 t_parsed (static_cast<time_t> (0)),
152 t_checked (static_cast<time_t> (0)),
181 error (
"max_recursion_depth exceeded");
236 "user-defined function",
237 "user-defined function");
246 param_list (pl), ret_list (rl), cmd_list (cl),
247 lead_comm (), trail_comm (), file_name (),
248 location_line (0), location_column (0),
249 parent_name (), t_parsed (static_cast<time_t> (0)),
250 t_checked (static_cast<time_t> (0)),
252 num_named_args (param_list ? param_list->length () : 0),
253 subfunction (
false), inline_function (
false),
254 anonymous_function (
false), nested_function (
false),
255 class_constructor (none), class_method (
false)
256 #if defined (HAVE_LLVM) 261 cmd_list->mark_as_function_body ();
264 m_scope.set_function (
this);
279 #if defined (HAVE_LLVM) 333 new_eof_line = next_to_last_stmt->
line ();
334 new_eof_col = next_to_last_stmt->
column ();
337 last_stmt->
set_location (new_eof_line + 1, new_eof_col);
345 std::map<std::string, octave_value> fcns =
subfunctions ();
349 for (
auto& nm_fnval : fcns)
354 f->maybe_relocate_end_internal ();
370 std::ostringstream
result;
376 result << parent_fcn_name () << '>
' << name (); 377 else if (is_class_method ()) 378 result << '@
' << dispatch_class () << '/
' << name (); 379 else if (is_class_constructor () || is_classdef_constructor ()) 380 result << '@
' << name (); 381 else if (is_inline_function ()) 382 result << "inline@" << fcn_file_name () 383 << ':
' << location_line << ':
' << location_column; 387 return result.str (); 391 octave_user_function::mark_as_system_fcn_file (void) 393 if (! file_name.empty ()) 395 // We really should stash the whole path to the file we found, 396 // when we looked it up, to avoid possible race conditions... 399 // We probably also don't need to
get the library
directory 411 system_fcn_file =
false;
452 std::map<std::string, octave_value>
470 std::list<std::string>
508 ret_args = args.
slice (0, 1,
true);
515 #if defined (HAVE_LLVM) 527 error (
"max_recursion_depth exceeded");
568 std::cerr <<
"defining param list, scope: " <<
m_scope 580 error (
"%s: invalid classdef constructor, no output argument defined",
672 varargout = varargout_varval.
xcell_value (
"varargout must be a cell array object");
734 retval =
"unrecognized enum value";
744 std::map<std::string, octave_value> m
788 if (! arg_names.
empty ())
796 m_scope.force_assign (
"argn", chm);
797 m_scope.force_assign (
".argn.",
Cell (arg_names));
799 m_scope.mark_hidden (
".argn.");
801 m_scope.mark_automatic (
"argn");
802 m_scope.mark_automatic (
".argn.");
805 m_scope.force_assign (
".nargin.",
nargin);
806 m_scope.force_assign (
".nargout.",
nargout);
808 m_scope.mark_hidden (
".nargin.");
809 m_scope.mark_hidden (
".nargout.");
811 m_scope.mark_automatic (
".nargin.");
812 m_scope.mark_automatic (
".nargout.");
814 m_scope.force_assign (
".saved_warning_states.",
octave_value ());
816 m_scope.mark_automatic (
".saved_warning_states.");
817 m_scope.mark_automatic (
".saved_warning_states.");
819 if (takes_varargs ())
824 m_scope.force_assign (
".ignored.", ignored_fcn_outputs);
826 m_scope.mark_hidden (
".ignored.");
827 m_scope.mark_automatic (
".ignored.");
835 if (
val.is_defined ())
840 if (!
val.isstruct ())
852 Fwarning (interp,
ovl (states(
i), ids(
i)));
889 int nargin = args.length ();
907 error (
"nargin: invalid function name: %s",
name.c_str ());
912 error (
"nargin: FCN must be a string or function handle");
922 error (
"nargin: number of input arguments unavailable for %s objects",
999 int nargin = args.length ();
1017 error (
"nargout: invalid function name: %s",
name.c_str ());
1034 error (
"nargout: FCN must be a string or function handle");
1044 error (
"nargout: number of output arguments unavailable for %s objects",
1058 error (
"nargout: invalid call at top level");
1090 static bool val_in_table (
const Matrix& table,
double val)
1096 return (
i > 0 && table(
i-1) ==
val);
1099 static bool isargout1 (
int nargout,
const Matrix& ignored,
double k)
1102 error (
"isargout: K must be a positive integer");
1104 return (
k == 1 ||
k <=
nargout) && ! val_in_table (ignored,
k);
1125 if (args.length () != 1)
1131 error (
"isargout: invalid call at top level");
1139 if (
tmp.is_defined ())
1140 ignored =
tmp.matrix_value ();
1142 if (args(0).is_scalar_type ())
1144 double k = args(0).double_value ();
1146 return ovl (isargout1 (nargout1, ignored,
k));
1150 const NDArray ka = args(0).array_value ();
1154 r(
i) = isargout1 (nargout1, ignored, ka(
i));
std::string profiler_name(void) const
void print_code_function_trailer(const std::string &prefix)
~octave_user_function(void)
void set_location(int l, int c)
virtual std::map< std::string, octave_value > subfunctions(void) const
static bool Voptimize_subsasgn_calls
void unbind_script_symbols(void)
octave_value find_function(const std::string &name, const octave_value_list &args=octave_value_list(), bool local_funcs=true)
void lock_subfunctions(void)
void undefine_parameter_list(tree_parameter_list *param_list)
octave::tree_expression * special_expr(void)
virtual octave::sys::time time_parsed(void) const
int int_value(bool req_int=false, bool frc_str_conv=false) const
static const std::string anonymous
void stash_subfunction_names(const std::list< std::string > &names)
#define DEFMETHOD(name, interp_name, args_name, nargout_name, doc)
Macro to define a builtin method.
void accept(octave::tree_walker &tw)
interpreter & __get_interpreter__(const std::string &who)
std::string string_value(bool force=false) const
void set_location(int l, int c)
bool is_end_of_fcn_or_script(void) const
void push_echo_state(unwind_protect &frame, int type, const std::string &file_name, size_t pos=1)
bp_table::intmap remove_all_breakpoints(const std::string &file)
octave_value dump(void) const
octave_user_function * define_ret_list(octave::tree_parameter_list *t)
octave::comment_list * lead_comm
OCTINTERP_API void print_usage(void)
octave_value_list slice(octave_idx_type offset, octave_idx_type len, bool tags=false) const
identity matrix If supplied two scalar respectively For allows like xample val
F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE * f
octave::sys::time t_parsed
void mark_subfunctions_in_scope_as_private(const std::string &class_name)
OCTINTERP_API std::string fcn_file_in_path(const std::string &)
octave_value_list all_va_args(const octave_value_list &args)
void maybe_relocate_end_internal(void)
bool is_special_expr(void) const
octave::file_info * m_file_info
octave::sys::time t_checked
bool is_end_of_file(void) const
std::string get_code_line(size_t line)
void bind_script_symbols(const symbol_scope &curr_scope)
size_t length(void) const
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
void error(const char *fmt,...)
int beginning_column(void) const
#define SET_INTERNAL_VARIABLE(NM)
virtual void visit_octave_user_function(octave_user_function &)=0
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
void visit_octave_user_function_trailer(octave_user_function &)
std::map< std::string, octave_value > subfunctions(void) const
#define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n, c)
bool is_defined(void) const
octave_value_list call(octave::tree_evaluator &tw, int nargout=0, const octave_value_list &args=octave_value_list())
std::deque< std::string > get_code_lines(size_t line, size_t num_lines)
static llvm::LLVMContext & context
void print_code_function_header(const std::string &prefix)
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function t
void restore_warning_states(void)
octave::jit_function_info * jit_info
bool takes_varargs(void) const
octave_value echo(const octave_value_list &args, int nargout)
virtual std::string fcn_file_name(void) const
std::list< tree_statement * >::reverse_iterator reverse_iterator
octave_value_list evaluate_n(tree_expression *expr, int nargout=1)
OCTAVE_EXPORT octave_value_list isnumeric
std::string fcn_file_dir(void)
void push(octave_function *fcn)
Matrix ignored_fcn_outputs(void) const
int beginning_line(void) const
bool takes_varargs(void) const
bool is_subfunction(void) const
reverse_iterator rbegin(void)
void bind_automatic_vars(octave::tree_evaluator &tw, const string_vector &arg_names, int nargin, int nargout, const octave_value_list &va_args)
nd deftypefn *std::string name
OCTAVE_EXPORT octave_value_list isdir nd deftypefn *std::string nm
std::string fcn_name(void) const
octave_idx_type lookup(const T &value, sortmode mode=UNSORTED) const
Do a binary lookup in a sorted array.
virtual octave_user_function * user_function_value(bool silent=false)
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function xample nargout(@histc)
std::string get_line(size_t line) const
octave::tree_parameter_list * ret_list
void accept(octave::tree_walker &tw)
bool is_function_handle(void) const
std::list< std::string > subfunction_names(void) const
void lock_subfunctions(void)
std::string dispatch_class(void) const
std::map< std::string, octave_value > subfunctions(void) const
symbol_record::context_id current_context(void) const
octave_value_list convert_return_list_to_const_vector(tree_parameter_list *ret_list, int nargout, const Cell &varargout)
void maybe_relocate_end(void)
void stash_subfunction_names(const std::list< std::string > &names)
bool takes_var_return(void) const
void accept(tree_walker &tw)
void unlock_subfunctions(void)
virtual bool takes_varargs(void) const
void erase_subfunctions(void)
virtual void mark_as_private_function(const std::string &cname="")
virtual bool takes_var_return(void) const
#define panic_impossible()
octave_function * function_value(bool silent=false) const
const Cell & contents(const_iterator p) const
std::deque< std::string > get_lines(size_t line, size_t num_lines) const
symbol_scope require_current_scope(const std::string &who)
bool has_subfunctions(void) const
octave_idx_type numel(void) const
octave_value varval(const std::string &name) const
void err_wrong_type_arg(const char *name, const char *s)
With real return the complex result
friend class octave_value
bool is_anonymous_function(void) const
void cache_function_text(const std::string &text, const octave::sys::time ×tamp)
void warning(const char *fmt,...)
int max_recursion_depth(void) const
octave::unwind_protect frame
octave::tree_statement_list * cmd_list
octave::tree_parameter_list * param_list
std::string fcn_file_name(void) const
bool subsasgn_optimization_ok(void)
octave_fcn_handle * fcn_handle_value(bool silent=false) const
std::string ctor_type_str(void) const
void erase_subfunctions(void)
bool is_undefined(void) const
string_vector name_tags(void) const
void visit_octave_user_function_header(octave_user_function &)
OCTAVE_EXPORT octave_value_list isa nd deftypefn *return ovl(args(0).isinteger())
octave::unwind_protect * curr_unwind_protect_frame
void unlock_subfunctions(void)
bool has_subfunctions(void) const
call_stack & __get_call_stack__(const std::string &who)
void stash_parent_fcn_scope(const octave::symbol_scope &ps)
octave::tree_statement_list * cmd_list
Cell cell_value(void) const
octave_idx_type length(void) const
class_ctor_type class_constructor
virtual void visit_octave_user_script(octave_user_script &)=0
virtual std::string type_name(void) const
symbol_scope get_current_scope(void)
void define_parameter_list_from_arg_vector(tree_parameter_list *param_list, const octave_value_list &args)
octave::sys::file_stat fs(filename)
void add_method(T *obj, void(T::*method)(void))
void assign(const idx_vector &i, const Array< T > &rhs, const T &rfv)
Indexed assignment (always with resize & fill).
std::string name(void) const
char string_fill_char(void) const
static bool execute(tree_simple_for_command &cmd, const octave_value &bounds)
bool is_string(void) const
octave::comment_list * trail_comm
std::list< std::string > subfunction_names(void) const
static stmt_list_type statement_context
bool is_classdef_constructor(const std::string &cname="") const
~octave_user_script(void)
void stash_fcn_file_name(const std::string &nm)
octave_value dump(void) const
octave_idx_type numel(void) const
Number of elements in the array.
tree_identifier * ident(void)
void set_parent(const symbol_scope &p)
reverse_iterator rend(void)
std::string name(void) const
profiler & get_profiler(void)
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
sys::time mtime(void) const
Cell xcell_value(const char *fmt,...) const
octave_value_list call(octave::tree_evaluator &tw, int nargout=0, const octave_value_list &args=octave_value_list())
octave::symbol_scope m_scope
bool is_inline_function(void) const
void mark_as_private_function(const std::string &cname="")
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)
tree_expression * expression(void)
OCTAVE_EXPORT octave_value_list directory