26 #if ! defined (octave_symscope_h)
27 #define octave_symscope_h 1
29 #include "octave-config.h"
54 :
public std::enable_shared_from_this<symbol_scope_rep>
58 typedef std::map<std::string, symbol_record>::const_iterator
60 typedef std::map<std::string, symbol_record>::iterator
63 typedef std::map<std::string, octave_value>::const_iterator
65 typedef std::map<std::string, octave_value>::iterator
118 std::shared_ptr<symbol_scope_rep>
dup (
void)
const
120 std::shared_ptr<symbol_scope_rep> new_sid
124 new_sid->m_symbols[nm_sr.first] = nm_sr.second.dup ();
174 void rename (
const std::string& old_name,
const std::string& new_name)
210 nm_sf.second.lock ();
216 nm_sf.second.unlock ();
265 void set_parent (
const std::shared_ptr<symbol_scope_rep>& parent);
284 bool is_relative (
const std::shared_ptr<symbol_scope_rep>& scope)
const;
298 const std::map<std::string, symbol_record>&
symbols (
void)
const
303 std::map<std::string, symbol_record>&
symbols (
void)
385 symbol_scope (
const std::shared_ptr<symbol_scope_rep> new_rep =
nullptr)
397 explicit operator bool ()
const {
return bool (
m_rep); }
412 m_rep->insert_symbol_record (sr);
428 m_rep->set_nesting_depth (depth);
444 m_rep->mark_static ();
449 return m_rep ?
m_rep->parent_scope_rep () :
nullptr;
454 return m_rep ?
m_rep->primary_parent_scope_rep () :
nullptr;
466 return m_rep ?
m_rep->persistent_varref (data_offset) : dummy_value;
490 void rename (
const std::string& old_name,
const std::string& new_name)
493 m_rep->rename (old_name, new_name);
508 m_rep->install_nestfunction (
name, fval, fcn_scope);
519 m_rep->lock_subfunctions ();
525 m_rep->unlock_subfunctions ();
531 ?
m_rep->subfunctions ()
532 : std::map<std::string, octave_value> ());
538 m_rep->erase_subfunctions ();
544 m_rep->mark_subfunctions_in_scope_as_private (class_name);
549 return m_rep ?
m_rep->has_subfunctions () :
false;
555 m_rep->stash_subfunction_names (names);
560 return m_rep ?
m_rep->subfunction_names () : std::list<std::string> ();
595 return m_rep ?
m_rep->parent_fcn_names () : std::list<std::string> ();
606 m_rep->set_user_code (code);
646 m_rep->mark_primary_fcn_scope ();
651 return m_rep ?
m_rep->is_primary_fcn_scope () :
false;
662 m_rep->mark_as_variable (nm);
668 m_rep->mark_as_variables (lst);
673 return m_rep ?
m_rep->is_variable (nm) :
false;
679 m_rep->update_nest ();
685 return m_rep ?
m_rep->look_nonlocal (
name, offset, result) :
false;
688 std::shared_ptr<symbol_scope_rep>
get_rep (
void)
const
703 const std::map<std::string, symbol_record>&
symbols (
void)
const
705 static const std::map<std::string, symbol_record> empty_map;
710 std::map<std::string, symbol_record>&
symbols (
void)
712 static std::map<std::string, symbol_record> empty_map;
719 static const std::list<symbol_record> empty_list;
721 return m_rep ?
m_rep->symbol_list () : empty_list;
726 std::shared_ptr<symbol_scope_rep>
m_rep;
void rename(const std::string &new_name)
bool has_subfunctions(void) const
symbol_record insert_local(const std::string &name)
std::string m_name
Name for this scope (usually the corresponding filename of the function corresponding to the scope).
std::map< std::string, symbol_record > m_symbols
Map from symbol names to symbol info.
std::list< octave_value > localfunctions(void) const
void mark_subfunctions_in_scope_as_private(const std::string &class_name)
octave_user_code * m_code
The associated user code (may be null).
std::map< std::string, symbol_record > & symbols(void)
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, octave_value > m_subfunctions
Map from symbol names to subfunctions.
octave_value dump(void) const
void erase_subfunctions(void)
void rename(const std::string &old_name, const std::string &new_name)
void unlock_subfunctions(void)
bool m_is_primary_fcn_scope
If true, this is the scope of a primary function.
std::map< std::string, octave_value >::iterator subfunctions_iterator
std::string dir_name(void) const
void cache_fcn_file_name(const std::string &name)
std::map< std::string, octave_value > subfunctions(void) const
void cache_dir_name(const std::string &name)
bool m_is_static
If true then no variables can be added.
bool is_relative(const std::shared_ptr< symbol_scope_rep > &scope) const
octave_user_code * user_code(void) const
std::shared_ptr< symbol_scope_rep > parent_scope_rep(void) const
bool is_static(void) const
std::list< symbol_record > symbol_list(void) const
std::string name(void) const
void set_nesting_depth(std::size_t depth)
std::weak_ptr< symbol_scope_rep > m_primary_parent
Primary (top) parent of nested function (may be null).
symbol_scope_rep(const std::string &name="")
void cache_fcn_name(const std::string &name)
bool is_primary_fcn_scope(void) const
symbol_scope_rep & operator=(const symbol_scope &)=delete
void set_primary_parent(const std::shared_ptr< symbol_scope_rep > &parent)
bool is_parent(void) const
std::map< std::string, symbol_record >::iterator table_iterator
symbol_record find_symbol(const std::string &name)
void mark_as_variables(const std::list< std::string > &lst)
void install_nestfunction(const std::string &name, const octave_value &fval, const symbol_scope &fcn_scope)
bool is_variable(const std::string &nm) const
std::map< std::string, octave_value >::const_iterator subfunctions_const_iterator
std::string m_fcn_file_name
The file name associated with m_code.
void mark_primary_fcn_scope(void)
void cache_name(const std::string &name)
void stash_subfunction_names(const std::list< std::string > &names)
void lock_subfunctions(void)
symbol_record insert(const std::string &name)
std::string fcn_file_name(void) const
octave_value find_subfunction(const std::string &name) const
std::string fcn_name(void) const
octave_value & persistent_varref(std::size_t data_offset)
std::string m_fcn_name
Simple name of the function corresponding to this scope.
void set_user_code(octave_user_code *code)
std::list< std::string > parent_fcn_names(void) const
std::size_t m_nesting_depth
If true, then this scope belongs to a nested function.
std::list< std::string > subfunction_names(void) const
std::string m_dir_name
The directory associated with m_code.
void set_parent(const std::shared_ptr< symbol_scope_rep > &parent)
~symbol_scope_rep(void)=default
std::shared_ptr< symbol_scope_rep > dup(void) const
std::map< std::size_t, octave_value > m_persistent_values
Map from data offset to persistent values in this scope.
std::vector< symbol_scope > m_children
Child nested functions.
octave_value dump_symbols_map(void) const
bool is_nested(void) const
void mark_as_variable(const std::string &nm)
std::size_t num_symbols(void) const
std::size_t nesting_depth(void) const
symbol_record lookup_symbol(const std::string &name) const
std::map< std::string, symbol_record >::const_iterator table_const_iterator
octave_value persistent_varval(std::size_t data_offset) const
void insert_symbol_record(symbol_record &sr)
const std::map< std::string, symbol_record > & symbols(void) const
std::weak_ptr< symbol_scope_rep > m_parent
Parent of nested function (may be null).
bool look_nonlocal(const std::string &name, std::size_t offset, symbol_record &result)
symbol_scope_rep(const symbol_scope &)=delete
void install_subfunction(const std::string &name, const octave_value &fval)
std::shared_ptr< symbol_scope_rep > primary_parent_scope_rep(void) const
std::list< std::string > parent_fcn_names(void) const
std::list< symbol_record > symbol_list(void) const
friend bool operator==(const symbol_scope &a, const symbol_scope &b)
friend bool operator!=(const symbol_scope &a, const symbol_scope &b)
symbol_record insert_local(const std::string &name)
void mark_primary_fcn_scope(void)
bool is_valid(void) const
std::shared_ptr< symbol_scope_rep > parent_scope(void) const
void lock_subfunctions(void)
void set_user_code(octave_user_code *code)
void insert_symbol_record(symbol_record &sr)
void stash_subfunction_names(const std::list< std::string > &names)
std::string fcn_file_name(void) const
std::list< std::string > subfunction_names(void) const
void cache_fcn_name(const std::string &name)
octave_value dump(void) const
void mark_as_variable(const std::string &nm)
symbol_scope(const std::string &name)
bool is_parent(void) const
octave_value find_subfunction(const std::string &name) const
bool is_variable(const std::string &nm) const
bool has_subfunctions(void) const
std::string dir_name(void) const
symbol_record find_symbol(const std::string &name)
std::size_t nesting_depth(void) const
symbol_scope(const symbol_scope &)=default
void set_parent(const symbol_scope &p)
bool is_nested(void) const
void mark_as_variables(const std::list< std::string > &lst)
void install_subfunction(const std::string &name, const octave_value &fval)
std::shared_ptr< symbol_scope_rep > primary_parent_scope(void) const
bool is_static(void) const
std::string name(void) const
symbol_scope & operator=(const symbol_scope &)=default
std::size_t num_symbols(void) const
octave_value persistent_varval(std::size_t data_offset) const
symbol_record insert(const std::string &name)
void cache_fcn_file_name(const std::string &name)
symbol_scope dup(void) const
const std::map< std::string, symbol_record > & symbols(void) const
std::shared_ptr< symbol_scope_rep > m_rep
std::string fcn_name(void) const
void erase_subfunctions(void)
octave_value & persistent_varref(std::size_t data_offset)
std::shared_ptr< symbol_scope_rep > get_rep(void) const
void set_nesting_depth(std::size_t depth)
void rename(const std::string &old_name, const std::string &new_name)
void set_primary_parent(const symbol_scope &p)
octave_user_code * user_code(void) const
bool is_relative(const symbol_scope &scope) const
void unlock_subfunctions(void)
std::map< std::string, symbol_record > & symbols(void)
std::list< octave_value > localfunctions(void) const
std::map< std::string, octave_value > subfunctions(void) const
symbol_record lookup_symbol(const std::string &name) const
~symbol_scope(void)=default
void mark_subfunctions_in_scope_as_private(const std::string &class_name)
void cache_name(const std::string &name)
void install_nestfunction(const std::string &name, const octave_value &fval, const symbol_scope &fcn_scope)
void cache_dir_name(const std::string &name)
bool is_primary_fcn_scope(void) const
symbol_scope(const std::shared_ptr< symbol_scope_rep > new_rep=nullptr)
bool look_nonlocal(const std::string &name, std::size_t offset, symbol_record &result)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))