annotate src/symtab.h @ 3355:c4983fc7318f

[project @ 1999-11-18 05:20:50 by jwe]
author jwe
date Thu, 18 Nov 1999 05:20:52 +0000
parents 2efa28a91e7a
children d2e12e998a78
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
2847
8b262e771614 [project @ 1997-03-27 16:18:26 by jwe]
jwe
parents: 2846
diff changeset
3 Copyright (C) 1996, 1997 John W. Eaton
8
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
4
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
6
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
9 Free Software Foundation; either version 2, or (at your option) any
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
10 later version.
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
11
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
15 for more details.
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
16
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
18 along with Octave; see the file COPYING. If not, write to the Free
1315
611d403c7f3d [project @ 1995-06-25 19:56:32 by jwe]
jwe
parents: 1297
diff changeset
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
8
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
20
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
383
0b52c68ec81f [project @ 1994-03-09 21:19:44 by jwe]
jwe
parents: 276
diff changeset
23 #if !defined (octave_symtab_h)
0b52c68ec81f [project @ 1994-03-09 21:19:44 by jwe]
jwe
parents: 276
diff changeset
24 #define octave_symtab_h 1
8
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
25
1297
12ecc2ecf0e3 [project @ 1995-05-01 18:39:43 by jwe]
jwe
parents: 1009
diff changeset
26 #if defined (__GNUG__)
12ecc2ecf0e3 [project @ 1995-05-01 18:39:43 by jwe]
jwe
parents: 1009
diff changeset
27 #pragma interface
12ecc2ecf0e3 [project @ 1995-05-01 18:39:43 by jwe]
jwe
parents: 1009
diff changeset
28 #endif
12ecc2ecf0e3 [project @ 1995-05-01 18:39:43 by jwe]
jwe
parents: 1009
diff changeset
29
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
30 #include <cassert>
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
31
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1738
diff changeset
32 #include <string>
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1738
diff changeset
33
220
f736a3ec137e [project @ 1993-11-14 00:10:26 by jwe]
jwe
parents: 200
diff changeset
34 #include "SLStack.h"
f736a3ec137e [project @ 1993-11-14 00:10:26 by jwe]
jwe
parents: 200
diff changeset
35
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
36 #include "oct-alloc.h"
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1738
diff changeset
37 #include "str-vec.h"
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1738
diff changeset
38
2975
b9c107cbe388 [project @ 1997-05-15 20:01:00 by jwe]
jwe
parents: 2956
diff changeset
39 #include "ov.h"
b9c107cbe388 [project @ 1997-05-15 20:01:00 by jwe]
jwe
parents: 2956
diff changeset
40
2979
a3556d2adec9 [project @ 1997-05-15 22:35:37 by jwe]
jwe
parents: 2975
diff changeset
41 class octave_lvalue;
8
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
42
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1738
diff changeset
43 class string_vector;
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1738
diff changeset
44
8
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
45 class symbol_record;
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
46 class symbol_table;
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
47
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
48 // Individual records in a symbol table.
8
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
49
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
50 class
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
51 symbol_record
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
52 {
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
53 public:
8
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
54
3258
4964d5391acc [project @ 1999-07-21 21:51:33 by jwe]
jwe
parents: 3239
diff changeset
55 // If you add or delete an entry here, you'll also need to change
3325
2efa28a91e7a [project @ 1999-10-29 21:39:20 by jwe]
jwe
parents: 3258
diff changeset
56 // the width parameter in the declaration for symbol_type below...
3258
4964d5391acc [project @ 1999-07-21 21:51:33 by jwe]
jwe
parents: 3239
diff changeset
57
195
13c6086c325c [project @ 1993-11-06 10:12:29 by jwe]
jwe
parents: 186
diff changeset
58 enum TYPE
13c6086c325c [project @ 1993-11-06 10:12:29 by jwe]
jwe
parents: 186
diff changeset
59 {
13c6086c325c [project @ 1993-11-06 10:12:29 by jwe]
jwe
parents: 186
diff changeset
60 UNKNOWN = 0,
13c6086c325c [project @ 1993-11-06 10:12:29 by jwe]
jwe
parents: 186
diff changeset
61 USER_FUNCTION = 1,
13c6086c325c [project @ 1993-11-06 10:12:29 by jwe]
jwe
parents: 186
diff changeset
62 USER_VARIABLE = 2,
3325
2efa28a91e7a [project @ 1999-10-29 21:39:20 by jwe]
jwe
parents: 3258
diff changeset
63 DLD_FUNCTION = 4,
2efa28a91e7a [project @ 1999-10-29 21:39:20 by jwe]
jwe
parents: 3258
diff changeset
64 BUILTIN_FUNCTION = 8,
2efa28a91e7a [project @ 1999-10-29 21:39:20 by jwe]
jwe
parents: 3258
diff changeset
65 TEXT_FUNCTION = 16,
2efa28a91e7a [project @ 1999-10-29 21:39:20 by jwe]
jwe
parents: 3258
diff changeset
66 MAPPER_FUNCTION = 32,
2efa28a91e7a [project @ 1999-10-29 21:39:20 by jwe]
jwe
parents: 3258
diff changeset
67 BUILTIN_VARIABLE = 64,
2efa28a91e7a [project @ 1999-10-29 21:39:20 by jwe]
jwe
parents: 3258
diff changeset
68 BUILTIN_CONSTANT = 128
195
13c6086c325c [project @ 1993-11-06 10:12:29 by jwe]
jwe
parents: 186
diff changeset
69 };
13c6086c325c [project @ 1993-11-06 10:12:29 by jwe]
jwe
parents: 186
diff changeset
70
8
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
71 private:
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
72
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
73 // Variables or functions.
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
74
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
75 class symbol_def
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
76 {
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
77 public:
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
78
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
79 symbol_def (const octave_value& val = octave_value (),
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
80 unsigned int sym_type = 0)
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
81 : symbol_type (sym_type), eternal (0), read_only (0), help_string (),
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
82 definition (val), next_elem (0), count (1) { }
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
83
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
84 ~symbol_def (void) { }
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
85
3258
4964d5391acc [project @ 1999-07-21 21:51:33 by jwe]
jwe
parents: 3239
diff changeset
86 bool is_constant (void) const
4964d5391acc [project @ 1999-07-21 21:51:33 by jwe]
jwe
parents: 3239
diff changeset
87 { return (symbol_type & symbol_record::BUILTIN_CONSTANT); }
4964d5391acc [project @ 1999-07-21 21:51:33 by jwe]
jwe
parents: 3239
diff changeset
88
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
89 bool is_variable (void) const
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
90 {
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
91 return (symbol_type & symbol_record::USER_VARIABLE
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
92 || symbol_type & symbol_record::BUILTIN_VARIABLE);
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
93 }
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
94
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
95 bool is_function (void) const
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
96 {
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
97 return (symbol_type & symbol_record::USER_FUNCTION
3325
2efa28a91e7a [project @ 1999-10-29 21:39:20 by jwe]
jwe
parents: 3258
diff changeset
98 || symbol_type & symbol_record::DLD_FUNCTION
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
99 || symbol_type & symbol_record::BUILTIN_FUNCTION);
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
100 }
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
101
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
102 bool is_user_variable (void) const
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
103 { return (symbol_type & symbol_record::USER_VARIABLE); }
195
13c6086c325c [project @ 1993-11-06 10:12:29 by jwe]
jwe
parents: 186
diff changeset
104
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
105 bool is_text_function (void) const
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
106 { return (symbol_type & symbol_record::TEXT_FUNCTION); }
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
107
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
108 bool is_mapper_function (void) const
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
109 { return (symbol_type & symbol_record::MAPPER_FUNCTION); }
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
110
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
111 bool is_user_function (void) const
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
112 { return (symbol_type & symbol_record::USER_FUNCTION); }
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
113
3258
4964d5391acc [project @ 1999-07-21 21:51:33 by jwe]
jwe
parents: 3239
diff changeset
114 bool is_builtin_constant (void) const
4964d5391acc [project @ 1999-07-21 21:51:33 by jwe]
jwe
parents: 3239
diff changeset
115 { return (symbol_type & symbol_record::BUILTIN_CONSTANT); }
4964d5391acc [project @ 1999-07-21 21:51:33 by jwe]
jwe
parents: 3239
diff changeset
116
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
117 bool is_builtin_variable (void) const
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
118 { return (symbol_type & symbol_record::BUILTIN_VARIABLE); }
195
13c6086c325c [project @ 1993-11-06 10:12:29 by jwe]
jwe
parents: 186
diff changeset
119
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
120 bool is_builtin_function (void) const
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
121 { return (symbol_type & symbol_record::BUILTIN_FUNCTION); }
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
122
3325
2efa28a91e7a [project @ 1999-10-29 21:39:20 by jwe]
jwe
parents: 3258
diff changeset
123 bool is_dld_function (void) const
2efa28a91e7a [project @ 1999-10-29 21:39:20 by jwe]
jwe
parents: 3258
diff changeset
124 { return (symbol_type & symbol_record::DLD_FUNCTION); }
2efa28a91e7a [project @ 1999-10-29 21:39:20 by jwe]
jwe
parents: 3258
diff changeset
125
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
126 // XXX FIXME XXX
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
127 bool is_map_element (const string& /* elts */) const
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
128 { return false; }
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
129
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
130 bool is_defined (void) const
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
131 { return definition.is_defined (); }
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
132
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
133 bool is_read_only (void) const
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
134 { return read_only; }
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
135
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
136 bool is_eternal (void) const
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
137 { return eternal; }
8
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
138
3013
66a1cede95e7 [project @ 1997-06-02 19:35:05 by jwe]
jwe
parents: 3011
diff changeset
139 int rows (void) const { return definition.rows (); }
66a1cede95e7 [project @ 1997-06-02 19:35:05 by jwe]
jwe
parents: 3011
diff changeset
140 int columns (void) const { return definition.columns (); }
66a1cede95e7 [project @ 1997-06-02 19:35:05 by jwe]
jwe
parents: 3011
diff changeset
141
66a1cede95e7 [project @ 1997-06-02 19:35:05 by jwe]
jwe
parents: 3011
diff changeset
142 string type_name (void) const { return definition.type_name (); }
66a1cede95e7 [project @ 1997-06-02 19:35:05 by jwe]
jwe
parents: 3011
diff changeset
143
3355
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3325
diff changeset
144 string type_as_string (void) const;
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3325
diff changeset
145
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3325
diff changeset
146 string which (const string& name);
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3325
diff changeset
147
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3325
diff changeset
148 void which (ostream& os, const string& name);
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3325
diff changeset
149
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
150 void define (const octave_value& val, unsigned int sym_type)
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
151 {
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
152 definition = val;
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
153 symbol_type = sym_type;
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
154 }
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
155
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
156 void protect (void) { read_only = 1; }
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
157
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
158 void unprotect (void) { read_only = 0; }
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
159
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
160 void make_eternal (void) { eternal = 1; }
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
161
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
162 octave_value& def (void) { return definition; }
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
163
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
164 string help (void) const { return help_string; }
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
165
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
166 void document (const string& h) { help_string = h; }
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
167
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
168 unsigned int type (void) { return symbol_type; }
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
169
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
170 void *operator new (size_t size)
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
171 { return allocator.alloc (size); }
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
172
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
173 void operator delete (void *p, size_t size)
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
174 { allocator.free (p, size); }
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
175
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
176 static octave_allocator allocator;
8
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
177
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
178 // The type of this symbol (see the enum above).
3325
2efa28a91e7a [project @ 1999-10-29 21:39:20 by jwe]
jwe
parents: 3258
diff changeset
179 unsigned int symbol_type : 8;
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
180
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
181 // Nonzero means this variable cannot be cleared.
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
182 unsigned int eternal : 1;
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
183
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
184 // Nonzero means this variable cannot be given a new value.
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
185 unsigned int read_only : 1;
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
186
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
187 // The doc string associated with this variable.
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
188 string help_string;
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
189
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
190 // The value of this definition. See ov.h and related files.
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
191 octave_value definition;
767
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 605
diff changeset
192
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
193 // Pointer to next definition in chain. This is used so that
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
194 // variables can hide function definitions, and so that the function
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
195 // definitions can reappear if the variable is cleared.
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
196 symbol_def *next_elem;
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
197
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
198 // Reference count.
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
199 int count;
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
200
3239
d54ef0aa6e82 [project @ 1999-03-27 17:40:45 by jwe]
jwe
parents: 3013
diff changeset
201 void dump_symbol_info (void);
d54ef0aa6e82 [project @ 1999-03-27 17:40:45 by jwe]
jwe
parents: 3013
diff changeset
202
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
203 // No copying!
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
204
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
205 symbol_def (const symbol_def& sd);
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
206
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
207 symbol_def& operator = (const symbol_def& sd);
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
208 };
8
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
209
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
210 public:
2953
ca7d3625ee01 [project @ 1997-05-09 14:56:52 by jwe]
jwe
parents: 2948
diff changeset
211
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
212 typedef int (*change_function) (void);
2953
ca7d3625ee01 [project @ 1997-05-09 14:56:52 by jwe]
jwe
parents: 2948
diff changeset
213
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
214 symbol_record (void)
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
215 : formal_param (0), linked_to_global (0), tagged_static (0),
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
216 nm (), chg_fcn (0), definition (new symbol_def ()),
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
217 next_elem (0) { }
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
218
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
219 symbol_record (const string& n, symbol_record *nxt)
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
220 : formal_param (0), linked_to_global (0), tagged_static (0),
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
221 nm (n), chg_fcn (0), definition (new symbol_def ()),
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
222 next_elem (nxt) { }
8
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
223
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1738
diff changeset
224 ~symbol_record (void) { }
8
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
225
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
226 string name (void) const { return nm; }
2975
b9c107cbe388 [project @ 1997-05-15 20:01:00 by jwe]
jwe
parents: 2956
diff changeset
227
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
228 string help (void) const { return definition->help (); }
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
229
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
230 octave_value& def (void) { return definition->def (); }
8
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
231
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1738
diff changeset
232 void rename (const string& new_name);
195
13c6086c325c [project @ 1993-11-06 10:12:29 by jwe]
jwe
parents: 186
diff changeset
233
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
234 bool is_function (void) const
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
235 { return definition->is_function (); }
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
236
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
237 bool is_text_function (void) const
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
238 { return definition->is_text_function (); }
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
239
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
240 bool is_mapper_function (void) const
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
241 { return definition->is_mapper_function (); }
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
242
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
243 bool is_user_function (void) const
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
244 { return definition->is_user_function (); }
195
13c6086c325c [project @ 1993-11-06 10:12:29 by jwe]
jwe
parents: 186
diff changeset
245
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
246 bool is_builtin_function (void) const
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
247 { return definition->is_builtin_function (); }
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
248
3325
2efa28a91e7a [project @ 1999-10-29 21:39:20 by jwe]
jwe
parents: 3258
diff changeset
249 bool is_dld_function (void) const
2efa28a91e7a [project @ 1999-10-29 21:39:20 by jwe]
jwe
parents: 3258
diff changeset
250 { return definition->is_dld_function (); }
2efa28a91e7a [project @ 1999-10-29 21:39:20 by jwe]
jwe
parents: 3258
diff changeset
251
3258
4964d5391acc [project @ 1999-07-21 21:51:33 by jwe]
jwe
parents: 3239
diff changeset
252 bool is_constant (void) const
4964d5391acc [project @ 1999-07-21 21:51:33 by jwe]
jwe
parents: 3239
diff changeset
253 { return definition->is_constant (); }
4964d5391acc [project @ 1999-07-21 21:51:33 by jwe]
jwe
parents: 3239
diff changeset
254
4964d5391acc [project @ 1999-07-21 21:51:33 by jwe]
jwe
parents: 3239
diff changeset
255 bool is_builtin_constant (void) const
4964d5391acc [project @ 1999-07-21 21:51:33 by jwe]
jwe
parents: 3239
diff changeset
256 { return definition->is_builtin_constant (); }
4964d5391acc [project @ 1999-07-21 21:51:33 by jwe]
jwe
parents: 3239
diff changeset
257
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
258 bool is_variable (void) const
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
259 { return definition->is_variable (); }
8
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
260
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
261 bool is_user_variable (void) const
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
262 { return definition->is_user_variable (); }
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
263
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
264 bool is_builtin_variable (void) const
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
265 { return definition->is_builtin_variable (); }
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
266
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
267 bool is_map_element (const string& elts) const
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
268 { return definition->is_map_element (elts); }
8
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
269
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
270 unsigned int type (void) const { return definition->type (); }
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
271
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
272 bool is_defined (void) const { return definition->is_defined (); }
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
273
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
274 bool is_read_only (void) const { return definition->is_read_only (); }
8
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
275
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
276 bool is_eternal (void) const { return definition->is_eternal (); }
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
277
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
278 void protect (void) { definition->protect (); }
195
13c6086c325c [project @ 1993-11-06 10:12:29 by jwe]
jwe
parents: 186
diff changeset
279
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
280 void unprotect (void) { definition->unprotect (); }
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
281
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
282 void make_eternal (void) { definition->make_eternal (); }
2893
9fd1df4b464a [project @ 1997-04-28 02:07:38 by jwe]
jwe
parents: 2856
diff changeset
283
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
284 void set_change_function (change_function f) { chg_fcn = f; }
2893
9fd1df4b464a [project @ 1997-04-28 02:07:38 by jwe]
jwe
parents: 2856
diff changeset
285
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
286 void define (const octave_value& v, unsigned int sym_type = USER_VARIABLE);
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
287
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
288 void define_builtin_var (const octave_value& v);
195
13c6086c325c [project @ 1993-11-06 10:12:29 by jwe]
jwe
parents: 186
diff changeset
289
3258
4964d5391acc [project @ 1999-07-21 21:51:33 by jwe]
jwe
parents: 3239
diff changeset
290 bool define_builtin_const (const octave_value& v);
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
291
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
292 bool define (octave_function *f, unsigned int sym_type);
2893
9fd1df4b464a [project @ 1997-04-28 02:07:38 by jwe]
jwe
parents: 2856
diff changeset
293
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
294 void document (const string& h) { definition->document (h); }
195
13c6086c325c [project @ 1993-11-06 10:12:29 by jwe]
jwe
parents: 186
diff changeset
295
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
296 void clear (void);
195
13c6086c325c [project @ 1993-11-06 10:12:29 by jwe]
jwe
parents: 186
diff changeset
297
2856
8c516da3c1f7 [project @ 1997-03-31 06:37:21 by jwe]
jwe
parents: 2847
diff changeset
298 void alias (symbol_record *s, bool force = false);
8
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
299
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
300 void mark_as_formal_parameter (void);
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
301 bool is_formal_parameter (void) const { return formal_param; }
8
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
302
195
13c6086c325c [project @ 1993-11-06 10:12:29 by jwe]
jwe
parents: 186
diff changeset
303 void mark_as_linked_to_global (void);
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
304 bool is_linked_to_global (void) const { return linked_to_global; }
8
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
305
2846
52e7c4509983 [project @ 1997-03-26 23:27:35 by jwe]
jwe
parents: 2791
diff changeset
306 void mark_as_static (void);
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
307 bool is_static (void) const { return tagged_static; }
2846
52e7c4509983 [project @ 1997-03-26 23:27:35 by jwe]
jwe
parents: 2791
diff changeset
308
3013
66a1cede95e7 [project @ 1997-06-02 19:35:05 by jwe]
jwe
parents: 3011
diff changeset
309 bool hides_fcn (void) const;
66a1cede95e7 [project @ 1997-06-02 19:35:05 by jwe]
jwe
parents: 3011
diff changeset
310 bool hides_builtin (void) const;
66a1cede95e7 [project @ 1997-06-02 19:35:05 by jwe]
jwe
parents: 3011
diff changeset
311
66a1cede95e7 [project @ 1997-06-02 19:35:05 by jwe]
jwe
parents: 3011
diff changeset
312 int rows (void) const { return definition->rows (); }
66a1cede95e7 [project @ 1997-06-02 19:35:05 by jwe]
jwe
parents: 3011
diff changeset
313 int columns (void) const { return definition->columns (); }
66a1cede95e7 [project @ 1997-06-02 19:35:05 by jwe]
jwe
parents: 3011
diff changeset
314
66a1cede95e7 [project @ 1997-06-02 19:35:05 by jwe]
jwe
parents: 3011
diff changeset
315 string type_name (void) const { return definition->type_name (); }
66a1cede95e7 [project @ 1997-06-02 19:35:05 by jwe]
jwe
parents: 3011
diff changeset
316
3355
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3325
diff changeset
317 string type_as_string (void) const
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3325
diff changeset
318 { return definition->type_as_string (); }
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3325
diff changeset
319
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3325
diff changeset
320 string which (void) { return definition->which (name ()); }
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3325
diff changeset
321
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3325
diff changeset
322 void which (ostream& os) { definition->which (os, name ()); }
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3325
diff changeset
323
2975
b9c107cbe388 [project @ 1997-05-15 20:01:00 by jwe]
jwe
parents: 2956
diff changeset
324 octave_value& variable_value (void);
2979
a3556d2adec9 [project @ 1997-05-15 22:35:37 by jwe]
jwe
parents: 2975
diff changeset
325 octave_lvalue variable_reference (void);
2390
c2c1482c34c8 [project @ 1996-10-12 19:13:23 by jwe]
jwe
parents: 2086
diff changeset
326
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
327 symbol_record *next (void) const { return next_elem; }
8
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
328
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
329 void chain (symbol_record *s) { next_elem = s; }
195
13c6086c325c [project @ 1993-11-06 10:12:29 by jwe]
jwe
parents: 186
diff changeset
330
220
f736a3ec137e [project @ 1993-11-14 00:10:26 by jwe]
jwe
parents: 200
diff changeset
331 void push_context (void);
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
332
220
f736a3ec137e [project @ 1993-11-14 00:10:26 by jwe]
jwe
parents: 200
diff changeset
333 void pop_context (void);
f736a3ec137e [project @ 1993-11-14 00:10:26 by jwe]
jwe
parents: 200
diff changeset
334
3013
66a1cede95e7 [project @ 1997-06-02 19:35:05 by jwe]
jwe
parents: 3011
diff changeset
335 void print_symbol_info_line (ostream& os);
66a1cede95e7 [project @ 1997-06-02 19:35:05 by jwe]
jwe
parents: 3011
diff changeset
336
3239
d54ef0aa6e82 [project @ 1999-03-27 17:40:45 by jwe]
jwe
parents: 3013
diff changeset
337 void dump_symbol_info (void);
d54ef0aa6e82 [project @ 1999-03-27 17:40:45 by jwe]
jwe
parents: 3013
diff changeset
338
8
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
339 private:
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
340
2893
9fd1df4b464a [project @ 1997-04-28 02:07:38 by jwe]
jwe
parents: 2856
diff changeset
341 unsigned int formal_param : 1;
9fd1df4b464a [project @ 1997-04-28 02:07:38 by jwe]
jwe
parents: 2856
diff changeset
342 unsigned int linked_to_global : 1;
9fd1df4b464a [project @ 1997-04-28 02:07:38 by jwe]
jwe
parents: 2856
diff changeset
343 unsigned int tagged_static : 1;
195
13c6086c325c [project @ 1993-11-06 10:12:29 by jwe]
jwe
parents: 186
diff changeset
344
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1738
diff changeset
345 string nm;
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
346 change_function chg_fcn;
195
13c6086c325c [project @ 1993-11-06 10:12:29 by jwe]
jwe
parents: 186
diff changeset
347 symbol_def *definition;
8
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
348 symbol_record *next_elem;
395
ee3da0884aaa [project @ 1994-03-24 09:23:18 by jwe]
jwe
parents: 383
diff changeset
349
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
350 // This should maybe be one stack with a structure containing all the
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
351 // items we need to save for recursive calls...
220
f736a3ec137e [project @ 1993-11-14 00:10:26 by jwe]
jwe
parents: 200
diff changeset
352 SLStack <symbol_def *> context;
2893
9fd1df4b464a [project @ 1997-04-28 02:07:38 by jwe]
jwe
parents: 2856
diff changeset
353 SLStack <unsigned int> global_link_context;
8
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
354
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
355 bool read_only_error (const char *action);
195
13c6086c325c [project @ 1993-11-06 10:12:29 by jwe]
jwe
parents: 186
diff changeset
356
13c6086c325c [project @ 1993-11-06 10:12:29 by jwe]
jwe
parents: 186
diff changeset
357 void push_def (symbol_def *sd);
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
358
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
359 void remove_top_def (void);
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
360
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
361 void replace_all_defs (symbol_def *sd);
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
362
3258
4964d5391acc [project @ 1999-07-21 21:51:33 by jwe]
jwe
parents: 3239
diff changeset
363 void link_to_builtin_variable (void);
4964d5391acc [project @ 1999-07-21 21:51:33 by jwe]
jwe
parents: 3239
diff changeset
364
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
365 // No copying!
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
366
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
367 symbol_record (const symbol_record& s);
195
13c6086c325c [project @ 1993-11-06 10:12:29 by jwe]
jwe
parents: 186
diff changeset
368
8
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
369 symbol_record& operator = (const symbol_record& s);
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
370 };
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
371
767
42731861ee09 [project @ 1994-10-05 21:26:54 by jwe]
jwe
parents: 605
diff changeset
372 // A symbol table.
200
2e4d2596f2c3 [project @ 1993-11-08 20:22:15 by jwe]
jwe
parents: 195
diff changeset
373
2e4d2596f2c3 [project @ 1993-11-08 20:22:15 by jwe]
jwe
parents: 195
diff changeset
374 #define SYMTAB_LOCAL_SCOPE 1
2e4d2596f2c3 [project @ 1993-11-08 20:22:15 by jwe]
jwe
parents: 195
diff changeset
375 #define SYMTAB_GLOBAL_SCOPE 2
2e4d2596f2c3 [project @ 1993-11-08 20:22:15 by jwe]
jwe
parents: 195
diff changeset
376
2e4d2596f2c3 [project @ 1993-11-08 20:22:15 by jwe]
jwe
parents: 195
diff changeset
377 #define SYMTAB_ALL_SCOPES (SYMTAB_LOCAL_SCOPE | SYMTAB_GLOBAL_SCOPE)
2e4d2596f2c3 [project @ 1993-11-08 20:22:15 by jwe]
jwe
parents: 195
diff changeset
378
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
379 #define SYMTAB_ALL_TYPES (symbol_record::USER_FUNCTION \
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
380 | symbol_record::USER_VARIABLE \
3325
2efa28a91e7a [project @ 1999-10-29 21:39:20 by jwe]
jwe
parents: 3258
diff changeset
381 | symbol_record::DLD_FUNCTION \
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
382 | symbol_record::BUILTIN_FUNCTION \
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
383 | symbol_record::TEXT_FUNCTION \
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
384 | symbol_record::MAPPER_FUNCTION \
3258
4964d5391acc [project @ 1999-07-21 21:51:33 by jwe]
jwe
parents: 3239
diff changeset
385 | symbol_record::BUILTIN_VARIABLE \
4964d5391acc [project @ 1999-07-21 21:51:33 by jwe]
jwe
parents: 3239
diff changeset
386 | symbol_record::BUILTIN_CONSTANT)
200
2e4d2596f2c3 [project @ 1993-11-08 20:22:15 by jwe]
jwe
parents: 195
diff changeset
387
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
388 #define SYMTAB_VARIABLES (symbol_record::USER_VARIABLE \
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
389 | symbol_record::BUILTIN_VARIABLE)
1412
5db963ba9614 [project @ 1995-09-15 08:47:17 by jwe]
jwe
parents: 1315
diff changeset
390
8
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
391 class
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
392 symbol_table
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
393 {
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
394 public:
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
395
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
396 symbol_table (unsigned int tab_size = 128)
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
397 : table_size (tab_size), table (new symbol_record [table_size])
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
398 {
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
399 assert ((tab_size % 2) == 0);
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
400 }
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
401
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
402 ~symbol_table (void)
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
403 {
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
404 delete [] table;
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
405 }
8
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
406
2856
8c516da3c1f7 [project @ 1997-03-31 06:37:21 by jwe]
jwe
parents: 2847
diff changeset
407 symbol_record *lookup (const string& nm, bool insert = false,
8c516da3c1f7 [project @ 1997-03-31 06:37:21 by jwe]
jwe
parents: 2847
diff changeset
408 bool warn = false);
8
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
409
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1738
diff changeset
410 void rename (const string& old_name, const string& new_name);
572
94fd73d1a0bc [project @ 1994-07-28 05:35:47 by jwe]
jwe
parents: 541
diff changeset
411
2856
8c516da3c1f7 [project @ 1997-03-31 06:37:21 by jwe]
jwe
parents: 2847
diff changeset
412 void clear (bool clear_user_functions = true);
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
413 bool clear (const string& nm, bool clear_user_functions = true);
8
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
414
164
e2c950dd96d2 [project @ 1993-10-18 19:32:00 by jwe]
jwe
parents: 121
diff changeset
415 int size (void) const;
8
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
416
3013
66a1cede95e7 [project @ 1997-06-02 19:35:05 by jwe]
jwe
parents: 3011
diff changeset
417 Array<symbol_record *>
3355
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3325
diff changeset
418 symbol_list (const string_vector& pats = string_vector (),
3013
66a1cede95e7 [project @ 1997-06-02 19:35:05 by jwe]
jwe
parents: 3011
diff changeset
419 unsigned int type = SYMTAB_ALL_TYPES,
66a1cede95e7 [project @ 1997-06-02 19:35:05 by jwe]
jwe
parents: 3011
diff changeset
420 unsigned int scope = SYMTAB_ALL_SCOPES) const;
66a1cede95e7 [project @ 1997-06-02 19:35:05 by jwe]
jwe
parents: 3011
diff changeset
421
195
13c6086c325c [project @ 1993-11-06 10:12:29 by jwe]
jwe
parents: 186
diff changeset
422
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1738
diff changeset
423 string_vector
3355
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3325
diff changeset
424 name_list (const string_vector& pats = string_vector (),
3013
66a1cede95e7 [project @ 1997-06-02 19:35:05 by jwe]
jwe
parents: 3011
diff changeset
425 bool sort = false, unsigned int type = SYMTAB_ALL_TYPES,
66a1cede95e7 [project @ 1997-06-02 19:35:05 by jwe]
jwe
parents: 3011
diff changeset
426 unsigned int scope = SYMTAB_ALL_SCOPES) const;
605
4f65175911a6 [project @ 1994-08-13 20:10:39 by jwe]
jwe
parents: 572
diff changeset
427
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
428
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
429 int maybe_list (const char *header, const string_vector& argv,
3013
66a1cede95e7 [project @ 1997-06-02 19:35:05 by jwe]
jwe
parents: 3011
diff changeset
430 ostream& os, bool show_verbose,
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
431 unsigned type, unsigned scope);
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
432
3355
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3325
diff changeset
433 Array<symbol_record *> glob (const string& pat = string ("*"),
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3325
diff changeset
434 unsigned int type = SYMTAB_ALL_TYPES,
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3325
diff changeset
435 unsigned int scope = SYMTAB_ALL_SCOPES) const;
8
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
436
220
f736a3ec137e [project @ 1993-11-14 00:10:26 by jwe]
jwe
parents: 200
diff changeset
437 void push_context (void);
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
438
220
f736a3ec137e [project @ 1993-11-14 00:10:26 by jwe]
jwe
parents: 200
diff changeset
439 void pop_context (void);
f736a3ec137e [project @ 1993-11-14 00:10:26 by jwe]
jwe
parents: 200
diff changeset
440
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
441 void print_stats (void);
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
442
8
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
443 private:
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
444
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
445 unsigned int table_size;
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
446
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
447 symbol_record *table;
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
448
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1738
diff changeset
449 unsigned int hash (const string& s);
8
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
450
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
451 // No copying!
8
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
452
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
453 symbol_table (const symbol_table&);
1962
d329b8ea86e8 [project @ 1996-02-16 04:24:22 by jwe]
jwe
parents: 1884
diff changeset
454
3011
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
455 symbol_table& operator = (const symbol_table&);
2ad9af85b89b [project @ 1997-06-01 19:34:20 by jwe]
jwe
parents: 2979
diff changeset
456 };
2790
ecc1a12678de [project @ 1997-03-05 02:47:54 by jwe]
jwe
parents: 2404
diff changeset
457
8
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
458 #endif
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
459
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
460 /*
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
461 ;;; Local Variables: ***
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
462 ;;; mode: C++ ***
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
463 ;;; End: ***
bd072d0a95f9 [project @ 1993-08-08 03:55:11 by jwe]
jwe
parents:
diff changeset
464 */