annotate libinterp/corefcn/symtab.h @ 23680:ef71711f6d64

rework __dump_symbol_table__ function * symtab.h, symtab.cc (F__dump_symtab_info__): Instead of printing results, return a struct containing all the info. (symbol_table::symbol_record::symbol_record_rep::dump, symbol_table::fcn_info::fcn_info_rep::dump, symbol_table::dump, symbol_table::scope::dump): Update interface. Create and return struct. (dump_container_map, symbol_table::dump_fcn_table_map, symbol_table::scope::dump_symbols_map): New functions. (fcn_file_name): Delete static function. (symbol_table::dump_global, symbol_table::dump_functions): Delete. * ov-usr-fcn.h, ov-usr-fcn.cc (octave_user_function::dump): Update interface. Create and return struct. (octave_user_function::ctor_type_str): New function. * ov-base.h, ov-base.cc (octave_base_value::dump): Update interface. Create and return struct. * ov.h (octave_value::dump): Update interface.
author John W. Eaton <jwe@octave.org>
date Thu, 22 Jun 2017 16:23:36 -0400
parents 2d4a7ae1f6cd
children b9378eff6d13
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"
23680
ef71711f6d64 rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents: 23667
diff changeset
38 #include "oct-refcount.h"
2846
52e7c4509983 [project @ 1997-03-26 23:27:35 by jwe]
jwe
parents: 2791
diff changeset
39
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
40 class tree_argument_list;
9639
8d79f36ebdde store scope->function pointer
Jaroslav Hajek <highegg@gmail.com>
parents: 9581
diff changeset
41 class octave_user_function;
3013
66a1cede95e7 [project @ 1997-06-02 19:35:05 by jwe]
jwe
parents: 3011
diff changeset
42
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
43 #include "ov.h"
20940
48b2ad5ee801 maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents: 20791
diff changeset
44 #include "ovl.h"
16468
0f143f68078d use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents: 16442
diff changeset
45 #include "workspace-element.h"
1412
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
23680
ef71711f6d64 rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents: 23667
diff changeset
291 octave_value dump (void) const;
7761
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
23680
ef71711f6d64 rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents: 23667
diff changeset
475 octave_value dump (void) const { return rep->dump (); }
7761
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7753
diff changeset
476
23603
18bd46c4b79a make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents: 23602
diff changeset
477 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
478
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
479 private:
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
480
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
481 symbol_record_rep *rep;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
482
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
483 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
484 };
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
485
21573
f3f8e1d3e399 avoid mulitple definitions of static function-scope vars (bug #47372)
John W. Eaton <jwe@octave.org>
parents: 19861
diff changeset
486 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
487
14912
3d3c002ccc60 Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents: 14899
diff changeset
488 // Always access a symbol from the current scope.
3d3c002ccc60 Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents: 14899
diff changeset
489 // 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
490 class
23602
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
491 symbol_reference
14912
3d3c002ccc60 Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents: 14899
diff changeset
492 {
3d3c002ccc60 Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents: 14899
diff changeset
493 public:
16442
302157614308 deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents: 16320
diff changeset
494
23602
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
495 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
496
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
497 symbol_reference (const symbol_record& record);
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
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 (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
500 context_id context)
23602
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
501 : 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
502 { }
14912
3d3c002ccc60 Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents: 14899
diff changeset
503
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
504 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
505
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
506 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
507
23602
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
508 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
509
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
510 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
511 {
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
512 update ();
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
513 return m_scope;
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
514 }
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 context_id context (void) const
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
517 {
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
518 update ();
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
519 return m_context;
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
520 }
16442
302157614308 deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents: 16320
diff changeset
521
14912
3d3c002ccc60 Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents: 14899
diff changeset
522 // 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
523 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
524
3d3c002ccc60 Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents: 14899
diff changeset
525 symbol_record *operator-> (void)
3d3c002ccc60 Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents: 14899
diff changeset
526 {
3d3c002ccc60 Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents: 14899
diff changeset
527 update ();
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
528 return &m_sym;
14912
3d3c002ccc60 Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents: 14899
diff changeset
529 }
3d3c002ccc60 Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents: 14899
diff changeset
530
14913
c7071907a641 Use symbol_record_ref instead of names in JIT
Max Brister <max@2bass.com>
parents: 14912
diff changeset
531 symbol_record *operator-> (void) const
c7071907a641 Use symbol_record_ref instead of names in JIT
Max Brister <max@2bass.com>
parents: 14912
diff changeset
532 {
c7071907a641 Use symbol_record_ref instead of names in JIT
Max Brister <max@2bass.com>
parents: 14912
diff changeset
533 update ();
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
534 return &m_sym;
14913
c7071907a641 Use symbol_record_ref instead of names in JIT
Max Brister <max@2bass.com>
parents: 14912
diff changeset
535 }
c7071907a641 Use symbol_record_ref instead of names in JIT
Max Brister <max@2bass.com>
parents: 14912
diff changeset
536
14930
7d44ed216b98 Rename symbol_table::symbol_record_ref to symbol_table::symbol_reference
Max Brister <max@2bass.com>
parents: 14913
diff changeset
537 // 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
538 // 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
539 struct comparator
3d3c002ccc60 Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents: 14899
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 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
542 const symbol_reference& rhs) const
14912
3d3c002ccc60 Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents: 14899
diff changeset
543 {
3d3c002ccc60 Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents: 14899
diff changeset
544 return lhs.name () < rhs.name ();
3d3c002ccc60 Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents: 14899
diff changeset
545 }
3d3c002ccc60 Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents: 14899
diff changeset
546 };
3d3c002ccc60 Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents: 14899
diff changeset
547 private:
16442
302157614308 deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents: 16320
diff changeset
548
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
549 void update (void) const;
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
550
23602
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
551 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
552 mutable context_id m_context;
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
553 mutable symbol_record m_sym;
14912
3d3c002ccc60 Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents: 14899
diff changeset
554 };
3d3c002ccc60 Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents: 14899
diff changeset
555
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
556 class
23602
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
557 fcn_info
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
558 {
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
559 public:
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
560
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
561 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
562 str_val_const_iterator;
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
563 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
564
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
565 private:
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
566
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
567 class
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
568 fcn_info_rep
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
569 {
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
570 public:
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
571
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
572 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
573 : 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
574 private_functions (), class_constructors (), class_methods (),
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11584
diff changeset
575 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
576 built_in_function (), count (1)
edbb123cbe3a Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16676
diff changeset
577 {
edbb123cbe3a Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16676
diff changeset
578 size_t pos = name.rfind ('.');
edbb123cbe3a Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16676
diff changeset
579
edbb123cbe3a Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16676
diff changeset
580 if (pos != std::string::npos)
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 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
583 name = name.substr (pos+1);
edbb123cbe3a Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16676
diff changeset
584 }
edbb123cbe3a Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16676
diff changeset
585 }
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
586
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
587 // No copying!
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
588
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
589 fcn_info_rep (const fcn_info_rep&) = delete;
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
590
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
591 fcn_info_rep& operator = (const fcn_info_rep&) = delete;
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
592
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
593 ~fcn_info_rep (void) = default;
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
594
23343
49f051ef6f2f local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
595 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
596
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
597 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
598
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
599 octave_value load_class_constructor (void);
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
600
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
601 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
602
9463
d34baf412786 support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
603 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
604
9444
0c785ad961fa improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents: 9443
diff changeset
605 octave_value builtin_find (void);
0c785ad961fa improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents: 9443
diff changeset
606
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
607 octave_value find_method (const std::string& dispatch_type);
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
608
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
609 octave_value find_autoload (void);
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
610
16684
edbb123cbe3a Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16676
diff changeset
611 octave_value find_package (void);
edbb123cbe3a Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16676
diff changeset
612
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
613 octave_value find_user_function (void);
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
614
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
615 bool is_user_function_defined (void) const
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
616 {
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
617 return function_on_path.is_defined ();
7336
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
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
620 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
621 bool local_funcs)
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
622 {
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
623 return find (args, local_funcs);
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
624 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
625
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
626 void install_cmdline_function (const octave_value& f)
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
627 {
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
628 cmdline_function = f;
7336
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
23343
49f051ef6f2f local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
631 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
632 const std::string& file_name)
49f051ef6f2f local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
633 {
49f051ef6f2f local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
634 local_functions[file_name] = f;
49f051ef6f2f local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
635 }
49f051ef6f2f local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
636
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
637 void install_user_function (const octave_value& f)
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
638 {
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
639 function_on_path = f;
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
640 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
641
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
642 void install_built_in_function (const octave_value& f)
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
643 {
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
644 built_in_function = f;
7336
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
22897
4090c32fccf8 store set of dispatch classes in built-in function objects
John W. Eaton <jwe@octave.org>
parents: 22893
diff changeset
647 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
648
21139
538b57866b90 consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents: 21134
diff changeset
649 template <typename T>
7489
8e4592e49fa7 don't clear locked functions
John W. Eaton <jwe@octave.org>
parents: 7374
diff changeset
650 void
16605
2f8fb02a6c31 erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
651 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
652 {
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
653 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
654
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
655 while (p != map.end ())
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
656 {
16605
2f8fb02a6c31 erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
657 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
658 map.erase (p++);
2f8fb02a6c31 erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
659 else
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
660 p++;
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
661 }
7489
8e4592e49fa7 don't clear locked functions
John W. Eaton <jwe@octave.org>
parents: 7374
diff changeset
662 }
8e4592e49fa7 don't clear locked functions
John W. Eaton <jwe@octave.org>
parents: 7374
diff changeset
663
16605
2f8fb02a6c31 erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
664 void clear_autoload_function (bool force = false)
7489
8e4592e49fa7 don't clear locked functions
John W. Eaton <jwe@octave.org>
parents: 7374
diff changeset
665 {
16605
2f8fb02a6c31 erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
666 if (force || ! autoload_function.islocked ())
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
667 autoload_function = octave_value ();
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
668 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
669
15003
1f5dbfc23fc2 'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents: 14981
diff changeset
670 // 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
671 // "user defined"
16605
2f8fb02a6c31 erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
672 void clear_user_function (bool force = false)
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
673 {
20477
c36f06ef7539 also clear autoloaded functions when clearing user functions
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
674 clear_autoload_function (force);
c36f06ef7539 also clear autoloaded functions when clearing user functions
John W. Eaton <jwe@octave.org>
parents: 20428
diff changeset
675
16605
2f8fb02a6c31 erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
676 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
677 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
678
2f8fb02a6c31 erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
679 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
680 cmdline_function = octave_value ();
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
681 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
682
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
683 void clear_mex_function (void)
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
684 {
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
685 if (function_on_path.is_mex_function ())
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
686 clear_user_function ();
7489
8e4592e49fa7 don't clear locked functions
John W. Eaton <jwe@octave.org>
parents: 7374
diff changeset
687 }
8e4592e49fa7 don't clear locked functions
John W. Eaton <jwe@octave.org>
parents: 7374
diff changeset
688
16676
7368654f302f Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16605
diff changeset
689 void clear_package (void)
7368654f302f Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16605
diff changeset
690 {
7368654f302f Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16605
diff changeset
691 package = octave_value ();
7368654f302f Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16605
diff changeset
692 }
7368654f302f Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16605
diff changeset
693
16605
2f8fb02a6c31 erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
694 void clear (bool force = false)
7489
8e4592e49fa7 don't clear locked functions
John W. Eaton <jwe@octave.org>
parents: 7374
diff changeset
695 {
23343
49f051ef6f2f local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
696 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
697 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
698 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
699 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
700
2f8fb02a6c31 erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
701 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
702 clear_user_function (force);
16676
7368654f302f Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16605
diff changeset
703 clear_package ();
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
704 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
705
23680
ef71711f6d64 rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents: 23667
diff changeset
706 octave_value dump (void) const;
7761
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7753
diff changeset
707
16684
edbb123cbe3a Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16676
diff changeset
708 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
709 {
edbb123cbe3a Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16676
diff changeset
710 if (package_name.empty ())
edbb123cbe3a Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16676
diff changeset
711 return name;
edbb123cbe3a Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16676
diff changeset
712 else
edbb123cbe3a Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16676
diff changeset
713 return package_name + "." + name;
edbb123cbe3a Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16676
diff changeset
714 }
edbb123cbe3a Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16676
diff changeset
715
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
716 std::string name;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
717
16684
edbb123cbe3a Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16676
diff changeset
718 std::string package_name;
edbb123cbe3a Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16676
diff changeset
719
23343
49f051ef6f2f local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
720 // File name to function object.
49f051ef6f2f local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
721 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
722
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
723 // Directory name to function object.
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
724 std::map<std::string, octave_value> private_functions;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
725
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
726 // Class name to function object.
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
727 std::map<std::string, octave_value> class_constructors;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
728
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
729 // Dispatch type to function object.
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
730 std::map<std::string, octave_value> class_methods;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
731
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
732 octave_value cmdline_function;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
733
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
734 octave_value autoload_function;
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 function_on_path;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
737
16676
7368654f302f Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16605
diff changeset
738 octave_value package;
7368654f302f Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16605
diff changeset
739
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
740 octave_value built_in_function;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
741
23012
27e4ec3b0b49 move octave_refcount inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22910
diff changeset
742 octave::refcount<size_t> count;
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
743
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
744 private:
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
745
9463
d34baf412786 support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
746 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
747
9444
0c785ad961fa improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents: 9443
diff changeset
748 octave_value x_builtin_find (void);
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
749 };
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
750
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
751 public:
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
752
21017
93748bcaec17 maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents: 21012
diff changeset
753 fcn_info (const std::string& nm = "")
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
754 : rep (new fcn_info_rep (nm)) { }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
755
8906
ab87d08d9a1b improve symbol inheritance for anonymous functions
John W. Eaton <jwe@octave.org>
parents: 8884
diff changeset
756 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
757 {
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
758 rep->count++;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
759 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
760
8906
ab87d08d9a1b improve symbol inheritance for anonymous functions
John W. Eaton <jwe@octave.org>
parents: 8884
diff changeset
761 fcn_info& operator = (const fcn_info& fi)
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
762 {
8906
ab87d08d9a1b improve symbol inheritance for anonymous functions
John W. Eaton <jwe@octave.org>
parents: 8884
diff changeset
763 if (this != &fi)
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
764 {
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
765 if (--rep->count == 0)
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
766 delete rep;
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
767
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
768 rep = fi.rep;
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
769 rep->count++;
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
770 }
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
771
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
772 return *this;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
773 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
774
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
775 ~fcn_info (void)
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
776 {
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
777 if (--rep->count == 0)
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
778 delete rep;
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
779 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
780
9463
d34baf412786 support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
781 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
782 bool local_funcs = true)
d34baf412786 support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
783 {
d34baf412786 support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
784 return rep->find (args, local_funcs);
d34baf412786 support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
785 }
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
786
9444
0c785ad961fa improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents: 9443
diff changeset
787 octave_value builtin_find (void)
0c785ad961fa improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents: 9443
diff changeset
788 {
0c785ad961fa improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents: 9443
diff changeset
789 return rep->builtin_find ();
0c785ad961fa improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents: 9443
diff changeset
790 }
0c785ad961fa improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents: 9443
diff changeset
791
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
792 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
793 {
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
794 return rep->find_method (dispatch_type);
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
795 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
796
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
797 octave_value find_built_in_function (void) const
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
798 {
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
799 return rep->built_in_function;
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
12911
d6151d774283 make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents: 12130
diff changeset
802 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
803 {
d6151d774283 make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents: 12130
diff changeset
804 return rep->cmdline_function;
d6151d774283 make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents: 12130
diff changeset
805 }
d6151d774283 make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents: 12130
diff changeset
806
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
807 octave_value find_autoload (void)
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
808 {
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
809 return rep->find_autoload ();
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
810 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
811
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
812 octave_value find_user_function (void)
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
813 {
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
814 return rep->find_user_function ();
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
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
817 bool is_user_function_defined (void) const
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
818 {
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
819 return rep->is_user_function_defined ();
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
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
822 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
823 = octave_value_list (),
9463
d34baf412786 support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
824 bool local_funcs = true)
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
825 {
9463
d34baf412786 support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents: 9450
diff changeset
826 return rep->find_function (args, local_funcs);
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
827 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
828
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
829 void install_cmdline_function (const octave_value& f)
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
830 {
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
831 rep->install_cmdline_function (f);
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
23343
49f051ef6f2f local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
834 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
835 const std::string& file_name)
49f051ef6f2f local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
836 {
49f051ef6f2f local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
837 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
838 }
49f051ef6f2f local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
839
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
840 void install_user_function (const octave_value& f)
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
841 {
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
842 rep->install_user_function (f);
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
843 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
844
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
845 void install_built_in_function (const octave_value& f)
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
846 {
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
847 rep->install_built_in_function (f);
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
22893
5ff6716cf157 allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
850 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
851 {
5ff6716cf157 allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
852 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
853 }
5ff6716cf157 allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
854
16605
2f8fb02a6c31 erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
855 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
856
2f8fb02a6c31 erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
857 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
858 {
2f8fb02a6c31 erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
859 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
860 }
2f8fb02a6c31 erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
861
2f8fb02a6c31 erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
862 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
863 {
2f8fb02a6c31 erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
864 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
865 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11584
diff changeset
866
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
867 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
868
23680
ef71711f6d64 rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents: 23667
diff changeset
869 octave_value dump (void) const { return rep->dump (); }
7761
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7753
diff changeset
870
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
871 private:
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
872
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
873 fcn_info_rep *rep;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
874 };
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
875
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
876 symbol_table (void)
23602
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
877 : 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
878 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
879 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
880 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
881 { }
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
882
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
883 // No copying!
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
884
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
885 symbol_table (const symbol_table&) = delete;
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
886
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
887 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
888
23602
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
889 ~symbol_table (void)
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
890 {
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
891 delete m_top_scope;
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
892 delete m_global_scope;
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
893 }
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
894
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
895 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
896 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
897
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
898 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
899
23611
91c8f006ed8b remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents: 23610
diff changeset
900 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
901 {
91c8f006ed8b remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents: 23610
diff changeset
902 if (! m_current_scope)
91c8f006ed8b remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents: 23610
diff changeset
903 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
904
91c8f006ed8b remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents: 23610
diff changeset
905 return m_current_scope;
91c8f006ed8b remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents: 23610
diff changeset
906 }
91c8f006ed8b remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents: 23610
diff changeset
907
23602
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
908 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
909 {
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
910 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
911 }
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
912
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
913 void set_scope (scope *sid)
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
914 {
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
915 set_scope_and_context (sid, 0);
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
916 }
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
917
23602
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
918 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
919 {
23602
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
920 if (sid == m_global_scope)
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
921 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
922
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
923 m_current_scope = sid;
23602
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
924
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
925 if (m_current_scope)
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
926 m_current_scope->set_context (context);
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7489
diff changeset
927 }
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7489
diff changeset
928
23603
18bd46c4b79a make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents: 23602
diff changeset
929 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
930 {
23602
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
931 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
932 }
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
933
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
934 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
935 {
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
936 return find_symbol (name, m_current_scope);
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
937 }
4009
27e461aed956 [project @ 2002-07-31 09:33:03 by jwe]
jwe
parents: 3968
diff changeset
938
23603
18bd46c4b79a make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents: 23602
diff changeset
939 void inherit (scope *recipient_scope, scope *donor_scope)
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
940 {
23602
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
941 if (recipient_scope)
23611
91c8f006ed8b remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents: 23610
diff changeset
942 recipient_scope->inherit (donor_scope);
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
943 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
944
23611
91c8f006ed8b remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents: 23610
diff changeset
945 void inherit (scope *recipient_scope)
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
946 {
23611
91c8f006ed8b remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents: 23610
diff changeset
947 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
948 }
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
949
23602
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
950 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
951
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
952 // 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
953 octave_value
23602
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
954 find (const std::string& name,
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
955 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
956 bool skip_variables = false,
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
957 bool local_funcs = true);
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
958
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
959 octave_value builtin_find (const std::string& name);
9444
0c785ad961fa improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents: 9443
diff changeset
960
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
961 void
16442
302157614308 deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents: 16320
diff changeset
962 global_assign (const std::string& name,
302157614308 deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents: 16320
diff changeset
963 const octave_value& value = octave_value ())
302157614308 deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents: 16320
diff changeset
964
302157614308 deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents: 16320
diff changeset
965 {
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
966 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
967
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
968 if (p == m_global_symbols.end ())
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
969 m_global_symbols[name] = value;
16442
302157614308 deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents: 16320
diff changeset
970 else
302157614308 deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents: 16320
diff changeset
971 p->second = 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 octave_value
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7489
diff changeset
975 global_varval (const std::string& name)
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7489
diff changeset
976 {
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
977 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
978
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
979 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
980 }
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7489
diff changeset
981
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
982 void
16442
302157614308 deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents: 16320
diff changeset
983 top_level_assign (const std::string& name,
302157614308 deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents: 16320
diff changeset
984 const octave_value& value = octave_value ())
302157614308 deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents: 16320
diff changeset
985 {
23610
2fe11412e785 remove deprecated and unused symbol_table functions
John W. Eaton <jwe@octave.org>
parents: 23604
diff changeset
986 m_top_scope->assign (name, value);
16442
302157614308 deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents: 16320
diff changeset
987 }
302157614308 deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents: 16320
diff changeset
988
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
989 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
990 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
991 {
23610
2fe11412e785 remove deprecated and unused symbol_table functions
John W. Eaton <jwe@octave.org>
parents: 23604
diff changeset
992 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
993 }
2ba69be3f3e8 accept scope as argument in most static symbol_table functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
994
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
995 bool
23602
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
996 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
997 {
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
998 octave_value val = find_built_in_function (name);
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
999
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1000 return val.is_defined ();
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1001 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1002
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1003 octave_value
23602
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
1004 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
1005 {
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1006 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
1007
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1008 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
1009 {
dfce76507f4b Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents: 21244
diff changeset
1010 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
1011
dfce76507f4b Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents: 21244
diff changeset
1012 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
1013 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
1014
dfce76507f4b Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents: 21244
diff changeset
1015 return fcn;
dfce76507f4b Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents: 21244
diff changeset
1016 }
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1017 else
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1018 {
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1019 fcn_info finfo (name);
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1020
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1021 octave_value fcn = finfo.find_method (dispatch_type);
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1022
21264
dfce76507f4b Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents: 21244
diff changeset
1023 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
1024 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
1025
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1026 if (fcn.is_defined ())
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1027 m_fcn_table[name] = finfo;
10313
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 return fcn;
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1030 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1031 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1032
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1033 octave_value
23602
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
1034 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
1035
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1036 octave_value
23602
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
1037 find_built_in_function (const std::string& name)
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1038 {
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1039 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
1040
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1041 return (p != m_fcn_table.end ()
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1042 ? p->second.find_built_in_function () : octave_value ());
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1043 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1044
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1045 octave_value
23602
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
1046 find_autoload (const std::string& name)
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1047 {
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1048 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
1049
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1050 return (p != m_fcn_table.end ()
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1051 ? p->second.find_autoload () : octave_value ());
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1052 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1053
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1054 octave_value
23602
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
1055 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
1056 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
1057 bool local_funcs = true);
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1058
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1059 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
1060 {
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1061 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
1062
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1063 return (p != m_fcn_table.end ()
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1064 ? p->second.find_user_function () : octave_value ());
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1065 }
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_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
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_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
1073 }
abf85f8cbd6c Expand type() to work on command-line entered functions (bug #40462).
John W. Eaton <jwe@octave.org>
parents: 19861
diff changeset
1074
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1075 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
1076 const octave_value& fcn)
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1077 {
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1078 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
1079
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1080 if (p != m_fcn_table.end ())
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1081 {
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1082 fcn_info& finfo = p->second;
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1083
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1084 finfo.install_cmdline_function (fcn);
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1085 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1086 else
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1087 {
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1088 fcn_info finfo (name);
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1089
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1090 finfo.install_cmdline_function (fcn);
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1091
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1092 m_fcn_table[name] = finfo;
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 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1095
23343
49f051ef6f2f local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
1096 // 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
1097 // the file containing the local function.
49f051ef6f2f local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
1098
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1099 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
1100 const octave_value& fcn,
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1101 const std::string& file_name)
23343
49f051ef6f2f local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
1102 {
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1103 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
1104
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1105 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
1106 {
49f051ef6f2f local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
1107 fcn_info& finfo = p->second;
49f051ef6f2f local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
1108
49f051ef6f2f local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
1109 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
1110 }
49f051ef6f2f local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
1111 else
49f051ef6f2f local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
1112 {
49f051ef6f2f local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
1113 fcn_info finfo (name);
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 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
1116
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1117 m_fcn_table[name] = finfo;
23343
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 }
49f051ef6f2f local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
1120
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1121 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
1122 const octave_value& fcn)
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1123 {
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1124 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
1125
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1126 if (p != m_fcn_table.end ())
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1127 {
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1128 fcn_info& finfo = p->second;
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1129
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1130 finfo.install_user_function (fcn);
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1131 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1132 else
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1133 {
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1134 fcn_info finfo (name);
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1135
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1136 finfo.install_user_function (fcn);
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1137
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1138 m_fcn_table[name] = finfo;
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 }
605
4f65175911a6 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents: 572
diff changeset
1141
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1142 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
1143 const octave_value& fcn)
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1144 {
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1145 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
1146
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1147 if (p != m_fcn_table.end ())
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1148 {
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1149 fcn_info& finfo = p->second;
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1150
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1151 finfo.install_built_in_function (fcn);
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1152 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1153 else
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1154 {
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1155 fcn_info finfo (name);
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1156
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1157 finfo.install_built_in_function (fcn);
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1158
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1159 m_fcn_table[name] = finfo;
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 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1162
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1163 void clear_all (bool force = false)
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1164 {
23611
91c8f006ed8b remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents: 23610
diff changeset
1165 if (m_current_scope)
91c8f006ed8b remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents: 23610
diff changeset
1166 {
91c8f006ed8b remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents: 23610
diff changeset
1167 m_current_scope->clear_variables ();
91c8f006ed8b remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents: 23610
diff changeset
1168 m_current_scope->clear_global_pattern ("*");
91c8f006ed8b remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents: 23610
diff changeset
1169 }
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1170
16605
2f8fb02a6c31 erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents: 16596
diff changeset
1171 clear_functions (force);
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1172 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1173
21813
2ba69be3f3e8 accept scope as argument in most static symbol_table functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
1174 // 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
1175 // 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
1176 // unwind_protect.
2ba69be3f3e8 accept scope as argument in most static symbol_table functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
1177
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1178 void clear_functions (bool force = false)
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1179 {
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1180 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
1181
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1182 while (p != m_fcn_table.end ())
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1183 (p++)->second.clear (force);
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1184 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
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_function (const std::string& name)
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1187 {
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1188 clear_user_function (name);
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1189 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1190
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1191 void clear_symbol (const std::string& name)
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1192 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1193 // FIXME: are we supposed to do both here?
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1194
23611
91c8f006ed8b remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents: 23610
diff changeset
1195 if (m_current_scope)
91c8f006ed8b remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents: 23610
diff changeset
1196 m_current_scope->clear_variable (name);
91c8f006ed8b remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents: 23610
diff changeset
1197
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1198 clear_function (name);
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1199 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1200
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1201 void clear_function_pattern (const std::string& pat)
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1202 {
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1203 glob_match pattern (pat);
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1204
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1205 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
1206
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1207 while (p != m_fcn_table.end ())
7336
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 if (pattern.match (p->first))
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1210 (p++)->second.clear_user_function ();
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1211 else
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1212 p++;
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1213 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1214 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1215
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1216 void clear_symbol_pattern (const std::string& pat)
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1217 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1218 // FIXME: are we supposed to do both here?
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1219
23611
91c8f006ed8b remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents: 23610
diff changeset
1220 if (m_current_scope)
91c8f006ed8b remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents: 23610
diff changeset
1221 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
1222
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1223 clear_function_pattern (pat);
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1224 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1225
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1226 void clear_user_function (const std::string& name)
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1227 {
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1228 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
1229
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1230 if (p != m_fcn_table.end ())
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1231 {
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1232 fcn_info& finfo = p->second;
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1233
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1234 finfo.clear_user_function ();
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1235 }
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1236 // FIXME: is this necessary, or even useful?
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1237 // else
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1238 // 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
1239 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1240
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21574
diff changeset
1241 // 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
1242 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
1243 {
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1244 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
1245
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1246 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
1247 {
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1248 fcn_info& finfo = p->second;
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1249
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1250 finfo.clear_autoload_function ();
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1251 finfo.clear_user_function ();
9958
80432f0ee895 improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents: 9639
diff changeset
1252 }
80432f0ee895 improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents: 9639
diff changeset
1253 }
80432f0ee895 improve octave_shlib for safer shared libs treatment
Jaroslav Hajek <highegg@gmail.com>
parents: 9639
diff changeset
1254
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1255 void clear_mex_functions (void)
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1256 {
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1257 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
1258
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1259 while (p != m_fcn_table.end ())
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1260 (p++)->second.clear_mex_function ();
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1261 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1262
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1263 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
1264 const std::string& inf_class);
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1265
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1266 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
1267
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1268 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
1269 const std::string& name)
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1270 {
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1271 octave_value fcn = find_built_in_function (name);
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1272
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1273 if (fcn.is_defined ())
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1274 {
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1275 fcn_info finfo (alias);
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1276
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1277 finfo.install_built_in_function (fcn);
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1278
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1279 m_fcn_table[alias] = finfo;
7336
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 else
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1282 panic ("alias: '%s' is undefined", name.c_str ());
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1283 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1284
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1285 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
1286 const std::string& klass)
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1287 {
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1288 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
1289
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1290 if (p != m_fcn_table.end ())
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1291 {
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1292 fcn_info& finfo = p->second;
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1293
22893
5ff6716cf157 allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
1294 finfo.install_built_in_dispatch (klass);
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1295 }
22893
5ff6716cf157 allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
1296 else
5ff6716cf157 allow dispatch types to be declared for built-in functions
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
1297 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
1298 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1299
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1300 void push_context (void)
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1301 {
23602
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
1302 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
1303 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
1304
23602
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
1305 if (m_current_scope)
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
1306 m_current_scope->push_context ();
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1307 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1308
21813
2ba69be3f3e8 accept scope as argument in most static symbol_table functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
1309 // 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
1310 // 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
1311 // unwind_protect.
2ba69be3f3e8 accept scope as argument in most static symbol_table functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
1312
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1313 void pop_context (void)
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1314 {
23602
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
1315 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
1316 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
1317
23602
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
1318 if (m_current_scope)
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
1319 m_current_scope->pop_context ();
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1320 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1321
21813
2ba69be3f3e8 accept scope as argument in most static symbol_table functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
1322 // 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
1323
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1324 void pop_context (void *) { pop_context (); }
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1325
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1326 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
1327 {
23602
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
1328 return (m_current_scope
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
1329 ? 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
1330 }
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1331
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1332 std::list<symbol_record>
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7489
diff changeset
1333 glob_global_variables (const std::string& pattern)
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7489
diff changeset
1334 {
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7489
diff changeset
1335 std::list<symbol_record> retval;
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7489
diff changeset
1336
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7489
diff changeset
1337 glob_match pat (pattern);
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7489
diff changeset
1338
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1339 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
1340 {
22862
e365e87371a3 maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents: 22755
diff changeset
1341 // 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
1342 // 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
1343 // way.
e365e87371a3 maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents: 22755
diff changeset
1344 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
1345 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
1346 nm_val.first, nm_val.second,
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1347 symbol_record::global));
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7489
diff changeset
1348 }
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7489
diff changeset
1349
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7489
diff changeset
1350 return retval;
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7489
diff changeset
1351 }
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7489
diff changeset
1352
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1353 std::list<symbol_record>
7779
791231dac333 Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents: 7767
diff changeset
1354 regexp_global_variables (const std::string& pattern)
791231dac333 Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents: 7767
diff changeset
1355 {
791231dac333 Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents: 7767
diff changeset
1356 std::list<symbol_record> retval;
791231dac333 Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents: 7767
diff changeset
1357
22333
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1358 octave::regexp pat (pattern);
7779
791231dac333 Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents: 7767
diff changeset
1359
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1360 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
1361 {
22862
e365e87371a3 maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents: 22755
diff changeset
1362 // 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
1363 // 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
1364 // way.
e365e87371a3 maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents: 22755
diff changeset
1365 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
1366 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
1367 nm_val.first, nm_val.second,
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1368 symbol_record::global));
7779
791231dac333 Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents: 7767
diff changeset
1369 }
791231dac333 Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents: 7767
diff changeset
1370
791231dac333 Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents: 7767
diff changeset
1371 return retval;
791231dac333 Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents: 7767
diff changeset
1372 }
791231dac333 Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents: 7767
diff changeset
1373
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1374 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
1375 {
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1376 std::list<symbol_record> retval;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1377
23644
3177e276e60f avoid inifite recursion in symbol table glob and regexp functions
John W. Eaton <jwe@octave.org>
parents: 23611
diff changeset
1378 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
1379 return retval;
3177e276e60f avoid inifite recursion in symbol table glob and regexp functions
John W. Eaton <jwe@octave.org>
parents: 23611
diff changeset
1380
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20207
diff changeset
1381 size_t len = patterns.numel ();
8
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
1382
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1383 for (size_t i = 0; i < len; i++)
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1384 {
23644
3177e276e60f avoid inifite recursion in symbol table glob and regexp functions
John W. Eaton <jwe@octave.org>
parents: 23611
diff changeset
1385 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
1386
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1387 retval.insert (retval.begin (), tmp.begin (), tmp.end ());
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1388 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1389
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1390 return retval;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1391 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1392
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1393 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
1394 {
791231dac333 Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents: 7767
diff changeset
1395 std::list<symbol_record> retval;
791231dac333 Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents: 7767
diff changeset
1396
23644
3177e276e60f avoid inifite recursion in symbol table glob and regexp functions
John W. Eaton <jwe@octave.org>
parents: 23611
diff changeset
1397 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
1398 return retval;
3177e276e60f avoid inifite recursion in symbol table glob and regexp functions
John W. Eaton <jwe@octave.org>
parents: 23611
diff changeset
1399
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20207
diff changeset
1400 size_t len = patterns.numel ();
7779
791231dac333 Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents: 7767
diff changeset
1401
791231dac333 Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents: 7767
diff changeset
1402 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
1403 {
23644
3177e276e60f avoid inifite recursion in symbol table glob and regexp functions
John W. Eaton <jwe@octave.org>
parents: 23611
diff changeset
1404 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
1405
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1406 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
1407 }
791231dac333 Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents: 7767
diff changeset
1408
791231dac333 Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents: 7767
diff changeset
1409 return retval;
791231dac333 Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents: 7767
diff changeset
1410 }
791231dac333 Add regexp matching to Fwho and Fclear
David Bateman <dbateman@free.fr>
parents: 7767
diff changeset
1411
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1412 std::list<std::string> user_function_names (void)
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1413 {
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1414 std::list<std::string> retval;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1415
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1416 for (const auto& nm_finfo : m_fcn_table)
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1417 {
22862
e365e87371a3 maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents: 22755
diff changeset
1418 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
1419 retval.push_back (nm_finfo.first);
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1420 }
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 if (! retval.empty ())
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1423 retval.sort ();
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1424
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1425 return retval;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1426 }
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
1427
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1428 std::list<std::string> global_variable_names (void)
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1429 {
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7489
diff changeset
1430 std::list<std::string> retval;
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7489
diff changeset
1431
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1432 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
1433 retval.push_back (nm_val.first);
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7489
diff changeset
1434
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7489
diff changeset
1435 retval.sort ();
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7489
diff changeset
1436
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7489
diff changeset
1437 return retval;
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7489
diff changeset
1438 }
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 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
1441 {
23602
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
1442 return (m_top_scope
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
1443 ? 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
1444 }
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7489
diff changeset
1445
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1446 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
1447 {
23602
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
1448 return (m_current_scope
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
1449 ? 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
1450 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1451
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1452 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
1453 {
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1454 std::list<std::string> retval;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1455
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1456 for (const auto& nm_finfo : m_fcn_table)
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1457 {
22862
e365e87371a3 maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents: 22755
diff changeset
1458 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
1459
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1460 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
1461 retval.push_back (nm_finfo.first);
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1462 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1463
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1464 if (! retval.empty ())
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1465 retval.sort ();
220
f736a3ec137e [project @ 1993-11-14 00:10:26 by jwe]
jwe
parents: 200
diff changeset
1466
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1467 return retval;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1468 }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
1469
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1470 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
1471 {
d6151d774283 make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents: 12130
diff changeset
1472 std::list<std::string> retval;
d6151d774283 make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents: 12130
diff changeset
1473
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1474 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
1475 {
22862
e365e87371a3 maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents: 22755
diff changeset
1476 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
1477
d6151d774283 make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents: 12130
diff changeset
1478 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
1479 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
1480 }
d6151d774283 make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents: 12130
diff changeset
1481
d6151d774283 make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents: 12130
diff changeset
1482 if (! retval.empty ())
d6151d774283 make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents: 12130
diff changeset
1483 retval.sort ();
d6151d774283 make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents: 12130
diff changeset
1484
d6151d774283 make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents: 12130
diff changeset
1485 return retval;
d6151d774283 make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents: 12130
diff changeset
1486 }
d6151d774283 make completion work for command-line functions
John W. Eaton <jwe@octave.org>
parents: 12130
diff changeset
1487
23680
ef71711f6d64 rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents: 23667
diff changeset
1488 octave_value dump (void) const;
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1489
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1490 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
1491 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
1492 {
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1493 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
1494 }
3d0d2bda3a0f fix previous change, avoid duplicate loads of methods in descendant classes
Jaroslav Hajek <highegg@gmail.com>
parents: 9509
diff changeset
1495
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1496 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
1497 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
1498 {
1783b360976f also consider parent classes when checking if class methods are out of date
John W. Eaton <jwe@octave.org>
parents: 10633
diff changeset
1499 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
1500
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1501 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
1502
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1503 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
1504 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
1505
22862
e365e87371a3 maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents: 22755
diff changeset
1506 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
1507 {
3229572cbe23 symbol_table::parent_classes: also add parents of parents to the list
John W. Eaton <jwe@octave.org>
parents: 12122
diff changeset
1508 // 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
1509
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1510 // 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
1511
22862
e365e87371a3 maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents: 22755
diff changeset
1512 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
1513
3229572cbe23 symbol_table::parent_classes: also add parents of parents to the list
John W. Eaton <jwe@octave.org>
parents: 12122
diff changeset
1514 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
1515 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
1516 }
3229572cbe23 symbol_table::parent_classes: also add parents of parents to the list
John W. Eaton <jwe@octave.org>
parents: 12122
diff changeset
1517
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
1518 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
1519 }
1783b360976f also consider parent classes when checking if class methods are out of date
John W. Eaton <jwe@octave.org>
parents: 10633
diff changeset
1520
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1521 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
1522 {
23602
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
1523 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
1524 }
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1525
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1526 void cleanup (void);
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1527
23680
ef71711f6d64 rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents: 23667
diff changeset
1528 fcn_info * get_fcn_info (const std::string& name)
ef71711f6d64 rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents: 23667
diff changeset
1529 {
ef71711f6d64 rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents: 23667
diff changeset
1530 fcn_table_iterator p = m_fcn_table.find (name);
ef71711f6d64 rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents: 23667
diff changeset
1531 return p != m_fcn_table.end () ? &p->second : 0;
ef71711f6d64 rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents: 23667
diff changeset
1532 }
ef71711f6d64 rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents: 23667
diff changeset
1533
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1534 class scope
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1535 {
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1536 public:
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 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
1539 table_const_iterator;
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1540 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
1541 table_iterator;
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1542
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1543 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
1544 m_persistent_symbols_const_iterator;
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1545 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
1546 m_persistent_symbols_iterator;
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1547
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1548 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
1549 subfunctions_const_iterator;
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1550 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
1551
23602
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
1552 scope (const std::string& name = "")
23680
ef71711f6d64 rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents: 23667
diff changeset
1553 : m_name (name), m_symbols (), m_persistent_symbols (), m_subfunctions (),
ef71711f6d64 rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents: 23667
diff changeset
1554 m_fcn (0), m_parent (0), m_children (), m_is_nested (false),
ef71711f6d64 rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents: 23667
diff changeset
1555 m_is_static (false), m_context (0)
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1556 { }
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1557
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1558 // No copying!
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1559
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1560 scope (const scope&) = delete;
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1561
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1562 scope& operator = (const scope&) = delete;
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 ~scope (void) = default;
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 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
1567 {
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1568 m_symbols[sr.name ()] = sr;
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
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1571 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
1572
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1573 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
1574
23602
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
1575 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
1576
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
1577 scope * dup (void) const
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1578 {
23602
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
1579 scope *new_sid = new scope ();
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1580
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1581 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
1582 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
1583
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
1584 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
1585
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
1586 return new_sid;
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1587 }
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1588
23602
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
1589 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
1590
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
1591 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
1592
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1593 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
1594 {
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1595 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
1596
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1597 if (p == m_symbols.end ())
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1598 return insert (name);
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1599 else
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1600 return p->second;
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1601 }
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1602
23611
91c8f006ed8b remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents: 23610
diff changeset
1603 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
1604 {
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1605 for (auto& nm_sr : m_symbols)
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1606 {
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1607 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
1608
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1609 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
1610 {
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1611 std::string nm = sr.name ();
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 if (nm != "__retval__")
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1614 {
23603
18bd46c4b79a make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents: 23602
diff changeset
1615 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
1616
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1617 if (val.is_defined ())
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1618 {
23603
18bd46c4b79a make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents: 23602
diff changeset
1619 sr.assign (val);
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1620
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1621 sr.mark_inherited ();
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 }
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1624 }
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1625 }
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
23611
91c8f006ed8b remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents: 23610
diff changeset
1628 void inherit (scope *donor_scope)
91c8f006ed8b remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents: 23610
diff changeset
1629 {
91c8f006ed8b remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents: 23610
diff changeset
1630 while (donor_scope)
91c8f006ed8b remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents: 23610
diff changeset
1631 {
91c8f006ed8b remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents: 23610
diff changeset
1632 inherit_internal (*donor_scope);
91c8f006ed8b remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents: 23610
diff changeset
1633
91c8f006ed8b remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents: 23610
diff changeset
1634 if (donor_scope->is_nested ())
91c8f006ed8b remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents: 23610
diff changeset
1635 donor_scope = donor_scope->parent_scope ();
91c8f006ed8b remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents: 23610
diff changeset
1636 else
91c8f006ed8b remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents: 23610
diff changeset
1637 break;
91c8f006ed8b remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents: 23610
diff changeset
1638 }
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
91c8f006ed8b remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents: 23610
diff changeset
1641
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1642 octave_value
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1643 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
1644 bool skip_variables, bool local_funcs);
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1645
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1646 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
1647
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1648 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
1649 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
1650
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1651 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
1652 {
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1653 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
1654
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1655 if (p != m_symbols.end ())
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 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
1658
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1659 sr.rename (new_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 m_symbols.erase (p);
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 m_symbols[new_name] = sr;
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 }
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 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
1668 bool force_add)
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1669 {
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1670 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
1671
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1672 if (p == m_symbols.end ())
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1673 {
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1674 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
1675
23603
18bd46c4b79a make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents: 23602
diff changeset
1676 sr.assign (value);
23599
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 else
23603
18bd46c4b79a make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents: 23602
diff changeset
1679 p->second.assign (value);
23602
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
1680 }
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
1681
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1682 void assign (const std::string& name,
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1683 const octave_value& value = octave_value ())
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1684 {
23603
18bd46c4b79a make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents: 23602
diff changeset
1685 assign (name, value, false);
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1686 }
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1687
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1688 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
1689 {
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1690 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
1691
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1692 if (p == m_symbols.end ())
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 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
1695
23603
18bd46c4b79a make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents: 23602
diff changeset
1696 sr.assign (value);
23599
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 else
23603
18bd46c4b79a make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents: 23602
diff changeset
1699 p->second.assign (value);
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1700 }
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 // 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
1703 // 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
1704 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
1705 {
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1706 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
1707
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1708 if (p == m_symbols.end ())
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1709 {
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1710 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
1711
23603
18bd46c4b79a make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents: 23602
diff changeset
1712 return sr.varref ();
23599
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 else
23603
18bd46c4b79a make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents: 23602
diff changeset
1715 return p->second.varref ();
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1716 }
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1717
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1718 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
1719 {
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1720 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
1721
23602
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
1722 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
1723 ? p->second.varval () : octave_value ());
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1724 }
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 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
1727 {
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1728 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
1729
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1730 if (p == m_persistent_symbols.end ())
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1731 m_persistent_symbols[name] = value;
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1732 else
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1733 p->second = value;
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1734 }
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 // Use persistent_assign (name, value) instead.
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1737 // 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
1738 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
1739 {
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1740 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
1741
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1742 return (p == m_persistent_symbols.end ()
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1743 ? m_persistent_symbols[name] : p->second);
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1744 }
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 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
1747 {
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1748 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
1749
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1750 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
1751 }
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1752
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1753 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
1754 {
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1755 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
1756
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1757 if (p != m_persistent_symbols.end ())
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1758 m_persistent_symbols.erase (p);
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1759 }
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 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
1762 {
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1763 bool retval = false;
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1764
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1765 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
1766
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1767 if (p != m_symbols.end ())
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 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
1770
23603
18bd46c4b79a make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents: 23602
diff changeset
1771 retval = sr.is_variable ();
23599
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
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1774 return retval;
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1775 }
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1776
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1777 void push_context (void)
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 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
1780 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
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 pop_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 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
1786
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1787 while (tbl_it != m_symbols.end ())
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1788 {
23602
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
1789 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
1790 m_symbols.erase (tbl_it++);
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1791 else
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1792 tbl_it++;
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1793 }
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1794 }
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1795
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1796 void clear_variables (void)
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1797 {
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1798 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
1799 nm_sr.second.clear (this);
23599
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_objects (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)
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1805 {
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1806 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
1807 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
1808 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
1809 nm_sr.second.clear (this);
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1810 }
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1811 }
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1812
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1813 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
1814
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1815 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
1816 {
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1817 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
1818
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1819 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
1820 p->second.clear (this);
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1821 }
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 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
1824
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1825 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
1826 {
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1827 glob_match pattern (pat);
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 for (auto& nm_sr : m_symbols)
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 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
1832
23603
18bd46c4b79a make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents: 23602
diff changeset
1833 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
1834 {
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1835 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
1836 sr.clear (this);
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1837 }
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1838 }
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1839 }
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 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
1842 {
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1843 octave::regexp pattern (pat);
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 for (auto& nm_sr : m_symbols)
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 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
1848
23603
18bd46c4b79a make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents: 23602
diff changeset
1849 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
1850 {
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1851 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
1852 sr.clear (this);
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1853 }
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1854 }
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1855 }
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 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
1858 {
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1859 insert (name).mark_automatic ();
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 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
1863 {
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1864 insert (name).mark_hidden ();
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1865 }
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 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
1868 {
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1869 insert (name).mark_global ();
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1870 }
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 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
1873 all_variables (bool defined_only = true,
91c8f006ed8b remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents: 23610
diff changeset
1874 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
1875 {
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1876 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
1877
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1878 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
1879 {
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1880 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
1881
23603
18bd46c4b79a make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents: 23602
diff changeset
1882 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
1883 || (sr.xstorage_class () & exclude))
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1884 continue;
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 retval.push_back (sr);
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1887 }
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1888
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1889 return retval;
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1890 }
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 std::list<symbol_table::symbol_record>
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1893 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
1894 {
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1895 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
1896
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1897 glob_match pat (pattern);
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1898
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1899 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
1900 {
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1901 if (pat.match (nm_sr.first))
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 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
1904
23603
18bd46c4b79a make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents: 23602
diff changeset
1905 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
1906 continue;
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1907
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1908 retval.push_back (sr);
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1909 }
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1910 }
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1911
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1912 return retval;
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
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1915 std::list<symbol_table::symbol_record>
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1916 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
1917 {
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1918 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
1919
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1920 octave::regexp pat (pattern);
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1921
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1922 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
1923 {
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1924 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
1925 {
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1926 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
1927
23603
18bd46c4b79a make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents: 23602
diff changeset
1928 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
1929 continue;
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1930
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1931 retval.push_back (sr);
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1932 }
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1933 }
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1934
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1935 return retval;
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
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1938 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
1939 {
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1940 std::list<std::string> retval;
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1941
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1942 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
1943 {
23603
18bd46c4b79a make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents: 23602
diff changeset
1944 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
1945 retval.push_back (nm_sr.first);
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1946 }
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 retval.sort ();
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1949
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1950 return retval;
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1951 }
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 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
1954 {
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1955 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
1956
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1957 return (p != m_symbols.end ()
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1958 && ! 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
1959 && p->second.is_defined ());
23599
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
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1962 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
1963 {
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1964 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
1965
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1966 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
1967 }
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1968
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1969 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
1970 const octave_value& fval,
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1971 bool is_nested = false);
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1972
23611
91c8f006ed8b remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents: 23610
diff changeset
1973 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
1974 const octave_value& fval)
91c8f006ed8b remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents: 23610
diff changeset
1975 {
91c8f006ed8b remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents: 23610
diff changeset
1976 install_subfunction (name, fval, true);
91c8f006ed8b remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents: 23610
diff changeset
1977 }
91c8f006ed8b remove additional functions from symbol_table class
John W. Eaton <jwe@octave.org>
parents: 23610
diff changeset
1978
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1979 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
1980
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1981 void lock_subfunctions (void)
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1982 {
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1983 for (auto& nm_sf : m_subfunctions)
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1984 nm_sf.second.lock ();
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1985 }
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 unlock_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.unlock ();
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 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
1994 {
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1995 return m_subfunctions;
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1996 }
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 void erase_subfunctions (void)
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
1999 {
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
2000 m_subfunctions.clear ();
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
2001 }
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 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
2004
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
2005 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
2006
23680
ef71711f6d64 rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents: 23667
diff changeset
2007 octave_value dump (void) const;
23599
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 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
2010
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
2011 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
2012
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
2013 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
2014
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
2015 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
2016
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
2017 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
2018
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
2019 void update_nest (void);
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 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
2022 symbol_table::symbol_record& result);
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
2023
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
2024 private:
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
2025
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
2026 // 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
2027 // function corresponding to the scope).
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
2028 std::string m_name;
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 // 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
2031 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
2032
23680
ef71711f6d64 rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents: 23667
diff changeset
2033 // Map from names of persistent variables to values.
ef71711f6d64 rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents: 23667
diff changeset
2034 std::map<std::string, octave_value> m_persistent_symbols;
23599
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 subfunctions.
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
2037 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
2038
23680
ef71711f6d64 rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents: 23667
diff changeset
2039 // The associated user code (may be null).
ef71711f6d64 rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents: 23667
diff changeset
2040 octave_user_function *m_fcn;
ef71711f6d64 rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents: 23667
diff changeset
2041
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
2042 // 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
2043 scope *m_parent;
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
2044
23680
ef71711f6d64 rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents: 23667
diff changeset
2045 // Child nested functions.
ef71711f6d64 rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents: 23667
diff changeset
2046 std::vector<scope*> m_children;
23599
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 // 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
2049 bool m_is_nested;
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 no variables can be added.
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
2052 bool m_is_static;
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
2053
23602
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
2054 context_id m_context;
23680
ef71711f6d64 rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents: 23667
diff changeset
2055
ef71711f6d64 rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents: 23667
diff changeset
2056 octave_value dump_symbols_map (void) const;
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
2057 };
9981
692ab4eaf965 clean up top-level variables when exiting Octave
Jaroslav Hajek <highegg@gmail.com>
parents: 9958
diff changeset
2058
8
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
2059 private:
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
2060
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2061 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
2062 global_symbols_const_iterator;
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2063 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
2064 global_symbols_iterator;
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
2065
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2066 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
2067 fcn_table_const_iterator;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2068 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
2069 fcn_table_iterator;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2070
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7489
diff changeset
2071 // 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
2072 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
2073
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
2074 // Map from function names to function info (private
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7067
diff changeset
2075 // 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
2076 // 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
2077 // them.
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
2078 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
2079
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
2080 // 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
2081 // precedence.
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
2082 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
2083
b6498c088fca maint: Don't write '> >' for declaration of templates that use templates.
Rik <rik@octave.org>
parents: 23457
diff changeset
2084 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
2085 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
2086 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
2087 class_precedence_table_iterator;
7972
5bf4e2c13ed8 make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents: 7901
diff changeset
2088
9581
3d0d2bda3a0f fix previous change, avoid duplicate loads of methods in descendant classes
Jaroslav Hajek <highegg@gmail.com>
parents: 9509
diff changeset
2089 // 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
2090 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
2091
b6498c088fca maint: Don't write '> >' for declaration of templates that use templates.
Rik <rik@octave.org>
parents: 23457
diff changeset
2092 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
2093 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
2094 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
2095 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
2096
23602
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
2097 scope *m_global_scope;
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
2098 scope *m_top_scope;
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
2099
214cb58ccc1c use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents: 23599
diff changeset
2100 scope *m_current_scope;
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7489
diff changeset
2101
23680
ef71711f6d64 rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents: 23667
diff changeset
2102 octave_value dump_fcn_table_map (void) const;
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
2103 };
2790
ecc1a12678de [project @ 1997-03-05 02:47:54 by jwe]
jwe
parents: 2404
diff changeset
2104
9450
cf714e75c656 implement overloaded function handles
Jaroslav Hajek <highegg@gmail.com>
parents: 9446
diff changeset
2105 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
2106 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
2107 bool check_relative = true);
9450
cf714e75c656 implement overloaded function handles
Jaroslav Hajek <highegg@gmail.com>
parents: 9446
diff changeset
2108
10087
090173f2db40 improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents: 10071
diff changeset
2109 extern OCTINTERP_API std::string
090173f2db40 improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents: 10071
diff changeset
2110 get_dispatch_type (const octave_value_list& args);
22653
e7a9dfb8bf16 remove obsolete function __dispatch__
John W. Eaton <jwe@octave.org>
parents: 22407
diff changeset
2111
10087
090173f2db40 improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents: 10071
diff changeset
2112 extern OCTINTERP_API std::string
10321
97b4bd6f0925 partially rewrite function handles
Jaroslav Hajek <highegg@gmail.com>
parents: 10313
diff changeset
2113 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
2114
8
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
2115 #endif