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