24 #if ! defined (octave_symscope_h) 25 #define octave_symscope_h 1 27 #include "octave-config.h" 41 class tree_argument_list;
53 :
public std::enable_shared_from_this<symbol_scope_rep>
57 typedef std::map<std::string, symbol_record>::const_iterator
59 typedef std::map<std::string, symbol_record>::iterator
62 typedef std::map<std::string, octave_value>::const_iterator
64 typedef std::map<std::string, octave_value>::iterator
99 std::shared_ptr<symbol_scope_rep>
dup (
void)
const 101 std::shared_ptr<symbol_scope_rep> new_sid
105 new_sid->insert_symbol_record (nm_sr.second.dup (new_sid));
133 (
const std::shared_ptr<symbol_scope_rep>& donor_scope_rep)
143 if (
nm !=
"__retval__")
147 if (
val.is_defined ())
158 void inherit (
const std::shared_ptr<symbol_scope_rep>& donor_scope_rep)
160 std::shared_ptr<symbol_scope_rep> dsr = donor_scope_rep;
166 if (dsr->is_nested ())
175 bool skip_variables,
bool local_funcs);
258 nm_sr.second.push_context ();
267 if (tbl_it->second.pop_context () == 0)
315 psr->clear_variable (
name);
339 psr->clear_variable_pattern (pat);
363 psr->clear_variable_regexp (pat);
382 std::list<symbol_record>
386 std::list<symbol_record>
retval;
402 std::list<symbol_record>
405 std::list<symbol_record>
retval;
411 if (pat.
match (nm_sr.first))
425 std::list<symbol_record>
428 std::list<symbol_record>
retval;
450 std::list<std::string>
retval;
454 if (nm_sr.second.is_variable (
m_context))
455 retval.push_back (nm_sr.first);
468 && !
p->second.is_global ()
476 return p !=
m_symbols.end () &&
p->second.is_global ();
499 nm_sf.second.lock ();
505 nm_sf.second.unlock ();
545 void set_parent (
const std::shared_ptr<symbol_scope_rep>& parent);
611 symbol_scope (
const std::shared_ptr<symbol_scope_rep> new_rep =
nullptr)
628 m_rep->insert_symbol_record (sr);
639 m_rep->mark_nested ();
650 m_rep->mark_static ();
655 return m_rep ?
m_rep->parent_scope_rep () :
nullptr;
687 bool skip_variables,
bool local_funcs)
690 ?
m_rep->find (
name, args, skip_variables, local_funcs)
704 m_rep->rename (old_name, new_name);
740 m_rep->push_context ();
746 m_rep->pop_context ();
758 m_rep->clear_variables ();
764 m_rep->clear_objects ();
776 m_rep->clear_variable_pattern (pat);
782 m_rep->clear_variable_regexp (pat);
807 std::list<symbol_record>
812 ?
m_rep->all_variables (defined_only, exclude)
813 : std::list<symbol_record> ());
816 std::list<symbol_record>
821 : std::list<symbol_record> ());
824 std::list<symbol_record>
829 : std::list<symbol_record> ());
834 return m_rep ?
m_rep->variable_names () : std::list<std::string> ();
859 m_rep->install_nestfunction (
name, fval, fcn_scope);
870 m_rep->lock_subfunctions ();
876 m_rep->unlock_subfunctions ();
882 ?
m_rep->subfunctions ()
883 : std::map<std::string, octave_value> ());
889 m_rep->erase_subfunctions ();
895 m_rep->mark_subfunctions_in_scope_as_private (class_name);
900 return m_rep ?
m_rep->has_subfunctions () :
false;
906 m_rep->stash_subfunction_names (names);
911 return m_rep ?
m_rep->subfunction_names () : std::list<std::string> ();
944 m_rep->set_parent (
p.get_rep ());
950 m_rep->update_nest ();
967 m_rep->unbind_script_symbols ();
970 std::shared_ptr<symbol_scope_rep>
get_rep (
void)
const 977 return a.m_rep ==
b.m_rep;
982 return a.m_rep !=
b.m_rep;
987 std::shared_ptr<symbol_scope_rep>
m_rep;
void set_parent(const std::shared_ptr< symbol_scope_rep > &parent)
octave_value varval(const std::string &name) const
void mark_global(const std::string &name)
void unbind_script_symbols(void)
void lock_subfunctions(void)
bool is_nested(void) const
void set_context(symbol_record::context_id context)
std::shared_ptr< symbol_scope_rep > parent_scope_rep(void) const
void stash_subfunction_names(const std::list< std::string > &names)
symbol_record::context_id current_context(void) const
symbol_record & insert(const std::string &name, bool force_add=false)
void bind_script_symbols(const std::shared_ptr< symbol_scope_rep > &curr_scope)
octave_value dump(void) const
bool is_global(void) const
void stash_subfunction_names(const std::list< std::string > &names)
void assign(const std::string &name, const octave_value &value, bool force_add)
void lock_subfunctions(void)
void unbind_script_symbols(void)
void insert_symbol_record(const symbol_record &sr)
void inherit(const symbol_scope &donor_scope)
symbol_record::context_id m_context
void assign(const octave_value &value, context_id context)
void assign(const std::string &name, const octave_value &value=octave_value())
void mark_inherited(void)
bool look_nonlocal(const std::string &name, symbol_record &result)
octave_value find(const std::string &name, const octave_value_list &args, bool skip_variables, bool local_funcs)
identity matrix If supplied two scalar respectively For allows like xample val
void inherit(const std::shared_ptr< symbol_scope_rep > &donor_scope_rep)
void mark_subfunctions_in_scope_as_private(const std::string &class_name)
void inherit_internal(const std::shared_ptr< symbol_scope_rep > &donor_scope_rep)
symbol_record find_symbol(const std::string &name)
symbol_record find_symbol(const std::string &name)
symbol_scope_rep(const std::string &name="")
unsigned int storage_class(void) const
bool is_variable(context_id context) const
void erase_subfunctions(void)
symbol_scope dup(void) const
void bind_script_symbols(const symbol_scope &curr_scope)
bool is_static(void) const
std::vector< symbol_scope > m_children
Child nested functions.
symbol_scope(const std::string &name)
void rename(const std::string &old_name, const std::string &new_name)
void clear_variable(const std::string &name)
~symbol_scope(void)=default
void assign(const std::string &name, const octave_value &value=octave_value())
static llvm::LLVMContext & context
std::map< std::string, octave_value > m_subfunctions
Map from symbol names to subfunctions.
void install_nestfunction(const std::string &name, const octave_value &fval, const symbol_scope &fcn_scope)
octave_user_function * m_fcn
The associated user code (may be null).
std::map< std::string, symbol_record > m_symbols
Map from symbol names to symbol info.
void mark_automatic(const std::string &name)
void clear_variable_regexp(const std::string &pat)
bool has_subfunctions(void) const
void install_subfunction(const std::string &name, const octave_value &fval)
bool is_local_variable(const std::string &name) const
void mark_hidden(const std::string &name)
std::map< std::string, symbol_record >::const_iterator table_const_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
bool is_global(const std::string &name) const
bool is_persistent(void) const
bool m_is_nested
If true, then this scope belongs to a nested function.
octave_value sort(octave_idx_type dim=0, sortmode mode=ASCENDING) const
std::list< symbol_record > all_variables(bool defined_only=true, unsigned int exclude=symbol_record::hidden) const
std::string name(void) const
bool m_is_static
If true then no variables can be added.
void set_function(octave_user_function *fcn)
void cache_name(const std::string &name)
std::shared_ptr< symbol_scope_rep > parent_scope(void) const
OCTAVE_EXPORT octave_value_list isdir nd deftypefn *std::string nm
void set_context(symbol_record::context_id context)
void clear(context_id context)
std::list< std::string > subfunction_names(void) const
void mark_hidden(const std::string &name)
friend bool operator==(const symbol_scope &a, const symbol_scope &b)
std::string name(void) const
std::map< std::string, octave_value > subfunctions(void) const
std::list< symbol_record > glob(const std::string &pattern, bool vars_only=false) const
void insert_symbol_record(const symbol_record &sr)
symbol_record::context_id current_context(void) const
std::shared_ptr< symbol_scope_rep > dup(void) const
bool is_valid(void) const
bool match(const std::string &str) const
void unbind_global_rep(void)
std::list< symbol_record > glob(const std::string &pattern, bool vars_only=false) const
void mark_automatic(const std::string &name)
std::shared_ptr< symbol_scope_rep > get_rep(void) const
void clear_variables(void)
void clear_variables(void)
void clear_variable(const std::string &name)
std::list< symbol_record > regexp(const std::string &pattern, bool vars_only=false) const
octave_value find_subfunction(const std::string &name) const
octave_value dump_symbols_map(void) const
void erase_subfunctions(void)
bool is_forwarded(void) const
bool is_nested(void) const
std::list< symbol_record > all_variables(bool defined_only=true, unsigned int exclude=symbol_record::hidden) const
symbol_scope_rep & operator=(const symbol_scope &)=delete
void rename(const std::string &old_name, const std::string &new_name)
std::list< std::string > subfunction_names(void) const
void force_assign(const std::string &name, const octave_value &value)
bool is_formal(void) const
bool is_variable(const std::string &name) const
std::list< std::string > variable_names(void)
bool is_automatic(void) const
bool is_match(const std::string &buffer)
bool is_static(void) const
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
void assign(const std::string &name, const octave_value &value, bool force_add)
void cache_name(const std::string &name)
octave_value varval(const std::string &name) const
With real return the complex result
void clear_variable_pattern(const std::string &pat)
std::string m_name
Name for this scope (usually the corresponding filename of the function corresponding to the scope)...
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
void unlock_subfunctions(void)
symbol_record & insert(const std::string &name, bool force_add=false)
void mark_global(const std::string &name)
bool is_variable(const std::string &name) const
void unlock_subfunctions(void)
bool has_subfunctions(void) const
std::weak_ptr< symbol_scope_rep > m_parent
Parent of nested function (may be null).
void force_assign(const std::string &name, const octave_value &value)
static const unsigned int hidden
void install_nestfunction(const std::string &name, const octave_value &fval, const symbol_scope &fcn_scope)
std::map< std::string, octave_value > subfunctions(void) const
void set_function(octave_user_function *fcn)
void mark_automatic(void)
bool is_defined(context_id context) const
std::map< std::string, octave_value >::const_iterator subfunctions_const_iterator
friend bool operator!=(const symbol_scope &a, const symbol_scope &b)
~symbol_scope_rep(void)=default
std::list< std::string > m_subfunction_names
The list of subfunctions (if any) in the order they appear in the function file.
std::map< std::string, symbol_record >::iterator table_iterator
void install_subfunction(const std::string &name, const octave_value &fval)
void rename(const std::string &new_name)
std::map< std::string, octave_value >::iterator subfunctions_iterator
octave_value varval(context_id context) const
octave_value dump(void) const
bool is_local_variable(const std::string &name) const
void set_parent(const symbol_scope &p)
octave_value find_subfunction(const std::string &name) const
std::string name(void) const
void mark_subfunctions_in_scope_as_private(const std::string &class_name)
bool is_global(const std::string &name) const
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
nd group nd example For each display the value
octave_value find(const std::string &name, const octave_value_list &args, bool skip_variables, bool local_funcs)
std::shared_ptr< symbol_scope_rep > m_rep
octave_value dump_symbols_map(void) const
symbol_scope(const std::shared_ptr< symbol_scope_rep > new_rep=nullptr)
bool look_nonlocal(const std::string &name, symbol_record &result)
void clear_variable_regexp(const std::string &pat)
std::list< std::string > variable_names(void)
void clear_variable_pattern(const std::string &pat)
symbol_scope & operator=(const symbol_scope &)=default
std::list< symbol_record > regexp(const std::string &pattern, bool vars_only=false) const