annotate libinterp/corefcn/symtab.h @ 23667:2d4a7ae1f6cd

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