Mercurial > octave
annotate libinterp/corefcn/symtab.h @ 23680:ef71711f6d64
rework __dump_symbol_table__ function
* symtab.h, symtab.cc (F__dump_symtab_info__): Instead of printing
results, return a struct containing all the info.
(symbol_table::symbol_record::symbol_record_rep::dump,
symbol_table::fcn_info::fcn_info_rep::dump, symbol_table::dump,
symbol_table::scope::dump): Update interface. Create and return struct.
(dump_container_map, symbol_table::dump_fcn_table_map,
symbol_table::scope::dump_symbols_map): New functions.
(fcn_file_name): Delete static function.
(symbol_table::dump_global, symbol_table::dump_functions): Delete.
* ov-usr-fcn.h, ov-usr-fcn.cc (octave_user_function::dump):
Update interface. Create and return struct.
(octave_user_function::ctor_type_str): New function.
* ov-base.h, ov-base.cc (octave_base_value::dump): Update interface.
Create and return struct.
* ov.h (octave_value::dump): Update interface.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 22 Jun 2017 16:23:36 -0400 |
parents | 2d4a7ae1f6cd |
children | b9378eff6d13 |
rev | line source |
---|---|
8 | 1 /* |
2 | |
23219
3ac9f9ecfae5
maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents:
23083
diff
changeset
|
3 Copyright (C) 1993-2017 John W. Eaton |
10521
4d1fc073fbb7
add some missing copyright stmts
Jaroslav Hajek <highegg@gmail.com>
parents:
10321
diff
changeset
|
4 Copyright (C) 2009 VZLU Prague |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11584
diff
changeset
|
5 |
8 | 6 This file is part of Octave. |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22653
diff
changeset
|
9 under the terms of the GNU General Public License as published by |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22653
diff
changeset
|
10 the Free Software Foundation; either version 3 of the License, or |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22653
diff
changeset
|
11 (at your option) any later version. |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22653
diff
changeset
|
12 |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22653
diff
changeset
|
13 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22653
diff
changeset
|
14 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22653
diff
changeset
|
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22653
diff
changeset
|
16 GNU General Public License for more details. |
8 | 17 |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
8 | 21 |
22 */ | |
23 | |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
20713
diff
changeset
|
24 #if ! defined (octave_symtab_h) |
383 | 25 #define octave_symtab_h 1 |
8 | 26 |
21244
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21139
diff
changeset
|
27 #include "octave-config.h" |
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21139
diff
changeset
|
28 |
7336 | 29 #include <deque> |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
30 #include <limits> |
7336 | 31 #include <list> |
32 #include <map> | |
33 #include <set> | |
34 #include <string> | |
2953 | 35 |
7336 | 36 #include "glob-match.h" |
16940
99122191d3dd
maint: Rename regexp.h to lo-regexp.h, regexp.cc to lo-regexp.cc in liboctave.
Rik <rik@octave.org>
parents:
16892
diff
changeset
|
37 #include "lo-regexp.h" |
23680
ef71711f6d64
rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
38 #include "oct-refcount.h" |
2846 | 39 |
7336 | 40 class tree_argument_list; |
9639
8d79f36ebdde
store scope->function pointer
Jaroslav Hajek <highegg@gmail.com>
parents:
9581
diff
changeset
|
41 class octave_user_function; |
3013 | 42 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
43 #include "ov.h" |
20940
48b2ad5ee801
maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents:
20791
diff
changeset
|
44 #include "ovl.h" |
16468
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
45 #include "workspace-element.h" |
1412 | 46 |
8 | 47 class |
6109 | 48 OCTINTERP_API |
8 | 49 symbol_table |
50 { | |
51 public: | |
52 | |
21573
f3f8e1d3e399
avoid mulitple definitions of static function-scope vars (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
53 static octave_value dummy_octave_value; |
f3f8e1d3e399
avoid mulitple definitions of static function-scope vars (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
54 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
55 typedef size_t context_id; |
7336 | 56 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
57 class scope; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
58 |
9413
5cd879a0d8c4
speed-up function call by caching its name lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
9409
diff
changeset
|
59 class fcn_info; |
5cd879a0d8c4
speed-up function call by caching its name lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
9409
diff
changeset
|
60 |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
61 class symbol_record |
7336 | 62 { |
63 public: | |
64 | |
65 // generic variable | |
66 static const unsigned int local = 1; | |
67 | |
68 // varargin, argn, .nargin., .nargout. | |
21066
258c787cd9ce
maint: Use "FIXME:" consistently in code base.
Rik <rik@octave.org>
parents:
21040
diff
changeset
|
69 // (FIXME: is this really used now?) |
7336 | 70 static const unsigned int automatic = 2; |
71 | |
72 // formal parameter | |
73 static const unsigned int formal = 4; | |
74 | |
75 // not listed or cleared (.nargin., .nargout.) | |
76 static const unsigned int hidden = 8; | |
77 | |
78 // inherited from parent scope; not cleared at function exit | |
79 static const unsigned int inherited = 16; | |
80 | |
81 // global (redirects to global scope) | |
82 static const unsigned int global = 32; | |
83 | |
84 // not cleared at function exit | |
85 static const unsigned int persistent = 64; | |
86 | |
15236
44d6ffdf9479
Disallow new variables in nested functions (bug #36271)
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
87 // this symbol may NOT become a variable. |
44d6ffdf9479
Disallow new variables in nested functions (bug #36271)
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
88 // (symbol added to a static workspace) |
16277
8cb65fd72164
eliminate obsolete concepts of "pending local" and "forced" variables
John W. Eaton <jwe@octave.org>
parents:
15572
diff
changeset
|
89 static const unsigned int added_static = 128; |
15236
44d6ffdf9479
Disallow new variables in nested functions (bug #36271)
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
90 |
7336 | 91 private: |
92 | |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
93 class symbol_record_rep |
4009 | 94 { |
7336 | 95 public: |
96 | |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
97 symbol_record_rep (scope *s, const std::string& nm, |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
98 const octave_value& v, unsigned int sc) |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
99 : m_decl_scope (s), curr_fcn (0), name (nm), value_stack (), |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
100 storage_class (sc), /* finfo (), */ valid (true), count (1) |
7336 | 101 { |
10313 | 102 value_stack.push_back (v); |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
103 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
104 |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
105 // No copying! |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
106 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
107 symbol_record_rep (const symbol_record_rep& ov) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
108 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
109 symbol_record_rep& operator = (const symbol_record_rep&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
110 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
111 ~symbol_record_rep (void) = default; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
112 |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
113 void assign (const octave_value& value) |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
114 { |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
115 varref () = value; |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
116 } |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
117 |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
118 void assign (octave_value::assign_op op, |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
119 const std::string& type, |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
120 const std::list<octave_value_list>& idx, |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
121 const octave_value& value) |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
122 { |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
123 varref().assign (op, type, idx, value); |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
124 } |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
125 |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
126 void assign (octave_value::assign_op op, const octave_value& value) |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
127 { |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
128 varref().assign (op, value); |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
129 } |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
130 |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
131 void do_non_const_unary_op (octave_value::unary_op op) |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
132 { |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
133 varref().do_non_const_unary_op (op); |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
134 } |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
135 |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
136 void do_non_const_unary_op (octave_value::unary_op op, |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
137 const std::string& type, |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
138 const std::list<octave_value_list>& idx) |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
139 { |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
140 varref().do_non_const_unary_op (op, type, idx); |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
141 } |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
142 |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
143 octave_value& varref (void) |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
144 { |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
145 context_id context |
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
146 = m_decl_scope ? m_decl_scope->current_context () : 0; |
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
147 |
10313 | 148 if (is_global ()) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
149 return xglobal_varref (); |
10313 | 150 else if (is_persistent ()) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
151 return xpersistent_varref (); |
10313 | 152 else |
153 { | |
154 context_id n = value_stack.size (); | |
155 while (n++ <= context) | |
156 value_stack.push_back (octave_value ()); | |
157 | |
158 return value_stack[context]; | |
159 } | |
7336 | 160 } |
161 | |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
162 octave_value varval (void) const |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
163 { |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
164 context_id context |
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
165 = m_decl_scope ? m_decl_scope->current_context () : 0; |
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
166 |
10313 | 167 if (is_global ()) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
168 return xglobal_varval (); |
10313 | 169 else if (is_persistent ()) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
170 return xpersistent_varval (); |
10313 | 171 else |
172 { | |
173 if (context < value_stack.size ()) | |
174 return value_stack[context]; | |
175 else | |
176 return octave_value (); | |
177 } | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
178 } |
7336 | 179 |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
180 void push_context (scope *sid) |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
181 { |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
182 if (! (is_persistent () || is_global ()) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
183 && sid == decl_scope ()) |
10313 | 184 value_stack.push_back (octave_value ()); |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
185 } |
7336 | 186 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
187 // If pop_context returns 0, we are out of values and this element |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
188 // of the symbol table should be deleted. This can happen for |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
189 // functions like |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
190 // |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
191 // function foo (n) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
192 // if (n > 0) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
193 // foo (n-1); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
194 // else |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
195 // eval ("x = 1"); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
196 // endif |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
197 // endfunction |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
198 // |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
199 // Here, X should only exist in the final stack frame. |
7336 | 200 |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
201 size_t pop_context (scope *sid) |
7374 | 202 { |
10313 | 203 size_t retval = 1; |
204 | |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
205 if (! (is_persistent () || is_global ()) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
206 && sid == decl_scope ()) |
10313 | 207 { |
208 value_stack.pop_back (); | |
209 retval = value_stack.size (); | |
210 } | |
211 | |
212 return retval; | |
7374 | 213 } |
7336 | 214 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
215 void clear (void) { clear (decl_scope ()); } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
216 |
23611
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
217 void clear (scope *sid); |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
218 |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
219 bool is_defined (void) const |
7336 | 220 { |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
221 return varval ().is_defined (); |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
222 } |
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
223 |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
224 bool is_valid (void) const |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
225 { |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
226 return valid; |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
227 } |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
228 |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
229 bool is_variable (void) const |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
230 { |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
231 return (! is_local () || is_defined ()); |
7336 | 232 } |
233 | |
234 bool is_local (void) const { return storage_class & local; } | |
235 bool is_automatic (void) const { return storage_class & automatic; } | |
236 bool is_formal (void) const { return storage_class & formal; } | |
237 bool is_hidden (void) const { return storage_class & hidden; } | |
238 bool is_inherited (void) const { return storage_class & inherited; } | |
239 bool is_global (void) const { return storage_class & global; } | |
240 bool is_persistent (void) const { return storage_class & persistent; } | |
15236
44d6ffdf9479
Disallow new variables in nested functions (bug #36271)
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
241 bool is_added_static (void) const {return storage_class & added_static; } |
7336 | 242 |
243 void mark_local (void) { storage_class |= local; } | |
244 void mark_automatic (void) { storage_class |= automatic; } | |
245 void mark_formal (void) { storage_class |= formal; } | |
246 void mark_hidden (void) { storage_class |= hidden; } | |
247 void mark_inherited (void) { storage_class |= inherited; } | |
248 void mark_global (void) | |
249 { | |
10313 | 250 if (is_persistent ()) |
251 error ("can't make persistent variable %s global", name.c_str ()); | |
20982
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20956
diff
changeset
|
252 |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20956
diff
changeset
|
253 storage_class |= global; |
7336 | 254 } |
255 void mark_persistent (void) | |
256 { | |
10313 | 257 if (is_global ()) |
258 error ("can't make global variable %s persistent", name.c_str ()); | |
20982
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20956
diff
changeset
|
259 |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20956
diff
changeset
|
260 storage_class |= persistent; |
7336 | 261 } |
15236
44d6ffdf9479
Disallow new variables in nested functions (bug #36271)
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
262 void mark_added_static (void) { storage_class |= added_static; } |
7336 | 263 |
264 void unmark_local (void) { storage_class &= ~local; } | |
265 void unmark_automatic (void) { storage_class &= ~automatic; } | |
266 void unmark_formal (void) { storage_class &= ~formal; } | |
267 void unmark_hidden (void) { storage_class &= ~hidden; } | |
268 void unmark_inherited (void) { storage_class &= ~inherited; } | |
269 void unmark_global (void) { storage_class &= ~global; } | |
270 void unmark_persistent (void) { storage_class &= ~persistent; } | |
15236
44d6ffdf9479
Disallow new variables in nested functions (bug #36271)
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
271 void unmark_added_static (void) { storage_class &= ~added_static; } |
7336 | 272 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
273 void init_persistent (void); |
7336 | 274 |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
275 void invalidate (void) |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
276 { |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
277 valid = false; |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
278 } |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
279 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
280 void erase_persistent (void); |
7336 | 281 |
23611
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
282 scope *decl_scope (void) { return m_decl_scope; } |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
283 |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
284 void set_curr_fcn (octave_user_function *fcn) |
7336 | 285 { |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
286 curr_fcn = fcn; |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
287 } |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
288 |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
289 symbol_record_rep * dup (scope *new_scope) const; |
7336 | 290 |
23680
ef71711f6d64
rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
291 octave_value dump (void) const; |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
292 |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
293 scope *m_decl_scope; |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
294 |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23446
diff
changeset
|
295 octave_user_function *curr_fcn; |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
296 |
7336 | 297 std::string name; |
298 | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
299 std::deque<octave_value> value_stack; |
7336 | 300 |
301 unsigned int storage_class; | |
302 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
303 // fcn_info *finfo; |
9413
5cd879a0d8c4
speed-up function call by caching its name lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
9409
diff
changeset
|
304 |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
305 bool valid; |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
306 |
23012
27e4ec3b0b49
move octave_refcount inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
307 octave::refcount<size_t> count; |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
308 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
309 private: |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
310 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
311 octave_value& xglobal_varref (void); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
312 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
313 octave_value& xpersistent_varref (void); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
314 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
315 octave_value xglobal_varval (void) const; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
316 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
317 octave_value xpersistent_varval (void) const; |
7336 | 318 }; |
319 | |
320 public: | |
321 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
322 symbol_record (void); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
323 |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
324 symbol_record (scope *s, const std::string& nm = "", |
10313 | 325 const octave_value& v = octave_value (), |
326 unsigned int sc = local) | |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
327 : rep (new symbol_record_rep (s, nm, v, sc)) { } |
7336 | 328 |
329 symbol_record (const symbol_record& sr) | |
330 : rep (sr.rep) | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11584
diff
changeset
|
331 { |
7336 | 332 rep->count++; |
333 } | |
334 | |
335 symbol_record& operator = (const symbol_record& sr) | |
336 { | |
337 if (this != &sr) | |
10313 | 338 { |
339 if (--rep->count == 0) | |
340 delete rep; | |
341 | |
342 rep = sr.rep; | |
343 rep->count++; | |
344 } | |
7336 | 345 |
346 return *this; | |
347 } | |
348 | |
349 ~symbol_record (void) | |
350 { | |
351 if (--rep->count == 0) | |
10313 | 352 delete rep; |
7336 | 353 } |
354 | |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
355 symbol_record dup (scope *sid) const |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
356 { |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
357 return symbol_record (rep->dup (sid)); |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
358 } |
7336 | 359 |
14899 | 360 const std::string& name (void) const { return rep->name; } |
7336 | 361 |
16502
45ae1038ee89
allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents:
16468
diff
changeset
|
362 void rename (const std::string& new_name) { rep->name = new_name; } |
45ae1038ee89
allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents:
16468
diff
changeset
|
363 |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
364 octave_value |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
365 find (const octave_value_list& args = octave_value_list ()) const; |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
366 |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
367 void assign (const octave_value& value) |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
368 { |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
369 rep->assign (value); |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
370 } |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
371 |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
372 void assign (octave_value::assign_op op, |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
373 const std::string& type, |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
374 const std::list<octave_value_list>& idx, |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
375 const octave_value& value) |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
376 { |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
377 rep->assign (op, type, idx, value); |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
378 } |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
379 |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
380 void assign (octave_value::assign_op op, const octave_value& value) |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
381 { |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
382 rep->assign (op, value); |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
383 } |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
384 |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
385 void do_non_const_unary_op (octave_value::unary_op op) |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
386 { |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
387 rep->do_non_const_unary_op (op); |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
388 } |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
389 |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
390 void do_non_const_unary_op (octave_value::unary_op op, |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
391 const std::string& type, |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
392 const std::list<octave_value_list>& idx) |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
393 { |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
394 rep->do_non_const_unary_op (op, type, idx); |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
395 } |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
396 |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
397 // Delete when deprecated varref functions are removed. |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
398 octave_value& varref (void) |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
399 { |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
400 return rep->varref (); |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
401 } |
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
402 |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
403 octave_value varval (void) const |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
404 { |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
405 return rep->varval (); |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
406 } |
7336 | 407 |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
408 void push_context (scope *sid) { rep->push_context (sid); } |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
409 |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
410 size_t pop_context (scope *sid) { return rep->pop_context (sid); } |
7336 | 411 |
412 void clear (void) { rep->clear (); } | |
413 | |
23611
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
414 void clear (scope *sid) { rep->clear (sid); } |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
415 |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
416 bool is_defined (void) const |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
417 { |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
418 return rep->is_defined (); |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
419 } |
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
420 |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
421 bool is_undefined (void) const |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
422 { |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
423 return ! rep->is_defined (); |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
424 } |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
425 |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
426 bool is_valid (void) const |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
427 { |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
428 return rep->is_valid (); |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
429 } |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
430 |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
431 bool is_variable (void) const |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
432 { |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
433 return rep->is_variable (); |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
434 } |
7336 | 435 |
436 bool is_local (void) const { return rep->is_local (); } | |
437 bool is_automatic (void) const { return rep->is_automatic (); } | |
438 bool is_formal (void) const { return rep->is_formal (); } | |
439 bool is_global (void) const { return rep->is_global (); } | |
440 bool is_hidden (void) const { return rep->is_hidden (); } | |
441 bool is_inherited (void) const { return rep->is_inherited (); } | |
442 bool is_persistent (void) const { return rep->is_persistent (); } | |
15236
44d6ffdf9479
Disallow new variables in nested functions (bug #36271)
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
443 bool is_added_static (void) const { return rep->is_added_static (); } |
7336 | 444 |
445 void mark_local (void) { rep->mark_local (); } | |
446 void mark_automatic (void) { rep->mark_automatic (); } | |
447 void mark_formal (void) { rep->mark_formal (); } | |
448 void mark_hidden (void) { rep->mark_hidden (); } | |
449 void mark_inherited (void) { rep->mark_inherited (); } | |
450 void mark_global (void) { rep->mark_global (); } | |
451 void mark_persistent (void) { rep->mark_persistent (); } | |
15236
44d6ffdf9479
Disallow new variables in nested functions (bug #36271)
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
452 void mark_added_static (void) { rep->mark_added_static (); } |
7336 | 453 |
454 void unmark_local (void) { rep->unmark_local (); } | |
455 void unmark_automatic (void) { rep->unmark_automatic (); } | |
456 void unmark_formal (void) { rep->unmark_formal (); } | |
457 void unmark_hidden (void) { rep->unmark_hidden (); } | |
458 void unmark_inherited (void) { rep->unmark_inherited (); } | |
459 void unmark_global (void) { rep->unmark_global (); } | |
460 void unmark_persistent (void) { rep->unmark_persistent (); } | |
15236
44d6ffdf9479
Disallow new variables in nested functions (bug #36271)
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
461 void unmark_added_static (void) { rep->unmark_added_static (); } |
7336 | 462 |
463 void init_persistent (void) { rep->init_persistent (); } | |
464 | |
465 void erase_persistent (void) { rep->erase_persistent (); } | |
466 | |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
467 void invalidate (void) { rep->invalidate (); } |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
468 |
23611
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
469 scope *decl_scope (void) { return rep->decl_scope (); } |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
470 |
7336 | 471 unsigned int xstorage_class (void) const { return rep->storage_class; } |
472 | |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
473 void set_curr_fcn (octave_user_function *fcn) { rep->set_curr_fcn (fcn); } |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
474 |
23680
ef71711f6d64
rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
475 octave_value dump (void) const { return rep->dump (); } |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
476 |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
477 const symbol_record_rep *xrep (void) const { return rep; } |
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
478 |
7336 | 479 private: |
480 | |
481 symbol_record_rep *rep; | |
482 | |
483 symbol_record (symbol_record_rep *new_rep) : rep (new_rep) { } | |
484 }; | |
485 | |
21573
f3f8e1d3e399
avoid mulitple definitions of static function-scope vars (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
486 static symbol_record dummy_symbol_record; |
f3f8e1d3e399
avoid mulitple definitions of static function-scope vars (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
487 |
14912
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14899
diff
changeset
|
488 // Always access a symbol from the current scope. |
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14899
diff
changeset
|
489 // Useful for scripts, as they may be executed in more than one scope. |
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14899
diff
changeset
|
490 class |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
491 symbol_reference |
14912
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14899
diff
changeset
|
492 { |
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14899
diff
changeset
|
493 public: |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
494 |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
495 symbol_reference (void) : m_scope (0), m_context (0) { } |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
496 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
497 symbol_reference (const symbol_record& record); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
498 |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
499 symbol_reference (const symbol_record& record, scope *curr_scope, |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
500 context_id context) |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
501 : m_scope (curr_scope), m_context (context), m_sym (record) |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
502 { } |
14912
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14899
diff
changeset
|
503 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
504 symbol_reference (const symbol_reference& ref) = default; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
505 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
506 symbol_reference& operator = (const symbol_reference& ref) = default; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
507 |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
508 bool is_black_hole (void) const { return ! m_scope; } |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
509 |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
510 symbol_table::scope * scope (void) const |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
511 { |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
512 update (); |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
513 return m_scope; |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
514 } |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
515 |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
516 context_id context (void) const |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
517 { |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
518 update (); |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
519 return m_context; |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
520 } |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
521 |
14912
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14899
diff
changeset
|
522 // The name is the same regardless of scope. |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
523 const std::string& name (void) const { return m_sym.name (); } |
14912
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14899
diff
changeset
|
524 |
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14899
diff
changeset
|
525 symbol_record *operator-> (void) |
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14899
diff
changeset
|
526 { |
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14899
diff
changeset
|
527 update (); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
528 return &m_sym; |
14912
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14899
diff
changeset
|
529 } |
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14899
diff
changeset
|
530 |
14913
c7071907a641
Use symbol_record_ref instead of names in JIT
Max Brister <max@2bass.com>
parents:
14912
diff
changeset
|
531 symbol_record *operator-> (void) const |
c7071907a641
Use symbol_record_ref instead of names in JIT
Max Brister <max@2bass.com>
parents:
14912
diff
changeset
|
532 { |
c7071907a641
Use symbol_record_ref instead of names in JIT
Max Brister <max@2bass.com>
parents:
14912
diff
changeset
|
533 update (); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
534 return &m_sym; |
14913
c7071907a641
Use symbol_record_ref instead of names in JIT
Max Brister <max@2bass.com>
parents:
14912
diff
changeset
|
535 } |
c7071907a641
Use symbol_record_ref instead of names in JIT
Max Brister <max@2bass.com>
parents:
14912
diff
changeset
|
536 |
14930
7d44ed216b98
Rename symbol_table::symbol_record_ref to symbol_table::symbol_reference
Max Brister <max@2bass.com>
parents:
14913
diff
changeset
|
537 // can be used to place symbol_reference in maps, we don't overload < as |
7d44ed216b98
Rename symbol_table::symbol_record_ref to symbol_table::symbol_reference
Max Brister <max@2bass.com>
parents:
14913
diff
changeset
|
538 // it doesn't make any sense for symbol_reference |
14912
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14899
diff
changeset
|
539 struct comparator |
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14899
diff
changeset
|
540 { |
14930
7d44ed216b98
Rename symbol_table::symbol_record_ref to symbol_table::symbol_reference
Max Brister <max@2bass.com>
parents:
14913
diff
changeset
|
541 bool operator ()(const symbol_reference& lhs, |
7d44ed216b98
Rename symbol_table::symbol_record_ref to symbol_table::symbol_reference
Max Brister <max@2bass.com>
parents:
14913
diff
changeset
|
542 const symbol_reference& rhs) const |
14912
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14899
diff
changeset
|
543 { |
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14899
diff
changeset
|
544 return lhs.name () < rhs.name (); |
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14899
diff
changeset
|
545 } |
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14899
diff
changeset
|
546 }; |
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14899
diff
changeset
|
547 private: |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
548 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
549 void update (void) const; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
550 |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
551 mutable symbol_table::scope *m_scope; |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
552 mutable context_id m_context; |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
553 mutable symbol_record m_sym; |
14912
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14899
diff
changeset
|
554 }; |
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14899
diff
changeset
|
555 |
7336 | 556 class |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
557 fcn_info |
7336 | 558 { |
559 public: | |
560 | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
561 typedef std::map<std::string, octave_value>::const_iterator |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
562 str_val_const_iterator; |
7336 | 563 typedef std::map<std::string, octave_value>::iterator str_val_iterator; |
564 | |
565 private: | |
566 | |
567 class | |
568 fcn_info_rep | |
569 { | |
570 public: | |
571 | |
572 fcn_info_rep (const std::string& nm) | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
573 : name (nm), package_name (), local_functions (), |
23343
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
574 private_functions (), class_constructors (), class_methods (), |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11584
diff
changeset
|
575 cmdline_function (), autoload_function (), function_on_path (), |
16684
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
576 built_in_function (), count (1) |
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
577 { |
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
578 size_t pos = name.rfind ('.'); |
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
579 |
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
580 if (pos != std::string::npos) |
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
581 { |
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
582 package_name = name.substr (0, pos); |
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
583 name = name.substr (pos+1); |
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
584 } |
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
585 } |
7336 | 586 |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
587 // No copying! |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
588 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
589 fcn_info_rep (const fcn_info_rep&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
590 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
591 fcn_info_rep& operator = (const fcn_info_rep&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
592 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
593 ~fcn_info_rep (void) = default; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
594 |
23343
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
595 octave_value install_local_function (const std::string& file_name); |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
596 |
7336 | 597 octave_value load_private_function (const std::string& dir_name); |
598 | |
599 octave_value load_class_constructor (void); | |
600 | |
601 octave_value load_class_method (const std::string& dispatch_type); | |
602 | |
9463
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
603 octave_value find (const octave_value_list& args, bool local_funcs); |
7336 | 604 |
9444
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
605 octave_value builtin_find (void); |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
606 |
7336 | 607 octave_value find_method (const std::string& dispatch_type); |
608 | |
609 octave_value find_autoload (void); | |
610 | |
16684
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
611 octave_value find_package (void); |
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
612 |
7336 | 613 octave_value find_user_function (void); |
614 | |
615 bool is_user_function_defined (void) const | |
616 { | |
10313 | 617 return function_on_path.is_defined (); |
7336 | 618 } |
619 | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
620 octave_value find_function (const octave_value_list& args, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
621 bool local_funcs) |
7336 | 622 { |
10313 | 623 return find (args, local_funcs); |
7336 | 624 } |
625 | |
626 void install_cmdline_function (const octave_value& f) | |
627 { | |
10313 | 628 cmdline_function = f; |
7336 | 629 } |
630 | |
23343
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
631 void install_local_function (const octave_value& f, |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
632 const std::string& file_name) |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
633 { |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
634 local_functions[file_name] = f; |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
635 } |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
636 |
7336 | 637 void install_user_function (const octave_value& f) |
638 { | |
10313 | 639 function_on_path = f; |
7336 | 640 } |
641 | |
642 void install_built_in_function (const octave_value& f) | |
643 { | |
10313 | 644 built_in_function = f; |
7336 | 645 } |
646 | |
22897
4090c32fccf8
store set of dispatch classes in built-in function objects
John W. Eaton <jwe@octave.org>
parents:
22893
diff
changeset
|
647 void install_built_in_dispatch (const std::string& klass); |
22893
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
648 |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
21134
diff
changeset
|
649 template <typename T> |
7489
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
650 void |
16605
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
651 clear_map (std::map<T, octave_value>& map, bool force = false) |
7336 | 652 { |
10313 | 653 typename std::map<T, octave_value>::iterator p = map.begin (); |
654 | |
655 while (p != map.end ()) | |
656 { | |
16605
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
657 if (force || ! p->second.islocked ()) |
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
658 map.erase (p++); |
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
659 else |
10313 | 660 p++; |
661 } | |
7489
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
662 } |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
663 |
16605
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
664 void clear_autoload_function (bool force = false) |
7489
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
665 { |
16605
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
666 if (force || ! autoload_function.islocked ()) |
10313 | 667 autoload_function = octave_value (); |
7336 | 668 } |
669 | |
15003
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14981
diff
changeset
|
670 // We also clear command line functions here, as these are both |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14981
diff
changeset
|
671 // "user defined" |
16605
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
672 void clear_user_function (bool force = false) |
7336 | 673 { |
20477
c36f06ef7539
also clear autoloaded functions when clearing user functions
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
674 clear_autoload_function (force); |
c36f06ef7539
also clear autoloaded functions when clearing user functions
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
675 |
16605
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
676 if (force || ! function_on_path.islocked ()) |
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
677 function_on_path = octave_value (); |
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
678 |
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
679 if (force || ! cmdline_function.islocked ()) |
15003
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14981
diff
changeset
|
680 cmdline_function = octave_value (); |
7336 | 681 } |
682 | |
683 void clear_mex_function (void) | |
684 { | |
10313 | 685 if (function_on_path.is_mex_function ()) |
686 clear_user_function (); | |
7489
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
687 } |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
688 |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16605
diff
changeset
|
689 void clear_package (void) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16605
diff
changeset
|
690 { |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16605
diff
changeset
|
691 package = octave_value (); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16605
diff
changeset
|
692 } |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16605
diff
changeset
|
693 |
16605
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
694 void clear (bool force = false) |
7489
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
695 { |
23343
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
696 clear_map (local_functions, force); |
16605
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
697 clear_map (private_functions, force); |
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
698 clear_map (class_constructors, force); |
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
699 clear_map (class_methods, force); |
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
700 |
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
701 clear_autoload_function (force); |
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
702 clear_user_function (force); |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16605
diff
changeset
|
703 clear_package (); |
7336 | 704 } |
705 | |
23680
ef71711f6d64
rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
706 octave_value dump (void) const; |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
707 |
16684
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
708 std::string full_name (void) const |
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
709 { |
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
710 if (package_name.empty ()) |
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
711 return name; |
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
712 else |
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
713 return package_name + "." + name; |
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
714 } |
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
715 |
7336 | 716 std::string name; |
717 | |
16684
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
718 std::string package_name; |
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
719 |
23343
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
720 // File name to function object. |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
721 std::map<std::string, octave_value> local_functions; |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
722 |
7336 | 723 // Directory name to function object. |
724 std::map<std::string, octave_value> private_functions; | |
725 | |
726 // Class name to function object. | |
727 std::map<std::string, octave_value> class_constructors; | |
728 | |
729 // Dispatch type to function object. | |
730 std::map<std::string, octave_value> class_methods; | |
731 | |
732 octave_value cmdline_function; | |
733 | |
734 octave_value autoload_function; | |
735 | |
736 octave_value function_on_path; | |
737 | |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16605
diff
changeset
|
738 octave_value package; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16605
diff
changeset
|
739 |
7336 | 740 octave_value built_in_function; |
741 | |
23012
27e4ec3b0b49
move octave_refcount inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
742 octave::refcount<size_t> count; |
7336 | 743 |
744 private: | |
745 | |
9463
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
746 octave_value xfind (const octave_value_list& args, bool local_funcs); |
8691
7838271ee25c
symtab.cc (symbol_table::fcn_info::fcn_info_rep::find): avoid recursive call
John W. Eaton <jwe@octave.org>
parents:
8282
diff
changeset
|
747 |
9444
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
748 octave_value x_builtin_find (void); |
7336 | 749 }; |
750 | |
751 public: | |
752 | |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
21012
diff
changeset
|
753 fcn_info (const std::string& nm = "") |
7336 | 754 : rep (new fcn_info_rep (nm)) { } |
755 | |
8906
ab87d08d9a1b
improve symbol inheritance for anonymous functions
John W. Eaton <jwe@octave.org>
parents:
8884
diff
changeset
|
756 fcn_info (const fcn_info& fi) : rep (fi.rep) |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11584
diff
changeset
|
757 { |
7336 | 758 rep->count++; |
759 } | |
760 | |
8906
ab87d08d9a1b
improve symbol inheritance for anonymous functions
John W. Eaton <jwe@octave.org>
parents:
8884
diff
changeset
|
761 fcn_info& operator = (const fcn_info& fi) |
7336 | 762 { |
8906
ab87d08d9a1b
improve symbol inheritance for anonymous functions
John W. Eaton <jwe@octave.org>
parents:
8884
diff
changeset
|
763 if (this != &fi) |
10313 | 764 { |
765 if (--rep->count == 0) | |
766 delete rep; | |
767 | |
768 rep = fi.rep; | |
769 rep->count++; | |
770 } | |
7336 | 771 |
772 return *this; | |
773 } | |
774 | |
775 ~fcn_info (void) | |
776 { | |
777 if (--rep->count == 0) | |
10313 | 778 delete rep; |
7336 | 779 } |
780 | |
9463
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
781 octave_value find (const octave_value_list& args = octave_value_list (), |
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
782 bool local_funcs = true) |
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
783 { |
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
784 return rep->find (args, local_funcs); |
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
785 } |
7336 | 786 |
9444
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
787 octave_value builtin_find (void) |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
788 { |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
789 return rep->builtin_find (); |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
790 } |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
791 |
7336 | 792 octave_value find_method (const std::string& dispatch_type) const |
793 { | |
794 return rep->find_method (dispatch_type); | |
795 } | |
796 | |
797 octave_value find_built_in_function (void) const | |
798 { | |
799 return rep->built_in_function; | |
800 } | |
801 | |
12911
d6151d774283
make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
12130
diff
changeset
|
802 octave_value find_cmdline_function (void) const |
d6151d774283
make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
12130
diff
changeset
|
803 { |
d6151d774283
make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
12130
diff
changeset
|
804 return rep->cmdline_function; |
d6151d774283
make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
12130
diff
changeset
|
805 } |
d6151d774283
make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
12130
diff
changeset
|
806 |
7336 | 807 octave_value find_autoload (void) |
808 { | |
809 return rep->find_autoload (); | |
810 } | |
811 | |
812 octave_value find_user_function (void) | |
813 { | |
814 return rep->find_user_function (); | |
815 } | |
816 | |
817 bool is_user_function_defined (void) const | |
818 { | |
819 return rep->is_user_function_defined (); | |
820 } | |
821 | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
822 octave_value find_function (const octave_value_list& args |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
823 = octave_value_list (), |
9463
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
824 bool local_funcs = true) |
7336 | 825 { |
9463
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
826 return rep->find_function (args, local_funcs); |
7336 | 827 } |
828 | |
829 void install_cmdline_function (const octave_value& f) | |
830 { | |
831 rep->install_cmdline_function (f); | |
832 } | |
833 | |
23343
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
834 void install_local_function (const octave_value& f, |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
835 const std::string& file_name) |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
836 { |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
837 rep->install_local_function (f, file_name); |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
838 } |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
839 |
7336 | 840 void install_user_function (const octave_value& f) |
841 { | |
842 rep->install_user_function (f); | |
843 } | |
844 | |
845 void install_built_in_function (const octave_value& f) | |
846 { | |
847 rep->install_built_in_function (f); | |
848 } | |
849 | |
22893
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
850 void install_built_in_dispatch (const std::string& klass) |
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
851 { |
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
852 rep->install_built_in_dispatch (klass); |
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
853 } |
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
854 |
16605
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
855 void clear (bool force = false) { rep->clear (force); } |
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
856 |
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
857 void clear_user_function (bool force = false) |
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
858 { |
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
859 rep->clear_user_function (force); |
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
860 } |
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
861 |
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
862 void clear_autoload_function (bool force = false) |
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
863 { |
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
864 rep->clear_autoload_function (force); |
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
865 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11584
diff
changeset
|
866 |
7336 | 867 void clear_mex_function (void) { rep->clear_mex_function (); } |
7972
5bf4e2c13ed8
make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents:
7901
diff
changeset
|
868 |
23680
ef71711f6d64
rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
869 octave_value dump (void) const { return rep->dump (); } |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
870 |
7336 | 871 private: |
872 | |
873 fcn_info_rep *rep; | |
874 }; | |
875 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
876 symbol_table (void) |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
877 : m_global_symbols (), m_fcn_table (), m_class_precedence_table (), |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
878 m_parent_map (), m_global_scope (new scope ("global scope")), |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
879 m_top_scope (new scope ("top scope")), |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
880 m_current_scope (m_top_scope) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
881 { } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
882 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
883 // No copying! |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
884 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
885 symbol_table (const symbol_table&) = delete; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
886 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
887 symbol_table& operator = (const symbol_table&) = delete; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
888 |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
889 ~symbol_table (void) |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
890 { |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
891 delete m_top_scope; |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
892 delete m_global_scope; |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
893 } |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
894 |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
895 scope *global_scope (void) { return m_global_scope; } |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
896 scope *top_scope (void) { return m_top_scope; } |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
897 |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
898 scope *current_scope (void) { return m_current_scope; } |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
899 |
23611
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
900 scope *require_current_scope (const std::string& who) |
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
901 { |
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
902 if (! m_current_scope) |
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
903 error ("%s: missing scope", who.c_str ()); |
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
904 |
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
905 return m_current_scope; |
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
906 } |
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
907 |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
908 context_id current_context (void) const |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
909 { |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
910 return m_current_scope ? m_current_scope->current_context () : 0; |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
911 } |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
912 |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
913 void set_scope (scope *sid) |
7336 | 914 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
915 set_scope_and_context (sid, 0); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
916 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
917 |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
918 void set_scope_and_context (scope *sid, context_id context) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
919 { |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
920 if (sid == m_global_scope) |
7336 | 921 error ("can't set scope to global"); |
20982
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20956
diff
changeset
|
922 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
923 m_current_scope = sid; |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
924 |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
925 if (m_current_scope) |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
926 m_current_scope->set_context (context); |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
927 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
928 |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
929 symbol_record find_symbol (const std::string& name, scope *sid) |
7336 | 930 { |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
931 return sid ? sid->find_symbol (name) : symbol_record (); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
932 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
933 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
934 symbol_record find_symbol (const std::string& name) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
935 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
936 return find_symbol (name, m_current_scope); |
7336 | 937 } |
4009 | 938 |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
939 void inherit (scope *recipient_scope, scope *donor_scope) |
7336 | 940 { |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
941 if (recipient_scope) |
23611
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
942 recipient_scope->inherit (donor_scope); |
7336 | 943 } |
944 | |
23611
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
945 void inherit (scope *recipient_scope) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
946 { |
23611
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
947 inherit (recipient_scope, m_current_scope); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
948 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
949 |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
950 bool at_top_level (void) { return m_current_scope == m_top_scope; } |
7336 | 951 |
952 // Find a value corresponding to the given name in the table. | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
953 octave_value |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
954 find (const std::string& name, |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
955 const octave_value_list& args = octave_value_list (), |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
956 bool skip_variables = false, |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
957 bool local_funcs = true); |
7336 | 958 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
959 octave_value builtin_find (const std::string& name); |
9444
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
960 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
961 void |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
962 global_assign (const std::string& name, |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
963 const octave_value& value = octave_value ()) |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
964 |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
965 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
966 global_symbols_iterator p = m_global_symbols.find (name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
967 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
968 if (p == m_global_symbols.end ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
969 m_global_symbols[name] = value; |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
970 else |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
971 p->second = value; |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
972 } |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
973 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
974 octave_value |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
975 global_varval (const std::string& name) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
976 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
977 global_symbols_const_iterator p = m_global_symbols.find (name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
978 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
979 return (p != m_global_symbols.end ()) ? p->second : octave_value (); |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
980 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
981 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
982 void |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
983 top_level_assign (const std::string& name, |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
984 const octave_value& value = octave_value ()) |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
985 { |
23610
2fe11412e785
remove deprecated and unused symbol_table functions
John W. Eaton <jwe@octave.org>
parents:
23604
diff
changeset
|
986 m_top_scope->assign (name, value); |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
987 } |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
988 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
989 octave_value |
10071
e42b1bbd1052
variables.cc (get_top_level_value, set_top_level_value): new functions
John W. Eaton <jwe@octave.org>
parents:
9981
diff
changeset
|
990 top_level_varval (const std::string& name) |
e42b1bbd1052
variables.cc (get_top_level_value, set_top_level_value): new functions
John W. Eaton <jwe@octave.org>
parents:
9981
diff
changeset
|
991 { |
23610
2fe11412e785
remove deprecated and unused symbol_table functions
John W. Eaton <jwe@octave.org>
parents:
23604
diff
changeset
|
992 return m_top_scope->varval (name); |
21813
2ba69be3f3e8
accept scope as argument in most static symbol_table functions
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
993 } |
2ba69be3f3e8
accept scope as argument in most static symbol_table functions
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
994 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
995 bool |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
996 is_built_in_function_name (const std::string& name) |
7336 | 997 { |
998 octave_value val = find_built_in_function (name); | |
999 | |
1000 return val.is_defined (); | |
1001 } | |
1002 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1003 octave_value |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1004 find_method (const std::string& name, const std::string& dispatch_type) |
7336 | 1005 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1006 fcn_table_const_iterator p = m_fcn_table.find (name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1007 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1008 if (p != m_fcn_table.end ()) |
21264
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21244
diff
changeset
|
1009 { |
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21244
diff
changeset
|
1010 octave_value fcn = p->second.find_method (dispatch_type); |
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21244
diff
changeset
|
1011 |
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21244
diff
changeset
|
1012 if (! fcn.is_defined ()) |
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21244
diff
changeset
|
1013 fcn = find_submethod (name, dispatch_type); |
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21244
diff
changeset
|
1014 |
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21244
diff
changeset
|
1015 return fcn; |
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21244
diff
changeset
|
1016 } |
7336 | 1017 else |
1018 { | |
10313 | 1019 fcn_info finfo (name); |
1020 | |
1021 octave_value fcn = finfo.find_method (dispatch_type); | |
1022 | |
21264
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21244
diff
changeset
|
1023 if (! fcn.is_defined ()) |
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21244
diff
changeset
|
1024 fcn = find_submethod (name, dispatch_type); |
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21244
diff
changeset
|
1025 |
10313 | 1026 if (fcn.is_defined ()) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1027 m_fcn_table[name] = finfo; |
10313 | 1028 |
1029 return fcn; | |
7336 | 1030 } |
1031 } | |
1032 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1033 octave_value |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1034 find_submethod (const std::string& name, const std::string& dispatch_type); |
21264
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21244
diff
changeset
|
1035 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1036 octave_value |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1037 find_built_in_function (const std::string& name) |
7336 | 1038 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1039 fcn_table_const_iterator p = m_fcn_table.find (name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1040 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1041 return (p != m_fcn_table.end () |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1042 ? p->second.find_built_in_function () : octave_value ()); |
7336 | 1043 } |
1044 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1045 octave_value |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1046 find_autoload (const std::string& name) |
7336 | 1047 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1048 fcn_table_iterator p = m_fcn_table.find (name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1049 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1050 return (p != m_fcn_table.end () |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1051 ? p->second.find_autoload () : octave_value ()); |
7336 | 1052 } |
1053 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1054 octave_value |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1055 find_function (const std::string& name, |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1056 const octave_value_list& args = octave_value_list (), |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1057 bool local_funcs = true); |
7336 | 1058 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1059 octave_value find_user_function (const std::string& name) |
7336 | 1060 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1061 fcn_table_iterator p = m_fcn_table.find (name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1062 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1063 return (p != m_fcn_table.end () |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1064 ? p->second.find_user_function () : octave_value ()); |
7336 | 1065 } |
1066 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1067 octave_value find_cmdline_function (const std::string& name) |
20207
abf85f8cbd6c
Expand type() to work on command-line entered functions (bug #40462).
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
1068 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1069 fcn_table_iterator p = m_fcn_table.find (name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1070 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1071 return (p != m_fcn_table.end () |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1072 ? p->second.find_cmdline_function () : octave_value ()); |
20207
abf85f8cbd6c
Expand type() to work on command-line entered functions (bug #40462).
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
1073 } |
abf85f8cbd6c
Expand type() to work on command-line entered functions (bug #40462).
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
1074 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1075 void install_cmdline_function (const std::string& name, |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1076 const octave_value& fcn) |
7336 | 1077 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1078 fcn_table_iterator p = m_fcn_table.find (name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1079 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1080 if (p != m_fcn_table.end ()) |
7336 | 1081 { |
10313 | 1082 fcn_info& finfo = p->second; |
1083 | |
1084 finfo.install_cmdline_function (fcn); | |
7336 | 1085 } |
1086 else | |
1087 { | |
10313 | 1088 fcn_info finfo (name); |
1089 | |
1090 finfo.install_cmdline_function (fcn); | |
1091 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1092 m_fcn_table[name] = finfo; |
7336 | 1093 } |
1094 } | |
1095 | |
23343
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
1096 // Install local function FCN named NAME. FILE_NAME is the name of |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
1097 // the file containing the local function. |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
1098 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1099 void install_local_function (const std::string& name, |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1100 const octave_value& fcn, |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1101 const std::string& file_name) |
23343
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
1102 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1103 fcn_table_iterator p = m_fcn_table.find (name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1104 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1105 if (p != m_fcn_table.end ()) |
23343
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
1106 { |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
1107 fcn_info& finfo = p->second; |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
1108 |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
1109 finfo.install_local_function (fcn, file_name); |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
1110 } |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
1111 else |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
1112 { |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
1113 fcn_info finfo (name); |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
1114 |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
1115 finfo.install_local_function (fcn, file_name); |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
1116 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1117 m_fcn_table[name] = finfo; |
23343
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
1118 } |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
1119 } |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
1120 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1121 void install_user_function (const std::string& name, |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1122 const octave_value& fcn) |
7336 | 1123 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1124 fcn_table_iterator p = m_fcn_table.find (name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1125 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1126 if (p != m_fcn_table.end ()) |
7336 | 1127 { |
10313 | 1128 fcn_info& finfo = p->second; |
1129 | |
1130 finfo.install_user_function (fcn); | |
7336 | 1131 } |
1132 else | |
1133 { | |
10313 | 1134 fcn_info finfo (name); |
1135 | |
1136 finfo.install_user_function (fcn); | |
1137 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1138 m_fcn_table[name] = finfo; |
7336 | 1139 } |
1140 } | |
605 | 1141 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1142 void install_built_in_function (const std::string& name, |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1143 const octave_value& fcn) |
7336 | 1144 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1145 fcn_table_iterator p = m_fcn_table.find (name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1146 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1147 if (p != m_fcn_table.end ()) |
7336 | 1148 { |
10313 | 1149 fcn_info& finfo = p->second; |
1150 | |
1151 finfo.install_built_in_function (fcn); | |
7336 | 1152 } |
1153 else | |
1154 { | |
10313 | 1155 fcn_info finfo (name); |
1156 | |
1157 finfo.install_built_in_function (fcn); | |
1158 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1159 m_fcn_table[name] = finfo; |
7336 | 1160 } |
1161 } | |
1162 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1163 void clear_all (bool force = false) |
7336 | 1164 { |
23611
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
1165 if (m_current_scope) |
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
1166 { |
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
1167 m_current_scope->clear_variables (); |
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
1168 m_current_scope->clear_global_pattern ("*"); |
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
1169 } |
7336 | 1170 |
16605
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
1171 clear_functions (force); |
7336 | 1172 } |
1173 | |
21813
2ba69be3f3e8
accept scope as argument in most static symbol_table functions
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1174 // This is written as two separate functions instead of a single |
2ba69be3f3e8
accept scope as argument in most static symbol_table functions
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1175 // function with default values so that it will work properly with |
2ba69be3f3e8
accept scope as argument in most static symbol_table functions
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1176 // unwind_protect. |
2ba69be3f3e8
accept scope as argument in most static symbol_table functions
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1177 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1178 void clear_functions (bool force = false) |
7336 | 1179 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1180 fcn_table_iterator p = m_fcn_table.begin (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1181 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1182 while (p != m_fcn_table.end ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1183 (p++)->second.clear (force); |
7336 | 1184 } |
1185 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1186 void clear_function (const std::string& name) |
7336 | 1187 { |
1188 clear_user_function (name); | |
1189 } | |
1190 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1191 void clear_symbol (const std::string& name) |
7336 | 1192 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1193 // FIXME: are we supposed to do both here? |
7336 | 1194 |
23611
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
1195 if (m_current_scope) |
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
1196 m_current_scope->clear_variable (name); |
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
1197 |
7336 | 1198 clear_function (name); |
1199 } | |
1200 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1201 void clear_function_pattern (const std::string& pat) |
7336 | 1202 { |
1203 glob_match pattern (pat); | |
1204 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1205 fcn_table_iterator p = m_fcn_table.begin (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1206 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1207 while (p != m_fcn_table.end ()) |
7336 | 1208 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1209 if (pattern.match (p->first)) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1210 (p++)->second.clear_user_function (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1211 else |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1212 p++; |
7336 | 1213 } |
1214 } | |
1215 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1216 void clear_symbol_pattern (const std::string& pat) |
7336 | 1217 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1218 // FIXME: are we supposed to do both here? |
7336 | 1219 |
23611
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
1220 if (m_current_scope) |
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
1221 m_current_scope->clear_variable_pattern (pat); |
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
1222 |
7336 | 1223 clear_function_pattern (pat); |
1224 } | |
1225 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1226 void clear_user_function (const std::string& name) |
7336 | 1227 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1228 fcn_table_iterator p = m_fcn_table.find (name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1229 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1230 if (p != m_fcn_table.end ()) |
7336 | 1231 { |
10313 | 1232 fcn_info& finfo = p->second; |
1233 | |
1234 finfo.clear_user_function (); | |
7336 | 1235 } |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1236 // FIXME: is this necessary, or even useful? |
7336 | 1237 // else |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
1238 // error ("clear: no such function '%s'", name.c_str ()); |
7336 | 1239 } |
1240 | |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21574
diff
changeset
|
1241 // This clears oct and mex files, including autoloads. |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1242 void clear_dld_function (const std::string& name) |
9958
80432f0ee895
improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents:
9639
diff
changeset
|
1243 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1244 fcn_table_iterator p = m_fcn_table.find (name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1245 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1246 if (p != m_fcn_table.end ()) |
9958
80432f0ee895
improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents:
9639
diff
changeset
|
1247 { |
10313 | 1248 fcn_info& finfo = p->second; |
1249 | |
1250 finfo.clear_autoload_function (); | |
1251 finfo.clear_user_function (); | |
9958
80432f0ee895
improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents:
9639
diff
changeset
|
1252 } |
80432f0ee895
improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents:
9639
diff
changeset
|
1253 } |
80432f0ee895
improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents:
9639
diff
changeset
|
1254 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1255 void clear_mex_functions (void) |
7336 | 1256 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1257 fcn_table_iterator p = m_fcn_table.begin (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1258 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1259 while (p != m_fcn_table.end ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1260 (p++)->second.clear_mex_function (); |
7336 | 1261 } |
1262 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1263 bool set_class_relationship (const std::string& sup_class, |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1264 const std::string& inf_class); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1265 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1266 bool is_superiorto (const std::string& a, const std::string& b); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1267 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1268 void alias_built_in_function (const std::string& alias, |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1269 const std::string& name) |
7336 | 1270 { |
1271 octave_value fcn = find_built_in_function (name); | |
1272 | |
1273 if (fcn.is_defined ()) | |
1274 { | |
10313 | 1275 fcn_info finfo (alias); |
1276 | |
1277 finfo.install_built_in_function (fcn); | |
1278 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1279 m_fcn_table[alias] = finfo; |
7336 | 1280 } |
1281 else | |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
1282 panic ("alias: '%s' is undefined", name.c_str ()); |
7336 | 1283 } |
1284 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1285 void install_built_in_dispatch (const std::string& name, |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1286 const std::string& klass) |
7336 | 1287 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1288 fcn_table_iterator p = m_fcn_table.find (name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1289 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1290 if (p != m_fcn_table.end ()) |
7336 | 1291 { |
10313 | 1292 fcn_info& finfo = p->second; |
1293 | |
22893
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
1294 finfo.install_built_in_dispatch (klass); |
7336 | 1295 } |
22893
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
1296 else |
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
1297 error ("install_built_in_dispatch: '%s' is undefined", name.c_str ()); |
7336 | 1298 } |
1299 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1300 void push_context (void) |
7336 | 1301 { |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1302 if (m_current_scope == m_top_scope) |
21813
2ba69be3f3e8
accept scope as argument in most static symbol_table functions
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1303 error ("invalid call to symtab::push_context"); |
2ba69be3f3e8
accept scope as argument in most static symbol_table functions
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1304 |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1305 if (m_current_scope) |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1306 m_current_scope->push_context (); |
7336 | 1307 } |
1308 | |
21813
2ba69be3f3e8
accept scope as argument in most static symbol_table functions
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1309 // This is written as two separate functions instead of a single |
2ba69be3f3e8
accept scope as argument in most static symbol_table functions
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1310 // function with default values so that it will work properly with |
2ba69be3f3e8
accept scope as argument in most static symbol_table functions
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1311 // unwind_protect. |
2ba69be3f3e8
accept scope as argument in most static symbol_table functions
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1312 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1313 void pop_context (void) |
7336 | 1314 { |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1315 if (m_current_scope == m_top_scope) |
21813
2ba69be3f3e8
accept scope as argument in most static symbol_table functions
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1316 error ("invalid call to symtab::pop_context"); |
2ba69be3f3e8
accept scope as argument in most static symbol_table functions
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1317 |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1318 if (m_current_scope) |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1319 m_current_scope->pop_context (); |
7336 | 1320 } |
1321 | |
21813
2ba69be3f3e8
accept scope as argument in most static symbol_table functions
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1322 // For unwind_protect where a pointer argument is needed. |
2ba69be3f3e8
accept scope as argument in most static symbol_table functions
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1323 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1324 void pop_context (void *) { pop_context (); } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1325 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1326 std::list<symbol_record> glob (const std::string& pattern) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1327 { |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1328 return (m_current_scope |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1329 ? m_current_scope->glob (pattern) : std::list<symbol_record> ()); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1330 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1331 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1332 std::list<symbol_record> |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1333 glob_global_variables (const std::string& pattern) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1334 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1335 std::list<symbol_record> retval; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1336 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1337 glob_match pat (pattern); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1338 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1339 for (const auto& nm_val : m_global_symbols) |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1340 { |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
1341 // We generate a list of symbol_record objects so that the results from |
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
1342 // glob_variables and glob_global_variables may be handled the same |
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
1343 // way. |
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
1344 if (pat.match (nm_val.first)) |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1345 retval.push_back (symbol_record (m_global_scope, |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
1346 nm_val.first, nm_val.second, |
10313 | 1347 symbol_record::global)); |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1348 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1349 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1350 return retval; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1351 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1352 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1353 std::list<symbol_record> |
7779
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1354 regexp_global_variables (const std::string& pattern) |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1355 { |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1356 std::list<symbol_record> retval; |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1357 |
22333
2758af148ced
move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
1358 octave::regexp pat (pattern); |
7779
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1359 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1360 for (const auto& nm_val : m_global_symbols) |
7779
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1361 { |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
1362 // We generate a list of symbol_record objects so that the results from |
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
1363 // regexp_variables and regexp_global_variables may be handled the same |
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
1364 // way. |
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
1365 if (pat.is_match (nm_val.first)) |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1366 retval.push_back (symbol_record (m_global_scope, |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
1367 nm_val.first, nm_val.second, |
10313 | 1368 symbol_record::global)); |
7779
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1369 } |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1370 |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1371 return retval; |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1372 } |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1373 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1374 std::list<symbol_record> glob_variables (const string_vector& patterns) |
7336 | 1375 { |
1376 std::list<symbol_record> retval; | |
1377 | |
23644
3177e276e60f
avoid inifite recursion in symbol table glob and regexp functions
John W. Eaton <jwe@octave.org>
parents:
23611
diff
changeset
|
1378 if (! m_current_scope) |
3177e276e60f
avoid inifite recursion in symbol table glob and regexp functions
John W. Eaton <jwe@octave.org>
parents:
23611
diff
changeset
|
1379 return retval; |
3177e276e60f
avoid inifite recursion in symbol table glob and regexp functions
John W. Eaton <jwe@octave.org>
parents:
23611
diff
changeset
|
1380 |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20207
diff
changeset
|
1381 size_t len = patterns.numel (); |
8 | 1382 |
7336 | 1383 for (size_t i = 0; i < len; i++) |
1384 { | |
23644
3177e276e60f
avoid inifite recursion in symbol table glob and regexp functions
John W. Eaton <jwe@octave.org>
parents:
23611
diff
changeset
|
1385 std::list<symbol_record> tmp = m_current_scope->glob (patterns[i]); |
10313 | 1386 |
1387 retval.insert (retval.begin (), tmp.begin (), tmp.end ()); | |
7336 | 1388 } |
1389 | |
1390 return retval; | |
1391 } | |
1392 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1393 std::list<symbol_record> regexp_variables (const string_vector& patterns) |
7779
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1394 { |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1395 std::list<symbol_record> retval; |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1396 |
23644
3177e276e60f
avoid inifite recursion in symbol table glob and regexp functions
John W. Eaton <jwe@octave.org>
parents:
23611
diff
changeset
|
1397 if (! m_current_scope) |
3177e276e60f
avoid inifite recursion in symbol table glob and regexp functions
John W. Eaton <jwe@octave.org>
parents:
23611
diff
changeset
|
1398 return retval; |
3177e276e60f
avoid inifite recursion in symbol table glob and regexp functions
John W. Eaton <jwe@octave.org>
parents:
23611
diff
changeset
|
1399 |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20207
diff
changeset
|
1400 size_t len = patterns.numel (); |
7779
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1401 |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1402 for (size_t i = 0; i < len; i++) |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1403 { |
23644
3177e276e60f
avoid inifite recursion in symbol table glob and regexp functions
John W. Eaton <jwe@octave.org>
parents:
23611
diff
changeset
|
1404 std::list<symbol_record> tmp = m_current_scope->regexp (patterns[i]); |
10313 | 1405 |
1406 retval.insert (retval.begin (), tmp.begin (), tmp.end ()); | |
7779
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1407 } |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1408 |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1409 return retval; |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1410 } |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1411 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1412 std::list<std::string> user_function_names (void) |
7336 | 1413 { |
1414 std::list<std::string> retval; | |
1415 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1416 for (const auto& nm_finfo : m_fcn_table) |
7336 | 1417 { |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
1418 if (nm_finfo.second.is_user_function_defined ()) |
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
1419 retval.push_back (nm_finfo.first); |
7336 | 1420 } |
1421 | |
1422 if (! retval.empty ()) | |
1423 retval.sort (); | |
1424 | |
1425 return retval; | |
1426 } | |
3011 | 1427 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1428 std::list<std::string> global_variable_names (void) |
7336 | 1429 { |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1430 std::list<std::string> retval; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1431 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1432 for (const auto& nm_val : m_global_symbols) |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
1433 retval.push_back (nm_val.first); |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1434 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1435 retval.sort (); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1436 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1437 return retval; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1438 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1439 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1440 std::list<std::string> top_level_variable_names (void) |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1441 { |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1442 return (m_top_scope |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1443 ? m_top_scope->variable_names () : std::list<std::string> ()); |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1444 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1445 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1446 std::list<std::string> variable_names (void) |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1447 { |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1448 return (m_current_scope |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1449 ? m_current_scope->variable_names () : std::list<std::string> ()); |
7336 | 1450 } |
1451 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1452 std::list<std::string> built_in_function_names (void) |
7336 | 1453 { |
1454 std::list<std::string> retval; | |
1455 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1456 for (const auto& nm_finfo : m_fcn_table) |
7336 | 1457 { |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
1458 octave_value fcn = nm_finfo.second.find_built_in_function (); |
10313 | 1459 |
1460 if (fcn.is_defined ()) | |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
1461 retval.push_back (nm_finfo.first); |
7336 | 1462 } |
1463 | |
1464 if (! retval.empty ()) | |
1465 retval.sort (); | |
220 | 1466 |
7336 | 1467 return retval; |
1468 } | |
1469 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1470 std::list<std::string> cmdline_function_names (void) |
12911
d6151d774283
make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
12130
diff
changeset
|
1471 { |
d6151d774283
make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
12130
diff
changeset
|
1472 std::list<std::string> retval; |
d6151d774283
make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
12130
diff
changeset
|
1473 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1474 for (const auto& nm_finfo : m_fcn_table) |
12911
d6151d774283
make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
12130
diff
changeset
|
1475 { |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
1476 octave_value fcn = nm_finfo.second.find_cmdline_function (); |
12911
d6151d774283
make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
12130
diff
changeset
|
1477 |
d6151d774283
make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
12130
diff
changeset
|
1478 if (fcn.is_defined ()) |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
1479 retval.push_back (nm_finfo.first); |
12911
d6151d774283
make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
12130
diff
changeset
|
1480 } |
d6151d774283
make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
12130
diff
changeset
|
1481 |
d6151d774283
make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
12130
diff
changeset
|
1482 if (! retval.empty ()) |
d6151d774283
make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
12130
diff
changeset
|
1483 retval.sort (); |
d6151d774283
make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
12130
diff
changeset
|
1484 |
d6151d774283
make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
12130
diff
changeset
|
1485 return retval; |
d6151d774283
make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
12130
diff
changeset
|
1486 } |
d6151d774283
make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
12130
diff
changeset
|
1487 |
23680
ef71711f6d64
rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
1488 octave_value dump (void) const; |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1489 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1490 void add_to_parent_map (const std::string& classname, |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1491 const std::list<std::string>& parent_list) |
9581
3d0d2bda3a0f
fix previous change, avoid duplicate loads of methods in descendant classes
Jaroslav Hajek <highegg@gmail.com>
parents:
9509
diff
changeset
|
1492 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1493 m_parent_map[classname] = parent_list; |
9581
3d0d2bda3a0f
fix previous change, avoid duplicate loads of methods in descendant classes
Jaroslav Hajek <highegg@gmail.com>
parents:
9509
diff
changeset
|
1494 } |
3d0d2bda3a0f
fix previous change, avoid duplicate loads of methods in descendant classes
Jaroslav Hajek <highegg@gmail.com>
parents:
9509
diff
changeset
|
1495 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1496 std::list<std::string> |
11238
1783b360976f
also consider parent classes when checking if class methods are out of date
John W. Eaton <jwe@octave.org>
parents:
10633
diff
changeset
|
1497 parent_classes (const std::string& dispatch_type) |
1783b360976f
also consider parent classes when checking if class methods are out of date
John W. Eaton <jwe@octave.org>
parents:
10633
diff
changeset
|
1498 { |
1783b360976f
also consider parent classes when checking if class methods are out of date
John W. Eaton <jwe@octave.org>
parents:
10633
diff
changeset
|
1499 std::list<std::string> retval; |
1783b360976f
also consider parent classes when checking if class methods are out of date
John W. Eaton <jwe@octave.org>
parents:
10633
diff
changeset
|
1500 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1501 const_parent_map_iterator it = m_parent_map.find (dispatch_type); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1502 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1503 if (it != m_parent_map.end ()) |
11238
1783b360976f
also consider parent classes when checking if class methods are out of date
John W. Eaton <jwe@octave.org>
parents:
10633
diff
changeset
|
1504 retval = it->second; |
1783b360976f
also consider parent classes when checking if class methods are out of date
John W. Eaton <jwe@octave.org>
parents:
10633
diff
changeset
|
1505 |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
1506 for (const auto& nm : retval) |
12130
3229572cbe23
symbol_table::parent_classes: also add parents of parents to the list
John W. Eaton <jwe@octave.org>
parents:
12122
diff
changeset
|
1507 { |
3229572cbe23
symbol_table::parent_classes: also add parents of parents to the list
John W. Eaton <jwe@octave.org>
parents:
12122
diff
changeset
|
1508 // Search for parents of parents and append them to the list. |
3229572cbe23
symbol_table::parent_classes: also add parents of parents to the list
John W. Eaton <jwe@octave.org>
parents:
12122
diff
changeset
|
1509 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1510 // FIXME: should we worry about a circular inheritance graph? |
12130
3229572cbe23
symbol_table::parent_classes: also add parents of parents to the list
John W. Eaton <jwe@octave.org>
parents:
12122
diff
changeset
|
1511 |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
1512 std::list<std::string> parents = parent_classes (nm); |
12130
3229572cbe23
symbol_table::parent_classes: also add parents of parents to the list
John W. Eaton <jwe@octave.org>
parents:
12122
diff
changeset
|
1513 |
3229572cbe23
symbol_table::parent_classes: also add parents of parents to the list
John W. Eaton <jwe@octave.org>
parents:
12122
diff
changeset
|
1514 if (! parents.empty ()) |
3229572cbe23
symbol_table::parent_classes: also add parents of parents to the list
John W. Eaton <jwe@octave.org>
parents:
12122
diff
changeset
|
1515 retval.insert (retval.end (), parents.begin (), parents.end ()); |
3229572cbe23
symbol_table::parent_classes: also add parents of parents to the list
John W. Eaton <jwe@octave.org>
parents:
12122
diff
changeset
|
1516 } |
3229572cbe23
symbol_table::parent_classes: also add parents of parents to the list
John W. Eaton <jwe@octave.org>
parents:
12122
diff
changeset
|
1517 |
11238
1783b360976f
also consider parent classes when checking if class methods are out of date
John W. Eaton <jwe@octave.org>
parents:
10633
diff
changeset
|
1518 return retval; |
1783b360976f
also consider parent classes when checking if class methods are out of date
John W. Eaton <jwe@octave.org>
parents:
10633
diff
changeset
|
1519 } |
1783b360976f
also consider parent classes when checking if class methods are out of date
John W. Eaton <jwe@octave.org>
parents:
10633
diff
changeset
|
1520 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1521 octave_user_function * get_curr_fcn (void) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1522 { |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1523 return m_current_scope ? m_current_scope->function () : 0; |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1524 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1525 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1526 void cleanup (void); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1527 |
23680
ef71711f6d64
rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
1528 fcn_info * get_fcn_info (const std::string& name) |
ef71711f6d64
rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
1529 { |
ef71711f6d64
rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
1530 fcn_table_iterator p = m_fcn_table.find (name); |
ef71711f6d64
rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
1531 return p != m_fcn_table.end () ? &p->second : 0; |
ef71711f6d64
rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
1532 } |
ef71711f6d64
rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
1533 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1534 class scope |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1535 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1536 public: |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1537 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1538 typedef std::map<std::string, symbol_table::symbol_record>::const_iterator |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1539 table_const_iterator; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1540 typedef std::map<std::string, symbol_table::symbol_record>::iterator |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1541 table_iterator; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1542 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1543 typedef std::map<std::string, octave_value>::const_iterator |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1544 m_persistent_symbols_const_iterator; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1545 typedef std::map<std::string, octave_value>::iterator |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1546 m_persistent_symbols_iterator; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1547 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1548 typedef std::map<std::string, octave_value>::const_iterator |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1549 subfunctions_const_iterator; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1550 typedef std::map<std::string, octave_value>::iterator subfunctions_iterator; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1551 |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1552 scope (const std::string& name = "") |
23680
ef71711f6d64
rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
1553 : m_name (name), m_symbols (), m_persistent_symbols (), m_subfunctions (), |
ef71711f6d64
rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
1554 m_fcn (0), m_parent (0), m_children (), m_is_nested (false), |
ef71711f6d64
rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
1555 m_is_static (false), m_context (0) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1556 { } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1557 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1558 // No copying! |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1559 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1560 scope (const scope&) = delete; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1561 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1562 scope& operator = (const scope&) = delete; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1563 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1564 ~scope (void) = default; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1565 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1566 void insert_symbol_record (const symbol_table::symbol_record& sr) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1567 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1568 m_symbols[sr.name ()] = sr; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1569 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1570 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1571 bool is_nested (void) const { return m_is_nested; } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1572 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1573 void mark_nested (void) { m_is_nested = true; } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1574 |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1575 scope * parent_scope (void) const { return m_parent; } |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1576 |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1577 scope * dup (void) const |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1578 { |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1579 scope *new_sid = new scope (); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1580 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1581 for (const auto& nm_sr : m_symbols) |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1582 new_sid->insert_symbol_record (nm_sr.second.dup (new_sid)); |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1583 |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1584 new_sid->m_parent = m_parent; |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1585 |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1586 return new_sid; |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1587 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1588 |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1589 void set_context (context_id context) { m_context = context; } |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1590 |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1591 context_id current_context (void) const { return m_context; } |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1592 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1593 symbol_table::symbol_record find_symbol (const std::string& name) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1594 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1595 table_iterator p = m_symbols.find (name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1596 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1597 if (p == m_symbols.end ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1598 return insert (name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1599 else |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1600 return p->second; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1601 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1602 |
23611
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
1603 void inherit_internal (scope& donor_scope) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1604 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1605 for (auto& nm_sr : m_symbols) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1606 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1607 symbol_table::symbol_record& sr = nm_sr.second; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1608 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1609 if (! (sr.is_automatic () || sr.is_formal ())) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1610 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1611 std::string nm = sr.name (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1612 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1613 if (nm != "__retval__") |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1614 { |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
1615 octave_value val = donor_scope.varval (nm); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1616 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1617 if (val.is_defined ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1618 { |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
1619 sr.assign (val); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1620 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1621 sr.mark_inherited (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1622 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1623 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1624 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1625 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1626 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1627 |
23611
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
1628 void inherit (scope *donor_scope) |
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
1629 { |
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
1630 while (donor_scope) |
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
1631 { |
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
1632 inherit_internal (*donor_scope); |
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
1633 |
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
1634 if (donor_scope->is_nested ()) |
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
1635 donor_scope = donor_scope->parent_scope (); |
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
1636 else |
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
1637 break; |
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
1638 } |
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
1639 } |
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
1640 |
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
1641 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1642 octave_value |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1643 find (const std::string& name, const octave_value_list& args, |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1644 bool skip_variables, bool local_funcs); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1645 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1646 octave_value builtin_find (const std::string& name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1647 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1648 symbol_table::symbol_record& |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
1649 insert (const std::string& name, bool force_add = false); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1650 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1651 void rename (const std::string& old_name, const std::string& new_name) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1652 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1653 table_iterator p = m_symbols.find (old_name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1654 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1655 if (p != m_symbols.end ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1656 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1657 symbol_table::symbol_record sr = p->second; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1658 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1659 sr.rename (new_name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1660 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1661 m_symbols.erase (p); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1662 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1663 m_symbols[new_name] = sr; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1664 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1665 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1666 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1667 void assign (const std::string& name, const octave_value& value, |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
1668 bool force_add) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1669 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1670 table_iterator p = m_symbols.find (name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1671 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1672 if (p == m_symbols.end ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1673 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1674 symbol_table::symbol_record& sr = insert (name, force_add); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1675 |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
1676 sr.assign (value); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1677 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1678 else |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
1679 p->second.assign (value); |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1680 } |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1681 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1682 void assign (const std::string& name, |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1683 const octave_value& value = octave_value ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1684 { |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
1685 assign (name, value, false); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1686 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1687 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1688 void force_assign (const std::string& name, const octave_value& value) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1689 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1690 table_iterator p = m_symbols.find (name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1691 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1692 if (p == m_symbols.end ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1693 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1694 symbol_table::symbol_record& sr = insert (name, true); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1695 |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
1696 sr.assign (value); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1697 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1698 else |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
1699 p->second.assign (value); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1700 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1701 |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
1702 // Use assign (name, value, force_add) instead. |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1703 // Delete when deprecated varref functions are removed. |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
1704 octave_value& varref (const std::string& name, bool force_add) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1705 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1706 table_iterator p = m_symbols.find (name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1707 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1708 if (p == m_symbols.end ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1709 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1710 symbol_table::symbol_record& sr = insert (name, force_add); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1711 |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
1712 return sr.varref (); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1713 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1714 else |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
1715 return p->second.varref (); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1716 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1717 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1718 octave_value varval (const std::string& name) const |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1719 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1720 table_const_iterator p = m_symbols.find (name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1721 |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1722 return (p != m_symbols.end () |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
1723 ? p->second.varval () : octave_value ()); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1724 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1725 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1726 void persistent_assign (const std::string& name, const octave_value& value) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1727 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1728 m_persistent_symbols_iterator p = m_persistent_symbols.find (name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1729 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1730 if (p == m_persistent_symbols.end ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1731 m_persistent_symbols[name] = value; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1732 else |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1733 p->second = value; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1734 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1735 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1736 // Use persistent_assign (name, value) instead. |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1737 // Delete when deprecated varref functions are removed. |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1738 octave_value& persistent_varref (const std::string& name) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1739 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1740 m_persistent_symbols_iterator p = m_persistent_symbols.find (name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1741 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1742 return (p == m_persistent_symbols.end () |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1743 ? m_persistent_symbols[name] : p->second); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1744 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1745 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1746 octave_value persistent_varval (const std::string& name) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1747 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1748 m_persistent_symbols_const_iterator p = m_persistent_symbols.find (name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1749 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1750 return (p != m_persistent_symbols.end ()) ? p->second : octave_value (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1751 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1752 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1753 void erase_persistent (const std::string& name) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1754 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1755 m_persistent_symbols_iterator p = m_persistent_symbols.find (name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1756 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1757 if (p != m_persistent_symbols.end ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1758 m_persistent_symbols.erase (p); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1759 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1760 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1761 bool is_variable (const std::string& name) const |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1762 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1763 bool retval = false; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1764 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1765 table_const_iterator p = m_symbols.find (name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1766 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1767 if (p != m_symbols.end ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1768 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1769 const symbol_table::symbol_record& sr = p->second; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1770 |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
1771 retval = sr.is_variable (); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1772 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1773 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1774 return retval; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1775 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1776 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1777 void push_context (void) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1778 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1779 for (auto& nm_sr : m_symbols) |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1780 nm_sr.second.push_context (this); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1781 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1782 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1783 void pop_context (void) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1784 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1785 table_iterator tbl_it = m_symbols.begin (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1786 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1787 while (tbl_it != m_symbols.end ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1788 { |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1789 if (tbl_it->second.pop_context (this) == 0) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1790 m_symbols.erase (tbl_it++); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1791 else |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1792 tbl_it++; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1793 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1794 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1795 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1796 void clear_variables (void) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1797 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1798 for (auto& nm_sr : m_symbols) |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
1799 nm_sr.second.clear (this); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1800 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1801 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1802 void clear_objects (void) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1803 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1804 for (auto& nm_sr : m_symbols) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1805 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1806 symbol_table::symbol_record& sr = nm_sr.second; |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
1807 octave_value val = sr.varval (); |
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
1808 if (val.isobject ()) |
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
1809 nm_sr.second.clear (this); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1810 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1811 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1812 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1813 void clear_global (const std::string& name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1814 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1815 void clear_variable (const std::string& name) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1816 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1817 table_iterator p = m_symbols.find (name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1818 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1819 if (p != m_symbols.end ()) |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
1820 p->second.clear (this); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1821 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1822 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1823 void clear_global_pattern (const std::string& pat); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1824 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1825 void clear_variable_pattern (const std::string& pat) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1826 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1827 glob_match pattern (pat); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1828 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1829 for (auto& nm_sr : m_symbols) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1830 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1831 symbol_table::symbol_record& sr = nm_sr.second; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1832 |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
1833 if (sr.is_defined () || sr.is_global ()) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1834 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1835 if (pattern.match (sr.name ())) |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1836 sr.clear (this); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1837 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1838 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1839 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1840 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1841 void clear_variable_regexp (const std::string& pat) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1842 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1843 octave::regexp pattern (pat); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1844 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1845 for (auto& nm_sr : m_symbols) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1846 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1847 symbol_table::symbol_record& sr = nm_sr.second; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1848 |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
1849 if (sr.is_defined () || sr.is_global ()) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1850 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1851 if (pattern.is_match (sr.name ())) |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
1852 sr.clear (this); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1853 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1854 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1855 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1856 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1857 void mark_automatic (const std::string& name) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1858 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1859 insert (name).mark_automatic (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1860 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1861 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1862 void mark_hidden (const std::string& name) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1863 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1864 insert (name).mark_hidden (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1865 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1866 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1867 void mark_global (const std::string& name) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1868 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1869 insert (name).mark_global (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1870 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1871 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1872 std::list<symbol_table::symbol_record> |
23611
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
1873 all_variables (bool defined_only = true, |
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
1874 unsigned int exclude = symbol_table::symbol_record::hidden) const |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1875 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1876 std::list<symbol_table::symbol_record> retval; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1877 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1878 for (const auto& nm_sr : m_symbols) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1879 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1880 const symbol_table::symbol_record& sr = nm_sr.second; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1881 |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
1882 if ((defined_only && ! sr.is_defined ()) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1883 || (sr.xstorage_class () & exclude)) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1884 continue; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1885 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1886 retval.push_back (sr); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1887 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1888 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1889 return retval; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1890 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1891 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1892 std::list<symbol_table::symbol_record> |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1893 glob (const std::string& pattern, bool vars_only = false) const |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1894 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1895 std::list<symbol_table::symbol_record> retval; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1896 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1897 glob_match pat (pattern); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1898 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1899 for (const auto& nm_sr : m_symbols) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1900 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1901 if (pat.match (nm_sr.first)) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1902 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1903 const symbol_table::symbol_record& sr = nm_sr.second; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1904 |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
1905 if (vars_only && ! sr.is_variable ()) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1906 continue; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1907 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1908 retval.push_back (sr); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1909 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1910 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1911 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1912 return retval; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1913 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1914 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1915 std::list<symbol_table::symbol_record> |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1916 regexp (const std::string& pattern, bool vars_only = false) const |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1917 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1918 std::list<symbol_table::symbol_record> retval; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1919 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1920 octave::regexp pat (pattern); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1921 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1922 for (const auto& nm_sr : m_symbols) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1923 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1924 if (pat.is_match (nm_sr.first)) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1925 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1926 const symbol_table::symbol_record& sr = nm_sr.second; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1927 |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
1928 if (vars_only && ! sr.is_variable ()) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1929 continue; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1930 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1931 retval.push_back (sr); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1932 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1933 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1934 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1935 return retval; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1936 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1937 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1938 std::list<std::string> variable_names (void) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1939 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1940 std::list<std::string> retval; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1941 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1942 for (const auto& nm_sr : m_symbols) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1943 { |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
1944 if (nm_sr.second.is_variable ()) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1945 retval.push_back (nm_sr.first); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1946 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1947 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1948 retval.sort (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1949 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1950 return retval; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1951 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1952 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1953 bool is_local_variable (const std::string& name) const |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1954 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1955 table_const_iterator p = m_symbols.find (name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1956 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1957 return (p != m_symbols.end () |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1958 && ! p->second.is_global () |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
1959 && p->second.is_defined ()); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1960 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1961 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1962 bool is_global (const std::string& name) const |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1963 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1964 table_const_iterator p = m_symbols.find (name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1965 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1966 return p != m_symbols.end () && p->second.is_global (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1967 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1968 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1969 void install_subfunction (const std::string& name, |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1970 const octave_value& fval, |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1971 bool is_nested = false); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1972 |
23611
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
1973 void install_nestfunction (const std::string& name, |
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
1974 const octave_value& fval) |
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
1975 { |
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
1976 install_subfunction (name, fval, true); |
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
1977 } |
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
1978 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1979 octave_value find_subfunction (const std::string& name) const; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1980 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1981 void lock_subfunctions (void) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1982 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1983 for (auto& nm_sf : m_subfunctions) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1984 nm_sf.second.lock (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1985 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1986 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1987 void unlock_subfunctions (void) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1988 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1989 for (auto& nm_sf : m_subfunctions) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1990 nm_sf.second.unlock (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1991 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1992 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1993 std::map<std::string, octave_value> subfunctions (void) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1994 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1995 return m_subfunctions; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1996 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1997 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1998 void erase_subfunctions (void) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1999 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2000 m_subfunctions.clear (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2001 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2002 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2003 void mark_subfunctions_in_scope_as_private (const std::string& class_name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2004 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2005 std::list<workspace_element> workspace_info (void) const; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2006 |
23680
ef71711f6d64
rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
2007 octave_value dump (void) const; |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2008 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2009 std::string name (void) const { return m_name; } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2010 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2011 void cache_name (const std::string& name) { m_name = name; } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2012 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2013 octave_user_function *function (void) { return m_fcn; } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2014 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2015 void set_function (octave_user_function *fcn) { m_fcn = fcn; } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2016 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2017 void set_parent (scope *p) { m_parent = p; } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2018 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2019 void update_nest (void); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2020 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2021 bool look_nonlocal (const std::string& name, |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
2022 symbol_table::symbol_record& result); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2023 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2024 private: |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2025 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2026 // Name for this scope (usually the corresponding filename of the |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2027 // function corresponding to the scope). |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2028 std::string m_name; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2029 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2030 // Map from symbol names to symbol info. |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2031 std::map<std::string, symbol_table::symbol_record> m_symbols; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2032 |
23680
ef71711f6d64
rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
2033 // Map from names of persistent variables to values. |
ef71711f6d64
rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
2034 std::map<std::string, octave_value> m_persistent_symbols; |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2035 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2036 // Map from symbol names to subfunctions. |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2037 std::map<std::string, octave_value> m_subfunctions; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2038 |
23680
ef71711f6d64
rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
2039 // The associated user code (may be null). |
ef71711f6d64
rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
2040 octave_user_function *m_fcn; |
ef71711f6d64
rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
2041 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2042 // Parent of nested function (may be null). |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2043 scope *m_parent; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2044 |
23680
ef71711f6d64
rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
2045 // Child nested functions. |
ef71711f6d64
rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
2046 std::vector<scope*> m_children; |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2047 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2048 // If true, then this scope belongs to a nested function. |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2049 bool m_is_nested; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2050 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2051 // If true then no variables can be added. |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2052 bool m_is_static; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2053 |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
2054 context_id m_context; |
23680
ef71711f6d64
rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
2055 |
ef71711f6d64
rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
2056 octave_value dump_symbols_map (void) const; |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2057 }; |
9981
692ab4eaf965
clean up top-level variables when exiting Octave
Jaroslav Hajek <highegg@gmail.com>
parents:
9958
diff
changeset
|
2058 |
8 | 2059 private: |
2060 | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2061 typedef std::map<std::string, octave_value>::const_iterator |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2062 global_symbols_const_iterator; |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2063 typedef std::map<std::string, octave_value>::iterator |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2064 global_symbols_iterator; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2065 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2066 typedef std::map<std::string, fcn_info>::const_iterator |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2067 fcn_table_const_iterator; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2068 typedef std::map<std::string, fcn_info>::iterator |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2069 fcn_table_iterator; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2070 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
2071 // Map from names of global variables to values. |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2072 std::map<std::string, octave_value> m_global_symbols; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2073 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2074 // Map from function names to function info (private |
7336 | 2075 // functions, class constructors, class methods, etc.) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2076 // Note that subfunctions are defined in the scope that contains |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2077 // them. |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2078 std::map<std::string, fcn_info> m_fcn_table; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2079 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2080 // Map from class names to set of classes that have lower |
7972
5bf4e2c13ed8
make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents:
7901
diff
changeset
|
2081 // precedence. |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2082 std::map<std::string, std::set<std::string>> m_class_precedence_table; |
23534
b6498c088fca
maint: Don't write '> >' for declaration of templates that use templates.
Rik <rik@octave.org>
parents:
23457
diff
changeset
|
2083 |
b6498c088fca
maint: Don't write '> >' for declaration of templates that use templates.
Rik <rik@octave.org>
parents:
23457
diff
changeset
|
2084 typedef std::map<std::string, std::set<std::string>>::const_iterator |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2085 class_precedence_table_const_iterator; |
23534
b6498c088fca
maint: Don't write '> >' for declaration of templates that use templates.
Rik <rik@octave.org>
parents:
23457
diff
changeset
|
2086 typedef std::map<std::string, std::set<std::string>>::iterator |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2087 class_precedence_table_iterator; |
7972
5bf4e2c13ed8
make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents:
7901
diff
changeset
|
2088 |
9581
3d0d2bda3a0f
fix previous change, avoid duplicate loads of methods in descendant classes
Jaroslav Hajek <highegg@gmail.com>
parents:
9509
diff
changeset
|
2089 // Map from class names to parent class names. |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2090 std::map<std::string, std::list<std::string>> m_parent_map; |
23534
b6498c088fca
maint: Don't write '> >' for declaration of templates that use templates.
Rik <rik@octave.org>
parents:
23457
diff
changeset
|
2091 |
b6498c088fca
maint: Don't write '> >' for declaration of templates that use templates.
Rik <rik@octave.org>
parents:
23457
diff
changeset
|
2092 typedef std::map<std::string, std::list<std::string>>::const_iterator |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2093 const_parent_map_iterator; |
23534
b6498c088fca
maint: Don't write '> >' for declaration of templates that use templates.
Rik <rik@octave.org>
parents:
23457
diff
changeset
|
2094 typedef std::map<std::string, std::list<std::string>>::iterator |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2095 parent_map_iterator; |
9581
3d0d2bda3a0f
fix previous change, avoid duplicate loads of methods in descendant classes
Jaroslav Hajek <highegg@gmail.com>
parents:
9509
diff
changeset
|
2096 |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
2097 scope *m_global_scope; |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
2098 scope *m_top_scope; |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
2099 |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
2100 scope *m_current_scope; |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
2101 |
23680
ef71711f6d64
rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
2102 octave_value dump_fcn_table_map (void) const; |
3011 | 2103 }; |
2790 | 2104 |
9450
cf714e75c656
implement overloaded function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
9446
diff
changeset
|
2105 extern bool out_of_date_check (octave_value& function, |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
21012
diff
changeset
|
2106 const std::string& dispatch_type = "", |
9509
c5330ef7aecd
fix handles to private functions, simplify out-of-date checks in symtab
Jaroslav Hajek <highegg@gmail.com>
parents:
9474
diff
changeset
|
2107 bool check_relative = true); |
9450
cf714e75c656
implement overloaded function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
9446
diff
changeset
|
2108 |
10087
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
10071
diff
changeset
|
2109 extern OCTINTERP_API std::string |
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
10071
diff
changeset
|
2110 get_dispatch_type (const octave_value_list& args); |
22653
e7a9dfb8bf16
remove obsolete function __dispatch__
John W. Eaton <jwe@octave.org>
parents:
22407
diff
changeset
|
2111 |
10087
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
10071
diff
changeset
|
2112 extern OCTINTERP_API std::string |
10321
97b4bd6f0925
partially rewrite function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
2113 get_dispatch_type (const octave_value_list& args, builtin_type_t& builtin_type); |
8123
eb2beef9a9ff
clear breakpoints is function found to be out of date
David Bateman <dbateman@free.fr>
parents:
8051
diff
changeset
|
2114 |
8 | 2115 #endif |