Mercurial > octave
annotate libinterp/corefcn/symtab.h @ 24269:f494b87d2a93
rename scope to symbol_scope
* symscope.h, symscope.cc: Rename from scope.h and scope.cc.
(class symbol_scope): Rename from scope. Change all uses.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 16 Nov 2017 19:39:00 -0500 |
parents | 3b302b2890d7 |
children | a01c210e4287 |
rev | line source |
---|---|
8 | 1 /* |
2 | |
23219
3ac9f9ecfae5
maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents:
23083
diff
changeset
|
3 Copyright (C) 1993-2017 John W. Eaton |
10521
4d1fc073fbb7
add some missing copyright stmts
Jaroslav Hajek <highegg@gmail.com>
parents:
10321
diff
changeset
|
4 Copyright (C) 2009 VZLU Prague |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11584
diff
changeset
|
5 |
8 | 6 This file is part of Octave. |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22653
diff
changeset
|
9 under the terms of the GNU General Public License as published by |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22653
diff
changeset
|
10 the Free Software Foundation; either version 3 of the License, or |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22653
diff
changeset
|
11 (at your option) any later version. |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22653
diff
changeset
|
12 |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22653
diff
changeset
|
13 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22653
diff
changeset
|
14 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22653
diff
changeset
|
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22653
diff
changeset
|
16 GNU General Public License for more details. |
8 | 17 |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
8 | 21 |
22 */ | |
23 | |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
20713
diff
changeset
|
24 #if ! defined (octave_symtab_h) |
383 | 25 #define octave_symtab_h 1 |
8 | 26 |
21244
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21139
diff
changeset
|
27 #include "octave-config.h" |
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21139
diff
changeset
|
28 |
7336 | 29 #include <deque> |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
30 #include <limits> |
7336 | 31 #include <list> |
32 #include <map> | |
33 #include <set> | |
34 #include <string> | |
2953 | 35 |
7336 | 36 #include "glob-match.h" |
16940
99122191d3dd
maint: Rename regexp.h to lo-regexp.h, regexp.cc to lo-regexp.cc in liboctave.
Rik <rik@octave.org>
parents:
16892
diff
changeset
|
37 #include "lo-regexp.h" |
23680
ef71711f6d64
rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
38 #include "oct-refcount.h" |
2846 | 39 |
7336 | 40 class tree_argument_list; |
9639
8d79f36ebdde
store scope->function pointer
Jaroslav Hajek <highegg@gmail.com>
parents:
9581
diff
changeset
|
41 class octave_user_function; |
3013 | 42 |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24113
diff
changeset
|
43 #include "fcn-info.h" |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
44 #include "ov.h" |
20940
48b2ad5ee801
maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents:
20791
diff
changeset
|
45 #include "ovl.h" |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24113
diff
changeset
|
46 #include "symrec.h" |
24269
f494b87d2a93
rename scope to symbol_scope
John W. Eaton <jwe@octave.org>
parents:
24263
diff
changeset
|
47 #include "symscope.h" |
16468
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
48 #include "workspace-element.h" |
1412 | 49 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
50 namespace octave |
8 | 51 { |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
52 class OCTINTERP_API symbol_table |
7336 | 53 { |
54 public: | |
55 | |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24113
diff
changeset
|
56 typedef octave::symbol_record symbol_record; |
24269
f494b87d2a93
rename scope to symbol_scope
John W. Eaton <jwe@octave.org>
parents:
24263
diff
changeset
|
57 typedef octave::symbol_scope scope; |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24113
diff
changeset
|
58 typedef octave::fcn_info fcn_info; |
24037
21915520ac7b
use more direct method for non-local symbol access (bug #38236)
John W. Eaton <jwe@octave.org>
parents:
24031
diff
changeset
|
59 |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24113
diff
changeset
|
60 typedef scope::context_id context_id; |
7336 | 61 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
62 symbol_table (void) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
63 : m_global_symbols (), m_fcn_table (), m_class_precedence_table (), |
24269
f494b87d2a93
rename scope to symbol_scope
John W. Eaton <jwe@octave.org>
parents:
24263
diff
changeset
|
64 m_parent_map (), m_global_scope (new scope ("global scope")), |
f494b87d2a93
rename scope to symbol_scope
John W. Eaton <jwe@octave.org>
parents:
24263
diff
changeset
|
65 m_top_scope (new symbol_scope ("top scope")), |
f494b87d2a93
rename scope to symbol_scope
John W. Eaton <jwe@octave.org>
parents:
24263
diff
changeset
|
66 m_current_scope (m_top_scope) |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
67 { } |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
68 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
69 // No copying! |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
70 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
71 symbol_table (const symbol_table&) = delete; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
72 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
73 symbol_table& operator = (const symbol_table&) = delete; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
74 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
75 ~symbol_table (void) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
76 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
77 delete m_top_scope; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
78 delete m_global_scope; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
79 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
80 |
24269
f494b87d2a93
rename scope to symbol_scope
John W. Eaton <jwe@octave.org>
parents:
24263
diff
changeset
|
81 symbol_scope *global_scope (void) { return m_global_scope; } |
f494b87d2a93
rename scope to symbol_scope
John W. Eaton <jwe@octave.org>
parents:
24263
diff
changeset
|
82 symbol_scope *top_scope (void) { return m_top_scope; } |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
83 |
24269
f494b87d2a93
rename scope to symbol_scope
John W. Eaton <jwe@octave.org>
parents:
24263
diff
changeset
|
84 symbol_scope *current_scope (void) { return m_current_scope; } |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
85 |
24269
f494b87d2a93
rename scope to symbol_scope
John W. Eaton <jwe@octave.org>
parents:
24263
diff
changeset
|
86 symbol_scope *require_current_scope (const std::string& who) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
87 { |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
88 if (! m_current_scope) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
89 error ("%s: missing scope", who.c_str ()); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
90 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
91 return m_current_scope; |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
92 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
93 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
94 context_id current_context (void) const |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
95 { |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
96 return m_current_scope ? m_current_scope->current_context () : 0; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
97 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
98 |
24269
f494b87d2a93
rename scope to symbol_scope
John W. Eaton <jwe@octave.org>
parents:
24263
diff
changeset
|
99 void set_scope (symbol_scope *sid) |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
100 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
101 set_scope_and_context (sid, 0); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
102 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
103 |
24269
f494b87d2a93
rename scope to symbol_scope
John W. Eaton <jwe@octave.org>
parents:
24263
diff
changeset
|
104 void set_scope_and_context (symbol_scope *sid, context_id context) |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
105 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
106 if (sid == m_global_scope) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
107 error ("can't set scope to global"); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
108 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
109 m_current_scope = sid; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
110 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
111 if (m_current_scope) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
112 m_current_scope->set_context (context); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
113 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
114 |
24269
f494b87d2a93
rename scope to symbol_scope
John W. Eaton <jwe@octave.org>
parents:
24263
diff
changeset
|
115 symbol_record find_symbol (const std::string& name, symbol_scope *sid) |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
116 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
117 return sid ? sid->find_symbol (name) : symbol_record (); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
118 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
119 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
120 symbol_record find_symbol (const std::string& name) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
121 { |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
122 return find_symbol (name, m_current_scope); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
123 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
124 |
24269
f494b87d2a93
rename scope to symbol_scope
John W. Eaton <jwe@octave.org>
parents:
24263
diff
changeset
|
125 void inherit (symbol_scope *recipient_scope, symbol_scope *donor_scope) |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
126 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
127 if (recipient_scope) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
128 recipient_scope->inherit (donor_scope); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
129 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
130 |
24269
f494b87d2a93
rename scope to symbol_scope
John W. Eaton <jwe@octave.org>
parents:
24263
diff
changeset
|
131 void inherit (symbol_scope *recipient_scope) |
23611
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
132 { |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
133 inherit (recipient_scope, m_current_scope); |
23611
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
134 } |
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
135 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
136 bool at_top_level (void) { return m_current_scope == m_top_scope; } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
137 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
138 // Find a value corresponding to the given name in the table. |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
139 octave_value |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
140 find (const std::string& name, |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
141 const octave_value_list& args = octave_value_list (), |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
142 bool skip_variables = false, |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
143 bool local_funcs = true); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
144 |
23699
b29904962d2d
deprecate some global functions that access the symbol table
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
145 void assign (const std::string& name, const octave_value& value, bool force_add) |
b29904962d2d
deprecate some global functions that access the symbol table
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
146 { |
b29904962d2d
deprecate some global functions that access the symbol table
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
147 if (m_current_scope) |
b29904962d2d
deprecate some global functions that access the symbol table
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
148 m_current_scope->assign (name, value, force_add); |
b29904962d2d
deprecate some global functions that access the symbol table
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
149 } |
b29904962d2d
deprecate some global functions that access the symbol table
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
150 |
b29904962d2d
deprecate some global functions that access the symbol table
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
151 void assign (const std::string& name, |
b29904962d2d
deprecate some global functions that access the symbol table
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
152 const octave_value& value = octave_value ()) |
b29904962d2d
deprecate some global functions that access the symbol table
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
153 { |
b29904962d2d
deprecate some global functions that access the symbol table
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
154 if (m_current_scope) |
b29904962d2d
deprecate some global functions that access the symbol table
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
155 m_current_scope->assign (name, value); |
b29904962d2d
deprecate some global functions that access the symbol table
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
156 } |
b29904962d2d
deprecate some global functions that access the symbol table
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
157 |
24037
21915520ac7b
use more direct method for non-local symbol access (bug #38236)
John W. Eaton <jwe@octave.org>
parents:
24031
diff
changeset
|
158 octave_value varval (const std::string& name) const |
23699
b29904962d2d
deprecate some global functions that access the symbol table
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
159 { |
b29904962d2d
deprecate some global functions that access the symbol table
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
160 return (m_current_scope |
b29904962d2d
deprecate some global functions that access the symbol table
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
161 ? m_current_scope->varval (name) : octave_value ()); |
b29904962d2d
deprecate some global functions that access the symbol table
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
162 } |
b29904962d2d
deprecate some global functions that access the symbol table
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
163 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
164 void |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
165 global_assign (const std::string& name, |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
166 const octave_value& value = octave_value ()) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
167 { |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
168 global_symbols_iterator p = m_global_symbols.find (name); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
169 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
170 if (p == m_global_symbols.end ()) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
171 m_global_symbols[name] = value; |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
172 else |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
173 p->second = value; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
174 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
175 |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24113
diff
changeset
|
176 octave_value& global_varref (const std::string& name) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24113
diff
changeset
|
177 { |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24113
diff
changeset
|
178 global_symbols_iterator p = m_global_symbols.find (name); |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24113
diff
changeset
|
179 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24113
diff
changeset
|
180 return (p == m_global_symbols.end () |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24113
diff
changeset
|
181 ? m_global_symbols[name] : p->second); |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24113
diff
changeset
|
182 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24113
diff
changeset
|
183 |
24037
21915520ac7b
use more direct method for non-local symbol access (bug #38236)
John W. Eaton <jwe@octave.org>
parents:
24031
diff
changeset
|
184 octave_value global_varval (const std::string& name) const |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
185 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
186 global_symbols_const_iterator p = m_global_symbols.find (name); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
187 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
188 return (p != m_global_symbols.end ()) ? p->second : octave_value (); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
189 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
190 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
191 void |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
192 top_level_assign (const std::string& name, |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
193 const octave_value& value = octave_value ()) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
194 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
195 m_top_scope->assign (name, value); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
196 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
197 |
24037
21915520ac7b
use more direct method for non-local symbol access (bug #38236)
John W. Eaton <jwe@octave.org>
parents:
24031
diff
changeset
|
198 octave_value top_level_varval (const std::string& name) const |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
199 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
200 return m_top_scope->varval (name); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
201 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
202 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
203 bool |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
204 is_built_in_function_name (const std::string& name) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
205 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
206 octave_value val = find_built_in_function (name); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
207 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
208 return val.is_defined (); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
209 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
210 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
211 octave_value |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
212 find_method (const std::string& name, const std::string& dispatch_type) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
213 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
214 fcn_table_const_iterator p = m_fcn_table.find (name); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
215 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
216 if (p != m_fcn_table.end ()) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
217 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
218 octave_value fcn = p->second.find_method (dispatch_type); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
219 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
220 if (! fcn.is_defined ()) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
221 fcn = find_submethod (name, dispatch_type); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
222 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
223 return fcn; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
224 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
225 else |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
226 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
227 fcn_info finfo (name); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
228 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
229 octave_value fcn = finfo.find_method (dispatch_type); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
230 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
231 if (! fcn.is_defined ()) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
232 fcn = find_submethod (name, dispatch_type); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
233 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
234 if (fcn.is_defined ()) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
235 m_fcn_table[name] = finfo; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
236 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
237 return fcn; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
238 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
239 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
240 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
241 octave_value |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
242 find_submethod (const std::string& name, const std::string& dispatch_type); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
243 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
244 octave_value |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
245 find_built_in_function (const std::string& name) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
246 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
247 fcn_table_const_iterator p = m_fcn_table.find (name); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
248 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
249 return (p != m_fcn_table.end () |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
250 ? p->second.find_built_in_function () : octave_value ()); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
251 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
252 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
253 octave_value |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
254 find_autoload (const std::string& name) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
255 { |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
256 fcn_table_iterator p = m_fcn_table.find (name); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
257 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
258 return (p != m_fcn_table.end () |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
259 ? p->second.find_autoload () : octave_value ()); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
260 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
261 |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24113
diff
changeset
|
262 octave_value builtin_find (const std::string& name); |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24113
diff
changeset
|
263 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24113
diff
changeset
|
264 octave_value |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24113
diff
changeset
|
265 fcn_table_find (const std::string& name, |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24113
diff
changeset
|
266 const octave_value_list& args = octave_value_list (), |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24113
diff
changeset
|
267 bool local_funcs = true); |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24113
diff
changeset
|
268 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
269 octave_value |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
270 find_function (const std::string& name, |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
271 const octave_value_list& args = octave_value_list (), |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
272 bool local_funcs = true); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
273 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
274 octave_value find_user_function (const std::string& name) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
275 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
276 fcn_table_iterator p = m_fcn_table.find (name); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
277 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
278 return (p != m_fcn_table.end () |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
279 ? p->second.find_user_function () : octave_value ()); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
280 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
281 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
282 octave_value find_cmdline_function (const std::string& name) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
283 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
284 fcn_table_iterator p = m_fcn_table.find (name); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
285 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
286 return (p != m_fcn_table.end () |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
287 ? p->second.find_cmdline_function () : octave_value ()); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
288 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
289 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
290 void install_cmdline_function (const std::string& name, |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
291 const octave_value& fcn) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
292 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
293 fcn_table_iterator p = m_fcn_table.find (name); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
294 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
295 if (p != m_fcn_table.end ()) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
296 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
297 fcn_info& finfo = p->second; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
298 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
299 finfo.install_cmdline_function (fcn); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
300 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
301 else |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
302 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
303 fcn_info finfo (name); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
304 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
305 finfo.install_cmdline_function (fcn); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
306 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
307 m_fcn_table[name] = finfo; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
308 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
309 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
310 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
311 // Install local function FCN named NAME. FILE_NAME is the name of |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
312 // the file containing the local function. |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
313 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
314 void install_local_function (const std::string& name, |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
315 const octave_value& fcn, |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
316 const std::string& file_name) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
317 { |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
318 fcn_table_iterator p = m_fcn_table.find (name); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
319 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
320 if (p != m_fcn_table.end ()) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
321 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
322 fcn_info& finfo = p->second; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
323 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
324 finfo.install_local_function (fcn, file_name); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
325 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
326 else |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
327 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
328 fcn_info finfo (name); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
329 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
330 finfo.install_local_function (fcn, file_name); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
331 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
332 m_fcn_table[name] = finfo; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
333 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
334 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
335 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
336 void install_user_function (const std::string& name, |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
337 const octave_value& fcn) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
338 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
339 fcn_table_iterator p = m_fcn_table.find (name); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
340 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
341 if (p != m_fcn_table.end ()) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
342 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
343 fcn_info& finfo = p->second; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
344 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
345 finfo.install_user_function (fcn); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
346 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
347 else |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
348 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
349 fcn_info finfo (name); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
350 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
351 finfo.install_user_function (fcn); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
352 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
353 m_fcn_table[name] = finfo; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
354 } |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
355 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
356 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
357 void install_built_in_function (const std::string& name, |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
358 const octave_value& fcn) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
359 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
360 fcn_table_iterator p = m_fcn_table.find (name); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
361 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
362 if (p != m_fcn_table.end ()) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
363 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
364 fcn_info& finfo = p->second; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
365 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
366 finfo.install_built_in_function (fcn); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
367 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
368 else |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
369 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
370 fcn_info finfo (name); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
371 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
372 finfo.install_built_in_function (fcn); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
373 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
374 m_fcn_table[name] = finfo; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
375 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
376 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
377 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
378 void clear_all (bool force = false) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
379 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
380 if (m_current_scope) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
381 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
382 m_current_scope->clear_variables (); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
383 m_current_scope->clear_global_pattern ("*"); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
384 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
385 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
386 clear_functions (force); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
387 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
388 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
389 // This is written as two separate functions instead of a single |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
390 // function with default values so that it will work properly with |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
391 // unwind_protect. |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
392 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
393 void clear_functions (bool force = false) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
394 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
395 fcn_table_iterator p = m_fcn_table.begin (); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
396 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
397 while (p != m_fcn_table.end ()) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
398 (p++)->second.clear (force); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
399 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
400 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
401 void clear_function (const std::string& name) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
402 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
403 clear_user_function (name); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
404 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
405 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
406 void clear_symbol (const std::string& name) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
407 { |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
408 // FIXME: are we supposed to do both here? |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
409 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
410 if (m_current_scope) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
411 m_current_scope->clear_variable (name); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
412 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
413 clear_function (name); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
414 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
415 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
416 void clear_function_pattern (const std::string& pat) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
417 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
418 glob_match pattern (pat); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
419 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
420 fcn_table_iterator p = m_fcn_table.begin (); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
421 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
422 while (p != m_fcn_table.end ()) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
423 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
424 if (pattern.match (p->first)) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
425 (p++)->second.clear_user_function (); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
426 else |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
427 p++; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
428 } |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
429 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
430 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
431 void clear_symbol_pattern (const std::string& pat) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
432 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
433 // FIXME: are we supposed to do both here? |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
434 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
435 if (m_current_scope) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
436 m_current_scope->clear_variable_pattern (pat); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
437 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
438 clear_function_pattern (pat); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
439 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
440 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
441 void clear_user_function (const std::string& name) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
442 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
443 fcn_table_iterator p = m_fcn_table.find (name); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
444 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
445 if (p != m_fcn_table.end ()) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
446 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
447 fcn_info& finfo = p->second; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
448 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
449 finfo.clear_user_function (); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
450 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
451 // FIXME: is this necessary, or even useful? |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
452 // else |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
453 // error ("clear: no such function '%s'", name.c_str ()); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
454 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
455 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
456 // This clears oct and mex files, including autoloads. |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
457 void clear_dld_function (const std::string& name) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
458 { |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
459 fcn_table_iterator p = m_fcn_table.find (name); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
460 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
461 if (p != m_fcn_table.end ()) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
462 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
463 fcn_info& finfo = p->second; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
464 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
465 finfo.clear_autoload_function (); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
466 finfo.clear_user_function (); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
467 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
468 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
469 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
470 void clear_mex_functions (void) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
471 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
472 fcn_table_iterator p = m_fcn_table.begin (); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
473 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
474 while (p != m_fcn_table.end ()) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
475 (p++)->second.clear_mex_function (); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
476 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
477 |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24113
diff
changeset
|
478 void erase_global (const std::string& name); |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24113
diff
changeset
|
479 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24113
diff
changeset
|
480 void erase_global_pattern (const glob_match& pattern); |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24113
diff
changeset
|
481 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
482 bool set_class_relationship (const std::string& sup_class, |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
483 const std::string& inf_class); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
484 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
485 bool is_superiorto (const std::string& a, const std::string& b); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
486 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
487 void alias_built_in_function (const std::string& alias, |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
488 const std::string& name) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
489 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
490 octave_value fcn = find_built_in_function (name); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
491 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
492 if (fcn.is_defined ()) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
493 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
494 fcn_info finfo (alias); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
495 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
496 finfo.install_built_in_function (fcn); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
497 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
498 m_fcn_table[alias] = finfo; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
499 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
500 else |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
501 panic ("alias: '%s' is undefined", name.c_str ()); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
502 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
503 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
504 void install_built_in_dispatch (const std::string& name, |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
505 const std::string& klass) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
506 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
507 fcn_table_iterator p = m_fcn_table.find (name); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
508 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
509 if (p != m_fcn_table.end ()) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
510 { |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
511 fcn_info& finfo = p->second; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
512 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
513 finfo.install_built_in_dispatch (klass); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
514 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
515 else |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
516 error ("install_built_in_dispatch: '%s' is undefined", name.c_str ()); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
517 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
518 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
519 void push_context (void) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
520 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
521 if (m_current_scope == m_top_scope) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
522 error ("invalid call to symtab::push_context"); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
523 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
524 if (m_current_scope) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
525 m_current_scope->push_context (); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
526 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
527 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
528 // This is written as two separate functions instead of a single |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
529 // function with default values so that it will work properly with |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
530 // unwind_protect. |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
531 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
532 void pop_context (void) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
533 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
534 if (m_current_scope == m_top_scope) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
535 error ("invalid call to symtab::pop_context"); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
536 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
537 if (m_current_scope) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
538 m_current_scope->pop_context (); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
539 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
540 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
541 // For unwind_protect where a pointer argument is needed. |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
542 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
543 void pop_context (void *) { pop_context (); } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
544 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
545 std::list<symbol_record> glob (const std::string& pattern) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
546 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
547 return (m_current_scope |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
548 ? m_current_scope->glob (pattern) : std::list<symbol_record> ()); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
549 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
550 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
551 std::list<symbol_record> |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
552 glob_global_variables (const std::string& pattern) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
553 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
554 std::list<symbol_record> retval; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
555 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
556 glob_match pat (pattern); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
557 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
558 for (const auto& nm_val : m_global_symbols) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
559 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
560 // We generate a list of symbol_record objects so that the results from |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
561 // glob_variables and glob_global_variables may be handled the same |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
562 // way. |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
563 if (pat.match (nm_val.first)) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
564 retval.push_back (symbol_record (m_global_scope, |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
565 nm_val.first, nm_val.second, |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
566 symbol_record::global)); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
567 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
568 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
569 return retval; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
570 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
571 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
572 std::list<symbol_record> |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
573 regexp_global_variables (const std::string& pattern) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
574 { |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
575 std::list<symbol_record> retval; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
576 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
577 octave::regexp pat (pattern); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
578 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
579 for (const auto& nm_val : m_global_symbols) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
580 { |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
581 // We generate a list of symbol_record objects so that the results from |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
582 // regexp_variables and regexp_global_variables may be handled the same |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
583 // way. |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
584 if (pat.is_match (nm_val.first)) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
585 retval.push_back (symbol_record (m_global_scope, |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
586 nm_val.first, nm_val.second, |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
587 symbol_record::global)); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
588 } |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
589 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
590 return retval; |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
591 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
592 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
593 std::list<symbol_record> glob_variables (const string_vector& patterns) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
594 { |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
595 std::list<symbol_record> retval; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
596 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
597 if (! m_current_scope) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
598 return retval; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
599 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
600 size_t len = patterns.numel (); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
601 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
602 for (size_t i = 0; i < len; i++) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
603 { |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
604 std::list<symbol_record> tmp = m_current_scope->glob (patterns[i]); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
605 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
606 retval.insert (retval.begin (), tmp.begin (), tmp.end ()); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
607 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
608 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
609 return retval; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
610 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
611 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
612 std::list<symbol_record> regexp_variables (const string_vector& patterns) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
613 { |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
614 std::list<symbol_record> retval; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
615 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
616 if (! m_current_scope) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
617 return retval; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
618 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
619 size_t len = patterns.numel (); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
620 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
621 for (size_t i = 0; i < len; i++) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
622 { |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
623 std::list<symbol_record> tmp = m_current_scope->regexp (patterns[i]); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
624 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
625 retval.insert (retval.begin (), tmp.begin (), tmp.end ()); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
626 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
627 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
628 return retval; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
629 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
630 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
631 std::list<std::string> user_function_names (void) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
632 { |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
633 std::list<std::string> retval; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
634 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
635 for (const auto& nm_finfo : m_fcn_table) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
636 { |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
637 if (nm_finfo.second.is_user_function_defined ()) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
638 retval.push_back (nm_finfo.first); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
639 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
640 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
641 if (! retval.empty ()) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
642 retval.sort (); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
643 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
644 return retval; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
645 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
646 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
647 std::list<std::string> global_variable_names (void) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
648 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
649 std::list<std::string> retval; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
650 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
651 for (const auto& nm_val : m_global_symbols) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
652 retval.push_back (nm_val.first); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
653 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
654 retval.sort (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
655 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
656 return retval; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
657 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
658 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
659 std::list<std::string> top_level_variable_names (void) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
660 { |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
661 return (m_top_scope |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
662 ? m_top_scope->variable_names () : std::list<std::string> ()); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
663 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
664 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
665 std::list<std::string> variable_names (void) |
23611
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
666 { |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
667 return (m_current_scope |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
668 ? m_current_scope->variable_names () : std::list<std::string> ()); |
23611
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
669 } |
91c8f006ed8b
remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
23610
diff
changeset
|
670 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
671 std::list<std::string> built_in_function_names (void) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
672 { |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
673 std::list<std::string> retval; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
674 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
675 for (const auto& nm_finfo : m_fcn_table) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
676 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
677 octave_value fcn = nm_finfo.second.find_built_in_function (); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
678 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
679 if (fcn.is_defined ()) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
680 retval.push_back (nm_finfo.first); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
681 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
682 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
683 if (! retval.empty ()) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
684 retval.sort (); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
685 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
686 return retval; |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
687 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
688 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
689 std::list<std::string> cmdline_function_names (void) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
690 { |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
691 std::list<std::string> retval; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
692 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
693 for (const auto& nm_finfo : m_fcn_table) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
694 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
695 octave_value fcn = nm_finfo.second.find_cmdline_function (); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
696 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
697 if (fcn.is_defined ()) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
698 retval.push_back (nm_finfo.first); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
699 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
700 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
701 if (! retval.empty ()) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
702 retval.sort (); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
703 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
704 return retval; |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
705 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
706 |
23680
ef71711f6d64
rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
707 octave_value dump (void) const; |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
708 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
709 void add_to_parent_map (const std::string& classname, |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
710 const std::list<std::string>& parent_list) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
711 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
712 m_parent_map[classname] = parent_list; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
713 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
714 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
715 std::list<std::string> |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
716 parent_classes (const std::string& dispatch_type) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
717 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
718 std::list<std::string> retval; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
719 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
720 const_parent_map_iterator it = m_parent_map.find (dispatch_type); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
721 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
722 if (it != m_parent_map.end ()) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
723 retval = it->second; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
724 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
725 for (const auto& nm : retval) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
726 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
727 // Search for parents of parents and append them to the list. |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
728 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
729 // FIXME: should we worry about a circular inheritance graph? |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
730 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
731 std::list<std::string> parents = parent_classes (nm); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
732 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
733 if (! parents.empty ()) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
734 retval.insert (retval.end (), parents.begin (), parents.end ()); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
735 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
736 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
737 return retval; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
738 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
739 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
740 octave_user_function * get_curr_fcn (void) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
741 { |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23699
diff
changeset
|
742 return m_current_scope ? m_current_scope->function () : nullptr; |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
743 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
744 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
745 void cleanup (void); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
746 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
747 fcn_info * get_fcn_info (const std::string& name) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
748 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
749 fcn_table_iterator p = m_fcn_table.find (name); |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23699
diff
changeset
|
750 return p != m_fcn_table.end () ? &p->second : nullptr; |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
751 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
752 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
753 private: |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
754 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
755 typedef std::map<std::string, octave_value>::const_iterator |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
756 global_symbols_const_iterator; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
757 typedef std::map<std::string, octave_value>::iterator |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
758 global_symbols_iterator; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
759 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
760 typedef std::map<std::string, fcn_info>::const_iterator |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
761 fcn_table_const_iterator; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
762 typedef std::map<std::string, fcn_info>::iterator |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
763 fcn_table_iterator; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
764 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
765 // Map from names of global variables to values. |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
766 std::map<std::string, octave_value> m_global_symbols; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
767 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
768 // Map from function names to function info (private |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
769 // functions, class constructors, class methods, etc.) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
770 // Note that subfunctions are defined in the scope that contains |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
771 // them. |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
772 std::map<std::string, fcn_info> m_fcn_table; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
773 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
774 // Map from class names to set of classes that have lower |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
775 // precedence. |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
776 std::map<std::string, std::set<std::string>> m_class_precedence_table; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
777 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
778 typedef std::map<std::string, std::set<std::string>>::const_iterator |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
779 class_precedence_table_const_iterator; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
780 typedef std::map<std::string, std::set<std::string>>::iterator |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
781 class_precedence_table_iterator; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
782 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
783 // Map from class names to parent class names. |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
784 std::map<std::string, std::list<std::string>> m_parent_map; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
785 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
786 typedef std::map<std::string, std::list<std::string>>::const_iterator |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
787 const_parent_map_iterator; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
788 typedef std::map<std::string, std::list<std::string>>::iterator |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
789 parent_map_iterator; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
790 |
24269
f494b87d2a93
rename scope to symbol_scope
John W. Eaton <jwe@octave.org>
parents:
24263
diff
changeset
|
791 symbol_scope *m_global_scope; |
f494b87d2a93
rename scope to symbol_scope
John W. Eaton <jwe@octave.org>
parents:
24263
diff
changeset
|
792 symbol_scope *m_top_scope; |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
793 |
24269
f494b87d2a93
rename scope to symbol_scope
John W. Eaton <jwe@octave.org>
parents:
24263
diff
changeset
|
794 symbol_scope *m_current_scope; |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
795 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
796 octave_value dump_fcn_table_map (void) const; |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
797 }; |
9981
692ab4eaf965
clean up top-level variables when exiting Octave
Jaroslav Hajek <highegg@gmail.com>
parents:
9958
diff
changeset
|
798 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
799 extern bool out_of_date_check (octave_value& function, |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
800 const std::string& dispatch_type = "", |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
801 bool check_relative = true); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
802 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
803 extern OCTINTERP_API std::string |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
804 get_dispatch_type (const octave_value_list& args); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
805 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
806 extern OCTINTERP_API std::string |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
807 get_dispatch_type (const octave_value_list& args, |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
808 builtin_type_t& builtin_type); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
809 } |
8123
eb2beef9a9ff
clear breakpoints is function found to be out of date
David Bateman <dbateman@free.fr>
parents:
8051
diff
changeset
|
810 |
8 | 811 #endif |