Mercurial > octave-nkf
annotate src/symtab.h @ 7761:5adeea5de26c
symbol table reporting functions
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 06 May 2008 05:51:17 -0400 |
parents | e76a4a6e3c47 |
children | 71f068b22fcc |
rev | line source |
---|---|
8 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2002, 2003, |
7346 | 4 2004, 2005, 2006, 2007, 2008 John W. Eaton |
7336 | 5 |
8 | 6 This file is part of Octave. |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
8 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
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 | |
383 | 24 #if !defined (octave_symtab_h) |
25 #define octave_symtab_h 1 | |
8 | 26 |
7336 | 27 #include <deque> |
28 #include <list> | |
29 #include <map> | |
30 #include <set> | |
31 #include <string> | |
2953 | 32 |
7336 | 33 #include "glob-match.h" |
2846 | 34 |
7336 | 35 class tree_argument_list; |
3013 | 36 |
7336 | 37 #include "oct-obj.h" |
38 #include "ov.h" | |
1412 | 39 |
8 | 40 class |
6109 | 41 OCTINTERP_API |
8 | 42 symbol_table |
43 { | |
44 public: | |
45 | |
7336 | 46 typedef int scope_id; |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
47 typedef size_t context_id; |
7336 | 48 |
49 class | |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
50 scope_id_cache |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
51 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
52 protected: |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
53 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
54 typedef std::set<scope_id>::iterator set_iterator; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
55 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
|
56 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
57 // 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
|
58 // and 1 for the top-level workspace. |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
59 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
60 scope_id_cache (void) : next_available (2), in_use (), free_list () { } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
61 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
62 public: |
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 ~scope_id_cache (void) { } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
65 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
66 static scope_id alloc (void) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
67 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
68 return instance_ok () ? instance->do_alloc () : -1; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
69 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
70 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
71 static void free (scope_id scope) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
72 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
73 if (instance_ok ()) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
74 return instance->do_free (scope); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
75 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
76 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
77 static std::list<scope_id> scopes (void) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
78 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
79 return instance_ok () ? instance->do_scopes () : std::list<scope_id> (); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
80 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
81 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
82 static bool instance_ok (void) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
83 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
84 bool retval = true; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
85 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
86 if (! instance) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
87 instance = new scope_id_cache (); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
88 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
89 if (! instance) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
90 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
91 ::error ("unable to create scope_id_cache object!"); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
92 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
93 retval = false; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
94 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
95 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
96 return retval; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
97 } |
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 private: |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
100 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
101 static scope_id_cache *instance; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
102 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
103 // The next available scope not in the free list. |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
104 scope_id next_available; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
105 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
106 // The set of scope IDs that are currently allocated. |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
107 std::set<scope_id> in_use; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
108 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
109 // The set of scope IDs that are currently available. |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
110 std::set<scope_id> free_list; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
111 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
112 scope_id do_alloc (void) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
113 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
114 scope_id retval; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
115 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
116 set_iterator p = free_list.begin (); |
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 if (p != free_list.end ()) |
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 retval = *p; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
121 free_list.erase (p); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
122 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
123 else |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
124 retval = next_available++; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
125 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
126 in_use.insert (retval); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
127 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
128 return retval; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
129 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
130 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
131 void do_free (scope_id scope) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
132 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
133 set_iterator p = in_use.find (scope); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
134 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
135 if (p != in_use.end ()) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
136 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
137 in_use.erase (p); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
138 free_list.insert (scope); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
139 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
140 else |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
141 error ("free_scope: scope %d not found!", scope); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
142 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
143 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
144 std::list<scope_id> do_scopes (void) const |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
145 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
146 std::list<scope_id> retval; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
147 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
148 for (set_const_iterator p = in_use.begin (); p != in_use.end (); p++) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
149 retval.push_back (*p); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
150 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
151 retval.sort (); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
152 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
153 return retval; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
154 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
155 }; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
156 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
157 class |
7336 | 158 symbol_record |
159 { | |
160 public: | |
161 | |
162 // generic variable | |
163 static const unsigned int local = 1; | |
164 | |
165 // varargin, argn, .nargin., .nargout. | |
166 // (FIXME -- is this really used now?) | |
167 static const unsigned int automatic = 2; | |
168 | |
169 // formal parameter | |
170 static const unsigned int formal = 4; | |
171 | |
172 // not listed or cleared (.nargin., .nargout.) | |
173 static const unsigned int hidden = 8; | |
174 | |
175 // inherited from parent scope; not cleared at function exit | |
176 static const unsigned int inherited = 16; | |
177 | |
178 // global (redirects to global scope) | |
179 static const unsigned int global = 32; | |
180 | |
181 // not cleared at function exit | |
182 static const unsigned int persistent = 64; | |
183 | |
184 private: | |
185 | |
186 class | |
187 symbol_record_rep | |
4009 | 188 { |
7336 | 189 public: |
190 | |
191 symbol_record_rep (const std::string& nm, const octave_value& v, | |
192 unsigned int sc) | |
193 : name (nm), value_stack (), storage_class (sc), count (1) | |
194 { | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
195 value_stack.push_back (v); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
196 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
197 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
198 octave_value& varref (void) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
199 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
200 if (is_global ()) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
201 return symbol_table::global_varref (name); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
202 else if (is_persistent ()) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
203 return symbol_table::persistent_varref (name); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
204 else |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
205 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
206 context_id n = value_stack.size (); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
207 while (n++ <= symbol_table::xcurrent_context) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
208 value_stack.push_back (octave_value ()); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
209 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
210 return value_stack[symbol_table::xcurrent_context]; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
211 } |
7336 | 212 } |
213 | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
214 octave_value varval (void) const |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
215 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
216 if (is_global ()) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
217 return symbol_table::global_varval (name); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
218 else if (is_persistent ()) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
219 return symbol_table::persistent_varval (name); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
220 else |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
221 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
222 if (symbol_table::xcurrent_context < value_stack.size ()) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
223 return value_stack[symbol_table::xcurrent_context]; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
224 else |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
225 return octave_value (); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
226 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
227 } |
7336 | 228 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
229 void push_context (void) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
230 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
231 if (! (is_persistent () || is_global ())) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
232 value_stack.push_back (octave_value ()); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
233 } |
7336 | 234 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
235 // 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
|
236 // 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
|
237 // functions like |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
238 // |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
239 // function foo (n) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
240 // if (n > 0) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
241 // foo (n-1); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
242 // else |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
243 // eval ("x = 1"); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
244 // endif |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
245 // endfunction |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
246 // |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
247 // Here, X should only exist in the final stack frame. |
7336 | 248 |
7374 | 249 size_t pop_context (void) |
250 { | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
251 size_t retval = 1; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
252 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
253 if (! (is_persistent () || is_global ())) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
254 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
255 value_stack.pop_back (); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
256 retval = value_stack.size (); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
257 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
258 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
259 return retval; |
7374 | 260 } |
7336 | 261 |
262 void clear (void) | |
263 { | |
264 if (! (is_hidden () || is_inherited ())) | |
265 { | |
266 if (is_global ()) | |
267 unmark_global (); | |
268 | |
269 if (is_persistent ()) | |
270 { | |
271 symbol_table::persistent_varref (name) = varval (); | |
272 unmark_persistent (); | |
273 } | |
274 | |
275 varref () = octave_value (); | |
276 } | |
277 } | |
278 | |
279 bool is_defined (void) const { return varval ().is_defined (); } | |
280 | |
281 bool is_variable (void) const | |
282 { | |
283 return (storage_class != local || is_defined ()); | |
284 } | |
285 | |
286 bool is_local (void) const { return storage_class & local; } | |
287 bool is_automatic (void) const { return storage_class & automatic; } | |
288 bool is_formal (void) const { return storage_class & formal; } | |
289 bool is_hidden (void) const { return storage_class & hidden; } | |
290 bool is_inherited (void) const { return storage_class & inherited; } | |
291 bool is_global (void) const { return storage_class & global; } | |
292 bool is_persistent (void) const { return storage_class & persistent; } | |
293 | |
294 void mark_local (void) { storage_class |= local; } | |
295 void mark_automatic (void) { storage_class |= automatic; } | |
296 void mark_formal (void) { storage_class |= formal; } | |
297 void mark_hidden (void) { storage_class |= hidden; } | |
298 void mark_inherited (void) { storage_class |= inherited; } | |
299 void mark_global (void) | |
300 { | |
301 if (is_persistent ()) | |
302 error ("can't make persistent variable %s global", name.c_str ()); | |
303 else | |
304 storage_class |= global; | |
305 } | |
306 void mark_persistent (void) | |
307 { | |
308 if (is_global ()) | |
309 error ("can't make global variable %s persistent", name.c_str ()); | |
310 else | |
311 storage_class |= persistent; | |
312 } | |
313 | |
314 void unmark_local (void) { storage_class &= ~local; } | |
315 void unmark_automatic (void) { storage_class &= ~automatic; } | |
316 void unmark_formal (void) { storage_class &= ~formal; } | |
317 void unmark_hidden (void) { storage_class &= ~hidden; } | |
318 void unmark_inherited (void) { storage_class &= ~inherited; } | |
319 void unmark_global (void) { storage_class &= ~global; } | |
320 void unmark_persistent (void) { storage_class &= ~persistent; } | |
321 | |
322 void init_persistent (void) | |
323 { | |
324 if (! is_defined ()) | |
325 { | |
326 mark_persistent (); | |
327 | |
328 varref () = symbol_table::persistent_varval (name); | |
329 } | |
330 // FIXME -- this causes trouble with recursive calls. | |
331 // else | |
332 // error ("unable to declare existing variable persistent"); | |
333 } | |
334 | |
335 void erase_persistent (void) | |
336 { | |
337 unmark_persistent (); | |
338 symbol_table::erase_persistent (name); | |
339 } | |
340 | |
341 symbol_record_rep *dup (void) | |
342 { | |
343 return new symbol_record_rep (name, varval (), storage_class); | |
344 } | |
345 | |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
346 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
|
347 |
7336 | 348 std::string name; |
349 | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
350 std::deque<octave_value> value_stack; |
7336 | 351 |
352 unsigned int storage_class; | |
353 | |
354 size_t count; | |
355 | |
356 private: | |
357 | |
358 // No copying! | |
359 | |
360 symbol_record_rep (const symbol_record_rep& ov); | |
361 | |
362 symbol_record_rep& operator = (const symbol_record_rep&); | |
363 }; | |
364 | |
365 public: | |
366 | |
367 symbol_record (const std::string& nm = std::string (), | |
368 const octave_value& v = octave_value (), | |
369 unsigned int sc = local) | |
370 : rep (new symbol_record_rep (nm, v, sc)) { } | |
371 | |
372 symbol_record (const symbol_record& sr) | |
373 : rep (sr.rep) | |
374 { | |
375 rep->count++; | |
376 } | |
377 | |
378 symbol_record& operator = (const symbol_record& sr) | |
379 { | |
380 if (this != &sr) | |
381 { | |
382 rep = sr.rep; | |
383 rep->count++; | |
384 } | |
385 | |
386 return *this; | |
387 } | |
388 | |
389 ~symbol_record (void) | |
390 { | |
391 if (--rep->count == 0) | |
392 delete rep; | |
393 } | |
394 | |
395 symbol_record dup (void) const { return symbol_record (rep->dup ()); } | |
396 | |
397 std::string name (void) const { return rep->name; } | |
398 | |
399 octave_value | |
400 find (tree_argument_list *args, const string_vector& arg_names, | |
401 octave_value_list& evaluated_args, bool& args_evaluated) const; | |
402 | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
403 octave_value& varref (void) { return rep->varref (); } |
7336 | 404 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
405 octave_value varval (void) const { return rep->varval (); } |
7336 | 406 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
407 void push_context (void) { rep->push_context (); } |
7336 | 408 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
409 size_t pop_context (void) { return rep->pop_context (); } |
7336 | 410 |
411 void clear (void) { rep->clear (); } | |
412 | |
413 bool is_defined (void) const { return rep->is_defined (); } | |
414 bool is_variable (void) const { return rep->is_variable (); } | |
415 | |
416 bool is_local (void) const { return rep->is_local (); } | |
417 bool is_automatic (void) const { return rep->is_automatic (); } | |
418 bool is_formal (void) const { return rep->is_formal (); } | |
419 bool is_global (void) const { return rep->is_global (); } | |
420 bool is_hidden (void) const { return rep->is_hidden (); } | |
421 bool is_inherited (void) const { return rep->is_inherited (); } | |
422 bool is_persistent (void) const { return rep->is_persistent (); } | |
423 | |
424 void mark_local (void) { rep->mark_local (); } | |
425 void mark_automatic (void) { rep->mark_automatic (); } | |
426 void mark_formal (void) { rep->mark_formal (); } | |
427 void mark_hidden (void) { rep->mark_hidden (); } | |
428 void mark_inherited (void) { rep->mark_inherited (); } | |
429 void mark_global (void) { rep->mark_global (); } | |
430 void mark_persistent (void) { rep->mark_persistent (); } | |
431 | |
432 void unmark_local (void) { rep->unmark_local (); } | |
433 void unmark_automatic (void) { rep->unmark_automatic (); } | |
434 void unmark_formal (void) { rep->unmark_formal (); } | |
435 void unmark_hidden (void) { rep->unmark_hidden (); } | |
436 void unmark_inherited (void) { rep->unmark_inherited (); } | |
437 void unmark_global (void) { rep->unmark_global (); } | |
438 void unmark_persistent (void) { rep->unmark_persistent (); } | |
439 | |
440 void init_persistent (void) { rep->init_persistent (); } | |
441 | |
442 void erase_persistent (void) { rep->erase_persistent (); } | |
443 | |
444 unsigned int xstorage_class (void) const { return rep->storage_class; } | |
445 | |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
446 void |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
447 dump (std::ostream& os, const std::string& prefix = std::string ()) const |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
448 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
449 rep->dump (os, prefix); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
450 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
451 |
7336 | 452 private: |
453 | |
454 symbol_record_rep *rep; | |
455 | |
456 symbol_record (symbol_record_rep *new_rep) : rep (new_rep) { } | |
457 }; | |
458 | |
459 class | |
460 fcn_info | |
461 { | |
462 public: | |
463 | |
464 typedef std::map<std::string, std::string> dispatch_map_type; | |
465 | |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
466 typedef std::map<scope_id, octave_value>::const_iterator scope_val_const_iterator; |
7336 | 467 typedef std::map<scope_id, octave_value>::iterator scope_val_iterator; |
4238 | 468 |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
469 typedef std::map<std::string, octave_value>::const_iterator str_val_const_iterator; |
7336 | 470 typedef std::map<std::string, octave_value>::iterator str_val_iterator; |
471 | |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
472 typedef dispatch_map_type::const_iterator dispatch_map_const_iterator; |
7336 | 473 typedef dispatch_map_type::iterator dispatch_map_iterator; |
474 | |
475 private: | |
476 | |
477 class | |
478 fcn_info_rep | |
479 { | |
480 public: | |
481 | |
482 fcn_info_rep (const std::string& nm) | |
483 : name (nm), subfunctions (), private_functions (), | |
484 class_constructors (), class_methods (), cmdline_function (), | |
485 autoload_function (), function_on_path (), built_in_function (), | |
486 count (1) { } | |
487 | |
488 octave_value load_private_function (const std::string& dir_name); | |
489 | |
490 octave_value load_class_constructor (void); | |
491 | |
492 octave_value load_class_method (const std::string& dispatch_type); | |
493 | |
494 octave_value | |
495 find (tree_argument_list *args, const string_vector& arg_names, | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
496 octave_value_list& evaluated_args, bool& args_evaluated); |
7336 | 497 |
498 octave_value find_method (const std::string& dispatch_type); | |
499 | |
500 octave_value find_autoload (void); | |
501 | |
502 octave_value find_user_function (void); | |
503 | |
504 bool is_user_function_defined (void) const | |
505 { | |
506 return function_on_path.is_defined (); | |
507 } | |
508 | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
509 octave_value find_function (void) |
7336 | 510 { |
511 octave_value_list args; | |
512 | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
513 return find_function (args); |
7336 | 514 } |
515 | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
516 octave_value find_function (const octave_value_list& args) |
7336 | 517 { |
518 string_vector arg_names; | |
519 octave_value_list evaluated_args = args; | |
7753
e76a4a6e3c47
initialize args_evaluated; delete useless statement
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
520 bool args_evaluated = false; |
7336 | 521 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
522 return find (0, arg_names, evaluated_args, args_evaluated); |
7336 | 523 } |
524 | |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
525 void lock_subfunction (scope_id scope) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
526 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
527 scope_val_iterator p = subfunctions.find (scope); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
528 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
529 if (p != subfunctions.end ()) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
530 p->second.lock (); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
531 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
532 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
533 void unlock_subfunction (scope_id scope) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
534 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
535 scope_val_iterator p = subfunctions.find (scope); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
536 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
537 if (p != subfunctions.end ()) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
538 p->second.unlock (); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
539 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
540 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
541 std::pair<std::string, octave_value> |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
542 subfunction_defined_in_scope (scope_id scope) const |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
543 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
544 scope_val_const_iterator p = subfunctions.find (scope); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
545 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
546 return p == subfunctions.end () |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
547 ? std::pair<std::string, octave_value> () |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
548 : std::pair<std::string, octave_value> (name, p->second); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
549 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
550 |
7336 | 551 void install_cmdline_function (const octave_value& f) |
552 { | |
553 cmdline_function = f; | |
554 } | |
555 | |
556 void install_subfunction (const octave_value& f, scope_id scope) | |
557 { | |
558 subfunctions[scope] = f; | |
559 } | |
560 | |
561 void install_user_function (const octave_value& f) | |
562 { | |
563 function_on_path = f; | |
564 } | |
565 | |
566 void install_built_in_function (const octave_value& f) | |
567 { | |
568 built_in_function = f; | |
569 } | |
570 | |
7489
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
571 template <class T> |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
572 void |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
573 clear_unlocked (std::map<T, octave_value>& map) |
7336 | 574 { |
7489
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
575 typename std::map<T, octave_value>::iterator p = map.begin (); |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
576 |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
577 while (p != map.end ()) |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
578 { |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
579 if (p->second.islocked ()) |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
580 p++; |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
581 else |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
582 map.erase (p++); |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
583 } |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
584 } |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
585 |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
586 void clear_cmdline_function (void) |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
587 { |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
588 if (! cmdline_function.islocked ()) |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
589 cmdline_function = octave_value (); |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
590 } |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
591 |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
592 void clear_autoload_function (void) |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
593 { |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
594 if (! autoload_function.islocked ()) |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
595 autoload_function = octave_value (); |
7336 | 596 } |
597 | |
598 // FIXME -- should this also clear the cmdline and other "user | |
599 // defined" functions? | |
600 void clear_user_function (void) | |
601 { | |
7489
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
602 if (! function_on_path.islocked ()) |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
603 function_on_path = octave_value (); |
7336 | 604 } |
605 | |
606 void clear_mex_function (void) | |
607 { | |
608 if (function_on_path.is_mex_function ()) | |
7489
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
609 clear_user_function (); |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
610 } |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
611 |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
612 void clear (void) |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
613 { |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
614 clear_unlocked (subfunctions); |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
615 clear_unlocked (private_functions); |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
616 clear_unlocked (class_constructors); |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
617 clear_unlocked (class_methods); |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
618 clear_cmdline_function (); |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
619 clear_autoload_function (); |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7374
diff
changeset
|
620 clear_user_function (); |
7336 | 621 } |
622 | |
623 void add_dispatch (const std::string& type, const std::string& fname) | |
624 { | |
625 dispatch_map[type] = fname; | |
626 } | |
627 | |
628 void clear_dispatch (const std::string& type) | |
629 { | |
630 dispatch_map_iterator p = dispatch_map.find (type); | |
631 | |
632 if (p != dispatch_map.end ()) | |
633 dispatch_map.erase (p); | |
634 } | |
635 | |
636 void print_dispatch (std::ostream& os) const; | |
637 | |
638 std::string help_for_dispatch (void) const; | |
639 | |
640 dispatch_map_type get_dispatch (void) const { return dispatch_map; } | |
641 | |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
642 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
|
643 |
7336 | 644 std::string name; |
645 | |
646 // Scope id to function object. | |
647 std::map<scope_id, octave_value> subfunctions; | |
648 | |
649 // Directory name to function object. | |
650 std::map<std::string, octave_value> private_functions; | |
651 | |
652 // Class name to function object. | |
653 std::map<std::string, octave_value> class_constructors; | |
654 | |
655 // Dispatch type to function object. | |
656 std::map<std::string, octave_value> class_methods; | |
657 | |
658 // Legacy dispatch map (dispatch type name to function name). | |
659 dispatch_map_type dispatch_map; | |
660 | |
661 octave_value cmdline_function; | |
662 | |
663 octave_value autoload_function; | |
664 | |
665 octave_value function_on_path; | |
666 | |
667 octave_value built_in_function; | |
668 | |
669 size_t count; | |
670 | |
671 private: | |
672 | |
673 // No copying! | |
674 | |
675 fcn_info_rep (const fcn_info_rep&); | |
676 | |
677 fcn_info_rep& operator = (const fcn_info_rep&); | |
678 }; | |
679 | |
680 public: | |
681 | |
682 fcn_info (const std::string& nm = std::string ()) | |
683 : rep (new fcn_info_rep (nm)) { } | |
684 | |
685 fcn_info (const fcn_info& ov) : rep (ov.rep) | |
686 { | |
687 rep->count++; | |
688 } | |
689 | |
690 fcn_info& operator = (const fcn_info& ov) | |
691 { | |
692 if (this != &ov) | |
4238 | 693 { |
7336 | 694 rep = ov.rep; |
695 rep->count++; | |
4238 | 696 } |
7336 | 697 |
698 return *this; | |
699 } | |
700 | |
701 ~fcn_info (void) | |
702 { | |
703 if (--rep->count == 0) | |
704 delete rep; | |
705 } | |
706 | |
707 octave_value | |
708 find (tree_argument_list *args, const string_vector& arg_names, | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
709 octave_value_list& evaluated_args, bool& args_evaluated); |
7336 | 710 |
711 octave_value find_method (const std::string& dispatch_type) const | |
712 { | |
713 return rep->find_method (dispatch_type); | |
714 } | |
715 | |
716 octave_value find_built_in_function (void) const | |
717 { | |
718 return rep->built_in_function; | |
719 } | |
720 | |
721 octave_value find_autoload (void) | |
722 { | |
723 return rep->find_autoload (); | |
724 } | |
725 | |
726 octave_value find_user_function (void) | |
727 { | |
728 return rep->find_user_function (); | |
729 } | |
730 | |
731 bool is_user_function_defined (void) const | |
732 { | |
733 return rep->is_user_function_defined (); | |
734 } | |
735 | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
736 octave_value find_function (void) |
7336 | 737 { |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
738 return rep->find_function (); |
7336 | 739 } |
740 | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
741 octave_value find_function (const octave_value_list& args) |
7336 | 742 { |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
743 return rep->find_function (args); |
7336 | 744 } |
745 | |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
746 void lock_subfunction (scope_id scope) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
747 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
748 rep->lock_subfunction (scope); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
749 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
750 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
751 void unlock_subfunction (scope_id scope) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
752 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
753 rep->unlock_subfunction (scope); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
754 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
755 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
756 std::pair<std::string, octave_value> |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
757 subfunction_defined_in_scope (scope_id scope = xcurrent_scope) const |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
758 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
759 return rep->subfunction_defined_in_scope (scope); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
760 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
761 |
7336 | 762 void install_cmdline_function (const octave_value& f) |
763 { | |
764 rep->install_cmdline_function (f); | |
765 } | |
766 | |
767 void install_subfunction (const octave_value& f, scope_id scope) | |
768 { | |
769 rep->install_subfunction (f, scope); | |
770 } | |
771 | |
772 void install_user_function (const octave_value& f) | |
773 { | |
774 rep->install_user_function (f); | |
775 } | |
776 | |
777 void install_built_in_function (const octave_value& f) | |
778 { | |
779 rep->install_built_in_function (f); | |
780 } | |
781 | |
782 void clear (void) { rep->clear (); } | |
783 | |
784 void clear_user_function (void) { rep->clear_user_function (); } | |
785 | |
786 void clear_mex_function (void) { rep->clear_mex_function (); } | |
787 | |
788 void add_dispatch (const std::string& type, const std::string& fname) | |
789 { | |
790 rep->add_dispatch (type, fname); | |
791 } | |
792 | |
793 void clear_dispatch (const std::string& type) | |
794 { | |
795 rep->clear_dispatch (type); | |
796 } | |
797 | |
798 void print_dispatch (std::ostream& os) const | |
799 { | |
800 rep->print_dispatch (os); | |
801 } | |
802 | |
803 std::string help_for_dispatch (void) const { return rep->help_for_dispatch (); } | |
804 | |
805 dispatch_map_type get_dispatch (void) const | |
806 { | |
807 return rep->get_dispatch (); | |
4009 | 808 } |
3011 | 809 |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
810 void |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
811 dump (std::ostream& os, const std::string& prefix = std::string ()) const |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
812 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
813 rep->dump (os, prefix); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
814 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
815 |
7336 | 816 private: |
817 | |
818 fcn_info_rep *rep; | |
819 }; | |
820 | |
821 static scope_id global_scope (void) { return xglobal_scope; } | |
822 static scope_id top_scope (void) { return xtop_scope; } | |
823 | |
824 static scope_id current_scope (void) { return xcurrent_scope; } | |
825 static scope_id current_caller_scope (void) { return xcurrent_caller_scope; } | |
826 | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
827 static context_id current_context (void) { return xcurrent_context; } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
828 |
7336 | 829 // We use parent_scope to handle parsing subfunctions. |
830 static scope_id parent_scope (void) { return xparent_scope; } | |
831 | |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
832 static scope_id alloc_scope (void) { return scope_id_cache::alloc (); } |
7336 | 833 |
834 static void set_scope (scope_id scope) | |
835 { | |
836 if (scope == xglobal_scope) | |
837 error ("can't set scope to global"); | |
838 else if (scope != xcurrent_scope) | |
839 { | |
840 all_instances_iterator p = all_instances.find (scope); | |
841 | |
842 if (p == all_instances.end ()) | |
843 { | |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
844 symbol_table *inst = new symbol_table (); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
845 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
846 if (inst) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
847 all_instances[scope] = instance = inst; |
7336 | 848 } |
849 else | |
850 instance = p->second; | |
851 | |
852 xcurrent_scope = scope; | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
853 xcurrent_context = instance->xcurrent_context_this_table; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
854 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
855 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
856 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
857 static void set_scope_and_context (scope_id scope, context_id context) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
858 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
859 if (scope == xglobal_scope) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
860 error ("can't set scope to global"); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
861 else |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
862 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
863 if (scope != xcurrent_scope) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
864 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
865 all_instances_iterator p = all_instances.find (scope); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
866 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
867 if (p == all_instances.end ()) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
868 error ("scope not found!"); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
869 else |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
870 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
871 instance = p->second; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
872 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
873 xcurrent_scope = scope; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
874 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
875 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
876 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
877 if (! error_state) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
878 xcurrent_context = context; |
7336 | 879 } |
880 } | |
881 | |
882 static void push_scope (scope_id scope) | |
883 { | |
884 if (scope_stack.empty ()) | |
885 scope_stack.push_front (xtop_scope); | |
886 | |
887 xcurrent_caller_scope = xcurrent_scope; | |
888 | |
889 set_scope (scope); | |
890 | |
891 scope_stack.push_front (scope); | |
892 } | |
893 | |
894 static void pop_scope (void) | |
895 { | |
896 scope_stack.pop_front (); | |
8 | 897 |
7336 | 898 set_scope (scope_stack[0]); |
899 | |
7346 | 900 xcurrent_caller_scope = scope_stack.size () > 1 ? scope_stack[1] : -1; |
7336 | 901 } |
902 | |
903 static void pop_scope (void *) { pop_scope (); } | |
904 | |
905 static void reset_scope (void) | |
906 { | |
907 scope_stack.clear (); | |
908 | |
909 scope_stack.push_front (xtop_scope); | |
572 | 910 |
7336 | 911 set_scope (xtop_scope); |
912 | |
913 xcurrent_caller_scope = -1; | |
914 } | |
915 | |
916 static void set_parent_scope (scope_id scope) | |
917 { | |
918 xparent_scope = scope; | |
919 } | |
920 | |
921 static void reset_parent_scope (void) | |
922 { | |
923 set_parent_scope (-1); | |
924 } | |
4009 | 925 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
926 static void erase_scope (scope_id scope) |
7336 | 927 { |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
928 assert (scope != xglobal_scope); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
929 |
7336 | 930 all_instances_iterator p = all_instances.find (scope); |
931 | |
932 if (p != all_instances.end ()) | |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
933 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
934 delete p->second; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
935 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
936 all_instances.erase (p); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
937 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
938 free_scope (scope); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
939 } |
7336 | 940 } |
941 | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
942 static scope_id dup_scope (scope_id scope) |
7336 | 943 { |
944 scope_id retval = -1; | |
945 | |
946 symbol_table *inst = get_instance (scope); | |
947 | |
948 if (inst) | |
949 { | |
950 scope_id new_scope = alloc_scope (); | |
951 | |
952 symbol_table *new_symbol_table = new symbol_table (); | |
953 | |
954 if (new_symbol_table) | |
955 { | |
956 all_instances[new_scope] = new_symbol_table; | |
957 | |
958 inst->do_dup_scope (*new_symbol_table); | |
959 | |
960 retval = new_scope; | |
961 } | |
962 } | |
963 | |
964 return retval; | |
965 } | |
966 | |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
967 static std::list<scope_id> scopes (void) |
7336 | 968 { |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
969 return scope_id_cache::scopes (); |
7336 | 970 } |
971 | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
972 static symbol_record |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
973 find_symbol (const std::string& name, scope_id scope = xcurrent_scope) |
7336 | 974 { |
975 symbol_table *inst = get_instance (scope); | |
976 | |
977 return inst ? inst->do_find_symbol (name) : symbol_record (); | |
978 } | |
4009 | 979 |
7336 | 980 static void inherit (scope_id scope, scope_id donor_scope) |
981 { | |
982 symbol_table *inst = get_instance (scope); | |
983 | |
984 if (inst) | |
985 inst->do_inherit (donor_scope); | |
986 } | |
987 | |
988 static bool at_top_level (void) { return xcurrent_scope == xtop_scope; } | |
989 | |
990 // Find a value corresponding to the given name in the table. | |
991 static octave_value | |
992 find (const std::string& name, tree_argument_list *args, | |
993 const string_vector& arg_names, | |
994 octave_value_list& evaluated_args, bool& args_evaluated, | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
995 bool skip_variables = false); |
7336 | 996 |
997 // Insert a new name in the table. | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
998 static symbol_record& insert (const std::string& name) |
7336 | 999 { |
1000 static symbol_record foobar; | |
1001 | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1002 symbol_table *inst = get_instance (xcurrent_scope); |
4009 | 1003 |
7336 | 1004 return inst ? inst->do_insert (name) : foobar; |
1005 } | |
1006 | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1007 static octave_value& varref (const std::string& name, |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1008 scope_id scope = xcurrent_scope) |
7336 | 1009 { |
1010 static octave_value foobar; | |
1011 | |
1012 symbol_table *inst = get_instance (scope); | |
1013 | |
1014 return inst ? inst->do_varref (name) : foobar; | |
1015 } | |
1016 | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1017 static octave_value varval (const std::string& name, |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1018 scope_id scope = xcurrent_scope) |
7336 | 1019 { |
1020 symbol_table *inst = get_instance (scope); | |
1021 | |
1022 return inst ? inst->do_varval (name) : octave_value (); | |
1023 } | |
1024 | |
1025 static octave_value& | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1026 global_varref (const std::string& name) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1027 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1028 global_table_iterator p = global_table.find (name); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1029 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1030 return (p == global_table.end ()) ? global_table[name] : p->second; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1031 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1032 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1033 static octave_value |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1034 global_varval (const std::string& name) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1035 { |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1036 global_table_const_iterator p = global_table.find (name); |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1037 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1038 return (p != global_table.end ()) ? p->second : octave_value (); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1039 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1040 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1041 static octave_value& persistent_varref (const std::string& name) |
7336 | 1042 { |
1043 static octave_value foobar; | |
1044 | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1045 symbol_table *inst = get_instance (xcurrent_scope); |
7336 | 1046 |
1047 return inst ? inst->do_persistent_varref (name) : foobar; | |
1048 } | |
1049 | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1050 static octave_value persistent_varval (const std::string& name) |
7336 | 1051 { |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1052 symbol_table *inst = get_instance (xcurrent_scope); |
7336 | 1053 |
1054 return inst ? inst->do_persistent_varval (name) : octave_value (); | |
1055 } | |
1056 | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1057 static void erase_persistent (const std::string& name) |
7336 | 1058 { |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1059 symbol_table *inst = get_instance (xcurrent_scope); |
7336 | 1060 |
1061 if (inst) | |
1062 inst->do_erase_persistent (name); | |
1063 } | |
8 | 1064 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1065 static bool is_variable (const std::string& name) |
7336 | 1066 { |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1067 symbol_table *inst = get_instance (xcurrent_scope); |
7336 | 1068 |
1069 return inst ? inst->do_is_variable (name) : false; | |
1070 } | |
1071 | |
1072 static bool | |
1073 is_built_in_function_name (const std::string& name) | |
1074 { | |
1075 octave_value val = find_built_in_function (name); | |
1076 | |
1077 return val.is_defined (); | |
1078 } | |
1079 | |
1080 static octave_value | |
1081 find_method (const std::string& name, const std::string& dispatch_type) | |
1082 { | |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1083 fcn_table_const_iterator p = fcn_table.find (name); |
8 | 1084 |
7336 | 1085 if (p != fcn_table.end ()) |
1086 return p->second.find_method (dispatch_type); | |
1087 else | |
1088 { | |
1089 fcn_info finfo (name); | |
1090 | |
1091 octave_value fcn = finfo.find_method (dispatch_type); | |
1092 | |
1093 if (fcn.is_defined ()) | |
1094 fcn_table[name] = finfo; | |
1095 | |
1096 return fcn; | |
1097 } | |
1098 } | |
1099 | |
1100 static octave_value | |
1101 find_built_in_function (const std::string& name) | |
1102 { | |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1103 fcn_table_const_iterator p = fcn_table.find (name); |
7336 | 1104 |
1105 return (p != fcn_table.end ()) | |
1106 ? p->second.find_built_in_function () : octave_value (); | |
1107 } | |
1108 | |
1109 static octave_value | |
1110 find_autoload (const std::string& name) | |
1111 { | |
1112 fcn_table_iterator p = fcn_table.find (name); | |
4913 | 1113 |
7336 | 1114 return (p != fcn_table.end ()) |
1115 ? p->second.find_autoload () : octave_value (); | |
1116 } | |
1117 | |
1118 static octave_value | |
1119 find_function (const std::string& name, tree_argument_list *args, | |
1120 const string_vector& arg_names, | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1121 octave_value_list& evaluated_args, bool& args_evaluated); |
7336 | 1122 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1123 static octave_value find_user_function (const std::string& name) |
7336 | 1124 { |
1125 fcn_table_iterator p = fcn_table.find (name); | |
1126 | |
1127 return (p != fcn_table.end ()) | |
1128 ? p->second.find_user_function () : octave_value (); | |
1129 } | |
1130 | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1131 static octave_value find_function (const std::string& name) |
7336 | 1132 { |
1133 octave_value_list evaluated_args; | |
1134 | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1135 return find_function (name, evaluated_args); |
7336 | 1136 } |
1137 | |
1138 static octave_value | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1139 find_function (const std::string& name, const octave_value_list& args) |
7336 | 1140 { |
1141 string_vector arg_names; | |
1142 octave_value_list evaluated_args = args; | |
1143 bool args_evaluated = ! args.empty (); | |
1144 | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1145 return find_function (name, 0, arg_names, evaluated_args, args_evaluated); |
7336 | 1146 } |
1147 | |
1148 static void install_cmdline_function (const std::string& name, | |
1149 const octave_value& fcn) | |
1150 { | |
1151 fcn_table_iterator p = fcn_table.find (name); | |
1152 | |
1153 if (p != fcn_table.end ()) | |
1154 { | |
1155 fcn_info& finfo = p->second; | |
3013 | 1156 |
7336 | 1157 finfo.install_cmdline_function (fcn); |
1158 } | |
1159 else | |
1160 { | |
1161 fcn_info finfo (name); | |
195 | 1162 |
7336 | 1163 finfo.install_cmdline_function (fcn); |
1164 | |
1165 fcn_table[name] = finfo; | |
1166 } | |
1167 } | |
1168 | |
1169 static void install_subfunction (const std::string& name, | |
1170 const octave_value& fcn, | |
1171 scope_id scope = xparent_scope) | |
1172 { | |
1173 fcn_table_iterator p = fcn_table.find (name); | |
1174 | |
1175 if (p != fcn_table.end ()) | |
1176 { | |
1177 fcn_info& finfo = p->second; | |
1178 | |
1179 finfo.install_subfunction (fcn, scope); | |
1180 } | |
1181 else | |
1182 { | |
1183 fcn_info finfo (name); | |
1184 | |
1185 finfo.install_subfunction (fcn, scope); | |
1186 | |
1187 fcn_table[name] = finfo; | |
1188 } | |
1189 } | |
1190 | |
1191 static void install_user_function (const std::string& name, | |
1192 const octave_value& fcn) | |
1193 { | |
1194 fcn_table_iterator p = fcn_table.find (name); | |
1195 | |
1196 if (p != fcn_table.end ()) | |
1197 { | |
1198 fcn_info& finfo = p->second; | |
1199 | |
1200 finfo.install_user_function (fcn); | |
1201 } | |
1202 else | |
1203 { | |
1204 fcn_info finfo (name); | |
1205 | |
1206 finfo.install_user_function (fcn); | |
1207 | |
1208 fcn_table[name] = finfo; | |
1209 } | |
1210 } | |
605 | 1211 |
7336 | 1212 static void install_built_in_function (const std::string& name, |
1213 const octave_value& fcn) | |
1214 { | |
1215 fcn_table_iterator p = fcn_table.find (name); | |
1216 | |
1217 if (p != fcn_table.end ()) | |
1218 { | |
1219 fcn_info& finfo = p->second; | |
1220 | |
1221 finfo.install_built_in_function (fcn); | |
1222 } | |
1223 else | |
1224 { | |
1225 fcn_info finfo (name); | |
1226 | |
1227 finfo.install_built_in_function (fcn); | |
1228 | |
1229 fcn_table[name] = finfo; | |
1230 } | |
1231 } | |
1232 | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1233 static void clear (const std::string& name) |
7336 | 1234 { |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1235 clear_variable (name); |
7336 | 1236 } |
1237 | |
1238 static void clear_all (void) | |
1239 { | |
1240 clear_variables (); | |
1241 | |
1242 clear_functions (); | |
1243 } | |
1244 | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1245 static void clear_variables (void) |
7336 | 1246 { |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1247 symbol_table *inst = get_instance (xcurrent_scope); |
7336 | 1248 |
1249 if (inst) | |
1250 inst->do_clear_variables (); | |
1251 } | |
1252 | |
1253 // For unwind_protect. | |
1254 static void clear_variables (void *) { clear_variables (); } | |
1255 | |
1256 static void clear_functions (void) | |
1257 { | |
1258 for (fcn_table_iterator p = fcn_table.begin (); p != fcn_table.end (); p++) | |
1259 p->second.clear (); | |
1260 } | |
1261 | |
1262 static void clear_function (const std::string& name) | |
1263 { | |
1264 clear_user_function (name); | |
1265 } | |
1266 | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1267 static void clear_global (const std::string& name) |
7336 | 1268 { |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1269 symbol_table *inst = get_instance (xcurrent_scope); |
7336 | 1270 |
1271 if (inst) | |
1272 inst->do_clear_global (name); | |
1273 } | |
1274 | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1275 static void clear_variable (const std::string& name) |
7336 | 1276 { |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1277 symbol_table *inst = get_instance (xcurrent_scope); |
7336 | 1278 |
1279 if (inst) | |
1280 inst->do_clear_variable (name); | |
1281 } | |
1282 | |
1283 static void clear_symbol (const std::string& name) | |
1284 { | |
1285 // FIXME -- are we supposed to do both here? | |
1286 | |
1287 clear_variable (name); | |
1288 clear_function (name); | |
1289 } | |
1290 | |
1291 static void clear_function_pattern (const std::string& pat) | |
1292 { | |
1293 glob_match pattern (pat); | |
1294 | |
1295 for (fcn_table_iterator p = fcn_table.begin (); p != fcn_table.end (); p++) | |
1296 { | |
1297 if (pattern.match (p->first)) | |
1298 p->second.clear_user_function (); | |
1299 } | |
1300 } | |
1301 | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1302 static void clear_global_pattern (const std::string& pat) |
7336 | 1303 { |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1304 symbol_table *inst = get_instance (xcurrent_scope); |
4009 | 1305 |
7336 | 1306 if (inst) |
1307 inst->do_clear_global_pattern (pat); | |
1308 } | |
1309 | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1310 static void clear_variable_pattern (const std::string& pat) |
7336 | 1311 { |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1312 symbol_table *inst = get_instance (xcurrent_scope); |
7336 | 1313 |
1314 if (inst) | |
1315 inst->do_clear_variable_pattern (pat); | |
1316 } | |
1317 | |
1318 static void clear_symbol_pattern (const std::string& pat) | |
1319 { | |
1320 // FIXME -- are we supposed to do both here? | |
1321 | |
1322 clear_variable_pattern (pat); | |
1323 clear_function_pattern (pat); | |
1324 } | |
1325 | |
1326 static void clear_user_function (const std::string& name) | |
1327 { | |
1328 fcn_table_iterator p = fcn_table.find (name); | |
1329 | |
1330 if (p != fcn_table.end ()) | |
1331 { | |
1332 fcn_info& finfo = p->second; | |
1333 | |
1334 finfo.clear_user_function (); | |
1335 } | |
1336 // FIXME -- is this necessary, or even useful? | |
1337 // else | |
1338 // error ("clear: no such function `%s'", name.c_str ()); | |
1339 } | |
1340 | |
1341 static void clear_mex_functions (void) | |
1342 { | |
1343 for (fcn_table_iterator p = fcn_table.begin (); p != fcn_table.end (); p++) | |
1344 { | |
1345 fcn_info& finfo = p->second; | |
1346 | |
1347 finfo.clear_mex_function (); | |
1348 } | |
1349 } | |
1350 | |
1351 static void alias_built_in_function (const std::string& alias, | |
1352 const std::string& name) | |
1353 { | |
1354 octave_value fcn = find_built_in_function (name); | |
1355 | |
1356 if (fcn.is_defined ()) | |
1357 { | |
1358 fcn_info finfo (alias); | |
1359 | |
1360 finfo.install_built_in_function (fcn); | |
1361 | |
1362 fcn_table[alias] = finfo; | |
1363 } | |
1364 else | |
1365 panic ("alias: `%s' is undefined", name.c_str ()); | |
1366 } | |
1367 | |
1368 static void add_dispatch (const std::string& name, const std::string& type, | |
1369 const std::string& fname) | |
1370 { | |
1371 fcn_table_iterator p = fcn_table.find (name); | |
1372 | |
1373 if (p != fcn_table.end ()) | |
1374 { | |
1375 fcn_info& finfo = p->second; | |
1376 | |
1377 finfo.add_dispatch (type, fname); | |
1378 } | |
1379 else | |
1380 { | |
1381 fcn_info finfo (name); | |
1382 | |
1383 finfo.add_dispatch (type, fname); | |
1384 | |
1385 fcn_table[name] = finfo; | |
1386 } | |
1387 } | |
1388 | |
1389 static void clear_dispatch (const std::string& name, const std::string& type) | |
1390 { | |
1391 fcn_table_iterator p = fcn_table.find (name); | |
1392 | |
1393 if (p != fcn_table.end ()) | |
1394 { | |
1395 fcn_info& finfo = p->second; | |
1396 | |
1397 finfo.clear_dispatch (type); | |
1398 } | |
1399 } | |
1400 | |
1401 static void print_dispatch (std::ostream& os, const std::string& name) | |
1402 { | |
1403 fcn_table_iterator p = fcn_table.find (name); | |
4009 | 1404 |
7336 | 1405 if (p != fcn_table.end ()) |
1406 { | |
1407 fcn_info& finfo = p->second; | |
1408 | |
1409 finfo.print_dispatch (os); | |
1410 } | |
1411 } | |
1412 | |
1413 static fcn_info::dispatch_map_type get_dispatch (const std::string& name) | |
1414 { | |
1415 fcn_info::dispatch_map_type retval; | |
1416 | |
1417 fcn_table_iterator p = fcn_table.find (name); | |
1418 | |
1419 if (p != fcn_table.end ()) | |
1420 { | |
1421 fcn_info& finfo = p->second; | |
1422 | |
1423 retval = finfo.get_dispatch (); | |
1424 } | |
1425 | |
1426 return retval; | |
1427 } | |
1428 | |
1429 static std::string help_for_dispatch (const std::string& name) | |
1430 { | |
1431 std::string retval; | |
1432 | |
1433 fcn_table_iterator p = fcn_table.find (name); | |
1434 | |
1435 if (p != fcn_table.end ()) | |
1436 { | |
1437 fcn_info& finfo = p->second; | |
1438 | |
1439 retval = finfo.help_for_dispatch (); | |
1440 } | |
1441 | |
1442 return retval; | |
1443 } | |
1444 | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1445 static void push_context (void) |
7336 | 1446 { |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1447 if (xcurrent_scope == xglobal_scope || xcurrent_scope == xtop_scope) |
7336 | 1448 error ("invalid call to xymtab::push_context"); |
1449 else | |
1450 { | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1451 symbol_table *inst = get_instance (xcurrent_scope); |
7336 | 1452 |
1453 if (inst) | |
1454 inst->do_push_context (); | |
1455 } | |
1456 } | |
1457 | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1458 static void pop_context (void) |
7336 | 1459 { |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1460 if (xcurrent_scope == xglobal_scope || xcurrent_scope == xtop_scope) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1461 error ("invalid call to xymtab::pop_context"); |
7336 | 1462 else |
1463 { | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1464 symbol_table *inst = get_instance (xcurrent_scope); |
7336 | 1465 |
1466 if (inst) | |
1467 inst->do_pop_context (); | |
1468 } | |
1469 } | |
1470 | |
1471 // For unwind_protect. | |
1472 static void pop_context (void *) { pop_context (); } | |
1473 | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1474 static void mark_hidden (const std::string& name) |
7336 | 1475 { |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1476 symbol_table *inst = get_instance (xcurrent_scope); |
7336 | 1477 |
1478 if (inst) | |
1479 inst->do_mark_hidden (name); | |
1480 } | |
1481 | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1482 static void mark_global (const std::string& name) |
7336 | 1483 { |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1484 symbol_table *inst = get_instance (xcurrent_scope); |
7336 | 1485 |
1486 if (inst) | |
1487 inst->do_mark_global (name); | |
1488 } | |
1489 | |
1490 static std::list<symbol_record> | |
1491 all_variables (scope_id scope = xcurrent_scope, bool defined_only = true) | |
1492 { | |
1493 symbol_table *inst = get_instance (scope); | |
1494 | |
1495 return inst | |
1496 ? inst->do_all_variables (defined_only) : std::list<symbol_record> (); | |
1497 } | |
3011 | 1498 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1499 static std::list<symbol_record> glob (const std::string& pattern) |
7336 | 1500 { |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1501 symbol_table *inst = get_instance (xcurrent_scope); |
7336 | 1502 |
1503 return inst ? inst->do_glob (pattern) : std::list<symbol_record> (); | |
1504 } | |
1505 | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1506 static std::list<symbol_record> glob_variables (const std::string& pattern) |
7336 | 1507 { |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1508 symbol_table *inst = get_instance (xcurrent_scope); |
7336 | 1509 |
1510 return inst ? inst->do_glob (pattern, true) : std::list<symbol_record> (); | |
1511 } | |
1512 | |
1513 static std::list<symbol_record> | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1514 glob_global_variables (const std::string& pattern) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1515 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1516 std::list<symbol_record> retval; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1517 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1518 glob_match pat (pattern); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1519 |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1520 for (global_table_const_iterator p = global_table.begin (); |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1521 p != global_table.end (); p++) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1522 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1523 // We generate a list of symbol_record objects so that |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1524 // the results from glob_variables and glob_global_variables |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1525 // may be handled the same way. |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1526 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1527 if (pat.match (p->first)) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1528 retval.push_back (symbol_record (p->first, p->second, |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1529 symbol_record::global)); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1530 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1531 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1532 return retval; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1533 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1534 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1535 static std::list<symbol_record> glob_variables (const string_vector& patterns) |
7336 | 1536 { |
1537 std::list<symbol_record> retval; | |
1538 | |
1539 size_t len = patterns.length (); | |
8 | 1540 |
7336 | 1541 for (size_t i = 0; i < len; i++) |
1542 { | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1543 std::list<symbol_record> tmp = glob_variables (patterns[i]); |
7336 | 1544 |
1545 retval.insert (retval.begin (), tmp.begin (), tmp.end ()); | |
1546 } | |
1547 | |
1548 return retval; | |
1549 } | |
1550 | |
1551 static std::list<std::string> user_function_names (void) | |
1552 { | |
1553 std::list<std::string> retval; | |
1554 | |
1555 for (fcn_table_iterator p = fcn_table.begin (); | |
1556 p != fcn_table.end (); p++) | |
1557 { | |
1558 if (p->second.is_user_function_defined ()) | |
1559 retval.push_back (p->first); | |
1560 } | |
1561 | |
1562 if (! retval.empty ()) | |
1563 retval.sort (); | |
1564 | |
1565 return retval; | |
1566 } | |
3011 | 1567 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1568 static std::list<std::string> global_variable_names (void) |
7336 | 1569 { |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1570 std::list<std::string> retval; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1571 |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1572 for (global_table_const_iterator p = global_table.begin (); |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1573 p != global_table.end (); p++) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1574 retval.push_back (p->first); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1575 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1576 retval.sort (); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1577 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1578 return retval; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1579 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1580 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1581 static std::list<std::string> top_level_variable_names (void) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1582 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1583 symbol_table *inst = get_instance (xtop_scope); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1584 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1585 return inst ? inst->do_variable_names () : std::list<std::string> (); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1586 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1587 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1588 static std::list<std::string> variable_names (void) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1589 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1590 symbol_table *inst = get_instance (xcurrent_scope); |
7336 | 1591 |
1592 return inst ? inst->do_variable_names () : std::list<std::string> (); | |
1593 } | |
1594 | |
1595 static std::list<std::string> built_in_function_names (void) | |
1596 { | |
1597 std::list<std::string> retval; | |
1598 | |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1599 for (fcn_table_const_iterator p = fcn_table.begin (); |
7336 | 1600 p != fcn_table.end (); p++) |
1601 { | |
1602 octave_value fcn = p->second.find_built_in_function (); | |
1603 | |
1604 if (fcn.is_defined ()) | |
1605 retval.push_back (p->first); | |
1606 } | |
1607 | |
1608 if (! retval.empty ()) | |
1609 retval.sort (); | |
220 | 1610 |
7336 | 1611 return retval; |
1612 } | |
1613 | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1614 static bool is_local_variable (const std::string& name) |
7336 | 1615 { |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1616 if (xcurrent_scope == xglobal_scope) |
7336 | 1617 return false; |
1618 else | |
1619 { | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1620 symbol_table *inst = get_instance (xcurrent_scope); |
5861 | 1621 |
7336 | 1622 return inst ? inst->do_is_local_variable (name) : false; |
1623 } | |
1624 } | |
5861 | 1625 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1626 static bool is_global (const std::string& name) |
7336 | 1627 { |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1628 if (xcurrent_scope == xglobal_scope) |
7336 | 1629 return true; |
1630 else | |
1631 { | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1632 symbol_table *inst = get_instance (xcurrent_scope); |
7336 | 1633 |
1634 return inst ? inst->do_is_global (name) : false; | |
1635 } | |
1636 } | |
3011 | 1637 |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1638 static void dump (std::ostream& os, scope_id scope = xcurrent_scope); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1639 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1640 static void dump_global (std::ostream& os); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1641 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1642 static void dump_functions (std::ostream& os); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1643 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1644 static void cache_name (scope_id scope, const std::string& name) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1645 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1646 symbol_table *inst = get_instance (scope, false); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1647 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1648 if (inst) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1649 inst->do_cache_name (name); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1650 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1651 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1652 static void lock_subfunctions (scope_id scope = xcurrent_scope) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1653 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1654 for (fcn_table_iterator p = fcn_table.begin (); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1655 p != fcn_table.end (); p++) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1656 p->second.lock_subfunction (scope); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1657 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1658 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1659 static void unlock_subfunctions (scope_id scope = xcurrent_scope) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1660 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1661 for (fcn_table_iterator p = fcn_table.begin (); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1662 p != fcn_table.end (); p++) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1663 p->second.unlock_subfunction (scope); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1664 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1665 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1666 static void free_scope (scope_id scope) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1667 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1668 if (scope == xglobal_scope || scope == xtop_scope) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1669 error ("can't free global or top-level scopes!"); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1670 else |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1671 symbol_table::scope_id_cache::free (scope); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1672 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1673 |
8 | 1674 private: |
1675 | |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1676 typedef std::map<std::string, symbol_record>::const_iterator table_const_iterator; |
7336 | 1677 typedef std::map<std::string, symbol_record>::iterator table_iterator; |
1678 | |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1679 typedef std::map<std::string, octave_value>::const_iterator global_table_const_iterator; |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1680 typedef std::map<std::string, octave_value>::iterator global_table_iterator; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1681 |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1682 typedef std::map<std::string, octave_value>::const_iterator persistent_table_const_iterator; |
7336 | 1683 typedef std::map<std::string, octave_value>::iterator persistent_table_iterator; |
1684 | |
1685 typedef std::map<scope_id, symbol_table*>::const_iterator all_instances_const_iterator; | |
1686 typedef std::map<scope_id, symbol_table*>::iterator all_instances_iterator; | |
1687 | |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1688 typedef std::map<std::string, fcn_info>::const_iterator fcn_table_const_iterator; |
7336 | 1689 typedef std::map<std::string, fcn_info>::iterator fcn_table_iterator; |
1690 | |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1691 // Name for this table (usually the file name of the function |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1692 // corresponding to the scope); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1693 std::string table_name; |
7336 | 1694 |
1695 // Map from symbol names to symbol info. | |
1696 std::map<std::string, symbol_record> table; | |
1697 | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1698 // Map from names of global variables to values. |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1699 static std::map<std::string, octave_value> global_table; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1700 |
7336 | 1701 // Map from names of persistent variables to values. |
1702 std::map<std::string, octave_value> persistent_table; | |
1703 | |
1704 // Pointer to symbol table for current scope (variables only). | |
1705 static symbol_table *instance; | |
3011 | 1706 |
7336 | 1707 // Map from scope id to symbol table instances. |
1708 static std::map<scope_id, symbol_table*> all_instances; | |
1709 | |
1710 // Map from function names to function info (subfunctions, private | |
1711 // functions, class constructors, class methods, etc.) | |
1712 static std::map<std::string, fcn_info> fcn_table; | |
1713 | |
1714 static const scope_id xglobal_scope; | |
1715 static const scope_id xtop_scope; | |
1716 | |
1717 static scope_id xcurrent_scope; | |
1718 static scope_id xcurrent_caller_scope; | |
1719 | |
1720 // We use parent_scope to handle parsing subfunctions. | |
1721 static scope_id xparent_scope; | |
1722 | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1723 // Used to handle recursive calls. |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1724 context_id xcurrent_context_this_table; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1725 static context_id xcurrent_context; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1726 |
7336 | 1727 static std::deque<scope_id> scope_stack; |
1728 | |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1729 symbol_table (void) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1730 : table_name (), table (), xcurrent_context_this_table () { } |
7336 | 1731 |
1732 ~symbol_table (void) { } | |
3011 | 1733 |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1734 static symbol_table *get_instance (scope_id scope, bool create = true) |
7336 | 1735 { |
1736 symbol_table *retval = 0; | |
1737 | |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1738 bool ok = true; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1739 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1740 if (scope != xglobal_scope) |
7336 | 1741 { |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1742 if (scope == xcurrent_scope) |
7336 | 1743 { |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1744 if (! instance && create) |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1745 { |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1746 symbol_table *inst = new symbol_table (); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1747 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1748 if (inst) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1749 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1750 all_instances[scope] = instance = inst; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1751 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1752 if (scope == xtop_scope) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1753 instance->do_cache_name ("top-level"); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1754 } |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1755 } |
7336 | 1756 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1757 if (! instance) |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1758 ok = false; |
7336 | 1759 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1760 retval = instance; |
7336 | 1761 } |
1762 else | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1763 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1764 all_instances_iterator p = all_instances.find (scope); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1765 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1766 if (p == all_instances.end ()) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1767 { |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1768 if (create) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1769 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1770 retval = new symbol_table (); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1771 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1772 if (retval) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1773 all_instances[scope] = retval; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1774 else |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1775 ok = false; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1776 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1777 else |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1778 ok = false; |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1779 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1780 else |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1781 retval = p->second; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1782 } |
7336 | 1783 } |
1784 | |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1785 if (! ok) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1786 error ("unable to %s symbol_table object for scope %d!", |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1787 create ? "create" : "find", scope); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1788 |
7336 | 1789 return retval; |
1790 } | |
1791 | |
1792 void insert_symbol_record (const symbol_record& sr) | |
1793 { | |
1794 table[sr.name ()] = sr; | |
1795 } | |
4238 | 1796 |
4913 | 1797 void |
7336 | 1798 do_dup_scope (symbol_table& new_symbol_table) const |
1799 { | |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1800 for (table_const_iterator p = table.begin (); p != table.end (); p++) |
7336 | 1801 new_symbol_table.insert_symbol_record (p->second.dup ()); |
1802 } | |
1803 | |
1804 symbol_record do_find_symbol (const std::string& name) | |
1805 { | |
1806 table_iterator p = table.find (name); | |
1807 | |
1808 if (p == table.end ()) | |
1809 return do_insert (name); | |
1810 else | |
1811 return p->second; | |
1812 } | |
1813 | |
1814 void do_inherit (scope_id donor_scope) | |
1815 { | |
1816 for (table_iterator p = table.begin (); p != table.end (); p++) | |
1817 { | |
1818 symbol_record& sr = p->second; | |
1819 | |
1820 std::string nm = sr.name (); | |
1821 | |
1822 if (! (sr.is_automatic () || sr.is_formal () || nm == "__retval__")) | |
1823 { | |
1824 octave_value val = symbol_table::varval (nm, donor_scope); | |
1825 | |
1826 if (val.is_defined ()) | |
1827 { | |
1828 sr.varref () = val; | |
1829 | |
1830 sr.mark_inherited (); | |
1831 } | |
1832 } | |
1833 } | |
1834 } | |
1835 | |
1836 octave_value | |
1837 do_find (const std::string& name, tree_argument_list *args, | |
1838 const string_vector& arg_names, | |
1839 octave_value_list& evaluated_args, bool& args_evaluated, | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1840 bool skip_variables); |
7336 | 1841 |
1842 symbol_record& do_insert (const std::string& name) | |
1843 { | |
1844 table_iterator p = table.find (name); | |
1845 | |
1846 return p == table.end () | |
1847 ? (table[name] = symbol_record (name)) : p->second; | |
1848 } | |
1849 | |
1850 octave_value& do_varref (const std::string& name) | |
1851 { | |
1852 table_iterator p = table.find (name); | |
1853 | |
1854 if (p == table.end ()) | |
1855 { | |
1856 symbol_record& sr = do_insert (name); | |
1857 | |
1858 return sr.varref (); | |
1859 } | |
1860 else | |
1861 return p->second.varref (); | |
1862 } | |
4913 | 1863 |
7336 | 1864 octave_value do_varval (const std::string& name) const |
1865 { | |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1866 table_const_iterator p = table.find (name); |
7336 | 1867 |
1868 return (p != table.end ()) ? p->second.varval () : octave_value (); | |
1869 } | |
1870 | |
1871 octave_value& do_persistent_varref (const std::string& name) | |
1872 { | |
1873 persistent_table_iterator p = persistent_table.find (name); | |
1874 | |
1875 return (p == persistent_table.end ()) | |
1876 ? persistent_table[name] : p->second; | |
1877 } | |
1878 | |
1879 octave_value do_persistent_varval (const std::string& name) | |
1880 { | |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1881 persistent_table_const_iterator p = persistent_table.find (name); |
7336 | 1882 |
1883 return (p != persistent_table.end ()) ? p->second : octave_value (); | |
1884 } | |
1885 | |
1886 void do_erase_persistent (const std::string& name) | |
1887 { | |
1888 persistent_table_iterator p = persistent_table.find (name); | |
1889 | |
1890 if (p != persistent_table.end ()) | |
1891 persistent_table.erase (p); | |
1892 } | |
1893 | |
1894 bool do_is_variable (const std::string& name) const | |
1895 { | |
1896 bool retval = false; | |
1897 | |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
1898 table_const_iterator p = table.find (name); |
7336 | 1899 |
1900 if (p != table.end ()) | |
1901 { | |
1902 const symbol_record& sr = p->second; | |
1903 | |
1904 retval = sr.is_variable (); | |
1905 } | |
1906 | |
1907 return retval; | |
1908 } | |
1909 | |
1910 void do_push_context (void) | |
1911 { | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1912 xcurrent_context = ++xcurrent_context_this_table; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1913 |
7336 | 1914 for (table_iterator p = table.begin (); p != table.end (); p++) |
1915 p->second.push_context (); | |
1916 } | |
1917 | |
1918 void do_pop_context (void) | |
1919 { | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1920 xcurrent_context = --xcurrent_context_this_table; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1921 |
7374 | 1922 for (table_iterator p = table.begin (); p != table.end (); ) |
1923 { | |
1924 if (p->second.pop_context () == 0) | |
1925 table.erase (p++); | |
1926 else | |
1927 p++; | |
1928 } | |
7336 | 1929 } |
1930 | |
1931 void do_clear_variables (void) | |
1932 { | |
1933 for (table_iterator p = table.begin (); p != table.end (); p++) | |
1934 p->second.clear (); | |
1935 } | |
1936 | |
1937 void do_clear_global (const std::string& name) | |
1938 { | |
1939 table_iterator p = table.find (name); | |
4913 | 1940 |
7336 | 1941 if (p != table.end ()) |
1942 { | |
1943 symbol_record& sr = p->second; | |
1944 | |
1945 if (sr.is_global ()) | |
1946 { | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1947 global_table_iterator q = global_table.find (name); |
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 if (q != global_table.end ()) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1950 global_table.erase (q); |
7336 | 1951 |
1952 sr.unmark_global (); | |
1953 } | |
1954 } | |
1955 } | |
1956 | |
1957 void do_clear_variable (const std::string& name) | |
1958 { | |
1959 table_iterator p = table.find (name); | |
1960 | |
1961 if (p != table.end ()) | |
1962 p->second.clear (); | |
1963 } | |
1964 | |
1965 void do_clear_global_pattern (const std::string& pat) | |
1966 { | |
1967 glob_match pattern (pat); | |
1968 | |
1969 for (table_iterator p = table.begin (); p != table.end (); p++) | |
1970 { | |
1971 symbol_record& sr = p->second; | |
8 | 1972 |
7336 | 1973 if (sr.is_global ()) |
1974 { | |
1975 if (pattern.match (sr.name ())) | |
1976 { | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1977 global_table_iterator q = global_table.find (sr.name ()); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1978 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1979 if (q != global_table.end ()) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7489
diff
changeset
|
1980 global_table.erase (q); |
7336 | 1981 |
1982 sr.unmark_global (); | |
1983 } | |
1984 } | |
1985 } | |
1986 } | |
1987 | |
1988 void do_clear_variable_pattern (const std::string& pat) | |
1989 { | |
1990 glob_match pattern (pat); | |
1991 | |
1992 for (table_iterator p = table.begin (); p != table.end (); p++) | |
1993 { | |
1994 symbol_record& sr = p->second; | |
1995 | |
1996 if (sr.is_defined () || sr.is_global ()) | |
1997 { | |
1998 if (pattern.match (sr.name ())) | |
1999 sr.clear (); | |
2000 } | |
2001 } | |
2002 } | |
2003 | |
2004 void do_mark_hidden (const std::string& name) | |
2005 { | |
2006 table_iterator p = table.find (name); | |
2007 | |
2008 if (p != table.end ()) | |
2009 p->second.mark_hidden (); | |
2010 } | |
2011 | |
2012 void do_mark_global (const std::string& name) | |
2013 { | |
2014 table_iterator p = table.find (name); | |
8 | 2015 |
7336 | 2016 if (p != table.end ()) |
2017 p->second.mark_global (); | |
2018 } | |
2019 | |
2020 std::list<symbol_record> do_all_variables (bool defined_only) const | |
2021 { | |
2022 std::list<symbol_record> retval; | |
2023 | |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
2024 for (table_const_iterator p = table.begin (); p != table.end (); p++) |
7336 | 2025 { |
2026 const symbol_record& sr = p->second; | |
2027 | |
2028 if (defined_only && ! sr.is_defined ()) | |
2029 continue; | |
2030 | |
2031 retval.push_back (sr); | |
2032 } | |
2033 | |
2034 return retval; | |
2035 } | |
2036 | |
2037 std::list<symbol_record> do_glob (const std::string& pattern, | |
2038 bool vars_only = false) const | |
2039 { | |
2040 std::list<symbol_record> retval; | |
2041 | |
2042 glob_match pat (pattern); | |
2043 | |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
2044 for (table_const_iterator p = table.begin (); p != table.end (); p++) |
7336 | 2045 { |
2046 if (pat.match (p->first)) | |
2047 { | |
2048 const symbol_record& sr = p->second; | |
1962 | 2049 |
7336 | 2050 if (vars_only && ! sr.is_variable ()) |
2051 continue; | |
2052 | |
2053 retval.push_back (sr); | |
2054 } | |
2055 } | |
2056 | |
2057 return retval; | |
2058 } | |
2059 | |
2060 std::list<std::string> do_variable_names (void) | |
2061 { | |
2062 std::list<std::string> retval; | |
2063 | |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
2064 for (table_const_iterator p = table.begin (); p != table.end (); p++) |
7336 | 2065 retval.push_back (p->first); |
2066 | |
2067 retval.sort (); | |
2068 | |
2069 return retval; | |
2070 } | |
2071 | |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
2072 static std::map<std::string, octave_value> |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
2073 subfunctions_defined_in_scope (scope_id scope = xcurrent_scope) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
2074 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
2075 std::map<std::string, octave_value> retval; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
2076 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
2077 for (fcn_table_const_iterator p = fcn_table.begin (); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
2078 p != fcn_table.end (); p++) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
2079 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
2080 std::pair<std::string, octave_value> tmp |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
2081 = p->second.subfunction_defined_in_scope (scope); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
2082 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
2083 std::string nm = tmp.first; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
2084 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
2085 if (! nm.empty ()) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
2086 retval[nm] = tmp.second; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
2087 } |
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 return retval; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
2090 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
2091 |
7336 | 2092 bool do_is_local_variable (const std::string& name) const |
2093 { | |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
2094 table_const_iterator p = table.find (name); |
7336 | 2095 |
2096 return (p != table.end () | |
2097 && ! p->second.is_global () | |
2098 && p->second.is_defined ()); | |
2099 } | |
2100 | |
2101 bool do_is_global (const std::string& name) const | |
2102 { | |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
2103 table_const_iterator p = table.find (name); |
7336 | 2104 |
2105 return p != table.end () && p->second.is_global (); | |
2106 } | |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
2107 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
2108 void do_dump (std::ostream& os); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
2109 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
2110 void do_cache_name (const std::string& name) { table_name = name; } |
3011 | 2111 }; |
2790 | 2112 |
7336 | 2113 extern bool out_of_date_check (octave_value& function); |
4913 | 2114 |
8 | 2115 #endif |
2116 | |
2117 /* | |
2118 ;;; Local Variables: *** | |
2119 ;;; mode: C++ *** | |
2120 ;;; End: *** | |
2121 */ |