24 #if defined (HAVE_CONFIG_H)
64 std::map<std::string, std::set<std::string> >
108 os << prefix <<
name;
113 << (is_local () ?
"l" :
"")
114 << (is_automatic () ?
"a" :
"")
115 << (is_formal () ?
"f" :
"")
116 << (is_hidden () ?
"h" :
"")
117 << (is_inherited () ?
"i" :
"")
119 << (is_persistent () ?
"p" :
"")
142 retval =
rep->finfo->find (args);
162 size_t pos = name.rfind (
'.');
167 if (pos != std::string::npos)
169 fname = name.substr (pos + 1);
170 pname = name.substr (0, pos);
233 bool relative = check_relative && fcn->
is_relative ();
238 bool clear_breakpoints =
false;
243 bool is_same_file =
false;
250 int nm_len = nm.length ();
254 && (nm.substr (nm_len-4) ==
".oct"
255 || nm.substr (nm_len-4) ==
".mex"))
257 && nm.substr (nm_len-2) ==
".m")))
265 if (! dispatch_type.empty ())
275 const std::list<std::string>& plist
277 std::list<std::string>::const_iterator it
280 while (it != plist.end ())
323 clear_breakpoints =
true;
325 else if (is_same_file)
334 if (! (Vignore_function_time_stamp == 2
335 || (Vignore_function_time_stamp
349 clear_breakpoints =
true;
356 clear_breakpoints =
true;
366 dispatch_type, pack);
368 clear_breakpoints =
true;
373 if (clear_breakpoints)
392 if (! file_name.empty ())
402 if (pos != std::string::npos)
407 class_name = tmp.substr (1);
414 private_functions[dir_name] =
retval;
431 if (! file_name.empty ())
461 retval = maybe_cdef_ctor;
466 function_on_path = old_function_on_path;
480 if (full_name () == dispatch_type)
481 retval = load_class_constructor ();
497 if (! file_name.empty ())
506 class_methods[dispatch_type] =
retval;
514 const std::list<std::string>& plist =
517 std::list<std::string>::const_iterator it = plist.begin ();
519 while (it != plist.end ())
525 class_methods[dispatch_type] =
retval;
544 if (p != subfunctions.end ())
556 if (dispatch_map.empty ())
557 os <<
"dispatch: " <<
name <<
" is not overloaded" << std::endl;
560 os <<
"Overloaded function " <<
name <<
":\n\n";
563 p != dispatch_map.end ();
p++)
564 os <<
" " << name <<
" (" <<
p->first <<
", ...) -> "
565 <<
p->second <<
" (" <<
p->first <<
", ...)\n";
576 if (! dispatch_map.empty ())
578 retval =
"Overloaded function:\n\n";
581 p != dispatch_map.end ();
p++)
582 retval +=
" " +
p->second +
" (" +
p->first +
", ...)\n\n";
611 sup_table[
i][j] = use_j ? jtyp : ityp;
629 builtin_type =
args(0).builtin_type ();
632 for (i = 1; i < n; i++)
648 dispatch_type =
args(i).class_name ();
650 for (
int j = i+1; j < n; j++)
662 dispatch_type = cname;
672 return dispatch_type;
713 retval = xfind (args, local_funcs);
734 if (r != subfunctions.end ())
754 if (! dir_name.empty ())
758 if (q == private_functions.end ())
802 if (q == class_constructors.end ())
829 if (! args.
empty () && ! dispatch_map.empty ())
837 if (p == dispatch_map.end ())
838 p = dispatch_map.find (
"any");
840 if (p != dispatch_map.end ())
854 if (cmdline_function.is_defined ())
855 return cmdline_function;
873 fcn = find_package ();
880 return built_in_function;
915 retval = x_builtin_find ();
925 if (built_in_function.is_defined ())
926 return built_in_function;
944 if (cmdline_function.is_defined ())
945 return cmdline_function;
955 if (! dir_name.empty ())
959 if (q == private_functions.end ())
993 if (r != subfunctions.end ())
1018 if (q == class_methods.end ())
1051 if (autoload_function.is_defined ())
1054 if (! autoload_function.is_defined ())
1058 if (! file_name.empty ())
1072 return autoload_function;
1080 if (function_on_path.is_defined ())
1083 if (function_on_path.is_undefined ())
1090 if (! file_name.empty ())
1100 return function_on_path;
1110 if (package.is_undefined ())
1116 package = octave_value (fcn);
1162 const std::set<std::string>& inferior_classes = p->second;
1163 std::set<std::string>::const_iterator q = inferior_classes.find (b);
1164 return (q != inferior_classes.end ());
1179 os << prefix << full_name ()
1181 << (cmdline_function.is_defined () ?
"c" :
"")
1182 << (built_in_function.is_defined () ?
"b" :
"")
1183 << (package.is_defined () ?
"p" :
"")
1188 if (autoload_function.is_defined ())
1189 os << tprefix <<
"autoload: "
1192 if (function_on_path.is_defined ())
1193 os << tprefix <<
"function from path: "
1196 if (! subfunctions.empty ())
1199 p != subfunctions.end ();
p++)
1201 <<
" [" <<
p->first <<
"]\n";
1204 if (! private_functions.empty ())
1207 p != private_functions.end ();
p++)
1209 <<
" [" <<
p->first <<
"]\n";
1212 if (! class_constructors.empty ())
1215 p != class_constructors.end ();
p++)
1217 <<
" [" <<
p->first <<
"]\n";
1220 if (! class_methods.empty ())
1223 p != class_methods.end ();
p++)
1225 <<
" [" <<
p->first <<
"]\n";
1228 if (! dispatch_map.empty ())
1231 p != dispatch_map.end ();
p++)
1233 <<
" [" <<
p->first <<
"]\n";
1251 parent_table->add_nest_child (*fcn_table_loc);
1257 bool skip_variables,
1263 ? inst->
do_find (name, args, skip_variables, local_funcs)
1282 if (! name.empty () && name[0] ==
'@')
1290 if (pos != std::string::npos)
1291 method = name.substr (pos + 1);
1299 if (pos == std::string::npos)
1300 retval =
find (name, args,
true, local_funcs);
1338 size_t pos = full_name.find_first_of (
Vfilemarker);
1340 if (pos != std::string::npos)
1342 std::string fcn_scope = full_name.substr (0, pos);
1378 os <<
"*** dumping symbol table scope " << scope
1381 std::map<std::string, octave_value> sfuns
1384 if (! sfuns.empty ())
1386 os <<
" subfunctions defined in this scope:\n";
1390 p != sfuns.end ();
p++)
1391 os <<
" " <<
p->first <<
"\n";
1406 os <<
"*** dumping global symbol table\n\n";
1414 os <<
" " << nm <<
" ";
1426 os <<
"*** dumping globally visible functions from symbol table\n"
1427 <<
" (c=commandline, b=built-in)\n\n";
1431 p->second.dump (os,
" ");
1448 std::pair<std::string, octave_value>
tmp
1449 =
p->second.subfunction_defined_in_scope (scope);
1468 bool skip_variables,
1475 if (! skip_variables)
1479 if (p !=
table.end ())
1498 return p->second.find (args, local_funcs);
1522 return p->second.builtin_find ();
1538 std::list<workspace_element>
1541 std::list<workspace_element>
retval;
1576 std::ostringstream buf;
1581 short_disp_str, dv.
str (),
1584 retval.push_back (elt);
1597 os <<
" persistent variables in this scope:\n\n";
1605 os <<
" " << nm <<
" ";
1613 if (!
table.empty ())
1615 os <<
" other symbols in this scope (l=local; a=auto; f=formal\n"
1616 <<
" h=hidden; i=inherited; g=global; p=persistent)\n\n";
1619 p->second.dump (os,
" ");
1666 error (
"global and persistent may only be used in the topmost level in which a nested variable is used");
1671 ti->second = parents;
1682 ti->second.set_curr_fcn (
curr_fcn);
1685 for (std::vector<symbol_table*>::iterator iter =
nest_children.begin ();
1687 (*iter)->do_update_nest ();
1718 switch (Vignore_function_time_stamp)
1736 std::string sval =
args(0).xstring_value (
"ignore_function_time_stamp: first argument must be a string");
1739 Vignore_function_time_stamp = 2;
1740 else if (sval ==
"system")
1741 Vignore_function_time_stamp = 1;
1742 else if (sval ==
"none")
1743 Vignore_function_time_stamp = 0;
1745 error (
"ignore_function_time_stamp: argument must be one of \"all\", \"system\", or \"none\"");
1789 int nargin =
args.length ();
1804 for (std::list<symbol_table::scope_id>::const_iterator
p = lst.begin ();
1805 p != lst.end ();
p++)
1816 if (s_arg ==
"scopes")
1824 for (std::list<symbol_table::scope_id>::const_iterator
1825 p = lst.begin ();
p != lst.end ();
p++)
1830 else if (s_arg ==
"functions")
1835 error (
"__dump_symtab_info__: string argument must be \"functions\" or \"scopes\"");
1839 int s = arg.
xint_value (
"__dump_symtab_info__: first argument must be string or scope id");
1854 if (
args.length () != 1)
1857 std::string name =
args(0).xstring_value (
"__get_cmd_line_function_text__: first argument must be function name");
1867 std::ostringstream buf;
1873 retval =
ovl (buf.str ());
void short_disp(std::ostream &os) const
octave_value find_user_function(void)
dispatch_map_type::iterator dispatch_map_iterator
static std::string dir_sep_str(void)
virtual bool is_classdef_constructor(const std::string &="") const
static void install_subfunction(const std::string &name, const octave_value &fcn, scope_id scope)
For example cd octave end example noindent changes the current working directory to file
time_t unix_time(void) const
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
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
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)
OCTAVE_EXPORT octave_value_list isa nd deftypefn *return ovl(args(0).is_integer_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 std::string dir_sep_chars(void)
identity matrix If supplied two scalar respectively For allows like xample val
F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &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 F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T F77_REAL F77_REAL &F77_RET_T F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE const F77_DBLE * f
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)
int xint_value(const char *fmt,...) const
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)
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)
virtual octave::sys::time time_checked(void) const
static bool load_out_of_date_fcn(const std::string &ff, const std::string &dir_name, octave_value &function, const std::string &dispatch_type="", const std::string &package_name="")
static std::map< std::string, octave_value > global_table
static std::string find_method(const std::string &class_name, const std::string &meth, std::string &dir_name, const std::string &pack_name="")
static void stash_dir_name_for_subfunctions(scope_id scope, const std::string &dir_name)
bool is_newer(const octave::sys::time &time) const
std::map< scope_id, octave_value >::iterator scope_val_iterator
static octave_value dummy_octave_value
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)
static std::string find_private_fcn(const std::string &dir, const std::string &fcn, const std::string &pack_name="")
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)
virtual octave::sys::time time_parsed(void) const
symbol_table::scope_id parent_fcn_scope(void) const
static octave_value find_cmdline_function(const std::string &name)
virtual symbol_table::scope_id scope(void)
static std::string find_fcn(const std::string &fcn, std::string &dir_name, const std::string &pack_name="")
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
calling an anonymous function involves an overhead quite comparable to the overhead of an m file function Passing a handle to a built in function is because the interpreter is not involved in the internal loop For a
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
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
OCTAVE_EXPORT octave_value_list isdir nd deftypefn *std::string nm
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::map< std::string, octave_value >::const_iterator str_val_const_iterator
bool is_persistent(void) const
static octave_value find_submethod(const std::string &name, const std::string &dispatch_type)
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
octave_value do_builtin_find(const std::string &name)
std::string btyp_class_name[btyp_num_types]
void mark_as_nested_function(void)
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
static bool absolute_pathname(const std::string &s)
bool is_complex_type(void) const
static void cleanup(void)
virtual void mark_as_private_function(const std::string &cname="")
std::map< std::string, symbol_record > table
static octave_function * find_package_symbol(const std::string &pack_name)
octave_value x_builtin_find(void)
static intmap remove_all_breakpoints_in_file(const std::string &fname, bool silent=false)
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 symbol_record dummy_symbol_record
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]
octave::sys::time Vlast_chdir_time
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)
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
virtual std::string fcn_file_name(void) const
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 bool is_global(const std::string &name, scope_id scope=xcurrent_scope)
static symbol_table * instance
static const scope_id xtop_scope
virtual void mark_fcn_file_up_to_date(const octave::sys::time &)
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)
=val(i)}if ode{val(i)}occurs in table i
static void dump_functions(std::ostream &os)
__current_scope__() Return the current scope and context as integers.eealso
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)
octave_idx_type ndims(void) const
Number of dimensions.
std::string class_name(void) const
bool is_undefined(void) const
octave::sys::file_stat fs(filename)
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)
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)
Vector representing the dimensions (size) of an Array.
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)
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
builtin_type_t builtin_type(void) const
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)
void accept(tree_walker &tw)
static octave_value find(const std::string &name, const octave_value_list &args=octave_value_list(), bool skip_variables=false, bool local_funcs=true)