Mercurial > octave
annotate libinterp/corefcn/symtab.h @ 23599:5cb3a2bb5e1e
don't use singleton for symbol_table
This is the first of a series of changes to make the symbol table a
part of the interpreter instead of a global object. These changes
also aim to simplify the implementation of symbol table so that it is
easier to understand and modify.
* Functions now own their scope (workspace) data.
* The list of subfunctions is contained in the scope rather than a
global list.
* symtab.h, symtab.cc (class symbol_table): Don't use singleton
pattern.
* interpreter.h, interpreter.cc (interpreter::m_symbol_table): New
data member.
(interpreter::~interpreter): Don't set instance to 0.
* interpreter-private.h, interpreter-private.cc
(__get_symbol_table__): New function.
Change all uses of call_stack to access call_stack object from the
interpreter.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 09 Jun 2017 02:21:28 -0400 |
parents | 0c468af9dc00 |
children | 214cb58ccc1c |
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" |
2846 | 38 |
7336 | 39 class tree_argument_list; |
9639
8d79f36ebdde
store scope->function pointer
Jaroslav Hajek <highegg@gmail.com>
parents:
9581
diff
changeset
|
40 class octave_user_function; |
3013 | 41 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
42 #include "oct-refcount.h" |
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 |
7336 | 55 typedef int scope_id; |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
56 typedef size_t context_id; |
7336 | 57 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
58 class scope; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
59 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
60 class scope_id_cache |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
61 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
62 public: |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
63 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
64 typedef std::set<scope_id>::iterator set_iterator; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
65 typedef std::set<scope_id>::const_iterator set_const_iterator; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
66 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
67 // We start with 2 because we allocate 0 for the global symbols |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
68 // and 1 for the top-level workspace. |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
69 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
70 scope_id_cache (void) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
71 : m_next_available (2), m_in_use (), m_free_list () { } |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
72 |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
73 // No copying! |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
74 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
75 scope_id_cache (const scope_id_cache&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
76 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
77 scope_id_cache& operator = (const scope_id_cache&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
78 |
22868
87e3163f6c87
use c++11 "= default" syntax for declaration of trivial destructors
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
79 ~scope_id_cache (void) = default; |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
80 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
81 scope_id alloc (void) |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
82 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
83 scope_id retval; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
84 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
85 set_iterator p = m_free_list.begin (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
86 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
87 if (p != m_free_list.end ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
88 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
89 retval = *p; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
90 m_free_list.erase (p); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
91 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
92 else |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
93 retval = m_next_available++; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
94 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
95 m_in_use.insert (retval); |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
96 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
97 return retval; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
98 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
99 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
100 void free (scope_id sid) |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
101 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
102 set_iterator p = m_in_use.find (sid); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
103 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
104 if (p == m_in_use.end ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
105 error ("free_scope: scope %d not found!", sid); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
106 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
107 m_in_use.erase (p); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
108 m_free_list.insert (sid); |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
109 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
110 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
111 std::list<scope_id> scopes (void) const |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
112 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
113 std::list<scope_id> retval; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
114 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
115 for (const auto& scope_id : m_in_use) |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
116 retval.push_back (scope_id); |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
117 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
118 retval.sort (); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
119 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
120 return retval; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
121 } |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
122 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
123 private: |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
124 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
125 // The next available scope not in the free list. |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
126 scope_id m_next_available; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
127 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
128 // The set of scope IDs that are currently allocated. |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
129 std::set<scope_id> m_in_use; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
130 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
131 // The set of scope IDs that are currently available. |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
132 std::set<scope_id> m_free_list; |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
133 }; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
134 |
9413
5cd879a0d8c4
speed-up function call by caching its name lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
9409
diff
changeset
|
135 class fcn_info; |
5cd879a0d8c4
speed-up function call by caching its name lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
9409
diff
changeset
|
136 |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
137 class |
7336 | 138 symbol_record |
139 { | |
140 public: | |
141 | |
142 // generic variable | |
143 static const unsigned int local = 1; | |
144 | |
145 // varargin, argn, .nargin., .nargout. | |
21066
258c787cd9ce
maint: Use "FIXME:" consistently in code base.
Rik <rik@octave.org>
parents:
21040
diff
changeset
|
146 // (FIXME: is this really used now?) |
7336 | 147 static const unsigned int automatic = 2; |
148 | |
149 // formal parameter | |
150 static const unsigned int formal = 4; | |
151 | |
152 // not listed or cleared (.nargin., .nargout.) | |
153 static const unsigned int hidden = 8; | |
154 | |
155 // inherited from parent scope; not cleared at function exit | |
156 static const unsigned int inherited = 16; | |
157 | |
158 // global (redirects to global scope) | |
159 static const unsigned int global = 32; | |
160 | |
161 // not cleared at function exit | |
162 static const unsigned int persistent = 64; | |
163 | |
15236
44d6ffdf9479
Disallow new variables in nested functions (bug #36271)
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
164 // 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
|
165 // (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
|
166 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
|
167 |
7336 | 168 private: |
169 | |
170 class | |
171 symbol_record_rep | |
4009 | 172 { |
7336 | 173 public: |
174 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
175 symbol_record_rep (scope_id sid, const std::string& nm, |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
176 const octave_value& v, unsigned int sc) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
177 : m_decl_scope (sid), curr_fcn (0), name (nm), value_stack (), |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
178 storage_class (sc), /* finfo (), */ valid (true), count (1) |
7336 | 179 { |
10313 | 180 value_stack.push_back (v); |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
181 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
182 |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
183 // No copying! |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
184 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
185 symbol_record_rep (const symbol_record_rep& ov) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
186 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
187 symbol_record_rep& operator = (const symbol_record_rep&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
188 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
189 ~symbol_record_rep (void) = default; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
190 |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
191 void assign (const octave_value& value, |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
192 context_id context = xdefault_context) |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
193 { |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
194 varref (context) = value; |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
195 } |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
196 |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
197 void assign (octave_value::assign_op op, |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
198 const std::string& type, |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
199 const std::list<octave_value_list>& idx, |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
200 const octave_value& value, |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
201 context_id context = xdefault_context) |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
202 { |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
203 varref(context).assign (op, type, idx, value); |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
204 } |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
205 |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
206 void assign (octave_value::assign_op op, const octave_value& value, |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
207 context_id context = xdefault_context) |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
208 { |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
209 varref(context).assign (op, value); |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
210 } |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
211 |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
212 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
|
213 context_id context = xdefault_context) |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
214 { |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
215 varref(context).do_non_const_unary_op (op); |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
216 } |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
217 |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
218 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
|
219 const std::string& type, |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
220 const std::list<octave_value_list>& idx, |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
221 context_id context = xdefault_context) |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
222 { |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
223 varref(context).do_non_const_unary_op (op, type, idx); |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
224 } |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
225 |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
226 octave_value& varref (context_id context = xdefault_context) |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
227 { |
10313 | 228 if (is_global ()) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
229 return xglobal_varref (); |
10313 | 230 else if (is_persistent ()) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
231 return xpersistent_varref (); |
10313 | 232 else |
233 { | |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
234 if (context == xdefault_context) |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
235 context = active_context (); |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
236 |
10313 | 237 context_id n = value_stack.size (); |
238 while (n++ <= context) | |
239 value_stack.push_back (octave_value ()); | |
240 | |
241 return value_stack[context]; | |
242 } | |
7336 | 243 } |
244 | |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
245 octave_value varval (context_id context = xdefault_context) const |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
246 { |
10313 | 247 if (is_global ()) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
248 return xglobal_varval (); |
10313 | 249 else if (is_persistent ()) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
250 return xpersistent_varval (); |
10313 | 251 else |
252 { | |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
253 if (context == xdefault_context) |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
254 context = active_context (); |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
255 |
10313 | 256 if (context < value_stack.size ()) |
257 return value_stack[context]; | |
258 else | |
259 return octave_value (); | |
260 } | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
261 } |
7336 | 262 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
263 void push_context (scope_id sid) |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
264 { |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
265 if (! (is_persistent () || is_global ()) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
266 && sid == decl_scope ()) |
10313 | 267 value_stack.push_back (octave_value ()); |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
268 } |
7336 | 269 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
270 // 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
|
271 // 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
|
272 // functions like |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
273 // |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
274 // function foo (n) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
275 // if (n > 0) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
276 // foo (n-1); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
277 // else |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
278 // eval ("x = 1"); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
279 // endif |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
280 // endfunction |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
281 // |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
282 // Here, X should only exist in the final stack frame. |
7336 | 283 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
284 size_t pop_context (scope_id sid) |
7374 | 285 { |
10313 | 286 size_t retval = 1; |
287 | |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
288 if (! (is_persistent () || is_global ()) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
289 && sid == decl_scope ()) |
10313 | 290 { |
291 value_stack.pop_back (); | |
292 retval = value_stack.size (); | |
293 } | |
294 | |
295 return retval; | |
7374 | 296 } |
7336 | 297 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
298 void clear (void) { clear (decl_scope ()); } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
299 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
300 void clear (scope_id sid); |
7336 | 301 |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
302 bool is_defined (context_id context = xdefault_context) const |
7336 | 303 { |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
304 if (context == xdefault_context) |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
305 context = active_context (); |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
306 |
10313 | 307 return varval (context).is_defined (); |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
308 } |
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
309 |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
310 bool is_valid (void) const |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
311 { |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
312 return valid; |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
313 } |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
314 |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
315 bool is_variable (context_id context) const |
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
316 { |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
317 if (context == xdefault_context) |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
318 context = active_context (); |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
319 |
16277
8cb65fd72164
eliminate obsolete concepts of "pending local" and "forced" variables
John W. Eaton <jwe@octave.org>
parents:
15572
diff
changeset
|
320 return (! is_local () || is_defined (context)); |
7336 | 321 } |
322 | |
323 bool is_local (void) const { return storage_class & local; } | |
324 bool is_automatic (void) const { return storage_class & automatic; } | |
325 bool is_formal (void) const { return storage_class & formal; } | |
326 bool is_hidden (void) const { return storage_class & hidden; } | |
327 bool is_inherited (void) const { return storage_class & inherited; } | |
328 bool is_global (void) const { return storage_class & global; } | |
329 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
|
330 bool is_added_static (void) const {return storage_class & added_static; } |
7336 | 331 |
332 void mark_local (void) { storage_class |= local; } | |
333 void mark_automatic (void) { storage_class |= automatic; } | |
334 void mark_formal (void) { storage_class |= formal; } | |
335 void mark_hidden (void) { storage_class |= hidden; } | |
336 void mark_inherited (void) { storage_class |= inherited; } | |
337 void mark_global (void) | |
338 { | |
10313 | 339 if (is_persistent ()) |
340 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
|
341 |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20956
diff
changeset
|
342 storage_class |= global; |
7336 | 343 } |
344 void mark_persistent (void) | |
345 { | |
10313 | 346 if (is_global ()) |
347 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
|
348 |
d27f66b4b8e6
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20956
diff
changeset
|
349 storage_class |= persistent; |
7336 | 350 } |
15236
44d6ffdf9479
Disallow new variables in nested functions (bug #36271)
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
351 void mark_added_static (void) { storage_class |= added_static; } |
7336 | 352 |
353 void unmark_local (void) { storage_class &= ~local; } | |
354 void unmark_automatic (void) { storage_class &= ~automatic; } | |
355 void unmark_formal (void) { storage_class &= ~formal; } | |
356 void unmark_hidden (void) { storage_class &= ~hidden; } | |
357 void unmark_inherited (void) { storage_class &= ~inherited; } | |
358 void unmark_global (void) { storage_class &= ~global; } | |
359 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
|
360 void unmark_added_static (void) { storage_class &= ~added_static; } |
7336 | 361 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
362 void init_persistent (void); |
7336 | 363 |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
364 void invalidate (void) |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
365 { |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
366 valid = false; |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
367 } |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
368 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
369 void erase_persistent (void); |
7336 | 370 |
15260
789c8c3c9af5
Export more symbols from liboctinterp.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15236
diff
changeset
|
371 OCTINTERP_API context_id active_context (void) const; |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
372 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
373 scope_id decl_scope (void) const { return m_decl_scope; } |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
374 |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
375 void set_curr_fcn (octave_user_function *fcn) |
7336 | 376 { |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
377 curr_fcn = fcn; |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
378 } |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
379 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23343
diff
changeset
|
380 symbol_record_rep * dup (scope_id new_scope) const |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
381 { |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
382 return new symbol_record_rep (new_scope, name, varval (), |
10313 | 383 storage_class); |
7336 | 384 } |
385 | |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
386 void dump (std::ostream& os, const std::string& prefix) const; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
387 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
388 scope_id m_decl_scope; |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
389 |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23446
diff
changeset
|
390 octave_user_function *curr_fcn; |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
391 |
7336 | 392 std::string name; |
393 | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
394 std::deque<octave_value> value_stack; |
7336 | 395 |
396 unsigned int storage_class; | |
397 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
398 // fcn_info *finfo; |
9413
5cd879a0d8c4
speed-up function call by caching its name lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
9409
diff
changeset
|
399 |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
400 bool valid; |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
401 |
23012
27e4ec3b0b49
move octave_refcount inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
402 octave::refcount<size_t> count; |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
403 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
404 private: |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
405 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
406 octave_value& xglobal_varref (void); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
407 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
408 octave_value& xpersistent_varref (void); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
409 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
410 octave_value xglobal_varval (void) const; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
411 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
412 octave_value xpersistent_varval (void) const; |
7336 | 413 }; |
414 | |
415 public: | |
416 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
417 symbol_record (void); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
418 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
419 symbol_record (scope_id s, const std::string& nm = "", |
10313 | 420 const octave_value& v = octave_value (), |
421 unsigned int sc = local) | |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
422 : rep (new symbol_record_rep (s, nm, v, sc)) { } |
7336 | 423 |
424 symbol_record (const symbol_record& sr) | |
425 : rep (sr.rep) | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11584
diff
changeset
|
426 { |
7336 | 427 rep->count++; |
428 } | |
429 | |
430 symbol_record& operator = (const symbol_record& sr) | |
431 { | |
432 if (this != &sr) | |
10313 | 433 { |
434 if (--rep->count == 0) | |
435 delete rep; | |
436 | |
437 rep = sr.rep; | |
438 rep->count++; | |
439 } | |
7336 | 440 |
441 return *this; | |
442 } | |
443 | |
444 ~symbol_record (void) | |
445 { | |
446 if (--rep->count == 0) | |
10313 | 447 delete rep; |
7336 | 448 } |
449 | |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
450 symbol_record dup (scope_id new_scope) const |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
451 { |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
452 return symbol_record (rep->dup (new_scope)); |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
453 } |
7336 | 454 |
14899 | 455 const std::string& name (void) const { return rep->name; } |
7336 | 456 |
16502
45ae1038ee89
allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents:
16468
diff
changeset
|
457 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
|
458 |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
459 octave_value |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
460 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
|
461 |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
462 void assign (const octave_value& value, |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
463 context_id context = xdefault_context) |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
464 { |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
465 rep->assign (value, context); |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
466 } |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
467 |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
468 void assign (octave_value::assign_op op, |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
469 const std::string& type, |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
470 const std::list<octave_value_list>& idx, |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
471 const octave_value& value, |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
472 context_id context = xdefault_context) |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
473 { |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
474 rep->assign (op, type, idx, value, context); |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
475 } |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
476 |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
477 void assign (octave_value::assign_op op, const octave_value& value, |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
478 context_id context = xdefault_context) |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
479 { |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
480 rep->assign (op, value, context); |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
481 } |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
482 |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
483 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
|
484 { |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
485 rep->do_non_const_unary_op (op); |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
486 } |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
487 |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
488 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
|
489 const std::string& type, |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
490 const std::list<octave_value_list>& idx) |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
491 { |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
492 rep->do_non_const_unary_op (op, type, idx); |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
493 } |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
494 |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
495 // Delete when deprecated varref functions are removed. |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
496 octave_value& varref (context_id context = xdefault_context) |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
497 { |
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
498 return rep->varref (context); |
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
499 } |
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
500 |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
501 octave_value varval (context_id context = xdefault_context) const |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
502 { |
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
503 return rep->varval (context); |
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
504 } |
7336 | 505 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
506 void push_context (scope_id sid) { rep->push_context (sid); } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
507 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
508 size_t pop_context (scope_id sid) { return rep->pop_context (sid); } |
7336 | 509 |
510 void clear (void) { rep->clear (); } | |
511 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
512 void clear (scope_id sid) { rep->clear (sid); } |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
513 |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
514 bool is_defined (context_id context = xdefault_context) const |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
515 { |
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
516 return rep->is_defined (context); |
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
517 } |
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
518 |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
519 bool is_undefined (context_id context = xdefault_context) const |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
520 { |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
521 return ! rep->is_defined (context); |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
522 } |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
523 |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
524 bool is_valid (void) const |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
525 { |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
526 return rep->is_valid (); |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
527 } |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
528 |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
529 bool is_variable (context_id context = xdefault_context) const |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
530 { |
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
531 return rep->is_variable (context); |
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
532 } |
7336 | 533 |
534 bool is_local (void) const { return rep->is_local (); } | |
535 bool is_automatic (void) const { return rep->is_automatic (); } | |
536 bool is_formal (void) const { return rep->is_formal (); } | |
537 bool is_global (void) const { return rep->is_global (); } | |
538 bool is_hidden (void) const { return rep->is_hidden (); } | |
539 bool is_inherited (void) const { return rep->is_inherited (); } | |
540 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
|
541 bool is_added_static (void) const { return rep->is_added_static (); } |
7336 | 542 |
543 void mark_local (void) { rep->mark_local (); } | |
544 void mark_automatic (void) { rep->mark_automatic (); } | |
545 void mark_formal (void) { rep->mark_formal (); } | |
546 void mark_hidden (void) { rep->mark_hidden (); } | |
547 void mark_inherited (void) { rep->mark_inherited (); } | |
548 void mark_global (void) { rep->mark_global (); } | |
549 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
|
550 void mark_added_static (void) { rep->mark_added_static (); } |
7336 | 551 |
552 void unmark_local (void) { rep->unmark_local (); } | |
553 void unmark_automatic (void) { rep->unmark_automatic (); } | |
554 void unmark_formal (void) { rep->unmark_formal (); } | |
555 void unmark_hidden (void) { rep->unmark_hidden (); } | |
556 void unmark_inherited (void) { rep->unmark_inherited (); } | |
557 void unmark_global (void) { rep->unmark_global (); } | |
558 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
|
559 void unmark_added_static (void) { rep->unmark_added_static (); } |
7336 | 560 |
561 void init_persistent (void) { rep->init_persistent (); } | |
562 | |
563 void erase_persistent (void) { rep->erase_persistent (); } | |
564 | |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
565 void invalidate (void) { rep->invalidate (); } |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
566 |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
567 context_id active_context (void) const { return rep->active_context (); } |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
568 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
569 scope_id decl_scope (void) const { return rep->decl_scope (); } |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
570 |
7336 | 571 unsigned int xstorage_class (void) const { return rep->storage_class; } |
572 | |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
573 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
|
574 |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
575 void |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
21012
diff
changeset
|
576 dump (std::ostream& os, const std::string& prefix = "") const |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
577 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
578 rep->dump (os, prefix); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
579 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
580 |
7336 | 581 private: |
582 | |
583 symbol_record_rep *rep; | |
584 | |
585 symbol_record (symbol_record_rep *new_rep) : rep (new_rep) { } | |
586 }; | |
587 | |
21573
f3f8e1d3e399
avoid mulitple definitions of static function-scope vars (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
588 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
|
589 |
14912
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14899
diff
changeset
|
590 // Always access a symbol from the current scope. |
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14899
diff
changeset
|
591 // 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
|
592 class |
14930
7d44ed216b98
Rename symbol_table::symbol_record_ref to symbol_table::symbol_reference
Max Brister <max@2bass.com>
parents:
14913
diff
changeset
|
593 symbol_reference |
14912
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14899
diff
changeset
|
594 { |
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14899
diff
changeset
|
595 public: |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
596 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
597 symbol_reference (void) : m_scope (-1) { } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
598 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
599 symbol_reference (const symbol_record& record); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
600 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
601 symbol_reference (const symbol_record& record, scope_id curr_scope) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
602 : m_scope (curr_scope), m_sym (record) |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
603 { } |
14912
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14899
diff
changeset
|
604 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
605 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
|
606 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
607 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
|
608 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
609 bool is_black_hole (void) const { return m_scope < 0; } |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
610 |
14912
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14899
diff
changeset
|
611 // 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
|
612 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
|
613 |
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14899
diff
changeset
|
614 symbol_record *operator-> (void) |
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14899
diff
changeset
|
615 { |
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14899
diff
changeset
|
616 update (); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
617 return &m_sym; |
14912
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14899
diff
changeset
|
618 } |
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14899
diff
changeset
|
619 |
14913
c7071907a641
Use symbol_record_ref instead of names in JIT
Max Brister <max@2bass.com>
parents:
14912
diff
changeset
|
620 symbol_record *operator-> (void) const |
c7071907a641
Use symbol_record_ref instead of names in JIT
Max Brister <max@2bass.com>
parents:
14912
diff
changeset
|
621 { |
c7071907a641
Use symbol_record_ref instead of names in JIT
Max Brister <max@2bass.com>
parents:
14912
diff
changeset
|
622 update (); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
623 return &m_sym; |
14913
c7071907a641
Use symbol_record_ref instead of names in JIT
Max Brister <max@2bass.com>
parents:
14912
diff
changeset
|
624 } |
c7071907a641
Use symbol_record_ref instead of names in JIT
Max Brister <max@2bass.com>
parents:
14912
diff
changeset
|
625 |
14930
7d44ed216b98
Rename symbol_table::symbol_record_ref to symbol_table::symbol_reference
Max Brister <max@2bass.com>
parents:
14913
diff
changeset
|
626 // 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
|
627 // 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
|
628 struct comparator |
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14899
diff
changeset
|
629 { |
14930
7d44ed216b98
Rename symbol_table::symbol_record_ref to symbol_table::symbol_reference
Max Brister <max@2bass.com>
parents:
14913
diff
changeset
|
630 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
|
631 const symbol_reference& rhs) const |
14912
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14899
diff
changeset
|
632 { |
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14899
diff
changeset
|
633 return lhs.name () < rhs.name (); |
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14899
diff
changeset
|
634 } |
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14899
diff
changeset
|
635 }; |
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14899
diff
changeset
|
636 private: |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
637 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
638 void update (void) const; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
639 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
640 mutable scope_id m_scope; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
641 mutable symbol_record m_sym; |
14912
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14899
diff
changeset
|
642 }; |
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14899
diff
changeset
|
643 |
7336 | 644 class |
645 fcn_info | |
646 { | |
647 public: | |
648 | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
649 typedef std::map<std::string, octave_value>::const_iterator |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
650 str_val_const_iterator; |
7336 | 651 typedef std::map<std::string, octave_value>::iterator str_val_iterator; |
652 | |
653 private: | |
654 | |
655 class | |
656 fcn_info_rep | |
657 { | |
658 public: | |
659 | |
660 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
|
661 : 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
|
662 private_functions (), class_constructors (), class_methods (), |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11584
diff
changeset
|
663 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
|
664 built_in_function (), count (1) |
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
665 { |
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
666 size_t pos = name.rfind ('.'); |
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
667 |
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
668 if (pos != std::string::npos) |
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
669 { |
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
670 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
|
671 name = name.substr (pos+1); |
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
672 } |
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
673 } |
7336 | 674 |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
675 // No copying! |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
676 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
677 fcn_info_rep (const fcn_info_rep&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
678 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
679 fcn_info_rep& operator = (const fcn_info_rep&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
680 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
681 ~fcn_info_rep (void) = default; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
682 |
23343
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
683 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
|
684 |
7336 | 685 octave_value load_private_function (const std::string& dir_name); |
686 | |
687 octave_value load_class_constructor (void); | |
688 | |
689 octave_value load_class_method (const std::string& dispatch_type); | |
690 | |
9463
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
691 octave_value find (const octave_value_list& args, bool local_funcs); |
7336 | 692 |
9444
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
693 octave_value builtin_find (void); |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
694 |
7336 | 695 octave_value find_method (const std::string& dispatch_type); |
696 | |
697 octave_value find_autoload (void); | |
698 | |
16684
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
699 octave_value find_package (void); |
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
700 |
7336 | 701 octave_value find_user_function (void); |
702 | |
703 bool is_user_function_defined (void) const | |
704 { | |
10313 | 705 return function_on_path.is_defined (); |
7336 | 706 } |
707 | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
708 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
|
709 bool local_funcs) |
7336 | 710 { |
10313 | 711 return find (args, local_funcs); |
7336 | 712 } |
713 | |
714 void install_cmdline_function (const octave_value& f) | |
715 { | |
10313 | 716 cmdline_function = f; |
7336 | 717 } |
718 | |
23343
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
719 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
|
720 const std::string& file_name) |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
721 { |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
722 local_functions[file_name] = f; |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
723 } |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
724 |
7336 | 725 void install_user_function (const octave_value& f) |
726 { | |
10313 | 727 function_on_path = f; |
7336 | 728 } |
729 | |
730 void install_built_in_function (const octave_value& f) | |
731 { | |
10313 | 732 built_in_function = f; |
7336 | 733 } |
734 | |
22897
4090c32fccf8
store set of dispatch classes in built-in function objects
John W. Eaton <jwe@octave.org>
parents:
22893
diff
changeset
|
735 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
|
736 |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
21134
diff
changeset
|
737 template <typename T> |
7489
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
738 void |
16605
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
739 clear_map (std::map<T, octave_value>& map, bool force = false) |
7336 | 740 { |
10313 | 741 typename std::map<T, octave_value>::iterator p = map.begin (); |
742 | |
743 while (p != map.end ()) | |
744 { | |
16605
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
745 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
|
746 map.erase (p++); |
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
747 else |
10313 | 748 p++; |
749 } | |
7489
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
750 } |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
751 |
16605
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
752 void clear_autoload_function (bool force = false) |
7489
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
753 { |
16605
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
754 if (force || ! autoload_function.islocked ()) |
10313 | 755 autoload_function = octave_value (); |
7336 | 756 } |
757 | |
15003
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14981
diff
changeset
|
758 // 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
|
759 // "user defined" |
16605
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
760 void clear_user_function (bool force = false) |
7336 | 761 { |
20477
c36f06ef7539
also clear autoloaded functions when clearing user functions
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
762 clear_autoload_function (force); |
c36f06ef7539
also clear autoloaded functions when clearing user functions
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
763 |
16605
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
764 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
|
765 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
|
766 |
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
767 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
|
768 cmdline_function = octave_value (); |
7336 | 769 } |
770 | |
771 void clear_mex_function (void) | |
772 { | |
10313 | 773 if (function_on_path.is_mex_function ()) |
774 clear_user_function (); | |
7489
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
775 } |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
776 |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16605
diff
changeset
|
777 void clear_package (void) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16605
diff
changeset
|
778 { |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16605
diff
changeset
|
779 package = octave_value (); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16605
diff
changeset
|
780 } |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16605
diff
changeset
|
781 |
16605
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
782 void clear (bool force = false) |
7489
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
783 { |
23343
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
784 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
|
785 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
|
786 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
|
787 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
|
788 |
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
789 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
|
790 clear_user_function (force); |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16605
diff
changeset
|
791 clear_package (); |
7336 | 792 } |
793 | |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
794 void dump (std::ostream& os, const std::string& prefix) const; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
795 |
16684
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
796 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
|
797 { |
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
798 if (package_name.empty ()) |
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
799 return name; |
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
800 else |
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
801 return package_name + "." + name; |
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
802 } |
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
803 |
7336 | 804 std::string name; |
805 | |
16684
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
806 std::string package_name; |
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
807 |
23343
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
808 // File name to function object. |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
809 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
|
810 |
7336 | 811 // Directory name to function object. |
812 std::map<std::string, octave_value> private_functions; | |
813 | |
814 // Class name to function object. | |
815 std::map<std::string, octave_value> class_constructors; | |
816 | |
817 // Dispatch type to function object. | |
818 std::map<std::string, octave_value> class_methods; | |
819 | |
820 octave_value cmdline_function; | |
821 | |
822 octave_value autoload_function; | |
823 | |
824 octave_value function_on_path; | |
825 | |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16605
diff
changeset
|
826 octave_value package; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16605
diff
changeset
|
827 |
7336 | 828 octave_value built_in_function; |
829 | |
23012
27e4ec3b0b49
move octave_refcount inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22910
diff
changeset
|
830 octave::refcount<size_t> count; |
7336 | 831 |
832 private: | |
833 | |
9463
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
834 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
|
835 |
9444
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
836 octave_value x_builtin_find (void); |
7336 | 837 }; |
838 | |
839 public: | |
840 | |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
21012
diff
changeset
|
841 fcn_info (const std::string& nm = "") |
7336 | 842 : rep (new fcn_info_rep (nm)) { } |
843 | |
8906
ab87d08d9a1b
improve symbol inheritance for anonymous functions
John W. Eaton <jwe@octave.org>
parents:
8884
diff
changeset
|
844 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
|
845 { |
7336 | 846 rep->count++; |
847 } | |
848 | |
8906
ab87d08d9a1b
improve symbol inheritance for anonymous functions
John W. Eaton <jwe@octave.org>
parents:
8884
diff
changeset
|
849 fcn_info& operator = (const fcn_info& fi) |
7336 | 850 { |
8906
ab87d08d9a1b
improve symbol inheritance for anonymous functions
John W. Eaton <jwe@octave.org>
parents:
8884
diff
changeset
|
851 if (this != &fi) |
10313 | 852 { |
853 if (--rep->count == 0) | |
854 delete rep; | |
855 | |
856 rep = fi.rep; | |
857 rep->count++; | |
858 } | |
7336 | 859 |
860 return *this; | |
861 } | |
862 | |
863 ~fcn_info (void) | |
864 { | |
865 if (--rep->count == 0) | |
10313 | 866 delete rep; |
7336 | 867 } |
868 | |
9463
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
869 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
|
870 bool local_funcs = true) |
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
871 { |
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
872 return rep->find (args, local_funcs); |
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
873 } |
7336 | 874 |
9444
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
875 octave_value builtin_find (void) |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
876 { |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
877 return rep->builtin_find (); |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
878 } |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
879 |
7336 | 880 octave_value find_method (const std::string& dispatch_type) const |
881 { | |
882 return rep->find_method (dispatch_type); | |
883 } | |
884 | |
885 octave_value find_built_in_function (void) const | |
886 { | |
887 return rep->built_in_function; | |
888 } | |
889 | |
12911
d6151d774283
make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
12130
diff
changeset
|
890 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
|
891 { |
d6151d774283
make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
12130
diff
changeset
|
892 return rep->cmdline_function; |
d6151d774283
make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
12130
diff
changeset
|
893 } |
d6151d774283
make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
12130
diff
changeset
|
894 |
7336 | 895 octave_value find_autoload (void) |
896 { | |
897 return rep->find_autoload (); | |
898 } | |
899 | |
900 octave_value find_user_function (void) | |
901 { | |
902 return rep->find_user_function (); | |
903 } | |
904 | |
905 bool is_user_function_defined (void) const | |
906 { | |
907 return rep->is_user_function_defined (); | |
908 } | |
909 | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
910 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
|
911 = octave_value_list (), |
9463
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
912 bool local_funcs = true) |
7336 | 913 { |
9463
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
914 return rep->find_function (args, local_funcs); |
7336 | 915 } |
916 | |
917 void install_cmdline_function (const octave_value& f) | |
918 { | |
919 rep->install_cmdline_function (f); | |
920 } | |
921 | |
23343
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
922 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
|
923 const std::string& file_name) |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
924 { |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
925 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
|
926 } |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
927 |
7336 | 928 void install_user_function (const octave_value& f) |
929 { | |
930 rep->install_user_function (f); | |
931 } | |
932 | |
933 void install_built_in_function (const octave_value& f) | |
934 { | |
935 rep->install_built_in_function (f); | |
936 } | |
937 | |
22893
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
938 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
|
939 { |
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
940 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
|
941 } |
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
942 |
16605
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
943 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
|
944 |
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
945 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
|
946 { |
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
947 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
|
948 } |
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
949 |
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
950 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
|
951 { |
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
952 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
|
953 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11584
diff
changeset
|
954 |
7336 | 955 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
|
956 |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
957 void |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
21012
diff
changeset
|
958 dump (std::ostream& os, const std::string& prefix = "") const |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
959 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
960 rep->dump (os, prefix); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
961 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
962 |
7336 | 963 private: |
964 | |
965 fcn_info_rep *rep; | |
966 }; | |
967 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
968 symbol_table (void) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
969 : m_scope_id_cache (), m_global_symbols (), m_all_scopes (), |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
970 m_fcn_table (), m_class_precedence_table (), m_parent_map (), |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
971 m_current_scope (xtop_scope) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
972 { } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
973 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
974 // No copying! |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
975 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
976 symbol_table (const symbol_table&) = delete; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
977 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
978 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
|
979 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
980 ~symbol_table (void) = default; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
981 |
7336 | 982 static scope_id global_scope (void) { return xglobal_scope; } |
983 static scope_id top_scope (void) { return xtop_scope; } | |
984 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
985 scope_id current_scope (void) { return m_current_scope; } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
986 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
987 context_id current_context (void) { return xcurrent_context; } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
988 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
989 scope_id alloc_scope (void) { return m_scope_id_cache.alloc (); } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
990 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
991 void set_scope (scope_id sid) |
7336 | 992 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
993 set_scope_and_context (sid, 0); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
994 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
995 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
996 void set_scope_and_context (scope_id sid, context_id context) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
997 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
998 if (sid == xglobal_scope) |
7336 | 999 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
|
1000 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1001 all_scopes_iterator p = m_all_scopes.find (sid); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1002 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1003 if (p == m_all_scopes.end ()) |
7336 | 1004 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1005 // Can only create a new scope if we are starting at the |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1006 // base context. |
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 (context != 0) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1009 error ("can't find scope %d", sid); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1010 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1011 scope *s = new scope (sid); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1012 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1013 if (! s) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1014 error ("failed to create scope %d", sid); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1015 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1016 m_all_scopes[sid] = s; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1017 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1018 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1019 m_current_scope = sid; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1020 xcurrent_context = context; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1021 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1022 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1023 void erase_scope (scope_id sid) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1024 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1025 assert (sid != xglobal_scope); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1026 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1027 all_scopes_iterator p = m_all_scopes.find (sid); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1028 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1029 if (p != m_all_scopes.end ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1030 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1031 m_all_scopes.erase (p); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1032 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1033 free_scope (sid); |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1034 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1035 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1036 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1037 void erase_subfunctions_in_scope (scope_id sid) |
7336 | 1038 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1039 scope *s = get_scope (sid); |
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 if (s) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1042 s->erase_subfunctions (); |
7336 | 1043 } |
1044 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1045 void mark_nested (scope_id sid) |
7876
8447a5024650
clear subfunctions when clearing parent function
John W. Eaton <jwe@octave.org>
parents:
7779
diff
changeset
|
1046 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1047 scope *s = get_scope (sid); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1048 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1049 if (s) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1050 s->mark_nested (); |
7876
8447a5024650
clear subfunctions when clearing parent function
John W. Eaton <jwe@octave.org>
parents:
7779
diff
changeset
|
1051 } |
8447a5024650
clear subfunctions when clearing parent function
John W. Eaton <jwe@octave.org>
parents:
7779
diff
changeset
|
1052 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1053 void |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1054 mark_subfunctions_in_scope_as_private (scope_id sid, |
11445
40f311a69417
fix OO field access in subfunctions of private functions
John W. Eaton <jwe@octave.org>
parents:
11238
diff
changeset
|
1055 const std::string& class_name) |
40f311a69417
fix OO field access in subfunctions of private functions
John W. Eaton <jwe@octave.org>
parents:
11238
diff
changeset
|
1056 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1057 scope *s = get_scope (sid); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1058 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1059 if (s) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1060 s->mark_subfunctions_in_scope_as_private (class_name); |
11445
40f311a69417
fix OO field access in subfunctions of private functions
John W. Eaton <jwe@octave.org>
parents:
11238
diff
changeset
|
1061 } |
40f311a69417
fix OO field access in subfunctions of private functions
John W. Eaton <jwe@octave.org>
parents:
11238
diff
changeset
|
1062 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1063 scope_id dup_scope (scope_id sid) |
7336 | 1064 { |
1065 scope_id retval = -1; | |
1066 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1067 scope *s = get_scope (sid); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1068 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1069 if (s) |
7336 | 1070 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1071 scope_id new_sid = alloc_scope (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1072 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1073 m_all_scopes[new_sid] = s->dup (new_sid); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1074 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1075 retval = new_sid; |
7336 | 1076 } |
1077 | |
1078 return retval; | |
1079 } | |
1080 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1081 std::list<scope_id> scopes (void) |
7336 | 1082 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1083 return m_scope_id_cache.scopes (); |
7336 | 1084 } |
1085 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1086 symbol_record |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1087 find_symbol (const std::string& name, scope_id sid) |
7336 | 1088 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1089 scope *s = get_scope (sid); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1090 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1091 return s ? s->find_symbol (name) : symbol_record (sid); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1092 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1093 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1094 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
|
1095 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1096 return find_symbol (name, m_current_scope); |
7336 | 1097 } |
4009 | 1098 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1099 void |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1100 inherit (scope_id sid, scope_id donor_sid, context_id donor_context) |
7336 | 1101 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1102 scope *s = get_scope (sid); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1103 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1104 if (s) |
8051
36a485f7f335
symtab.h (symbol_table::do_inherit): copy alll symbols from donor scope
John W. Eaton <jwe@octave.org>
parents:
7972
diff
changeset
|
1105 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1106 while (donor_sid > 0) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1107 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1108 scope *donor_scope = get_scope (donor_sid); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1109 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1110 if (donor_scope) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1111 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1112 s->inherit (*donor_scope, donor_context); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1113 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1114 if (donor_scope->is_nested ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1115 donor_sid = donor_scope->parent_scope_id (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1116 else |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1117 break; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1118 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1119 } |
8051
36a485f7f335
symtab.h (symbol_table::do_inherit): copy alll symbols from donor scope
John W. Eaton <jwe@octave.org>
parents:
7972
diff
changeset
|
1120 } |
7336 | 1121 } |
1122 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1123 void |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1124 inherit (scope_id sid, scope_id donor_sid) |
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 inherit (sid, donor_sid, xcurrent_context); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1127 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1128 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1129 void inherit (scope_id sid) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1130 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1131 inherit (sid, m_current_scope); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1132 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1133 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1134 bool at_top_level (void) { return m_current_scope == xtop_scope; } |
7336 | 1135 |
1136 // 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
|
1137 octave_value |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11584
diff
changeset
|
1138 find (const std::string& name, |
9445
c5f03874ea2a
simplify symbol_table::find and associated functions
Jaroslav Hajek <highegg@gmail.com>
parents:
9444
diff
changeset
|
1139 const octave_value_list& args = octave_value_list (), |
10313 | 1140 bool skip_variables = false, |
9463
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
1141 bool local_funcs = true); |
7336 | 1142 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1143 octave_value builtin_find (const std::string& name); |
9444
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1144 |
7336 | 1145 // Insert a new name in the table. |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1146 OCTAVE_DEPRECATED ("use 'get_scope' with 'insert (name)' instead") |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1147 symbol_record& insert (const std::string& name, scope_id sid) |
7336 | 1148 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1149 scope *s = get_scope (sid); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1150 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1151 return s ? s->insert (name) : symbol_table::dummy_symbol_record; |
7336 | 1152 } |
1153 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1154 symbol_record& insert (const std::string& name) |
16502
45ae1038ee89
allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents:
16468
diff
changeset
|
1155 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1156 scope *s = get_scope (m_current_scope); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1157 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1158 return s ? s->insert (name) : symbol_table::dummy_symbol_record; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1159 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1160 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1161 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
|
1162 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1163 scope *s = get_scope (m_current_scope); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1164 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1165 if (s) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1166 s->rename (old_name, new_name); |
16502
45ae1038ee89
allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents:
16468
diff
changeset
|
1167 } |
45ae1038ee89
allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents:
16468
diff
changeset
|
1168 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1169 void 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
|
1170 scope_id sid, context_id context, bool force_add) |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1171 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1172 scope *s = get_scope (sid); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1173 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1174 if (s) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1175 s->assign (name, value, context, force_add); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1176 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1177 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1178 void 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
|
1179 scope_id sid, context_id context) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1180 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1181 assign (name, value, sid, context, false); |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1182 } |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1183 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1184 void 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
|
1185 scope_id sid) |
7336 | 1186 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1187 assign (name, value, sid, xdefault_context); |
15236
44d6ffdf9479
Disallow new variables in nested functions (bug #36271)
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
1188 } |
44d6ffdf9479
Disallow new variables in nested functions (bug #36271)
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
1189 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1190 void assign (const std::string& name, |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1191 const octave_value& value = octave_value ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1192 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1193 assign (name, value, m_current_scope); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1194 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1195 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1196 // use 'assign' instead |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1197 // octave_value& |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1198 // varref (const std::string& name, scope_id sid = xcurrent_scope, |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1199 // context_id context = xdefault_context, bool force_add = false); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1200 |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1201 // Convenience function to simplify |
15236
44d6ffdf9479
Disallow new variables in nested functions (bug #36271)
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
1202 // octave_user_function::bind_automatic_vars |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1203 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1204 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
|
1205 scope_id sid, context_id context) |
15236
44d6ffdf9479
Disallow new variables in nested functions (bug #36271)
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
1206 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1207 assign (name, value, sid, context, true); |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1208 } |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1209 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1210 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
|
1211 scope_id sid) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1212 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1213 assign (name, value, sid, xdefault_context); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1214 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1215 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1216 void force_assign (const std::string& name, |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1217 const octave_value& value = octave_value ()) |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1218 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1219 assign (name, value, m_current_scope); |
7336 | 1220 } |
1221 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1222 // use 'force_assign' instead |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1223 // octave_value& |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1224 // force_varref (const std::string& name, scope_id sid = xcurrent_scope, |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1225 // context_id context = xdefault_context); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1226 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1227 octave_value varval (const std::string& name, scope_id sid, |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1228 context_id context) |
7336 | 1229 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1230 scope *s = get_scope (sid); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1231 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1232 return s ? s->varval (name, context) : octave_value (); |
7336 | 1233 } |
1234 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1235 octave_value varval (const std::string& name, scope_id sid) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1236 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1237 return varval (name, sid, xdefault_context); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1238 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1239 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1240 octave_value varval (const std::string& name) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1241 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1242 return varval (name, m_current_scope); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1243 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1244 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1245 void |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1246 global_assign (const std::string& name, |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1247 const octave_value& value = octave_value ()) |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1248 |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1249 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1250 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
|
1251 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1252 if (p == m_global_symbols.end ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1253 m_global_symbols[name] = value; |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1254 else |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1255 p->second = value; |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1256 } |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1257 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1258 // use 'global_assign' instead |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1259 // octave_value& |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1260 // global_varref (const std::string& name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1261 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1262 octave_value |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1263 global_varval (const std::string& name) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1264 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1265 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
|
1266 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1267 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
|
1268 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1269 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1270 void |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1271 top_level_assign (const std::string& name, |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1272 const octave_value& value = octave_value ()) |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1273 { |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1274 assign (name, value, top_scope (), 0); |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1275 } |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1276 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1277 // use 'top_level_assign' instead |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1278 // octave_value& |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1279 // top_level_varref (const std::string& name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1280 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1281 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
|
1282 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
|
1283 { |
e42b1bbd1052
variables.cc (get_top_level_value, set_top_level_value): new functions
John W. Eaton <jwe@octave.org>
parents:
9981
diff
changeset
|
1284 return varval (name, top_scope (), 0); |
e42b1bbd1052
variables.cc (get_top_level_value, set_top_level_value): new functions
John W. Eaton <jwe@octave.org>
parents:
9981
diff
changeset
|
1285 } |
e42b1bbd1052
variables.cc (get_top_level_value, set_top_level_value): new functions
John W. Eaton <jwe@octave.org>
parents:
9981
diff
changeset
|
1286 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1287 void |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1288 persistent_assign (const std::string& name, scope_id sid, |
21813
2ba69be3f3e8
accept scope as argument in most static symbol_table functions
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1289 const octave_value& value = octave_value ()) |
2ba69be3f3e8
accept scope as argument in most static symbol_table functions
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1290 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1291 scope *s = get_scope (sid); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1292 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1293 if (s) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1294 s->persistent_assign (name, value); |
21813
2ba69be3f3e8
accept scope as argument in most static symbol_table functions
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1295 } |
2ba69be3f3e8
accept scope as argument in most static symbol_table functions
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1296 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1297 void |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1298 persistent_assign (const std::string& name, |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1299 const octave_value& value = octave_value ()) |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1300 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1301 persistent_assign (name, m_current_scope, value); |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1302 } |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16320
diff
changeset
|
1303 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1304 // use 'persistent_assign' instead |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1305 // octave_value& |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1306 // persistent_varref (const std::string& name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1307 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1308 octave_value persistent_varval (const std::string& name) |
7336 | 1309 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1310 scope *s = get_scope (m_current_scope); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1311 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1312 return s ? s->persistent_varval (name) : octave_value (); |
7336 | 1313 } |
1314 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1315 void erase_persistent (const std::string& name) |
7336 | 1316 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1317 scope *s = get_scope (m_current_scope); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1318 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1319 if (s) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1320 s->erase_persistent (name); |
7336 | 1321 } |
8 | 1322 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1323 OCTAVE_DEPRECATED ("use 'get_scope' with 'is_variable (name)' instead") |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1324 bool is_variable (const std::string& name, scope_id sid) |
7336 | 1325 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1326 scope *s = get_scope (sid); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1327 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1328 return s ? s->is_variable (name) : false; |
7336 | 1329 } |
1330 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1331 bool is_variable (const std::string& name) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1332 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1333 scope *s = get_scope (m_current_scope); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1334 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1335 return s ? s->is_variable (name) : false; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1336 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1337 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1338 bool |
7336 | 1339 is_built_in_function_name (const std::string& name) |
1340 { | |
1341 octave_value val = find_built_in_function (name); | |
1342 | |
1343 return val.is_defined (); | |
1344 } | |
1345 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1346 octave_value |
7336 | 1347 find_method (const std::string& name, const std::string& dispatch_type) |
1348 { | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1349 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
|
1350 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1351 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
|
1352 { |
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21244
diff
changeset
|
1353 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
|
1354 |
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21244
diff
changeset
|
1355 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
|
1356 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
|
1357 |
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21244
diff
changeset
|
1358 return fcn; |
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21244
diff
changeset
|
1359 } |
7336 | 1360 else |
1361 { | |
10313 | 1362 fcn_info finfo (name); |
1363 | |
1364 octave_value fcn = finfo.find_method (dispatch_type); | |
1365 | |
21264
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21244
diff
changeset
|
1366 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
|
1367 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
|
1368 |
10313 | 1369 if (fcn.is_defined ()) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1370 m_fcn_table[name] = finfo; |
10313 | 1371 |
1372 return fcn; | |
7336 | 1373 } |
1374 } | |
1375 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1376 octave_value |
21264
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21244
diff
changeset
|
1377 find_submethod (const std::string& name, const std::string& dispatch_type); |
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21244
diff
changeset
|
1378 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1379 octave_value |
7336 | 1380 find_built_in_function (const std::string& name) |
1381 { | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1382 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
|
1383 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1384 return (p != m_fcn_table.end () |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1385 ? p->second.find_built_in_function () : octave_value ()); |
7336 | 1386 } |
1387 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1388 octave_value |
7336 | 1389 find_autoload (const std::string& name) |
1390 { | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1391 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
|
1392 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1393 return (p != m_fcn_table.end () |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1394 ? p->second.find_autoload () : octave_value ()); |
7336 | 1395 } |
1396 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1397 octave_value |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11584
diff
changeset
|
1398 find_function (const std::string& name, |
9463
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
1399 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
|
1400 bool local_funcs = true); |
7336 | 1401 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1402 octave_value find_user_function (const std::string& name) |
7336 | 1403 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1404 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
|
1405 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1406 return (p != m_fcn_table.end () |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1407 ? p->second.find_user_function () : octave_value ()); |
7336 | 1408 } |
1409 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1410 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
|
1411 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1412 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
|
1413 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1414 return (p != m_fcn_table.end () |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1415 ? 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
|
1416 } |
abf85f8cbd6c
Expand type() to work on command-line entered functions (bug #40462).
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
1417 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1418 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
|
1419 const octave_value& fcn) |
7336 | 1420 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1421 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
|
1422 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1423 if (p != m_fcn_table.end ()) |
7336 | 1424 { |
10313 | 1425 fcn_info& finfo = p->second; |
1426 | |
1427 finfo.install_cmdline_function (fcn); | |
7336 | 1428 } |
1429 else | |
1430 { | |
10313 | 1431 fcn_info finfo (name); |
1432 | |
1433 finfo.install_cmdline_function (fcn); | |
1434 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1435 m_fcn_table[name] = finfo; |
7336 | 1436 } |
1437 } | |
1438 | |
16605
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
1439 // Install subfunction FCN named NAME. SCOPE is the scope of the |
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
1440 // primary function corresponding to this subfunction. |
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
1441 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1442 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
|
1443 const octave_value& fcn, |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1444 scope_id parent_scope) |
7336 | 1445 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1446 scope *s = get_scope (parent_scope); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1447 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1448 if (s) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1449 s->install_subfunction (name, fcn); |
7336 | 1450 } |
1451 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1452 void install_nestfunction (const std::string& name, |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1453 const octave_value& fcn, |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1454 scope_id parent_scope) |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
1455 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1456 scope *s = get_scope (parent_scope); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1457 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1458 if (s) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1459 s->install_subfunction (name, fcn, true); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1460 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1461 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1462 void update_nest (scope_id sid) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1463 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1464 scope *s = get_scope (sid); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1465 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1466 if (s) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1467 s->update_nest (); |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
1468 } |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
1469 |
23343
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
1470 // 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
|
1471 // the file containing the local function. |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
1472 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1473 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
|
1474 const octave_value& fcn, |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1475 const std::string& file_name) |
23343
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
1476 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1477 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
|
1478 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1479 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
|
1480 { |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
1481 fcn_info& finfo = p->second; |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
1482 |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
1483 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
|
1484 } |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
1485 else |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
1486 { |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
1487 fcn_info finfo (name); |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
1488 |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
1489 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
|
1490 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1491 m_fcn_table[name] = finfo; |
23343
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
1492 } |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
1493 } |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
1494 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1495 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
|
1496 const octave_value& fcn) |
7336 | 1497 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1498 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
|
1499 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1500 if (p != m_fcn_table.end ()) |
7336 | 1501 { |
10313 | 1502 fcn_info& finfo = p->second; |
1503 | |
1504 finfo.install_user_function (fcn); | |
7336 | 1505 } |
1506 else | |
1507 { | |
10313 | 1508 fcn_info finfo (name); |
1509 | |
1510 finfo.install_user_function (fcn); | |
1511 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1512 m_fcn_table[name] = finfo; |
7336 | 1513 } |
1514 } | |
605 | 1515 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1516 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
|
1517 const octave_value& fcn) |
7336 | 1518 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1519 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
|
1520 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1521 if (p != m_fcn_table.end ()) |
7336 | 1522 { |
10313 | 1523 fcn_info& finfo = p->second; |
1524 | |
1525 finfo.install_built_in_function (fcn); | |
7336 | 1526 } |
1527 else | |
1528 { | |
10313 | 1529 fcn_info finfo (name); |
1530 | |
1531 finfo.install_built_in_function (fcn); | |
1532 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1533 m_fcn_table[name] = finfo; |
7336 | 1534 } |
1535 } | |
1536 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1537 void clear (const std::string& name) |
7336 | 1538 { |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1539 clear_variable (name); |
7336 | 1540 } |
1541 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1542 void clear_all (bool force = false) |
7336 | 1543 { |
1544 clear_variables (); | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11584
diff
changeset
|
1545 |
10559
0ecbb17d130a
Clear global variables when 'clear -all' called
Rik <code@nomad.inbox5.com>
parents:
10521
diff
changeset
|
1546 clear_global_pattern ("*"); |
7336 | 1547 |
16605
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
1548 clear_functions (force); |
7336 | 1549 } |
1550 | |
21813
2ba69be3f3e8
accept scope as argument in most static symbol_table functions
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1551 // 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
|
1552 // 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
|
1553 // unwind_protect. |
2ba69be3f3e8
accept scope as argument in most static symbol_table functions
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1554 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1555 void clear_variables (scope_id sid) |
7336 | 1556 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1557 scope *s = get_scope (sid); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1558 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1559 if (s) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1560 s->clear_variables (); |
7336 | 1561 } |
1562 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1563 void clear_variables (void) |
9396
17af7cce7d1b
yet more unwind_protect improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
9355
diff
changeset
|
1564 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1565 clear_variables (m_current_scope); |
9396
17af7cce7d1b
yet more unwind_protect improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
9355
diff
changeset
|
1566 } |
17af7cce7d1b
yet more unwind_protect improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
9355
diff
changeset
|
1567 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1568 void clear_objects (void) |
9240
f27a8c07f0b2
clear -classes and support.
Robert T. Short <octave@phaselockedsystems.com>
parents:
9144
diff
changeset
|
1569 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1570 scope *s = get_scope (m_current_scope); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1571 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1572 if (s) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1573 s->clear_objects (); |
9240
f27a8c07f0b2
clear -classes and support.
Robert T. Short <octave@phaselockedsystems.com>
parents:
9144
diff
changeset
|
1574 } |
f27a8c07f0b2
clear -classes and support.
Robert T. Short <octave@phaselockedsystems.com>
parents:
9144
diff
changeset
|
1575 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1576 void clear_functions (bool force = false) |
7336 | 1577 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1578 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
|
1579 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1580 while (p != m_fcn_table.end ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1581 (p++)->second.clear (force); |
7336 | 1582 } |
1583 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1584 void clear_function (const std::string& name) |
7336 | 1585 { |
1586 clear_user_function (name); | |
1587 } | |
1588 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1589 void clear_global (const std::string& name) |
7336 | 1590 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1591 scope *s = get_scope (m_current_scope); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1592 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1593 if (s) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1594 s->clear_global (name); |
7336 | 1595 } |
1596 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1597 void clear_variable (const std::string& name) |
7336 | 1598 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1599 scope *s = get_scope (m_current_scope); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1600 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1601 if (s) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1602 s->clear_variable (name); |
7336 | 1603 } |
1604 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1605 void clear_symbol (const std::string& name) |
7336 | 1606 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1607 // FIXME: are we supposed to do both here? |
7336 | 1608 |
1609 clear_variable (name); | |
1610 clear_function (name); | |
1611 } | |
1612 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1613 void clear_function_pattern (const std::string& pat) |
7336 | 1614 { |
1615 glob_match pattern (pat); | |
1616 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1617 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
|
1618 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1619 while (p != m_fcn_table.end ()) |
7336 | 1620 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1621 if (pattern.match (p->first)) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1622 (p++)->second.clear_user_function (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1623 else |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1624 p++; |
7336 | 1625 } |
1626 } | |
1627 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1628 void clear_global_pattern (const std::string& pat) |
7336 | 1629 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1630 scope *s = get_scope (m_current_scope); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1631 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1632 if (s) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1633 s->clear_global_pattern (pat); |
7336 | 1634 } |
1635 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1636 void clear_variable_pattern (const std::string& pat) |
7336 | 1637 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1638 scope *s = get_scope (m_current_scope); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1639 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1640 if (s) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1641 s->clear_variable_pattern (pat); |
7336 | 1642 } |
1643 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1644 void clear_variable_regexp (const std::string& pat) |
7779
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1645 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1646 scope *s = get_scope (m_current_scope); |
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 if (s) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1649 s->clear_variable_regexp (pat); |
7779
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1650 } |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1651 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1652 void clear_symbol_pattern (const std::string& pat) |
7336 | 1653 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1654 // FIXME: are we supposed to do both here? |
7336 | 1655 |
1656 clear_variable_pattern (pat); | |
1657 clear_function_pattern (pat); | |
1658 } | |
1659 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1660 void clear_user_function (const std::string& name) |
7336 | 1661 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1662 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
|
1663 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1664 if (p != m_fcn_table.end ()) |
7336 | 1665 { |
10313 | 1666 fcn_info& finfo = p->second; |
1667 | |
1668 finfo.clear_user_function (); | |
7336 | 1669 } |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1670 // FIXME: is this necessary, or even useful? |
7336 | 1671 // else |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
1672 // error ("clear: no such function '%s'", name.c_str ()); |
7336 | 1673 } |
1674 | |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21574
diff
changeset
|
1675 // 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
|
1676 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
|
1677 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1678 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
|
1679 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1680 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
|
1681 { |
10313 | 1682 fcn_info& finfo = p->second; |
1683 | |
1684 finfo.clear_autoload_function (); | |
1685 finfo.clear_user_function (); | |
9958
80432f0ee895
improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents:
9639
diff
changeset
|
1686 } |
80432f0ee895
improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents:
9639
diff
changeset
|
1687 } |
80432f0ee895
improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents:
9639
diff
changeset
|
1688 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1689 void clear_mex_functions (void) |
7336 | 1690 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1691 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
|
1692 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1693 while (p != m_fcn_table.end ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1694 (p++)->second.clear_mex_function (); |
7336 | 1695 } |
1696 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1697 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
|
1698 const std::string& inf_class); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1699 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1700 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
|
1701 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1702 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
|
1703 const std::string& name) |
7336 | 1704 { |
1705 octave_value fcn = find_built_in_function (name); | |
1706 | |
1707 if (fcn.is_defined ()) | |
1708 { | |
10313 | 1709 fcn_info finfo (alias); |
1710 | |
1711 finfo.install_built_in_function (fcn); | |
1712 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1713 m_fcn_table[alias] = finfo; |
7336 | 1714 } |
1715 else | |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
1716 panic ("alias: '%s' is undefined", name.c_str ()); |
7336 | 1717 } |
1718 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1719 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
|
1720 const std::string& klass) |
7336 | 1721 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1722 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
|
1723 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1724 if (p != m_fcn_table.end ()) |
7336 | 1725 { |
10313 | 1726 fcn_info& finfo = p->second; |
1727 | |
22893
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
1728 finfo.install_built_in_dispatch (klass); |
7336 | 1729 } |
22893
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
1730 else |
5ff6716cf157
allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
1731 error ("install_built_in_dispatch: '%s' is undefined", name.c_str ()); |
7336 | 1732 } |
1733 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1734 void push_context (void) |
7336 | 1735 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1736 if (m_current_scope == xtop_scope) |
21813
2ba69be3f3e8
accept scope as argument in most static symbol_table functions
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1737 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
|
1738 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1739 scope *s = get_scope (m_current_scope); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1740 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1741 if (s) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1742 s->push_context (); |
7336 | 1743 } |
1744 | |
21813
2ba69be3f3e8
accept scope as argument in most static symbol_table functions
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1745 // 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
|
1746 // 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
|
1747 // unwind_protect. |
2ba69be3f3e8
accept scope as argument in most static symbol_table functions
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1748 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1749 void pop_context (void) |
7336 | 1750 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1751 if (m_current_scope == xtop_scope) |
21813
2ba69be3f3e8
accept scope as argument in most static symbol_table functions
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1752 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
|
1753 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1754 scope *s = get_scope (m_current_scope); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1755 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1756 if (s) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1757 s->pop_context (); |
7336 | 1758 } |
1759 | |
21813
2ba69be3f3e8
accept scope as argument in most static symbol_table functions
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1760 // 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
|
1761 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1762 void pop_context (void *) { pop_context (); } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1763 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1764 void mark_automatic (const std::string& name) |
11557
e9d72a3caa46
mark automatic variables as automatic
John W. Eaton <jwe@octave.org>
parents:
11548
diff
changeset
|
1765 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1766 scope *s = get_scope (m_current_scope); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1767 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1768 if (s) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1769 s->mark_automatic (name); |
11557
e9d72a3caa46
mark automatic variables as automatic
John W. Eaton <jwe@octave.org>
parents:
11548
diff
changeset
|
1770 } |
e9d72a3caa46
mark automatic variables as automatic
John W. Eaton <jwe@octave.org>
parents:
11548
diff
changeset
|
1771 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1772 void mark_hidden (const std::string& name) |
7336 | 1773 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1774 scope *s = get_scope (m_current_scope); |
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 if (s) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1777 s->mark_hidden (name); |
7336 | 1778 } |
1779 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1780 void mark_global (const std::string& name) |
7336 | 1781 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1782 scope *s = get_scope (m_current_scope); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1783 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1784 if (s) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1785 s->mark_global (name); |
7336 | 1786 } |
1787 | |
15572
859c8bf6d134
Fix saved struct with function handle fails to load (bug #33857)
Max Brister <max@2bass.com>
parents:
15467
diff
changeset
|
1788 // exclude: Storage classes to exclude, you can OR them together |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1789 std::list<symbol_record> |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1790 all_variables (scope_id sid, context_id context, bool defined_only, |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1791 unsigned int exclude) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1792 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1793 scope *s = get_scope (sid); |
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 return (s |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1796 ? s->all_variables (context, defined_only, exclude) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1797 : std::list<symbol_record> ()); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1798 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1799 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1800 std::list<symbol_record> |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1801 all_variables (scope_id sid, context_id context, bool defined_only) |
7336 | 1802 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1803 return all_variables (sid, context, defined_only, symbol_record::hidden); |
7336 | 1804 } |
3011 | 1805 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1806 std::list<symbol_record> |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1807 all_variables (scope_id sid, context_id context) |
7336 | 1808 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1809 return all_variables (sid, context, true); |
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 std::list<symbol_record> |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1813 all_variables (scope_id sid) |
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 return all_variables (sid, xdefault_context); |
7336 | 1816 } |
1817 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1818 std::list<symbol_record> |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1819 all_variables (void) |
7779
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1820 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1821 return all_variables (m_current_scope); |
7779
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1822 } |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1823 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1824 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
|
1825 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1826 scope *s = get_scope (m_current_scope); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1827 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1828 return s ? s->glob (pattern) : std::list<symbol_record> (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1829 } |
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 std::list<symbol_record> regexp (const std::string& pattern) |
7336 | 1832 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1833 scope *s = get_scope (m_current_scope); |
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 return s ? s->regexp (pattern) : std::list<symbol_record> (); |
7336 | 1836 } |
1837 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1838 std::list<symbol_record> glob_variables (const std::string& pattern) |
7779
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1839 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1840 scope *s = get_scope (m_current_scope); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1841 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1842 return s ? s->glob (pattern, true) : std::list<symbol_record> (); |
7779
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1843 } |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1844 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1845 std::list<symbol_record> regexp_variables (const std::string& pattern) |
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 scope *s = get_scope (m_current_scope); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1848 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1849 return s ? s->regexp (pattern, true) : std::list<symbol_record> (); |
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 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1852 std::list<symbol_record> |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1853 glob_global_variables (const std::string& pattern) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1854 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1855 std::list<symbol_record> retval; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1856 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1857 glob_match pat (pattern); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1858 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1859 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
|
1860 { |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
1861 // 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
|
1862 // 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
|
1863 // way. |
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
1864 if (pat.match (nm_val.first)) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1865 retval.push_back (symbol_record (xglobal_scope, |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
1866 nm_val.first, nm_val.second, |
10313 | 1867 symbol_record::global)); |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1868 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1869 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1870 return retval; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1871 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1872 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1873 std::list<symbol_record> |
7779
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1874 regexp_global_variables (const std::string& pattern) |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1875 { |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1876 std::list<symbol_record> retval; |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1877 |
22333
2758af148ced
move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
1878 octave::regexp pat (pattern); |
7779
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1879 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1880 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
|
1881 { |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
1882 // 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
|
1883 // 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
|
1884 // way. |
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
1885 if (pat.is_match (nm_val.first)) |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
1886 retval.push_back (symbol_record (xglobal_scope, |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
1887 nm_val.first, nm_val.second, |
10313 | 1888 symbol_record::global)); |
7779
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1889 } |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1890 |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1891 return retval; |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1892 } |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1893 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1894 std::list<symbol_record> glob_variables (const string_vector& patterns) |
7336 | 1895 { |
1896 std::list<symbol_record> retval; | |
1897 | |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20207
diff
changeset
|
1898 size_t len = patterns.numel (); |
8 | 1899 |
7336 | 1900 for (size_t i = 0; i < len; i++) |
1901 { | |
10313 | 1902 std::list<symbol_record> tmp = glob_variables (patterns[i]); |
1903 | |
1904 retval.insert (retval.begin (), tmp.begin (), tmp.end ()); | |
7336 | 1905 } |
1906 | |
1907 return retval; | |
1908 } | |
1909 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1910 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
|
1911 { |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1912 std::list<symbol_record> retval; |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1913 |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20207
diff
changeset
|
1914 size_t len = patterns.numel (); |
7779
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1915 |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1916 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
|
1917 { |
10313 | 1918 std::list<symbol_record> tmp = regexp_variables (patterns[i]); |
1919 | |
1920 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
|
1921 } |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1922 |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1923 return retval; |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1924 } |
791231dac333
Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1925 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1926 std::list<std::string> user_function_names (void) |
7336 | 1927 { |
1928 std::list<std::string> retval; | |
1929 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1930 for (const auto& nm_finfo : m_fcn_table) |
7336 | 1931 { |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
1932 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
|
1933 retval.push_back (nm_finfo.first); |
7336 | 1934 } |
1935 | |
1936 if (! retval.empty ()) | |
1937 retval.sort (); | |
1938 | |
1939 return retval; | |
1940 } | |
3011 | 1941 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1942 std::list<std::string> global_variable_names (void) |
7336 | 1943 { |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1944 std::list<std::string> retval; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1945 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1946 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
|
1947 retval.push_back (nm_val.first); |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1948 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1949 retval.sort (); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1950 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1951 return retval; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1952 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1953 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1954 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
|
1955 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1956 scope *s = get_scope (xtop_scope); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1957 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1958 return s ? s->variable_names () : std::list<std::string> (); |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1959 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1960 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1961 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
|
1962 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1963 scope *s = get_scope (m_current_scope); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1964 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1965 return s ? s->variable_names () : std::list<std::string> (); |
7336 | 1966 } |
1967 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1968 std::list<std::string> built_in_function_names (void) |
7336 | 1969 { |
1970 std::list<std::string> retval; | |
1971 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1972 for (const auto& nm_finfo : m_fcn_table) |
7336 | 1973 { |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
1974 octave_value fcn = nm_finfo.second.find_built_in_function (); |
10313 | 1975 |
1976 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
|
1977 retval.push_back (nm_finfo.first); |
7336 | 1978 } |
1979 | |
1980 if (! retval.empty ()) | |
1981 retval.sort (); | |
220 | 1982 |
7336 | 1983 return retval; |
1984 } | |
1985 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1986 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
|
1987 { |
d6151d774283
make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
12130
diff
changeset
|
1988 std::list<std::string> retval; |
d6151d774283
make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
12130
diff
changeset
|
1989 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1990 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
|
1991 { |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
1992 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
|
1993 |
d6151d774283
make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
12130
diff
changeset
|
1994 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
|
1995 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
|
1996 } |
d6151d774283
make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
12130
diff
changeset
|
1997 |
d6151d774283
make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
12130
diff
changeset
|
1998 if (! retval.empty ()) |
d6151d774283
make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
12130
diff
changeset
|
1999 retval.sort (); |
d6151d774283
make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
12130
diff
changeset
|
2000 |
d6151d774283
make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
12130
diff
changeset
|
2001 return retval; |
d6151d774283
make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
12130
diff
changeset
|
2002 } |
d6151d774283
make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents:
12130
diff
changeset
|
2003 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2004 bool is_local_variable (const std::string& name) |
7336 | 2005 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2006 scope *s = get_scope (m_current_scope); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2007 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2008 return s ? s->is_local_variable (name) : false; |
7336 | 2009 } |
5861 | 2010 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2011 bool is_global (const std::string& 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 scope *s = get_scope (m_current_scope); |
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 return s ? s->is_global (name) : false; |
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 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2018 std::list<workspace_element> workspace_info (void) |
7336 | 2019 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2020 scope *s = get_scope (m_current_scope); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2021 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2022 return s ? s->workspace_info () : std::list<workspace_element> (); |
7336 | 2023 } |
3011 | 2024 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2025 void dump (std::ostream& os, scope_id sid); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2026 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2027 void dump_global (std::ostream& os); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2028 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2029 void dump_functions (std::ostream& os); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2030 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2031 void cache_name (scope_id sid, const std::string& name) |
16468
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
2032 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2033 scope *s = get_scope (sid, false); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2034 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2035 if (s) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2036 s->cache_name (name); |
16468
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
2037 } |
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
2038 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2039 void lock_subfunctions (scope_id sid) |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
2040 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2041 scope *s = get_scope (sid); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2042 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2043 if (s) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2044 s->lock_subfunctions (); |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
2045 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
2046 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2047 void unlock_subfunctions (scope_id sid) |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
2048 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2049 scope *s = get_scope (sid); |
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 (s) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2052 s->unlock_subfunctions (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11584
diff
changeset
|
2053 } |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
2054 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2055 std::map<std::string, octave_value> |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2056 subfunctions_defined_in_scope (scope_id sid) |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
2057 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2058 scope *s = get_scope (sid); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2059 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2060 return (s |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2061 ? s->subfunctions () |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2062 : std::map<std::string, octave_value> ()); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11584
diff
changeset
|
2063 } |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
2064 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2065 void free_scope (scope_id sid) |
16596
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16502
diff
changeset
|
2066 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2067 if (sid == xglobal_scope || sid == xtop_scope) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2068 error ("can't free global or top-level scopes!"); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2069 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2070 m_scope_id_cache.free (sid); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2071 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2072 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2073 void stash_dir_name_for_subfunctions (scope_id sid, |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2074 const std::string& dir_name) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2075 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2076 scope *s = get_scope (sid); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2077 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2078 if (s) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2079 s->stash_dir_name_for_subfunctions (dir_name); |
16596
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16502
diff
changeset
|
2080 } |
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16502
diff
changeset
|
2081 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2082 void set_parent (scope_id child_scope_id, scope_id parent_scope_id) |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
2083 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2084 scope *child_scope = get_scope (child_scope_id); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2085 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2086 if (child_scope) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2087 child_scope->set_parent (get_scope (parent_scope_id)); |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
2088 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
2089 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2090 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
|
2091 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
|
2092 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2093 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
|
2094 } |
3d0d2bda3a0f
fix previous change, avoid duplicate loads of methods in descendant classes
Jaroslav Hajek <highegg@gmail.com>
parents:
9509
diff
changeset
|
2095 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2096 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
|
2097 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
|
2098 { |
1783b360976f
also consider parent classes when checking if class methods are out of date
John W. Eaton <jwe@octave.org>
parents:
10633
diff
changeset
|
2099 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
|
2100 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2101 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
|
2102 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2103 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
|
2104 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
|
2105 |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
2106 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
|
2107 { |
3229572cbe23
symbol_table::parent_classes: also add parents of parents to the list
John W. Eaton <jwe@octave.org>
parents:
12122
diff
changeset
|
2108 // 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
|
2109 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2110 // 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
|
2111 |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
2112 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
|
2113 |
3229572cbe23
symbol_table::parent_classes: also add parents of parents to the list
John W. Eaton <jwe@octave.org>
parents:
12122
diff
changeset
|
2114 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
|
2115 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
|
2116 } |
3229572cbe23
symbol_table::parent_classes: also add parents of parents to the list
John W. Eaton <jwe@octave.org>
parents:
12122
diff
changeset
|
2117 |
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
|
2118 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
|
2119 } |
1783b360976f
also consider parent classes when checking if class methods are out of date
John W. Eaton <jwe@octave.org>
parents:
10633
diff
changeset
|
2120 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2121 OCTAVE_DEPRECATED ("use 'get_scope' with 'get_curr_fcn (name)' instead") |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2122 octave_user_function * get_curr_fcn (scope_id sid) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2123 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2124 scope *s = get_scope (sid); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2125 return s->function (); |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2126 } |
9639
8d79f36ebdde
store scope->function pointer
Jaroslav Hajek <highegg@gmail.com>
parents:
9581
diff
changeset
|
2127 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2128 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
|
2129 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2130 scope *s = get_scope (m_current_scope); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2131 return s->function (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2132 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2133 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2134 OCTAVE_DEPRECATED ("set_curr_fcn") |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2135 void set_curr_fcn (octave_user_function *curr_fcn, scope_id sid) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2136 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2137 assert (sid != xtop_scope && sid != xglobal_scope); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2138 scope *s = get_scope (sid); |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2139 // FIXME: normally, functions should not usurp each other's scope. |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2140 // If for any incredible reason this is needed, call |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21574
diff
changeset
|
2141 // set_user_function (0, scope) first. This may cause problems with |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2142 // nested functions, as the curr_fcn of symbol_records must be updated. |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2143 assert (s->function () == 0 || curr_fcn == 0); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2144 s->set_function (curr_fcn); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2145 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2146 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2147 scope * get_scope (scope_id sid, bool create = true) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2148 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2149 scope *retval = nullptr; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2150 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2151 bool ok = true; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2152 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2153 if (sid == xglobal_scope) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2154 error ("can't get global scope"); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2155 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2156 all_scopes_iterator p = m_all_scopes.find (sid); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2157 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2158 if (p == m_all_scopes.end ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2159 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2160 if (create) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2161 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2162 retval = new scope (sid); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2163 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2164 if (retval) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2165 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2166 m_all_scopes[sid] = retval; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2167 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2168 if (sid == xtop_scope) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2169 retval->cache_name ("top-level"); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2170 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2171 else |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2172 ok = false; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2173 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2174 else |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2175 ok = false; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2176 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2177 else |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2178 retval = p->second; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2179 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2180 if (! ok) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2181 error ("unable to %s scope object for scope id %d!", |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2182 create ? "create" : "find", sid); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2183 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2184 return retval; |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2185 } |
9639
8d79f36ebdde
store scope->function pointer
Jaroslav Hajek <highegg@gmail.com>
parents:
9581
diff
changeset
|
2186 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2187 void cleanup (void); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2188 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2189 class scope |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2190 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2191 public: |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2192 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2193 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
|
2194 table_const_iterator; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2195 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
|
2196 table_iterator; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2197 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2198 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
|
2199 m_persistent_symbols_const_iterator; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2200 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
|
2201 m_persistent_symbols_iterator; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2202 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2203 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
|
2204 subfunctions_const_iterator; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2205 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
|
2206 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2207 scope (scope_id sid) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2208 : m_scope (sid), m_name (), m_symbols (), m_children (), |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2209 m_subfunctions (), m_parent (0), m_fcn (0), m_is_nested (false), |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2210 m_is_static (false), m_persistent_symbols () |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2211 { } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2212 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2213 // No copying! |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2214 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2215 scope (const scope&) = delete; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2216 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2217 scope& operator = (const scope&) = delete; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2218 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2219 ~scope (void) = default; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2220 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2221 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
|
2222 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2223 m_symbols[sr.name ()] = sr; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2224 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2225 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2226 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
|
2227 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2228 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
|
2229 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2230 scope_id parent_scope_id (void) const |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2231 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2232 return m_parent ? m_parent->m_scope : -1; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2233 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2234 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2235 scope * dup (scope_id new_sid) const |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2236 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2237 scope *new_scope = new scope (new_sid); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2238 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2239 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
|
2240 new_scope->insert_symbol_record (nm_sr.second.dup (new_sid)); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2241 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2242 new_scope->m_parent = m_parent; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2243 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2244 return new_scope; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2245 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2246 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2247 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
|
2248 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2249 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
|
2250 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2251 if (p == m_symbols.end ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2252 return insert (name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2253 else |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2254 return p->second; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2255 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2256 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2257 void inherit (scope& donor_table, context_id donor_context) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2258 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2259 for (auto& nm_sr : m_symbols) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2260 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2261 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
|
2262 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2263 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
|
2264 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2265 std::string nm = sr.name (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2266 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2267 if (nm != "__retval__") |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2268 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2269 octave_value val = donor_table.varval (nm, donor_context); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2270 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2271 if (val.is_defined ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2272 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2273 sr.assign (val, 0); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2274 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2275 sr.mark_inherited (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2276 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2277 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2278 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2279 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2280 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2281 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2282 octave_value |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2283 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
|
2284 bool skip_variables, bool local_funcs); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2285 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2286 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
|
2287 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2288 symbol_table::symbol_record& |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2289 insert (const std::string& name, bool force_add = false) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2290 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2291 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
|
2292 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2293 if (p == m_symbols.end ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2294 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2295 symbol_table::symbol_record ret (m_scope, name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2296 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2297 if (m_is_nested && m_parent && m_parent->look_nonlocal (name, ret)) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2298 return m_symbols[name] = ret; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2299 else |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2300 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2301 if (m_is_static && ! force_add) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2302 ret.mark_added_static (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2303 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2304 return m_symbols[name] = ret; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2305 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2306 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2307 else |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2308 return p->second; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2309 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2310 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2311 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
|
2312 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2313 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
|
2314 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2315 if (p != m_symbols.end ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2316 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2317 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
|
2318 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2319 sr.rename (new_name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2320 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2321 m_symbols.erase (p); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2322 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2323 m_symbols[new_name] = sr; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2324 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2325 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2326 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2327 void 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
|
2328 context_id context, bool force_add) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2329 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2330 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
|
2331 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2332 if (p == m_symbols.end ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2333 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2334 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
|
2335 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2336 sr.assign (value, context); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2337 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2338 else |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2339 p->second.assign (value, context); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2340 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2341 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2342 void assign (const std::string& name, |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2343 const octave_value& value = octave_value ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2344 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2345 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
|
2346 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2347 if (p == m_symbols.end ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2348 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2349 symbol_table::symbol_record& sr = insert (name, false); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2350 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2351 sr.assign (value); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2352 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2353 else |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2354 p->second.assign (value); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2355 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2356 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2357 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
|
2358 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2359 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
|
2360 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2361 if (p == m_symbols.end ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2362 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2363 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
|
2364 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2365 sr.assign (value); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2366 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2367 else |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2368 p->second.assign (value); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2369 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2370 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2371 // Use assign (name, value, context, force_add) instead. |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2372 // 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
|
2373 octave_value& |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2374 varref (const std::string& name, context_id context, bool force_add) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2375 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2376 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
|
2377 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2378 if (p == m_symbols.end ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2379 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2380 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
|
2381 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2382 return sr.varref (context); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2383 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2384 else |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2385 return p->second.varref (context); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2386 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2387 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2388 octave_value varval (const std::string& name, context_id context) const |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2389 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2390 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
|
2391 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2392 return (p != m_symbols.end () |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2393 ? p->second.varval (context) : octave_value ()); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2394 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2395 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2396 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
|
2397 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2398 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
|
2399 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2400 return p != m_symbols.end () ? p->second.varval () : octave_value (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2401 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2402 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2403 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
|
2404 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2405 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
|
2406 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2407 if (p == m_persistent_symbols.end ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2408 m_persistent_symbols[name] = value; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2409 else |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2410 p->second = value; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2411 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2412 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2413 // Use persistent_assign (name, value) instead. |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2414 // 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
|
2415 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
|
2416 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2417 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
|
2418 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2419 return (p == m_persistent_symbols.end () |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2420 ? m_persistent_symbols[name] : p->second); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2421 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2422 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2423 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
|
2424 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2425 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
|
2426 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2427 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
|
2428 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2429 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2430 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
|
2431 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2432 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
|
2433 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2434 if (p != m_persistent_symbols.end ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2435 m_persistent_symbols.erase (p); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2436 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2437 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2438 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
|
2439 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2440 bool retval = false; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2441 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2442 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
|
2443 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2444 if (p != m_symbols.end ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2445 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2446 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
|
2447 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2448 retval = sr.is_variable (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2449 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2450 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2451 return retval; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2452 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2453 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2454 void push_context (void) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2455 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2456 for (auto& nm_sr : m_symbols) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2457 nm_sr.second.push_context (m_scope); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2458 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2459 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2460 void pop_context (void) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2461 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2462 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
|
2463 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2464 while (tbl_it != m_symbols.end ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2465 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2466 if (tbl_it->second.pop_context (m_scope) == 0) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2467 m_symbols.erase (tbl_it++); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2468 else |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2469 tbl_it++; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2470 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2471 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2472 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2473 void clear_variables (void) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2474 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2475 for (auto& nm_sr : m_symbols) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2476 nm_sr.second.clear (m_scope); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2477 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2478 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2479 void clear_objects (void) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2480 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2481 for (auto& nm_sr : m_symbols) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2482 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2483 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
|
2484 octave_value val = sr.varval (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2485 if (val.is_object ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2486 nm_sr.second.clear (m_scope); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2487 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2488 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2489 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2490 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
|
2491 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2492 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
|
2493 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2494 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
|
2495 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2496 if (p != m_symbols.end ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2497 p->second.clear (m_scope); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2498 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2499 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2500 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
|
2501 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2502 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
|
2503 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2504 glob_match pattern (pat); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2505 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2506 for (auto& nm_sr : m_symbols) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2507 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2508 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
|
2509 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2510 if (sr.is_defined () || sr.is_global ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2511 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2512 if (pattern.match (sr.name ())) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2513 sr.clear (m_scope); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2514 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2515 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2516 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2517 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2518 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
|
2519 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2520 octave::regexp pattern (pat); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2521 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2522 for (auto& nm_sr : m_symbols) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2523 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2524 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
|
2525 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2526 if (sr.is_defined () || sr.is_global ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2527 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2528 if (pattern.is_match (sr.name ())) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2529 sr.clear (m_scope); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2530 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2531 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2532 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2533 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2534 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
|
2535 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2536 insert (name).mark_automatic (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2537 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2538 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2539 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
|
2540 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2541 insert (name).mark_hidden (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2542 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2543 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2544 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
|
2545 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2546 insert (name).mark_global (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2547 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2548 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2549 std::list<symbol_table::symbol_record> |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2550 all_variables (context_id context, bool defined_only, |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2551 unsigned int exclude) const |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2552 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2553 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
|
2554 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2555 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
|
2556 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2557 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
|
2558 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2559 if ((defined_only && ! sr.is_defined (context)) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2560 || (sr.xstorage_class () & exclude)) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2561 continue; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2562 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2563 retval.push_back (sr); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2564 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2565 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2566 return retval; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2567 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2568 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2569 std::list<symbol_table::symbol_record> |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2570 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
|
2571 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2572 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
|
2573 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2574 glob_match pat (pattern); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2575 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2576 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
|
2577 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2578 if (pat.match (nm_sr.first)) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2579 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2580 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
|
2581 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2582 if (vars_only && ! sr.is_variable ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2583 continue; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2584 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2585 retval.push_back (sr); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2586 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2587 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2588 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2589 return retval; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2590 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2591 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2592 std::list<symbol_table::symbol_record> |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2593 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
|
2594 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2595 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
|
2596 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2597 octave::regexp pat (pattern); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2598 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2599 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
|
2600 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2601 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
|
2602 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2603 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
|
2604 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2605 if (vars_only && ! sr.is_variable ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2606 continue; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2607 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2608 retval.push_back (sr); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2609 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2610 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2611 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2612 return retval; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2613 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2614 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2615 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
|
2616 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2617 std::list<std::string> retval; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2618 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2619 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
|
2620 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2621 if (nm_sr.second.is_variable ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2622 retval.push_back (nm_sr.first); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2623 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2624 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2625 retval.sort (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2626 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2627 return retval; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2628 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2629 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2630 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
|
2631 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2632 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
|
2633 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2634 return (p != m_symbols.end () |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2635 && ! p->second.is_global () |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2636 && p->second.is_defined ()); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2637 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2638 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2639 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
|
2640 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2641 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
|
2642 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2643 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
|
2644 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2645 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2646 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
|
2647 const octave_value& fval, |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2648 bool is_nested = false); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2649 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2650 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
|
2651 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2652 void lock_subfunctions (void) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2653 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2654 for (auto& nm_sf : m_subfunctions) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2655 nm_sf.second.lock (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2656 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2657 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2658 void unlock_subfunctions (void) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2659 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2660 for (auto& nm_sf : m_subfunctions) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2661 nm_sf.second.unlock (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2662 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2663 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2664 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
|
2665 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2666 return m_subfunctions; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2667 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2668 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2669 void erase_subfunctions (void) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2670 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2671 m_subfunctions.clear (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2672 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2673 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2674 void stash_dir_name_for_subfunctions (const std::string& dir_name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2675 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2676 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
|
2677 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2678 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
|
2679 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2680 void dump (std::ostream& os); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2681 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2682 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
|
2683 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2684 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
|
2685 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2686 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
|
2687 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2688 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
|
2689 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2690 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
|
2691 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2692 void update_nest (void); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2693 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2694 bool look_nonlocal (const std::string& name, |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2695 symbol_table::symbol_record& result) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2696 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2697 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
|
2698 if (p == m_symbols.end ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2699 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2700 if (m_is_nested && m_parent) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2701 return m_parent->look_nonlocal (name, result); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2702 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2703 else if (! p->second.is_automatic ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2704 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2705 result = p->second; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2706 return true; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2707 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2708 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2709 return false; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2710 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2711 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2712 private: |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2713 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2714 // The ID for this scope. |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2715 scope_id m_scope; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2716 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2717 // 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
|
2718 // function corresponding to the scope). |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2719 std::string m_name; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2720 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2721 // 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
|
2722 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
|
2723 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2724 // Child nested functions. |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2725 std::vector<scope*> m_children; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2726 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2727 // Map from symbol names to subfunctions. |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2728 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
|
2729 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2730 // 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
|
2731 scope *m_parent; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2732 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2733 // The associated user code (may be null). |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2734 octave_user_function *m_fcn; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2735 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2736 // 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
|
2737 bool m_is_nested; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2738 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2739 // 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
|
2740 bool m_is_static; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2741 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2742 // Map from names of persistent variables to values. |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2743 std::map<std::string, octave_value> m_persistent_symbols; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2744 }; |
9981
692ab4eaf965
clean up top-level variables when exiting Octave
Jaroslav Hajek <highegg@gmail.com>
parents:
9958
diff
changeset
|
2745 |
8 | 2746 private: |
2747 | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2748 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
|
2749 global_symbols_const_iterator; |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2750 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
|
2751 global_symbols_iterator; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2752 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2753 typedef std::map<scope_id, scope*>::const_iterator all_scopes_const_iterator; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2754 typedef std::map<scope_id, scope*>::iterator |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2755 all_scopes_iterator; |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2756 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2757 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
|
2758 fcn_table_const_iterator; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2759 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
|
2760 fcn_table_iterator; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2761 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2762 scope_id_cache m_scope_id_cache; |
15236
44d6ffdf9479
Disallow new variables in nested functions (bug #36271)
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
2763 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
2764 // 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
|
2765 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
|
2766 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2767 // Map from scope id to symbol table scopes. |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2768 std::map<scope_id, scope*> m_all_scopes; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2769 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2770 // Map from function names to function info (private |
7336 | 2771 // 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
|
2772 // 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
|
2773 // them. |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2774 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
|
2775 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2776 // 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
|
2777 // precedence. |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2778 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
|
2779 |
b6498c088fca
maint: Don't write '> >' for declaration of templates that use templates.
Rik <rik@octave.org>
parents:
23457
diff
changeset
|
2780 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
|
2781 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
|
2782 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
|
2783 class_precedence_table_iterator; |
7972
5bf4e2c13ed8
make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents:
7901
diff
changeset
|
2784 |
9581
3d0d2bda3a0f
fix previous change, avoid duplicate loads of methods in descendant classes
Jaroslav Hajek <highegg@gmail.com>
parents:
9509
diff
changeset
|
2785 // 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
|
2786 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
|
2787 |
b6498c088fca
maint: Don't write '> >' for declaration of templates that use templates.
Rik <rik@octave.org>
parents:
23457
diff
changeset
|
2788 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
|
2789 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
|
2790 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
|
2791 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
|
2792 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2793 scope_id m_current_scope; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2794 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2795 static const scope_id xglobal_scope = 0; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2796 static const scope_id xtop_scope = 1; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2797 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2798 static const context_id xdefault_context |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2799 = std::numeric_limits<context_id>::max (); |
7336 | 2800 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
2801 static context_id xcurrent_context; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
2802 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2803 fcn_info * get_fcn_info (const std::string& name) |
7336 | 2804 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
2805 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
|
2806 return p != m_fcn_table.end () ? &p->second : 0; |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
2807 } |
3011 | 2808 }; |
2790 | 2809 |
9450
cf714e75c656
implement overloaded function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
9446
diff
changeset
|
2810 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
|
2811 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
|
2812 bool check_relative = true); |
9450
cf714e75c656
implement overloaded function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
9446
diff
changeset
|
2813 |
10087
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
10071
diff
changeset
|
2814 extern OCTINTERP_API std::string |
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
10071
diff
changeset
|
2815 get_dispatch_type (const octave_value_list& args); |
22653
e7a9dfb8bf16
remove obsolete function __dispatch__
John W. Eaton <jwe@octave.org>
parents:
22407
diff
changeset
|
2816 |
10087
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
10071
diff
changeset
|
2817 extern OCTINTERP_API std::string |
10321
97b4bd6f0925
partially rewrite function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
2818 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
|
2819 |
8 | 2820 #endif |