24 #if !defined (octave_symtab_h)
25 #define octave_symtab_h 1
70 static scope_id alloc (
void)
72 return instance_ok () ? instance->do_alloc () : -1;
75 static void free (scope_id
scope)
78 return instance->do_free (scope);
81 static std::list<scope_id> scopes (
void)
83 return instance_ok () ? instance->do_scopes () : std::list<scope_id> ();
86 static void create_instance (
void);
88 static bool instance_ok (
void)
97 ::error (
"unable to create scope_id_cache object!");
126 scope_id do_alloc (
void)
130 set_iterator p = free_list.begin ();
132 if (p != free_list.end ())
138 retval = next_available++;
140 in_use.insert (retval);
147 set_iterator p = in_use.find (scope);
149 if (p != in_use.end ())
152 free_list.insert (scope);
155 error (
"free_scope: scope %d not found!", scope);
158 std::list<scope_id> do_scopes (
void)
const
160 std::list<scope_id> retval;
162 for (set_const_iterator p = in_use.begin (); p != in_use.end (); p++)
163 retval.push_back (*p);
179 static const unsigned int local = 1;
183 static const unsigned int automatic = 2;
186 static const unsigned int formal = 4;
189 static const unsigned int hidden = 8;
192 static const unsigned int inherited = 16;
195 static const unsigned int global = 32;
198 static const unsigned int persistent = 64;
202 static const unsigned int added_static = 128;
213 : decl_scope (s), curr_fcn (0), name (nm), value_stack (),
214 storage_class (sc), finfo (), valid (true), count (1)
216 value_stack.push_back (v);
220 context_id
context = xdefault_context)
226 const std::string&
type,
227 const std::list<octave_value_list>& idx,
229 context_id
context = xdefault_context)
235 context_id
context = xdefault_context)
241 context_id
context = xdefault_context)
247 const std::string&
type,
248 const std::list<octave_value_list>& idx,
249 context_id
context = xdefault_context)
267 else if (is_persistent ())
278 if (
context == xdefault_context)
281 context_id n = value_stack.size ();
293 else if (is_persistent ())
297 if (
context == xdefault_context)
300 if (
context < value_stack.size ())
307 void push_context (scope_id s)
309 if (! (is_persistent () || is_global ())
328 size_t pop_context (scope_id s)
332 if (! (is_persistent () || is_global ())
335 value_stack.pop_back ();
336 retval = value_stack.size ();
346 if (! (is_hidden () || is_inherited ())
352 if (is_persistent ())
356 unmark_persistent ();
363 bool is_defined (context_id
context = xdefault_context)
const
365 if (
context == xdefault_context)
368 return varval (
context).is_defined ();
371 bool is_valid (
void)
const
378 if (context == xdefault_context)
379 context = active_context ();
381 return (! is_local () || is_defined (context));
384 bool is_local (
void)
const {
return storage_class & local; }
386 bool is_formal (
void)
const {
return storage_class & formal; }
387 bool is_hidden (
void)
const {
return storage_class & hidden; }
389 bool is_global (
void)
const {
return storage_class & global; }
398 void mark_global (
void)
400 if (is_persistent ())
401 error (
"can't make persistent variable %s global", name.c_str ());
403 storage_class |= global;
405 void mark_persistent (
void)
408 error (
"can't make global variable %s persistent", name.c_str ());
410 storage_class |= persistent;
423 void init_persistent (
void)
436 void invalidate (
void)
441 void erase_persistent (
void)
443 unmark_persistent ();
449 scope_id
scope (
void)
const {
return decl_scope; }
462 void dump (std::ostream& os,
const std::string& prefix)
const;
492 const std::string& nm = std::string (),
494 unsigned int sc = local)
507 if (--rep->count == 0)
519 if (--rep->count == 0)
528 const std::string&
name (
void)
const {
return rep->name; }
530 void rename (
const std::string& new_name) { rep->name = new_name; }
536 context_id
context = xdefault_context)
542 const std::string&
type,
543 const std::list<octave_value_list>& idx,
545 context_id
context = xdefault_context)
547 rep->assign (op, type, idx, value,
context);
551 context_id
context = xdefault_context)
553 rep->assign (op, value,
context);
558 rep->do_non_const_unary_op (op);
562 const std::string&
type,
563 const std::list<octave_value_list>& idx)
565 rep->do_non_const_unary_op (op, type, idx);
583 void clear (
void) { rep->clear (); }
585 void clear (scope_id s) { rep->clear (s); }
587 bool is_defined (context_id
context = xdefault_context)
const
589 return rep->is_defined (
context);
592 bool is_undefined (context_id
context = xdefault_context)
const
594 return ! rep->is_defined (
context);
597 bool is_valid (
void)
const
599 return rep->is_valid ();
604 return rep->is_variable (
context);
607 bool is_local (
void)
const {
return rep->is_local (); }
609 bool is_formal (
void)
const {
return rep->is_formal (); }
610 bool is_global (
void)
const {
return rep->is_global (); }
611 bool is_hidden (
void)
const {
return rep->is_hidden (); }
642 scope_id
scope (
void)
const {
return rep->scope (); }
649 dump (std::ostream& os,
const std::string& prefix = std::string ())
const
651 rep->dump (os, prefix);
672 : scope (curr_scope), sym (record)
676 : scope (ref.scope), sym (ref.sym)
692 const std::string&
name (
void)
const {
return sym.name (); }
718 void update (
void)
const
722 if (scope != curr_scope || ! sym.is_valid ())
740 typedef std::map<scope_id, octave_value>::const_iterator
744 typedef std::map<std::string, octave_value>::const_iterator
759 : name (nm), subfunctions (), private_functions (),
760 class_constructors (), class_methods (), dispatch_map (),
761 cmdline_function (), autoload_function (), function_on_path (),
762 built_in_function (), count (1) { }
764 octave_value load_private_function (
const std::string& dir_name);
768 octave_value load_class_method (
const std::string& dispatch_type);
774 octave_value find_method (
const std::string& dispatch_type);
780 bool is_user_function_defined (
void)
const
782 return function_on_path.is_defined ();
788 return find (args, local_funcs);
791 void lock_subfunction (scope_id scope)
793 scope_val_iterator p = subfunctions.find (scope);
795 if (p != subfunctions.end ())
799 void unlock_subfunction (scope_id scope)
801 scope_val_iterator p = subfunctions.find (scope);
803 if (p != subfunctions.end ())
807 std::pair<std::string, octave_value>
808 subfunction_defined_in_scope (scope_id scope)
const
812 return p == subfunctions.end ()
813 ? std::pair<std::string, octave_value> ()
814 : std::pair<std::string, octave_value> (name, p->second);
817 void erase_subfunction (scope_id scope)
819 scope_val_iterator p = subfunctions.find (scope);
821 if (p != subfunctions.end ())
822 subfunctions.erase (p);
825 void mark_subfunction_in_scope_as_private (scope_id scope,
826 const std::string& class_name);
830 cmdline_function =
f;
835 subfunctions[scope] =
f;
840 function_on_path =
f;
845 built_in_function =
f;
850 clear_map (std::map<T, octave_value>& map,
bool force =
false)
852 typename std::map<T, octave_value>::iterator p = map.begin ();
854 while (p != map.end ())
856 if (force || ! p->second.islocked ())
863 void clear_autoload_function (
bool force =
false)
865 if (force || ! autoload_function.islocked ())
871 void clear_user_function (
bool force =
false)
873 if (force || ! function_on_path.islocked ())
876 if (force || ! cmdline_function.islocked ())
880 void clear_mex_function (
void)
882 if (function_on_path.is_mex_function ())
883 clear_user_function ();
888 clear_map (subfunctions, force);
889 clear_map (private_functions, force);
890 clear_map (class_constructors, force);
891 clear_map (class_methods, force);
893 clear_autoload_function (force);
894 clear_user_function (force);
897 void add_dispatch (
const std::string&
type,
const std::string& fname)
899 dispatch_map[
type] = fname;
902 void clear_dispatch (
const std::string&
type)
904 dispatch_map_iterator p = dispatch_map.find (type);
906 if (p != dispatch_map.end ())
907 dispatch_map.erase (p);
910 void print_dispatch (std::ostream& os)
const;
912 std::string help_for_dispatch (
void)
const;
916 void dump (std::ostream& os,
const std::string& prefix)
const;
972 if (--rep->count == 0)
984 if (--rep->count == 0)
989 bool local_funcs =
true)
991 return rep->find (args, local_funcs);
996 return rep->builtin_find ();
1001 return rep->find_method (dispatch_type);
1006 return rep->built_in_function;
1011 return rep->cmdline_function;
1016 return rep->find_autoload ();
1021 return rep->find_user_function ();
1024 bool is_user_function_defined (
void)
const
1026 return rep->is_user_function_defined ();
1031 bool local_funcs =
true)
1033 return rep->find_function (args, local_funcs);
1036 void lock_subfunction (scope_id scope)
1038 rep->lock_subfunction (scope);
1041 void unlock_subfunction (scope_id scope)
1043 rep->unlock_subfunction (scope);
1046 std::pair<std::string, octave_value>
1047 subfunction_defined_in_scope (scope_id scope = xcurrent_scope)
const
1049 return rep->subfunction_defined_in_scope (scope);
1052 void erase_subfunction (scope_id scope)
1054 rep->erase_subfunction (scope);
1057 void mark_subfunction_in_scope_as_private (scope_id scope,
1058 const std::string& class_name)
1060 rep->mark_subfunction_in_scope_as_private (scope, class_name);
1065 rep->install_cmdline_function (f);
1070 rep->install_subfunction (f, scope);
1075 rep->install_user_function (f);
1080 rep->install_built_in_function (f);
1083 void clear (
bool force =
false) { rep->clear (force); }
1085 void clear_user_function (
bool force =
false)
1087 rep->clear_user_function (force);
1090 void clear_autoload_function (
bool force =
false)
1092 rep->clear_autoload_function (force);
1097 void add_dispatch (
const std::string&
type,
const std::string& fname)
1099 rep->add_dispatch (type, fname);
1102 void clear_dispatch (
const std::string&
type)
1104 rep->clear_dispatch (type);
1107 void print_dispatch (std::ostream& os)
const
1109 rep->print_dispatch (os);
1112 std::string help_for_dispatch (
void)
const
1113 {
return rep->help_for_dispatch (); }
1115 dispatch_map_type get_dispatch (
void)
const
1117 return rep->get_dispatch ();
1121 dump (std::ostream& os,
const std::string& prefix = std::string ())
const
1123 rep->dump (os, prefix);
1138 static scope_id
alloc_scope (
void) {
return scope_id_cache::alloc (); }
1140 static void set_scope (scope_id scope)
1142 if (scope == xglobal_scope)
1143 error (
"can't set scope to global");
1144 else if (scope != xcurrent_scope)
1148 if (p == all_instances.end ())
1153 all_instances[scope] = instance = inst;
1156 instance = p->second;
1158 xcurrent_scope = scope;
1159 xcurrent_context = 0;
1163 static void set_scope_and_context (scope_id scope, context_id
context)
1165 if (scope == xglobal_scope)
1166 error (
"can't set scope to global");
1169 if (scope != xcurrent_scope)
1173 if (p == all_instances.end ())
1174 error (
"scope not found!");
1177 instance = p->second;
1179 xcurrent_scope = scope;
1189 static void erase_scope (scope_id scope)
1191 assert (scope != xglobal_scope);
1193 erase_subfunctions_in_scope (scope);
1197 if (p != all_instances.end ())
1201 all_instances.erase (p);
1207 static void erase_subfunctions_in_scope (scope_id scope)
1210 q->second.erase_subfunction (scope);
1214 mark_subfunctions_in_scope_as_private (scope_id scope,
1215 const std::string& class_name)
1218 q->second.mark_subfunction_in_scope_as_private (scope, class_name);
1221 static scope_id dup_scope (scope_id scope)
1223 scope_id retval = -1;
1229 scope_id new_scope = alloc_scope ();
1233 if (new_symbol_table)
1235 all_instances[new_scope] = new_symbol_table;
1246 static std::list<scope_id> scopes (
void)
1248 return scope_id_cache::scopes ();
1251 static symbol_record
1252 find_symbol (
const std::string& name, scope_id scope = xcurrent_scope)
1261 inherit (scope_id scope, scope_id donor_scope, context_id donor_context)
1267 symbol_table *donor_symbol_table = get_instance (donor_scope);
1269 if (donor_symbol_table)
1270 inst->
do_inherit (*donor_symbol_table, donor_context);
1278 find (
const std::string& name,
1280 bool skip_variables =
false,
1281 bool local_funcs =
true);
1283 static octave_value builtin_find (
const std::string& name);
1287 scope_id scope = xcurrent_scope)
1293 return inst ? inst->
do_insert (name) : foobar;
1296 static void rename (
const std::string& old_name,
1297 const std::string& new_name,
1298 scope_id scope = xcurrent_scope)
1306 static void assign (
const std::string& name,
1308 scope_id scope = xcurrent_scope,
1309 context_id
context = xdefault_context,
1310 bool force_add =
false)
1322 varref (
const std::string& name, scope_id scope = xcurrent_scope,
1323 context_id
context = xdefault_context,
bool force_add =
false)
1336 static void force_assign (
const std::string& name,
1338 scope_id scope = xcurrent_scope,
1339 context_id
context = xdefault_context)
1341 assign (name, value, scope,
context,
true);
1346 force_varref (
const std::string& name, scope_id scope = xcurrent_scope,
1357 scope_id scope = xcurrent_scope,
1358 context_id
context = xdefault_context)
1366 global_assign (
const std::string& name,
1372 if (p == global_table.end ())
1373 global_table[name] = value;
1385 return (p == global_table.end ()) ? global_table[name] : p->second;
1389 global_varval (
const std::string& name)
1393 return (p != global_table.end ()) ? p->second :
octave_value ();
1397 top_level_assign (
const std::string& name,
1400 assign (name, value, top_scope (), 0);
1411 return inst ? inst->
do_varref (name, 0,
true) : foobar;
1415 top_level_varval (
const std::string& name)
1417 return varval (name, top_scope (), 0);
1421 persistent_assign (
const std::string& name,
1448 static void erase_persistent (
const std::string& name)
1464 is_built_in_function_name (
const std::string& name)
1472 find_method (
const std::string& name,
const std::string& dispatch_type)
1476 if (p != fcn_table.end ())
1477 return p->second.find_method (dispatch_type);
1485 fcn_table[name] = finfo;
1492 find_built_in_function (
const std::string& name)
1496 return (p != fcn_table.end ())
1497 ? p->second.find_built_in_function () :
octave_value ();
1501 find_autoload (
const std::string& name)
1505 return (p != fcn_table.end ())
1510 find_function (
const std::string& name,
1512 bool local_funcs =
true);
1518 return (p != fcn_table.end ())
1522 static void install_cmdline_function (
const std::string& name,
1527 if (p != fcn_table.end ())
1539 fcn_table[name] = finfo;
1546 static void install_subfunction (
const std::string& name,
1552 if (p != fcn_table.end ())
1564 fcn_table[name] = finfo;
1568 static void install_nestfunction (
const std::string& name,
1570 scope_id parent_scope);
1572 static void update_nest (scope_id scope)
1579 static void install_user_function (
const std::string& name,
1584 if (p != fcn_table.end ())
1596 fcn_table[name] = finfo;
1600 static void install_built_in_function (
const std::string& name,
1605 if (p != fcn_table.end ())
1617 fcn_table[name] = finfo;
1621 static void clear (
const std::string& name)
1626 static void clear_all (
bool force =
false)
1630 clear_global_pattern (
"*");
1632 clear_functions (force);
1635 static void clear_variables (scope_id scope)
1644 static void clear_variables (
void)
1646 clear_variables (xcurrent_scope);
1649 static void clear_objects (scope_id scope = xcurrent_scope)
1657 static void clear_functions (
bool force =
false)
1660 p->second.clear (force);
1665 clear_user_function (name);
1668 static void clear_global (
const std::string& name)
1692 static void clear_function_pattern (
const std::string& pat)
1698 if (pattern.
match (p->first))
1699 p->second.clear_user_function ();
1703 static void clear_global_pattern (
const std::string& pat)
1711 static void clear_variable_pattern (
const std::string& pat)
1719 static void clear_variable_regexp (
const std::string& pat)
1727 static void clear_symbol_pattern (
const std::string& pat)
1731 clear_variable_pattern (pat);
1732 clear_function_pattern (pat);
1735 static void clear_user_function (
const std::string& name)
1739 if (p != fcn_table.end ())
1751 static void clear_dld_function (
const std::string& name)
1755 if (p != fcn_table.end ())
1774 static bool set_class_relationship (
const std::string& sup_class,
1775 const std::string& inf_class);
1777 static bool is_superiorto (
const std::string& a,
const std::string& b);
1779 static void alias_built_in_function (
const std::string& alias,
1780 const std::string& name)
1790 fcn_table[alias] = finfo;
1793 panic (
"alias: '%s' is undefined", name.c_str ());
1796 static void add_dispatch (
const std::string& name,
const std::string&
type,
1797 const std::string& fname)
1801 if (p != fcn_table.end ())
1813 fcn_table[name] = finfo;
1817 static void clear_dispatch (
const std::string& name,
const std::string&
type)
1821 if (p != fcn_table.end ())
1829 static void print_dispatch (std::ostream& os,
const std::string& name)
1833 if (p != fcn_table.end ())
1847 if (p != fcn_table.end ())
1857 static std::string help_for_dispatch (
const std::string& name)
1863 if (p != fcn_table.end ())
1873 static void push_context (
void)
1875 if (xcurrent_scope == xglobal_scope || xcurrent_scope == xtop_scope)
1876 error (
"invalid call to xymtab::push_context");
1886 static void pop_context (
void)
1888 if (xcurrent_scope == xglobal_scope || xcurrent_scope == xtop_scope)
1889 error (
"invalid call to xymtab::pop_context");
1902 static void mark_automatic (
const std::string& name)
1910 static void mark_hidden (
const std::string& name)
1918 static void mark_global (
const std::string& name)
1927 static std::list<symbol_record>
1928 all_variables (scope_id scope = xcurrent_scope,
1929 context_id
context = xdefault_context,
1930 bool defined_only =
true,
1931 unsigned int exclude = symbol_record::hidden)
1937 : std::list<symbol_record> ();
1940 static std::list<symbol_record> glob (
const std::string& pattern)
1944 return inst ? inst->
do_glob (pattern) : std::list<symbol_record> ();
1947 static std::list<symbol_record>
regexp (
const std::string& pattern)
1951 return inst ? inst->
do_regexp (pattern) : std::list<symbol_record> ();
1954 static std::list<symbol_record> glob_variables (
const std::string& pattern)
1958 return inst ? inst->
do_glob (pattern,
true) : std::list<symbol_record> ();
1961 static std::list<symbol_record> regexp_variables (
const std::string& pattern)
1965 return inst ? inst->
do_regexp (pattern,
true) : std::list<symbol_record> ();
1968 static std::list<symbol_record>
1969 glob_global_variables (
const std::string& pattern)
1971 std::list<symbol_record> retval;
1976 p != global_table.end (); p++)
1982 if (pat.
match (p->first))
1984 p->first, p->second,
1985 symbol_record::global));
1991 static std::list<symbol_record>
1992 regexp_global_variables (
const std::string& pattern)
1994 std::list<symbol_record> retval;
1999 p != global_table.end (); p++)
2007 p->first, p->second,
2008 symbol_record::global));
2016 std::list<symbol_record> retval;
2018 size_t len = patterns.
length ();
2020 for (
size_t i = 0; i < len; i++)
2022 std::list<symbol_record> tmp = glob_variables (patterns[i]);
2024 retval.insert (retval.begin (), tmp.begin (), tmp.end ());
2030 static std::list<symbol_record> regexp_variables
2033 std::list<symbol_record> retval;
2035 size_t len = patterns.
length ();
2037 for (
size_t i = 0; i < len; i++)
2039 std::list<symbol_record> tmp = regexp_variables (patterns[i]);
2041 retval.insert (retval.begin (), tmp.begin (), tmp.end ());
2047 static std::list<std::string> user_function_names (
void)
2049 std::list<std::string> retval;
2052 p != fcn_table.end (); p++)
2054 if (p->second.is_user_function_defined ())
2055 retval.push_back (p->first);
2058 if (! retval.empty ())
2064 static std::list<std::string> global_variable_names (
void)
2066 std::list<std::string> retval;
2069 p != global_table.end (); p++)
2070 retval.push_back (p->first);
2077 static std::list<std::string> top_level_variable_names (
void)
2084 static std::list<std::string> variable_names (
void)
2091 static std::list<std::string> built_in_function_names (
void)
2093 std::list<std::string> retval;
2096 p != fcn_table.end (); p++)
2098 octave_value fcn = p->second.find_built_in_function ();
2101 retval.push_back (p->first);
2104 if (! retval.empty ())
2110 static std::list<std::string> cmdline_function_names (
void)
2112 std::list<std::string> retval;
2115 p != fcn_table.end (); p++)
2120 retval.push_back (p->first);
2123 if (! retval.empty ())
2129 static bool is_local_variable (
const std::string& name)
2131 if (xcurrent_scope == xglobal_scope)
2141 static bool is_global (
const std::string& name)
2143 if (xcurrent_scope == xglobal_scope)
2153 static std::list<workspace_element> workspace_info (
void)
2161 static void dump (std::ostream& os, scope_id scope = xcurrent_scope);
2163 static void dump_global (std::ostream& os);
2165 static void dump_functions (std::ostream& os);
2167 static void cache_name (scope_id scope,
const std::string& name)
2175 static void lock_subfunctions (scope_id scope = xcurrent_scope)
2178 p != fcn_table.end (); p++)
2179 p->second.lock_subfunction (scope);
2182 static void unlock_subfunctions (scope_id scope = xcurrent_scope)
2185 p != fcn_table.end (); p++)
2186 p->second.unlock_subfunction (scope);
2189 static std::map<std::string, octave_value>
2190 subfunctions_defined_in_scope (scope_id scope = xcurrent_scope)
2192 std::map<std::string, octave_value> retval;
2195 p != fcn_table.end (); p++)
2197 std::pair<std::string, octave_value> tmp
2198 = p->second.subfunction_defined_in_scope (scope);
2200 std::string nm = tmp.first;
2203 retval[nm] = tmp.second;
2209 static void free_scope (scope_id scope)
2211 if (scope == xglobal_scope || scope == xtop_scope)
2212 error (
"can't free global or top-level scopes!");
2217 static void stash_dir_name_for_subfunctions (scope_id scope,
2218 const std::string& dir_name);
2220 static void add_to_parent_map (
const std::string& classname,
2221 const std::list<std::string>& parent_list)
2223 parent_map[classname] = parent_list;
2226 static std::list<std::string>
2227 parent_classes (
const std::string& dispatch_type)
2229 std::list<std::string> retval;
2233 if (it != parent_map.end ())
2234 retval = it->second;
2236 for (std::list<std::string>::const_iterator lit = retval.begin ();
2237 lit != retval.end (); lit++)
2243 std::list<std::string> parents = parent_classes (*lit);
2245 if (! parents.empty ())
2246 retval.insert (retval.end (), parents.begin (), parents.end ());
2259 scope_id scope = xcurrent_scope)
2261 assert (scope != xtop_scope && scope != xglobal_scope);
2267 assert (inst->
curr_fcn == 0 || curr_fcn == 0);
2271 static void cleanup (
void);
2281 typedef std::map<std::string, symbol_record>::const_iterator
2283 typedef std::map<std::string, symbol_record>::iterator
2286 typedef std::map<std::string, octave_value>::const_iterator
2288 typedef std::map<std::string, octave_value>::iterator
2291 typedef std::map<std::string, octave_value>::const_iterator
2293 typedef std::map<std::string, octave_value>::iterator
2296 typedef std::map<scope_id, symbol_table*>::const_iterator
2298 typedef std::map<scope_id, symbol_table*>::iterator
2301 typedef std::map<std::string, fcn_info>::const_iterator
2303 typedef std::map<std::string, fcn_info>::iterator
2314 std::map<std::string, symbol_record>
table;
2348 typedef std::map<std::string, std::set<std::string> >::const_iterator
2350 typedef std::map<std::string, std::set<std::string> >::iterator
2354 static std::map<std::string, std::list<std::string> >
parent_map;
2356 typedef std::map<std::string, std::list<std::string> >::const_iterator
2358 typedef std::map<std::string, std::list<std::string> >::iterator
2368 static const context_id xdefault_context =
static_cast<context_id
> (-1);
2371 : my_scope (scope), table_name (), table (), nest_children (),
2372 nest_parent (0), curr_fcn (0), static_workspace (false),
2373 persistent_table () { }
2383 if (scope != xglobal_scope)
2385 if (scope == xcurrent_scope)
2387 if (! instance && create)
2393 all_instances[scope] = instance = inst;
2395 if (scope == xtop_scope)
2409 if (p == all_instances.end ())
2416 all_instances[scope] = retval;
2429 error (
"unable to %s symbol_table object for scope %d!",
2430 create ?
"create" :
"find", scope);
2438 nest_children.push_back (&st);
2444 table[sr.
name ()] = sr;
2459 if (p == table.end ())
2460 return do_insert (name);
2473 std::string nm = sr.
name ();
2475 if (nm !=
"__retval__")
2490 static fcn_info *get_fcn_info (
const std::string& name)
2493 return p != fcn_table.end () ? &p->second : 0;
2498 bool skip_variables,
bool local_funcs);
2500 octave_value do_builtin_find (
const std::string& name);
2506 if (p == table.end ())
2511 return table[name] = ret;
2514 if (static_workspace && ! force_add)
2517 return table[name] = ret;
2524 void do_rename (
const std::string& old_name,
const std::string& new_name)
2528 if (p != table.end ())
2536 table[new_name] = sr;
2541 context_id
context,
bool force_add)
2545 if (p == table.end ())
2549 sr.
assign (value, context);
2552 p->second.assign (value, context);
2562 if (p == table.end ())
2566 return sr.
varref (context);
2569 return p->second.varref (context);
2576 return (p != table.end ()) ? p->second.varval (context) :
octave_value ();
2579 void do_persistent_assign (
const std::string& name,
const octave_value& value)
2583 if (p == persistent_table.end ())
2584 persistent_table[name] = value;
2595 return (p == persistent_table.end ())
2596 ? persistent_table[name] : p->second;
2603 return (p != persistent_table.end ()) ? p->second :
octave_value ();
2606 void do_erase_persistent (
const std::string& name)
2610 if (p != persistent_table.end ())
2611 persistent_table.erase (p);
2614 bool do_is_variable (
const std::string& name)
const
2616 bool retval =
false;
2620 if (p != table.end ())
2630 void do_push_context (
void)
2633 p->second.push_context (my_scope);
2636 void do_pop_context (
void)
2640 while (p != table.end ())
2642 if (p->second.pop_context (my_scope) == 0)
2652 p->second.clear (my_scope);
2655 void do_clear_objects (
void)
2662 p->second.clear (my_scope);
2666 void do_clear_global (
const std::string& name)
2670 if (p != table.end ())
2680 if (q != global_table.end ())
2681 global_table.erase (q);
2685 void do_clear_variable (
const std::string& name)
2689 if (p != table.end ())
2690 p->second.clear (my_scope);
2693 void do_clear_global_pattern (
const std::string& pat)
2707 while (q != global_table.end ())
2709 if (pattern.
match (q->first))
2710 global_table.erase (q++);
2718 void do_clear_variable_pattern (
const std::string& pat)
2729 sr.
clear (my_scope);
2734 void do_clear_variable_regexp (
const std::string& pat)
2745 sr.
clear (my_scope);
2750 void do_mark_automatic (
const std::string& name)
2752 do_insert (name).mark_automatic ();
2755 void do_mark_hidden (
const std::string& name)
2757 do_insert (name).mark_hidden ();
2760 void do_mark_global (
const std::string& name)
2762 do_insert (name).mark_global ();
2765 std::list<symbol_record>
2766 do_all_variables (context_id
context,
bool defined_only,
2767 unsigned int exclude)
const
2769 std::list<symbol_record> retval;
2775 if ((defined_only && ! sr.
is_defined (context))
2779 retval.push_back (sr);
2785 std::list<symbol_record> do_glob (
const std::string& pattern,
2786 bool vars_only =
false)
const
2788 std::list<symbol_record> retval;
2794 if (pat.
match (p->first))
2801 retval.push_back (sr);
2808 std::list<symbol_record> do_regexp (
const std::string& pattern,
2809 bool vars_only =
false)
const
2811 std::list<symbol_record> retval;
2824 retval.push_back (sr);
2831 std::list<std::string> do_variable_names (
void)
2833 std::list<std::string> retval;
2837 if (p->second.is_variable ())
2838 retval.push_back (p->first);
2846 bool do_is_local_variable (
const std::string& name)
const
2850 return (p != table.end ()
2851 && ! p->second.is_global ()
2852 && p->second.is_defined ());
2855 bool do_is_global (
const std::string& name)
const
2859 return p != table.end () && p->second.is_global ();
2862 std::list<workspace_element> do_workspace_info (
void)
const;
2864 void do_dump (std::ostream& os);
2868 void do_update_nest (
void);
2873 if (p == table.end ())
2878 else if (! p->second.is_automatic ())
2889 const std::string& dispatch_type = std::string (),
2890 bool check_relative =
true);