24 #if ! defined (octave_symtab_h) 25 #define octave_symtab_h 1 27 #include "octave-config.h" 40 class tree_argument_list;
59 : m_fcn_table (), m_class_precedence_table (),
60 m_parent_map (), m_global_scope (
"global scope"),
61 m_top_scope (
"top scope"), m_current_scope (m_top_scope)
81 if (! m_current_scope)
82 error (
"%s: missing scope", who.c_str ());
84 return m_current_scope;
89 return m_current_scope ? m_current_scope.current_context () : 0;
94 set_scope_and_context (sid, 0);
100 if (sid == m_global_scope)
101 error (
"can't set scope to global");
103 m_current_scope = sid;
116 return find_symbol (
name, m_current_scope);
132 recipient_scope.
inherit (donor_scope);
137 inherit (recipient_scope, m_current_scope);
146 bool skip_variables =
false,
147 bool local_funcs =
true);
152 m_current_scope.assign (
name,
value, force_add);
164 return (m_current_scope
176 return m_global_scope.varval (
name);
188 return m_top_scope.varval (
name);
196 return val.is_defined ();
204 if (
p != m_fcn_table.end ())
209 fcn = find_submethod (
name, dispatch_type);
220 fcn = find_submethod (
name, dispatch_type);
223 m_fcn_table[
name] = finfo;
237 return (
p != m_fcn_table.end ()
246 return (
p != m_fcn_table.end ()
255 bool local_funcs =
true);
260 bool local_funcs =
true);
266 return (
p != m_fcn_table.end ()
274 return (
p != m_fcn_table.end ()
283 if (
p != m_fcn_table.end ())
295 m_fcn_table[
name] = finfo;
308 if (
p != m_fcn_table.end ())
320 m_fcn_table[
name] = finfo;
329 if (
p != m_fcn_table.end ())
341 m_fcn_table[
name] = finfo;
352 if (
p != m_fcn_table.end ())
364 m_fcn_table[
name] = finfo;
370 m_current_scope.clear_variables ();
371 m_global_scope.clear_variables ();
373 clear_functions (force);
388 while (
p != m_fcn_table.end ())
389 (
p++)->second.clear (force);
394 clear_user_function (
name);
402 m_current_scope.clear_variable (
name);
413 while (
p != m_fcn_table.end ())
416 (
p++)->second.clear_user_function ();
427 m_current_scope.clear_variable_pattern (pat);
429 clear_function_pattern (pat);
436 if (
p != m_fcn_table.end ())
452 if (
p != m_fcn_table.end ())
465 while (
p != m_fcn_table.end ())
466 (
p++)->second.clear_mex_function ();
469 bool set_class_relationship (
const std::string& sup_class,
485 m_fcn_table[alias] = finfo;
488 panic (
"alias: '%s' is undefined",
name.c_str ());
496 if (
p != m_fcn_table.end ())
503 error (
"install_built_in_dispatch: '%s' is undefined",
name.c_str ());
508 return (m_current_scope
509 ? m_current_scope.glob (
pattern) : std::list<symbol_record> ());
514 return m_global_scope.glob (
pattern);
517 std::list<symbol_record>
520 return m_global_scope.regexp (
pattern);
525 std::list<symbol_record>
retval;
527 if (! m_current_scope)
530 size_t len = patterns.
numel ();
532 for (
size_t i = 0;
i < len;
i++)
534 std::list<symbol_record>
tmp = m_current_scope.glob (patterns[
i]);
544 std::list<symbol_record>
retval;
546 if (! m_current_scope)
549 size_t len = patterns.
numel ();
551 for (
size_t i = 0;
i < len;
i++)
553 std::list<symbol_record>
tmp = m_current_scope.regexp (patterns[
i]);
563 std::list<std::string>
retval;
565 for (
const auto& nm_finfo : m_fcn_table)
567 if (nm_finfo.second.is_user_function_defined ())
568 retval.push_back (nm_finfo.first);
579 return m_global_scope.variable_names ();
585 ? m_top_scope.variable_names () : std::list<std::string> ());
590 return (m_current_scope
591 ? m_current_scope.variable_names () : std::list<std::string> ());
596 std::list<std::string>
retval;
598 for (
const auto& nm_finfo : m_fcn_table)
603 retval.push_back (nm_finfo.first);
614 std::list<std::string>
retval;
616 for (
const auto& nm_finfo : m_fcn_table)
621 retval.push_back (nm_finfo.first);
633 const std::list<std::string>& parent_list)
635 m_parent_map[classname] = parent_list;
638 std::list<std::string>
641 std::list<std::string>
retval;
645 if (it != m_parent_map.end ())
654 std::list<std::string> parents = parent_classes (
nm);
656 if (! parents.empty ())
657 retval.insert (
retval.end (), parents.begin (), parents.end ());
665 return m_current_scope ? m_current_scope.function () :
nullptr;
673 return p != m_fcn_table.end () ? &
p->second :
nullptr;
678 typedef std::map<std::string, octave_value>::const_iterator
680 typedef std::map<std::string, octave_value>::iterator
683 typedef std::map<std::string, fcn_info>::const_iterator
685 typedef std::map<std::string, fcn_info>::iterator
698 typedef std::map<std::string, std::set<std::string>>::const_iterator
700 typedef std::map<std::string, std::set<std::string>>::iterator
706 typedef std::map<std::string, std::list<std::string>>::const_iterator
708 typedef std::map<std::string, std::list<std::string>>::iterator
719 void install_builtins (
void);
724 bool check_relative =
true);
std::list< std::string > built_in_function_names(void)
void install_built_in_dispatch(const std::string &name, const std::string &klass)
void panic(const char *fmt,...)
OCTINTERP_API void clear_function(const std::string &nm)
void assign(const std::string &name, const octave_value &value=octave_value())
void set_context(symbol_record::context_id context)
symbol_record find_symbol(const std::string &name, symbol_scope &sid)
symbol_scope top_scope(void)
octave_user_function * get_curr_fcn(void)
for(octave_idx_type n=0;n< hcv.numel();n++)
symbol_record::context_id current_context(void) const
octave_value varval(const std::string &name) const
std::map< std::string, std::list< std::string > >::const_iterator const_parent_map_iterator
void inherit(const symbol_scope &donor_scope)
void clear_dld_function(const std::string &name)
bool is_built_in_function_name(const std::string &name)
symbol_scope global_scope(void)
void alias_built_in_function(const std::string &alias, const std::string &name)
void install_built_in_function(const std::string &name, const octave_value &fcn)
identity matrix If supplied two scalar respectively For allows like xample val
symbol_scope current_scope(void)
void install_built_in_function(const octave_value &f)
symbol_record find_symbol(const std::string &name)
void clear_user_function(bool force=false)
void install_user_function(const std::string &name, const octave_value &fcn)
std::list< std::string > cmdline_function_names(void)
std::map< std::string, fcn_info >::iterator fcn_table_iterator
void install_local_function(const octave_value &f, const std::string &file_name)
void error(const char *fmt,...)
void clear_all(bool force=false)
std::list< symbol_record > regexp_variables(const string_vector &patterns)
symbol_record find_symbol(const std::string &name)
std::map< std::string, std::set< std::string > >::const_iterator class_precedence_table_const_iterator
static llvm::LLVMContext & context
void assign(const std::string &name, const octave_value &value, bool force_add)
std::list< symbol_record > glob_variables(const string_vector &patterns)
std::list< std::string > parent_classes(const std::string &dispatch_type)
bool is_defined(void) const
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
std::map< std::string, std::list< std::string > > m_parent_map
octave_value find_autoload(const std::string &name)
octave_value sort(octave_idx_type dim=0, sortmode mode=ASCENDING) const
void install_built_in_dispatch(const std::string &klass)
std::list< symbol_record > glob(const std::string &pattern)
void install_local_function(const std::string &name, const octave_value &fcn, const std::string &file_name)
nd deftypefn *std::string name
std::list< std::string > user_function_names(void)
OCTAVE_EXPORT octave_value_list isdir nd deftypefn *std::string nm
void inherit(symbol_scope &recipient_scope, const symbol_scope &donor_scope)
void install_cmdline_function(const octave_value &f)
std::map< std::string, std::set< std::string > > m_class_precedence_table
std::map< std::string, std::list< std::string > >::iterator parent_map_iterator
std::string get_dispatch_type(const octave_value_list &args, builtin_type_t &builtin_type)
void set_scope_and_context(const symbol_scope &sid, symbol_record::context_id context)
octave::symbol_record symbol_record
octave::fcn_info fcn_info
std::list< std::string > global_variable_names(void)
octave_value find_method(const std::string &name, const std::string &dispatch_type)
std::map< std::string, fcn_info >::const_iterator fcn_table_const_iterator
octave_value find_method(const std::string &dispatch_type) const
symbol_scope require_current_scope(const std::string &who)
symbol_scope m_global_scope
is longer than or if then or only for unique occurrences of the complete pattern(false). The default is true. If a cell array of strings ar
std::map< std::string, octave_value >::iterator global_symbols_iterator
void install_user_function(const octave_value &f)
symbol_record find_global_symbol(const std::string &name)
octave_value find_user_function(const std::string &name)
static octave_idx_type find(octave_idx_type i, octave_idx_type *pp)
void clear_mex_functions(void)
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
fcn_info * get_fcn_info(const std::string &name)
std::map< std::string, std::set< std::string > >::iterator class_precedence_table_iterator
void add_to_parent_map(const std::string &classname, const std::list< std::string > &parent_list)
octave_value global_varval(const std::string &name) const
std::map< std::string, fcn_info > m_fcn_table
octave_value top_level_varval(const std::string &name) const
octave::symbol_scope scope
bool out_of_date_check(octave_value &function, const std::string &dispatch_type, bool check_relative)
void clear_functions(bool force=false)
void clear_symbol(const std::string &name)
symbol_scope m_current_scope
void inherit(symbol_scope &recipient_scope)
void clear_function_pattern(const std::string &pat)
void clear_function(const std::string &name)
void set_scope(const symbol_scope &sid)
std::list< std::string > variable_names(void)
void clear_symbol_pattern(const std::string &pat)
void clear_user_function(const std::string &name)
octave_value find_built_in_function(const std::string &name)
octave_idx_type numel(void) const
Number of elements in the array.
void install_cmdline_function(const std::string &name, const octave_value &fcn)
octave_value find_cmdline_function(const std::string &name)
std::list< std::string > top_level_variable_names(void)
void clear_autoload_function(bool force=false)
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
void global_assign(const std::string &name, const octave_value &value=octave_value())
nd group nd example For each display the value
void top_level_assign(const std::string &name, const octave_value &value=octave_value())
std::map< std::string, octave_value >::const_iterator global_symbols_const_iterator
std::list< symbol_record > regexp_global_variables(const std::string &pattern)
std::list< symbol_record > glob_global_variables(const std::string &pattern)