61 std::map<std::string, std::set<std::string> >
101 (std::ostream& os,
const std::string& prefix)
const
105 os << prefix << name;
110 << (is_local () ?
"l" :
"")
111 << (is_automatic () ?
"a" :
"")
112 << (is_formal () ?
"f" :
"")
113 << (is_hidden () ?
"h" :
"")
114 << (is_inherited () ?
"i" :
"")
116 << (is_persistent () ?
"p" :
"")
139 retval = rep->finfo->find (args);
157 size_t pos = name.rfind (
'.');
162 if (pos != std::string::npos)
164 fname = name.substr (pos + 1);
165 pname = name.substr (0, pos);
187 const std::string& dispatch_type = std::string (),
188 const std::string& package_name = std::string ())
209 const std::string& dispatch_type,
228 bool relative = check_relative && fcn->
is_relative ();
233 bool clear_breakpoints =
false;
234 std::string nm = fcn->
name ();
238 bool is_same_file =
false;
241 std::string dir_name;
245 int nm_len = nm.length ();
249 && (nm.substr (nm_len-4) ==
".oct"
250 || nm.substr (nm_len-4) ==
".mex"))
252 && nm.substr (nm_len-2) ==
".m")))
260 if (! dispatch_type.empty ())
270 const std::list<std::string>& plist
272 std::list<std::string>::const_iterator it
275 while (it != plist.end ())
318 clear_breakpoints =
true;
320 else if (is_same_file)
329 if (! (Vignore_function_time_stamp == 2
330 || (Vignore_function_time_stamp
344 clear_breakpoints =
true;
351 clear_breakpoints =
true;
361 dispatch_type, pack);
363 clear_breakpoints =
true;
368 if (clear_breakpoints)
381 (
const std::string& dir_name)
387 if (! file_name.empty ())
393 std::string class_name;
397 if (pos != std::string::npos)
399 std::string tmp = dir_name.substr (pos+1);
402 class_name = tmp.substr (1);
409 private_functions[dir_name] = retval;
421 std::string dir_name;
426 if (! file_name.empty ())
435 class_constructors[name] = retval;
455 retval = maybe_cdef_ctor;
457 class_constructors[name] = retval;
459 function_on_path = old_function_on_path;
469 (
const std::string& dispatch_type)
473 if (full_name () == dispatch_type)
474 retval = load_class_constructor ();
485 std::string dir_name;
490 if (! file_name.empty ())
499 class_methods[dispatch_type] = retval;
507 const std::list<std::string>& plist =
510 std::list<std::string>::const_iterator it = plist.begin ();
512 while (it != plist.end ())
518 class_methods[dispatch_type] = retval;
537 if (p != subfunctions.end ())
549 if (dispatch_map.empty ())
550 os <<
"dispatch: " << name <<
" is not overloaded" << std::endl;
553 os <<
"Overloaded function " << name <<
":\n\n";
556 p != dispatch_map.end (); p++)
557 os <<
" " << name <<
" (" << p->first <<
", ...) -> "
558 << p->second <<
" (" << p->first <<
", ...)\n";
569 if (! dispatch_map.empty ())
571 retval =
"Overloaded function:\n\n";
574 p != dispatch_map.end (); p++)
575 retval +=
" " + p->second +
" (" + p->first +
", ...)\n\n";
604 sup_table[i][j] = use_j ? jtyp : ityp;
615 std::string dispatch_type;
622 builtin_type = args(0).builtin_type ();
625 for (i = 1; i < n; i++)
629 builtin_type = sup_table[builtin_type][bti];
641 dispatch_type = args(i).class_name ();
643 for (
int j = i+1; j < n; j++)
655 dispatch_type = cname;
665 return dispatch_type;
706 retval = xfind (args, local_funcs);
727 if (r != subfunctions.end ())
745 std::string dir_name = curr_fcn->
dir_name ();
747 if (! dir_name.empty ())
751 if (q == private_functions.end ())
795 if (q == class_constructors.end ())
822 if (! args.
empty () && ! dispatch_map.empty ())
824 std::string dispatch_type = args(0).type_name ();
830 if (p == dispatch_map.end ())
831 p = dispatch_map.find (
"any");
833 if (p != dispatch_map.end ())
847 if (cmdline_function.is_defined ())
848 return cmdline_function;
866 fcn = find_package ();
873 return built_in_function;
908 retval = x_builtin_find ();
918 if (built_in_function.is_defined ())
919 return built_in_function;
937 if (cmdline_function.is_defined ())
938 return cmdline_function;
946 std::string dir_name = curr_fcn->
dir_name ();
948 if (! dir_name.empty ())
952 if (q == private_functions.end ())
986 if (r != subfunctions.end ())
1005 (
const std::string& dispatch_type)
1011 if (q == class_methods.end ())
1046 if (autoload_function.is_defined ())
1049 if (! autoload_function.is_defined ())
1053 if (! file_name.empty ())
1057 std::string dir_name = file_name.substr (0, pos);
1067 return autoload_function;
1075 if (function_on_path.is_defined ())
1078 if (! (
error_state || function_on_path.is_defined ()))
1080 std::string dir_name;
1085 if (! file_name.empty ())
1095 return function_on_path;
1111 package = octave_value (fcn);
1123 const std::string& inf_class)
1157 const std::set<std::string>& inferior_classes = p->second;
1158 std::set<std::string>::const_iterator q = inferior_classes.find (b);
1159 return (q != inferior_classes.end ());
1172 const std::string& prefix)
const
1174 os << prefix << full_name ()
1176 << (cmdline_function.is_defined () ?
"c" :
"")
1177 << (built_in_function.is_defined () ?
"b" :
"")
1178 << (package.is_defined () ?
"p" :
"")
1181 std::string tprefix = prefix +
" ";
1183 if (autoload_function.is_defined ())
1184 os << tprefix <<
"autoload: "
1187 if (function_on_path.is_defined ())
1188 os << tprefix <<
"function from path: "
1191 if (! subfunctions.empty ())
1194 p != subfunctions.end (); p++)
1195 os << tprefix <<
"subfunction: " <<
fcn_file_name (p->second)
1196 <<
" [" << p->first <<
"]\n";
1199 if (! private_functions.empty ())
1202 p != private_functions.end (); p++)
1204 <<
" [" << p->first <<
"]\n";
1207 if (! class_constructors.empty ())
1210 p != class_constructors.end (); p++)
1211 os << tprefix <<
"constructor: " <<
fcn_file_name (p->second)
1212 <<
" [" << p->first <<
"]\n";
1215 if (! class_methods.empty ())
1218 p != class_methods.end (); p++)
1220 <<
" [" << p->first <<
"]\n";
1223 if (! dispatch_map.empty ())
1226 p != dispatch_map.end (); p++)
1228 <<
" [" << p->first <<
"]\n";
1246 parent_table->add_nest_child (*fcn_table_loc);
1252 bool skip_variables,
1258 ? inst->
do_find (name, args, skip_variables, local_funcs)
1277 if (! name.empty () && name[0] ==
'@')
1280 std::string dispatch_type =
1285 if (pos != std::string::npos)
1286 method = name.substr (pos + 1);
1294 if (pos == std::string::npos)
1295 retval =
find (name, args,
true, local_funcs);
1298 std::string fcn_scope = name.substr (0, pos);
1335 os <<
"*** dumping symbol table scope " << scope
1338 std::map<std::string, octave_value> sfuns
1341 if (! sfuns.empty ())
1343 os <<
" subfunctions defined in this scope:\n";
1345 for (std::map<std::string,
1347 p != sfuns.end (); p++)
1348 os <<
" " << p->first <<
"\n";
1363 os <<
"*** dumping global symbol table\n\n";
1368 std::string nm = p->first;
1371 os <<
" " << nm <<
" ";
1383 os <<
"*** dumping globally visible functions from symbol table\n"
1384 <<
" (c=commandline, b=built-in)\n\n";
1388 p->second.dump (os,
" ");
1396 const std::string& dir_name)
1405 std::pair<std::string, octave_value> tmp
1406 = p->second.subfunction_defined_in_scope (scope);
1408 std::string nm = tmp.first;
1425 bool skip_variables,
1432 if (! skip_variables)
1436 if (p !=
table.end ())
1455 return p->second.find (args, local_funcs);
1479 return p->second.builtin_find ();
1495 std::list<workspace_element>
1498 std::list<workspace_element> retval;
1502 std::string nm = p->first;
1533 std::ostringstream buf;
1535 std::string short_disp_str = buf.str ();
1538 short_disp_str, dv.
str (),
1541 retval.push_back (elt);
1554 os <<
" persistent variables in this scope:\n\n";
1559 std::string nm = p->first;
1562 os <<
" " << nm <<
" ";
1570 if (!
table.empty ())
1572 os <<
" other symbols in this scope (l=local; a=auto; f=formal\n"
1573 <<
" h=hidden; i=inherited; g=global; p=persistent)\n\n";
1576 p->second.dump (os,
" ");
1623 ::
error (
"global and persistent may only be used in the topmost level in which a nested variable is used");
1628 ti->second = parents;
1639 ti->second.set_curr_fcn (
curr_fcn);
1642 for (std::vector<symbol_table*>::iterator iter =
nest_children.begin ();
1644 (*iter)->do_update_nest ();
1647 DEFUN (ignore_function_time_stamp, args, nargout,
1649 @deftypefn {Built-in Function} {@var{val} =} ignore_function_time_stamp ()\n\
1650 @deftypefnx {Built-in Function} {@var{old_val} =} ignore_function_time_stamp (@var{new_val})\n\
1651 Query or set the internal variable that controls whether Octave checks\n\
1652 the time stamp on files each time it looks up functions defined in\n\
1655 If the internal variable is set to @qcode{\"system\"}, Octave will not\n\
1656 automatically recompile function files in subdirectories of\n\
1657 @file{@var{octave-home}/lib/@var{version}} if they have changed since they were last compiled, but will recompile other function files in the search path if they change.\n\
1659 If set to @qcode{\"all\"}, Octave will not recompile any function files\n\
1660 unless their definitions are removed with @code{clear}.\n\
1662 If set to @qcode{\"none\"}, Octave will always check time stamps on files to\n\
1663 determine whether functions defined in function files need to recompiled.\n\
1668 int nargin = args.
length ();
1670 if (nargout > 0 || nargin == 0)
1672 switch (Vignore_function_time_stamp)
1690 if (args(0).is_string ())
1694 Vignore_function_time_stamp = 2;
1695 else if (sval ==
"system")
1696 Vignore_function_time_stamp = 1;
1697 else if (sval ==
"none")
1698 Vignore_function_time_stamp = 0;
1700 error (
"ignore_function_time_stamp: argument must be \"all\", \"system\", or \"none\"");
1703 error (
"ignore_function_time_stamp: expecting argument to be character string");
1705 else if (nargin > 1)
1729 DEFUN (__current_scope__, , ,
1731 @deftypefn {Built-in Function} {[@var{scope}, @var{context}]} __dump_symtab_info__ ()\n\
1732 Undocumented internal function.\n\
1743 DEFUN (__dump_symtab_info__, args, ,
1745 @deftypefn {Built-in Function} {} __dump_symtab_info__ ()\n\
1746 @deftypefnx {Built-in Function} {} __dump_symtab_info__ (@var{scope})\n\
1747 @deftypefnx {Built-in Function} {} __dump_symtab_info__ (\"scopes\")\n\
1748 @deftypefnx {Built-in Function} {} __dump_symtab_info__ (\"functions\")\n\
1749 Undocumented internal function.\n\
1754 int nargin = args.
length ();
1764 for (std::list<symbol_table::scope_id>::const_iterator p = lst.begin ();
1765 p != lst.end (); p++)
1768 else if (nargin == 1)
1776 if (s_arg ==
"scopes")
1784 for (std::list<symbol_table::scope_id>::const_iterator
1785 p = lst.begin (); p != lst.end (); p++)
1790 else if (s_arg ==
"functions")
1795 error (
"__dump_symtab_info__: expecting \"functions\" or \"scopes\"");
1804 error (
"__dump_symtab_info__: expecting string or scope id");
1817 DEFUN (set_variable, args, ,
"set_variable (NAME, VALUE)")
1821 if (args.length () == 2)
1828 error (
"set_variable: expecting variable name as first argument");
1836 DEFUN (variable_value, args, ,
"VALUE = variable_value (NAME)")
1840 if (args.length () == 1)
1849 error (
"variable_value: '%s' is not a variable in the current scope",
1853 error (
"variable_value: expecting variable name as first argument");
void short_disp(std::ostream &os) const
octave_value find_user_function(void)
dispatch_map_type::iterator dispatch_map_iterator
virtual void mark_fcn_file_up_to_date(const octave_time &)
static void install_subfunction(const std::string &name, const octave_value &fcn, scope_id scope)
bool is_relative(void) const
bool same_file(const std::string &f, const std::string &g)
octave_user_function * curr_fcn
std::string help_for_dispatch(void) const
std::string str(char sep= 'x') const
static std::string find_private_fcn(const std::string &dir, const std::string &fcn, const std::string &pack_name=std::string())
octave_function * 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)
std::list< workspace_element > do_workspace_info(void) const
virtual octave_time time_checked(void) const
void dump(std::ostream &os, const std::string &prefix) const
octave_value load_private_function(const std::string &dir_name)
symbol_table * nest_parent
std::map< std::string, octave_value >::const_iterator global_table_const_iterator
static octave_value find_method(const std::string &name, const std::string &dispatch_type)
static void create_instance(void)
void do_update_nest(void)
OCTINTERP_API void print_usage(void)
octave_idx_type numel(void) const
Number of elements in the array.
static symbol_table * get_instance(scope_id scope, bool create=true)
octave_idx_type length(void) const
OCTINTERP_API context_id active_context(void) const
bool out_of_date_check(octave_value &function, const std::string &dispatch_type, bool check_relative)
static std::string find_fcn(const std::string &fcn, std::string &dir_name, const std::string &pack_name=std::string())
bool is_defined(void) const
bool is_automatic(void) const
static std::map< std::string, fcn_info > fcn_table
bool look_nonlocal(const std::string &name, symbol_record &result)
int int_value(bool req_int=false, bool frc_str_conv=false) const
void mark_subfunction_in_scope_as_private(scope_id scope, const std::string &class_name)
#define DEFUN(name, args_name, nargout_name, doc)
void error(const char *fmt,...)
std::string name(void) const
octave_value find(const octave_value_list &args=octave_value_list()) const
octave_value varval(context_id context=xdefault_context) const
bool btyp_isarray(builtin_type_t btyp)
octave_value find(const octave_value_list &args, bool local_funcs)
static void cleanup_instance(void)
bool is_newer(const octave_time &time) const
static std::map< std::string, octave_value > global_table
static void stash_dir_name_for_subfunctions(scope_id scope, const std::string &dir_name)
std::map< scope_id, octave_value >::iterator scope_val_iterator
void stash_dir_name(const std::string &dir)
static octave_function * find_method_symbol(const std::string &method_name, const std::string &class_name)
static octave_value find_function(const std::string &name, const octave_value_list &args=octave_value_list(), bool local_funcs=true)
static void dump(std::ostream &os, scope_id scope=xcurrent_scope)
symbol_table::context_id active_context() const
bool is_formal(void) const
static octave_value varval(const std::string &name, scope_id scope=xcurrent_scope, context_id context=xdefault_context)
symbol_table::scope_id parent_fcn_scope(void) const
virtual symbol_table::scope_id scope(void)
static void split_name_with_package(const std::string &name, std::string &fname, std::string &pname)
std::map< std::string, symbol_record >::iterator table_iterator
static context_id current_context(void)
octave_value load_class_method(const std::string &dispatch_type)
dispatch_map_type::const_iterator dispatch_map_const_iterator
static octave_value global_varval(const std::string &name)
std::map< std::string, fcn_info >::iterator fcn_table_iterator
static scope_id_cache * instance
virtual bool is_classdef_constructor(const std::string &=std::string()) const
static context_id xcurrent_context
static std::map< std::string, std::list< std::string > > parent_map
static std::string fcn_file_name(const octave_value &fcn)
void dump(std::ostream &os) const
F77_RET_T const double const double * f
std::map< std::string, octave_value >::const_iterator str_val_const_iterator
bool is_persistent(void) const
std::map< std::string, octave_value >::const_iterator persistent_table_const_iterator
std::string string_value(bool force=false) const
bool is_global(void) const
time_t unix_time(void) const
octave_value do_builtin_find(const std::string &name)
std::string btyp_class_name[btyp_num_types]
void mark_as_nested_function(void)
static bool is_global(const std::string &name)
bool is_string(void) const
octave_user_function * user_function_value(bool silent=false) const
std::string package_name(void) const
static int Vignore_function_time_stamp
bool is_complex_type(void) const
static void cleanup(void)
std::map< std::string, symbol_record > table
static octave_function * find_package_symbol(const std::string &pack_name)
static void assign(const std::string &name, const octave_value &value=octave_value(), scope_id scope=xcurrent_scope, context_id context=xdefault_context, bool force_add=false)
static std::string find_method(const std::string &class_name, const std::string &meth, std::string &dir_name, const std::string &pack_name=std::string())
octave_value x_builtin_find(void)
octave_idx_type length(void) const
static intmap remove_all_breakpoints_in_file(const std::string &fname, bool silent=false)
static bool absolute_pathname(const std::string &s)
octave_value builtin_find(void)
static std::list< std::string > parent_classes(const std::string &dispatch_type)
octave_value find_method(const std::string &dispatch_type)
static dim_vector alloc(int n)
static scope_id xcurrent_scope
bool btyp_isinteger(builtin_type_t btyp)
static octave_value find_autoload(const std::string &name)
static octave_user_function * get_curr_fcn(scope_id scope=xcurrent_scope)
static builtin_type_t(* build_sup_table(void))[btyp_num_types]
std::string canonical_name(void) const
static std::map< scope_id, symbol_table * > all_instances
static std::map< std::string, std::set< std::string > > class_precedence_table
octave_value xfind(const octave_value_list &args, bool local_funcs)
static bool load_out_of_date_fcn(const std::string &ff, const std::string &dir_name, octave_value &function, const std::string &dispatch_type=std::string(), const std::string &package_name=std::string())
octave_function * function_value(bool silent=false) const
static bool set_class_relationship(const std::string &sup_class, const std::string &inf_class)
static void dump_global(std::ostream &os)
std::string dir_name(void) const
std::map< scope_id, symbol_table * >::iterator all_instances_iterator
static void clear_all(bool force=false)
virtual bool is_system_fcn_file(void) const
static std::string dir_sep_chars(void)
virtual std::string fcn_file_name(void) const
octave_time Vlast_chdir_time
std::map< std::string, symbol_record >::const_iterator table_const_iterator
std::map< std::string, octave_value >::iterator str_val_iterator
void dump(std::ostream &os, const std::string &prefix) const
static symbol_table * instance
static const scope_id xtop_scope
virtual bool is_subfunction(void) const
static bool is_superiorto(const std::string &a, const std::string &b)
static std::list< scope_id > scopes(void)
static void dump_functions(std::ostream &os)
std::map< std::string, octave_value > persistent_table
std::string get_dispatch_type(const octave_value_list &args, builtin_type_t &builtin_type)
static const scope_id xglobal_scope
octave_value builtin_find(void)
std::string class_name(void) const
virtual octave_time time_parsed(void) const
bool is_undefined(void) const
static octave_value builtin_find(const std::string &name)
std::map< std::string, std::set< std::string > >::const_iterator class_precedence_table_const_iterator
void set_curr_fcn(octave_user_function *fcn)
static fcn_info * get_fcn_info(const std::string &name)
octave_value do_find(const std::string &name, const octave_value_list &args, bool skip_variables, bool local_funcs)
octave_value find_autoload(void)
static std::string dir_sep_str(void)
std::string lookup_autoload(const std::string &nm)
virtual octave_function * function_value(bool silent=false)
static void install_nestfunction(const std::string &name, const octave_value &fcn, scope_id parent_scope)
bool is_inherited(void) const
std::vector< symbol_table * > nest_children
std::map< std::string, fcn_info >::const_iterator fcn_table_const_iterator
void do_dump(std::ostream &os)
static octave_value find_user_function(const std::string &name)
static std::map< std::string, octave_value > subfunctions_defined_in_scope(scope_id scope=xcurrent_scope)
builtin_type_t builtin_type(void) const
virtual void mark_as_private_function(const std::string &cname=std::string())
octave_value find(const octave_value_list &args=octave_value_list(), bool local_funcs=true)
octave_value find_package(void)
void print_dispatch(std::ostream &os) const
return octave_value(v1.char_array_value().concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string())? '\'': '"'))
octave_value load_class_constructor(void)
std::map< scope_id, octave_value >::const_iterator scope_val_const_iterator
bool is_hidden(void) const
static scope_id current_scope(void)
static octave_value find(const std::string &name, const octave_value_list &args=octave_value_list(), bool skip_variables=false, bool local_funcs=true)