26 #if defined (HAVE_CONFIG_H)
49 static int Vignore_function_time_stamp = 1;
54 fcn_info::fcn_info_rep::load_private_function (
const std::string& dir_name)
62 if (file_name.empty ())
75 std::string class_name;
79 if (pos != std::string::npos)
81 std::string tmp = dir_name.substr (pos+1);
84 class_name = tmp.substr (1);
95 fcn_info::fcn_info_rep::load_class_constructor ()
103 std::string file_name = lp.
find_method (name, name, dir_name, package_name);
105 if (! file_name.empty ())
118 class_constructors[name] = retval;
119 class_methods[name] = retval;
139 retval = maybe_cdef_ctor;
141 class_constructors[name] = retval;
142 class_methods[name] = retval;
144 function_on_path = old_function_on_path;
153 fcn_info::fcn_info_rep::load_class_method (
const std::string& dispatch_type)
157 if (full_name () == dispatch_type)
158 retval = load_class_constructor ();
167 std::string dir_name;
171 std::string file_name = lp.
find_method (dispatch_type, name,
174 if (! file_name.empty ())
188 class_methods[dispatch_type] = retval;
199 const std::list<std::string>& plist
202 auto it = plist.begin ();
204 while (it != plist.end ())
206 retval = find_method (*it);
210 class_methods[dispatch_type] = retval;
223 if (built_in_function.is_defined ())
229 retval = built_in_function;
231 class_methods[dispatch_type] = retval;
264 sup_table[i][j] = (use_j ? jtyp : ityp);
275 std::string dispatch_type;
282 builtin_type = args(0).builtin_type ();
285 for (i = 1; i <
n; i++)
289 builtin_type = sup_table[builtin_type][bti];
301 dispatch_type = args(i).class_name ();
305 for (
int j = i+1; j <
n; j++)
317 dispatch_type = cname;
327 return dispatch_type;
351 fcn_info::fcn_info_rep::find (
const symbol_scope& scope,
370 retval = xfind (search_scope, args);
378 split_name_with_package (
const std::string& name, std::string& fname,
381 std::size_t pos = name.rfind (
'.');
386 if (pos != std::string::npos)
388 fname = name.substr (pos + 1);
389 pname = name.substr (0, pos);
409 load_out_of_date_fcn (
const std::string& file_name,
410 const std::string& dir_name_arg,
412 const std::string& dispatch_type =
"",
413 const std::string& package_name =
"")
417 std::string dir_name = dir_name_arg;
419 if (dir_name.empty ())
423 dir_name = file_name.substr (0, pos);
432 = pos != std::string::npos && dir_name.substr (pos+1) ==
"private";
435 dir_name = dir_name.substr (0, pos);
437 std::string class_name;
441 if (pos != std::string::npos)
443 std::string tmp = dir_name.substr (pos+1);
446 class_name = tmp.substr (1);
472 const std::string& dispatch_type =
"",
473 bool check_relative =
true)
491 bool relative = check_relative && fcn->
is_relative ();
496 bool clear_breakpoints =
false;
497 std::string nm = fcn->
name ();
501 bool is_same_file =
false;
504 std::string dir_name;
508 int nm_len = nm.length ();
510 if (sys::env::absolute_pathname (nm)
512 && (nm.substr (nm_len-4) ==
".oct"
513 || nm.substr (nm_len-4) ==
".mex"))
515 && nm.substr (nm_len-2) ==
".m")))
523 if (! dispatch_type.empty ())
537 const std::list<std::string>& plist
540 std::list<std::string>::const_iterator it
543 while (it != plist.end ())
545 split_name_with_package (*it, s_name,
572 file = lp.
find_fcn (nm, dir_name, pack);
592 clear_breakpoints =
true;
594 else if (is_same_file)
599 OCTAVE_TIME_T tp = ottp.unix_time ();
603 if (! (Vignore_function_time_stamp == 2
604 || (Vignore_function_time_stamp
607 sys::file_stat fs (ff);
611 if (fs.is_newer (tp))
613 retval = load_out_of_date_fcn (ff, dir_name,
618 clear_breakpoints =
true;
625 clear_breakpoints =
true;
634 retval = load_out_of_date_fcn (file, dir_name,
function,
635 dispatch_type, pack);
637 clear_breakpoints =
true;
642 if (clear_breakpoints)
658 fcn_info::fcn_info_rep::find_scoped_function (
const symbol_scope& search_scope)
677 if (! fcn_file.empty ())
679 auto r = local_functions.find (fcn_file);
681 if (
r != local_functions.end ())
694 return find_private_function (search_scope.
dir_name ());
701 fcn_info::fcn_info_rep::find_private_function (
const std::string& dir_name)
703 if (! dir_name.empty ())
705 auto q = private_functions.find (dir_name);
707 if (q == private_functions.end ())
719 out_of_date_check (fval,
"",
false);
743 return find_method (dispatch_type);
750 fcn_info::fcn_info_rep::xfind (
const symbol_scope& search_scope,
757 fcn = find_scoped_function (search_scope);
764 fcn = find_method (args);
771 auto q = class_constructors.find (name);
773 if (q == class_constructors.end ())
785 out_of_date_check (fval, name);
800 if (cmdline_function.is_defined ())
801 return cmdline_function;
805 fcn = find_autoload ();
812 fcn = find_user_function ();
819 fcn = find_package ();
826 return built_in_function;
848 fcn_info::fcn_info_rep::builtin_find (
const symbol_scope& scope)
866 retval = x_builtin_find (search_scope);
873 fcn_info::fcn_info_rep::x_builtin_find (
const symbol_scope& search_scope)
876 if (built_in_function.is_defined ())
877 return built_in_function;
888 fcn = find_autoload ();
895 if (cmdline_function.is_defined ())
896 return cmdline_function;
904 std::string dir_name = search_scope.
dir_name ();
906 if (! dir_name.empty ())
908 auto q = private_functions.find (dir_name);
910 if (q == private_functions.end ())
922 out_of_date_check (fval);
940 if (! fcn_file.empty ())
942 auto r = local_functions.find (fcn_file);
944 if (
r != local_functions.end ())
968 fcn_info::fcn_info_rep::find_method (
const std::string& dispatch_type)
972 auto q = class_methods.find (dispatch_type);
974 if (q == class_methods.end ())
975 retval = load_class_method (dispatch_type);
981 out_of_date_check (retval, dispatch_type);
984 retval = load_class_method (dispatch_type);
1008 fcn_info::fcn_info_rep::find_autoload ()
1012 if (autoload_function.is_defined ())
1013 out_of_date_check (autoload_function);
1015 if (! autoload_function.is_defined ())
1021 if (! file_name.empty ())
1025 std::string dir_name = file_name.substr (0, pos);
1035 return autoload_function;
1039 fcn_info::fcn_info_rep::find_user_function ()
1043 if (function_on_path.is_defined ())
1044 out_of_date_check (function_on_path);
1046 if (function_on_path.is_undefined ())
1048 std::string dir_name;
1053 std::string file_name = lp.
find_fcn (name, dir_name, package_name);
1055 if (! file_name.empty ())
1061 function_on_path = ov_fcn;
1065 return function_on_path;
1069 fcn_info::fcn_info_rep::find_package ()
1075 if (package.is_undefined ())
1079 package = cdm.find_package_symbol (full_name ());
1086 fcn_info::fcn_info_rep::install_built_in_dispatch (
const std::string& klass)
1088 if (built_in_function.is_defined ())
1095 warning (
"install_built_in_dispatch: '%s' already defined for class '%s'",
1096 name.c_str (), klass.c_str ());
1102 error (
"install_built_in_dispatch: '%s' is not a built-in function",
1107 fcn_info::fcn_info_rep::dump ()
const
1109 std::map<std::string, octave_value>
m
1110 = {{
"name", full_name () },
1111 {
"package", package.dump () },
1116 {
"cmdline_function", cmdline_function.
dump () },
1117 {
"autoload_function", autoload_function.
dump () },
1118 {
"function_on_path", function_on_path.
dump () },
1119 {
"built_in_function", built_in_function.
dump () }
1128 if (fcn_map.empty ())
1131 std::map<std::string, octave_value> info_map;
1133 for (
const auto& nm_fcn : fcn_map)
1135 std::string nm = nm_fcn.first;
1137 info_map[nm] = fcn.
dump ();
1143 DEFUN (ignore_function_time_stamp, args, nargout,
1165 int nargin = args.
length ();
1172 if (nargout > 0 || nargin == 0)
1174 switch (Vignore_function_time_stamp)
1192 std::string sval = args(0).xstring_value (
"ignore_function_time_stamp: first argument must be a string");
1195 Vignore_function_time_stamp = 2;
1196 else if (sval ==
"system")
1197 Vignore_function_time_stamp = 1;
1198 else if (sval ==
"none")
1199 Vignore_function_time_stamp = 0;
1201 error (R
"(ignore_function_time_stamp: argument must be one of "all", "system", or "none")");
1225 OCTAVE_END_NAMESPACE(
octave)
bp_lines remove_all_breakpoints_from_function(const std::string &fcn_ident, bool silent=false)
octave_value find_method_symbol(const std::string &method_name, const std::string &class_name)
std::string find_fcn(const std::string &fcn, std::string &dir_name, const std::string &pack_name="")
std::string find_private_fcn(const std::string &dir, const std::string &fcn, const std::string &pack_name="")
std::string find_method(const std::string &class_name, const std::string &meth, std::string &dir_name, const std::string &pack_name="")
virtual bool is_anonymous_function() const
virtual octave_function * function_value(bool silent=false)
virtual bool handles_dispatch_class(const std::string &) const
virtual bool is_subfunction() const
std::string canonical_name() const
std::string package_name() const
bool is_class_method(const std::string &cname="") const
virtual octave::sys::time time_checked() const
virtual void push_dispatch_class(const std::string &)
virtual bool is_classdef_constructor(const std::string &="") const
virtual void mark_fcn_file_up_to_date(const octave::sys::time &)
virtual octave::sys::time time_parsed() const
virtual std::string fcn_file_name() const
virtual void mark_as_private_function(const std::string &cname="")
virtual bool is_system_fcn_file() const
octave_idx_type length() const
bool is_undefined() const
std::string class_name() const
bool is_classdef_meta() const
octave_value dump() const
octave_function * function_value(bool silent=false) const
builtin_type_t builtin_type() const
std::string fcn_file_name() const
octave_value find_subfunction(const std::string &name) const
std::string dir_name() const
bool is_superiorto(const std::string &a, const std::string &b)
std::list< std::string > parent_classes(const std::string &dispatch_type)
std::string lookup_autoload(const std::string &nm) const
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
void warning(const char *fmt,...)
void() error(const char *fmt,...)
octave_value dump_function_map(const std::map< std::string, octave_value > &fcn_map)
std::string dir_sep_chars()
bp_table & __get_bp_table__()
symbol_scope __get_current_scope__()
cdef_manager & __get_cdef_manager__()
load_path & __get_load_path__()
tree_evaluator & __get_evaluator__()
symbol_table & __get_symbol_table__()
sys::time Vlast_chdir_time
bool same_file(const std::string &file1, const std::string &file2)
std::string canonicalize_file_name(const std::string &name)
std::string get_dispatch_type(const octave_value_list &args)
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
std::string btyp_class_name[btyp_num_types+1]
bool btyp_isinteger(builtin_type_t btyp)
bool btyp_isarray(builtin_type_t btyp)
octave_value load_fcn_from_file(const std::string &file_name, const std::string &dir_name="", const std::string &dispatch_type="", const std::string &package_name="", const std::string &fcn_name="", bool autoload=false)