26 #if defined (HAVE_CONFIG_H)
54 : m_interpreter (interp), m_fcn_table (), m_class_precedence_table (),
83 fcn_table_const_iterator p = m_fcn_table.find (name);
85 if (p != m_fcn_table.end ())
86 return p->second.find_scoped_function (search_scope);
94 m_fcn_table[name] = finfo;
102 const std::string& name)
107 fcn_table_const_iterator p = m_fcn_table.find (name);
109 if (p != m_fcn_table.end ())
110 return p->second.find_private_function (dir_name);
118 m_fcn_table[name] = finfo;
129 const std::string& dispatch_type)
134 fcn_table_const_iterator p = m_fcn_table.find (name);
136 if (p != m_fcn_table.end ())
137 return p->second.find_method (dispatch_type);
145 m_fcn_table[name] = finfo;
154 fcn_table_const_iterator p = m_fcn_table.find (name);
156 if (p != m_fcn_table.end ())
157 return p->second.find_built_in_function ();
165 m_fcn_table[name] = finfo;
177 auto p = m_fcn_table.find (name);
179 if (p != m_fcn_table.end ())
180 return p->second.find_autoload ();
188 m_fcn_table[name] = finfo;
201 fcn_table_iterator p = m_fcn_table.find (name);
206 if (p != m_fcn_table.end ())
207 return p->second.builtin_find (search_scope);
215 m_fcn_table[name] = finfo;
231 fcn_table_iterator p = m_fcn_table.find (name);
236 if (p != m_fcn_table.end ())
237 return p->second.find (search_scope, args);
245 m_fcn_table[name] = finfo;
262 std::size_t pos = name.find_first_of (
'/');
264 if (pos == std::string::npos)
267 std::string method = name.substr (pos+1);
268 std::string dispatch_type = name.substr (1, pos-1);
298 auto p = m_fcn_table.find (name);
300 if (p != m_fcn_table.end ())
301 return p->second.find_user_function ();
309 m_fcn_table[name] = finfo;
321 auto p = m_fcn_table.find (name);
323 if (p != m_fcn_table.end ())
324 return p->second.find_cmdline_function ();
332 m_fcn_table[name] = finfo;
342 auto p = m_fcn_table.find (name);
344 if (p != m_fcn_table.end ())
356 m_fcn_table[name] = finfo;
366 const std::string& file_name)
368 auto p = m_fcn_table.find (name);
370 if (p != m_fcn_table.end ())
382 m_fcn_table[name] = finfo;
390 auto p = m_fcn_table.find (name);
392 if (p != m_fcn_table.end ())
404 m_fcn_table[name] = finfo;
414 auto p = m_fcn_table.find (name);
416 if (p != m_fcn_table.end ())
428 m_fcn_table[name] = finfo;
439 auto p = m_fcn_table.begin ();
441 while (p != m_fcn_table.end ())
442 (p++)->second.clear (force);
456 auto p = m_fcn_table.begin ();
458 while (p != m_fcn_table.end ())
460 if (pattern.
match (p->first))
461 (p++)->second.clear_user_function ();
472 auto p = m_fcn_table.begin ();
474 while (p != m_fcn_table.end ())
477 (p++)->second.clear_user_function ();
486 auto p = m_fcn_table.find (name);
488 if (p != m_fcn_table.end ())
503 auto p = m_fcn_table.find (name);
505 if (p != m_fcn_table.end ())
517 auto p = m_fcn_table.begin ();
519 while (p != m_fcn_table.end ())
520 (p++)->second.clear_mex_function ();
529 const std::string& inf_class)
537 m_class_precedence_table[sup_class].insert (inf_class);
558 class_precedence_table_const_iterator p = m_class_precedence_table.find (a);
560 if (p == m_class_precedence_table.end ())
563 const std::set<std::string>& inferior_classes = p->second;
564 std::set<std::string>::const_iterator q = inferior_classes.find (b);
565 return (q != inferior_classes.end ());
570 const std::string& name)
580 m_fcn_table[alias] = finfo;
583 panic (
"alias: '%s' is undefined", name.c_str ());
588 const std::string& klass)
590 auto p = m_fcn_table.find (name);
592 if (p != m_fcn_table.end ())
599 error (
"install_built_in_dispatch: '%s' is undefined", name.c_str ());
602 std::list<std::string>
605 std::list<std::string> retval;
607 for (
const auto& nm_finfo : m_fcn_table)
609 if (nm_finfo.second.is_user_function_defined ())
610 retval.push_back (nm_finfo.first);
613 if (! retval.empty ())
619 std::list<std::string>
622 std::list<std::string> retval;
624 for (
const auto& nm_finfo : m_fcn_table)
626 octave_value fcn = nm_finfo.second.find_built_in_function ();
629 retval.push_back (nm_finfo.first);
632 if (! retval.empty ())
638 std::list<std::string>
641 std::list<std::string> retval;
643 for (
const auto& nm_finfo : m_fcn_table)
645 octave_value fcn = nm_finfo.second.find_cmdline_function ();
648 retval.push_back (nm_finfo.first);
651 if (! retval.empty ())
657 template <
template <
typename,
typename...>
class C,
typename V,
660 dump_container_map (
const std::map<std::string, C<V, A...>>& container_map)
662 if (container_map.empty ())
665 std::map<std::string, octave_value> info_map;
667 for (
const auto& nm_container : container_map)
669 std::string nm = nm_container.first;
670 const C<
V,
A...>& container = nm_container.second;
671 info_map[nm] =
Cell (container);
680 std::map<std::string, octave_value>
m
681 = {{
"function_info", dump_fcn_table_map () },
682 {
"precedence_table", dump_container_map (m_class_precedence_table) },
683 {
"parent_classes", dump_container_map (m_parent_map) }
691 const std::list<std::string>& parent_list)
693 m_parent_map[classname] = parent_list;
696 std::list<std::string>
699 std::list<std::string> retval;
701 const_parent_map_iterator it = m_parent_map.find (dispatch_type);
703 if (it != m_parent_map.end ())
706 for (
const auto& nm : retval)
714 if (! parents.empty ())
715 retval.insert (retval.end (), parents.begin (), parents.end ());
726 m_fcn_table.clear ();
727 m_class_precedence_table.clear ();
728 m_parent_map.clear ();
734 auto p = m_fcn_table.find (name);
735 return p != m_fcn_table.end () ? &p->second :
nullptr;
739 symbol_table::dump_fcn_table_map ()
const
741 if (m_fcn_table.empty ())
744 std::map<std::string, octave_value> info_map;
746 for (
const auto& nm_finfo : m_fcn_table)
748 std::string nm = nm_finfo.first;
749 const fcn_info& finfo = nm_finfo.second;
750 info_map[nm] = finfo.
dump ();
756 DEFMETHOD (__dump_symtab_info__, interp, args, ,
763 int nargin = args.length ();
771 return symtab.
dump ();
774 std::string fname = args(0).
xstring_value (
"__dump_symtab_info__: argument must be a function name");
779 return finfo->
dump ();
785 DEFMETHOD (__get_cmdline_fcn_txt__, interp, args, ,
791 if (args.length () != 1)
794 std::string name = args(0).xstring_value (
"__get_cmdline_fcn_txt__: first argument must be function name");
806 std::ostringstream buf;
812 retval =
ovl (buf.str ());
882 OCTAVE_END_NAMESPACE(
octave)
octave_value find_method(const std::string &dispatch_type) const
octave_value find_user_function()
octave_value find_scoped_function(const symbol_scope &search_scope) const
void install_built_in_dispatch(const std::string &klass)
octave_value builtin_find(const symbol_scope &search_scope)
octave_value dump() const
octave_value find_built_in_function() const
void clear_autoload_function(bool force=false)
octave_value find_autoload()
octave_value find_cmdline_function() const
void install_user_function(const octave_value &f)
void install_local_function(const octave_value &f, const std::string &file_name)
void install_cmdline_function(const octave_value &f)
octave_value find(const symbol_scope &search_scope, const octave_value_list &args=octave_value_list())
void clear_user_function(bool force=false)
octave_value find_private_function(const std::string &dir_name) const
void install_built_in_function(const octave_value &f)
tree_evaluator & get_evaluator()
octave_user_function * user_function_value(bool silent=false) const
octave_value sort(octave_idx_type dim=0, sortmode mode=ASCENDING) const
std::string xstring_value(const char *fmt,...) const
bool is_match(const std::string &buffer) const
bool match(const std::string &sym)
octave_value find_scoped_function(const std::string &name, const symbol_scope &search_scope)
octave_value find_method(const std::string &name, const std::string &dispatch_type)
bool is_built_in_function_name(const std::string &name)
octave_value find_private_function(const std::string &dir_name, const std::string &name)
void clear_function(const std::string &name)
void clear_function_pattern(const std::string &pat)
octave_value builtin_find(const std::string &name, const symbol_scope &search_scope=symbol_scope::invalid())
void clear_functions(bool force=false)
void alias_built_in_function(const std::string &alias, const std::string &name)
void add_to_parent_map(const std::string &classname, const std::list< std::string > &parent_list)
fcn_info * get_fcn_info(const std::string &name)
void install_cmdline_function(const std::string &name, const octave_value &fcn)
void clear_user_function(const std::string &name)
octave_value find_function(const std::string &name, const symbol_scope &search_scope=symbol_scope::invalid())
void install_user_function(const std::string &name, const octave_value &fcn)
void clear_dld_function(const std::string &name)
void clear_mex_functions()
octave_value find_cmdline_function(const std::string &name)
octave_value dump() const
void install_built_in_function(const std::string &name, const octave_value &fcn)
void install_built_in_dispatch(const std::string &name, const std::string &klass)
octave_value fcn_table_find(const std::string &name, const octave_value_list &args=ovl(), const symbol_scope &search_scope=symbol_scope::invalid())
octave_value find_built_in_function(const std::string &name)
std::list< std::string > cmdline_function_names()
bool is_superiorto(const std::string &a, const std::string &b)
std::list< std::string > built_in_function_names()
std::list< std::string > user_function_names()
symbol_scope current_scope() const
octave_value find_autoload(const std::string &name)
octave_value find_user_function(const std::string &name)
void clear_function_regexp(const std::string &pat)
void install_local_function(const std::string &name, const octave_value &fcn, const std::string &file_name)
bool set_class_relationship(const std::string &sup_class, const std::string &inf_class)
std::list< std::string > parent_classes(const std::string &dispatch_type)
symbol_scope get_current_scope() const
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
#define DEFMETHOD(name, interp_name, args_name, nargout_name, doc)
Macro to define a builtin method.
OCTAVE_NORETURN void panic(const char *fmt,...)
void() error(const char *fmt,...)
F77_RET_T const F77_INT const F77_INT const F77_INT const F77_DBLE const F77_DBLE F77_INT F77_DBLE * V
F77_RET_T const F77_INT F77_CMPLX * A
F77_RET_T const F77_DBLE const F77_DBLE * f
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.