annotate gcc/ada/namet.ads @ 144:8f4e72ab4e11

fix segmentation fault caused by nothing next cur_op to end
author Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Sun, 23 Dec 2018 21:23:56 +0900
parents 84e7813d76e9
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT COMPILER COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- N A M E T --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
9 -- Copyright (C) 1992-2018, Free Software Foundation, Inc. --
111
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
kono
parents:
diff changeset
17 -- --
kono
parents:
diff changeset
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
kono
parents:
diff changeset
19 -- additional permissions described in the GCC Runtime Library Exception, --
kono
parents:
diff changeset
20 -- version 3.1, as published by the Free Software Foundation. --
kono
parents:
diff changeset
21 -- --
kono
parents:
diff changeset
22 -- You should have received a copy of the GNU General Public License and --
kono
parents:
diff changeset
23 -- a copy of the GCC Runtime Library Exception along with this program; --
kono
parents:
diff changeset
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
kono
parents:
diff changeset
25 -- <http://www.gnu.org/licenses/>. --
kono
parents:
diff changeset
26 -- --
kono
parents:
diff changeset
27 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
29 -- --
kono
parents:
diff changeset
30 ------------------------------------------------------------------------------
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 with Alloc;
kono
parents:
diff changeset
33 with Hostparm; use Hostparm;
kono
parents:
diff changeset
34 with Table;
kono
parents:
diff changeset
35 with Types; use Types;
kono
parents:
diff changeset
36
kono
parents:
diff changeset
37 package Namet is
kono
parents:
diff changeset
38
kono
parents:
diff changeset
39 -- WARNING: There is a C version of this package. Any changes to this
kono
parents:
diff changeset
40 -- source file must be properly reflected in the C header file namet.h
kono
parents:
diff changeset
41 -- which is created manually from namet.ads and namet.adb.
kono
parents:
diff changeset
42
kono
parents:
diff changeset
43 -- This package contains routines for handling the names table. The table
kono
parents:
diff changeset
44 -- is used to store character strings for identifiers and operator symbols,
kono
parents:
diff changeset
45 -- as well as other string values such as unit names and file names.
kono
parents:
diff changeset
46
kono
parents:
diff changeset
47 -- The forms of the entries are as follows:
kono
parents:
diff changeset
48
kono
parents:
diff changeset
49 -- Identifiers Stored with upper case letters folded to lower case.
kono
parents:
diff changeset
50 -- Upper half (16#80# bit set) and wide characters are
kono
parents:
diff changeset
51 -- stored in an encoded form (Uhh for upper half char,
kono
parents:
diff changeset
52 -- Whhhh for wide characters, WWhhhhhhhh as provided by
kono
parents:
diff changeset
53 -- the routine Append_Encoded, where hh are hex
kono
parents:
diff changeset
54 -- digits for the character code using lower case a-f).
kono
parents:
diff changeset
55 -- Normally the use of U or W in other internal names is
kono
parents:
diff changeset
56 -- avoided, but these letters may be used in internal
kono
parents:
diff changeset
57 -- names (without this special meaning), if they appear
kono
parents:
diff changeset
58 -- as the last character of the name, or they are
kono
parents:
diff changeset
59 -- followed by an upper case letter (other than the WW
kono
parents:
diff changeset
60 -- sequence), or an underscore.
kono
parents:
diff changeset
61
kono
parents:
diff changeset
62 -- Operator symbols Stored with an initial letter O, and the remainder
kono
parents:
diff changeset
63 -- of the name is the lower case characters XXX where
kono
parents:
diff changeset
64 -- the name is Name_Op_XXX, see Snames spec for a full
kono
parents:
diff changeset
65 -- list of the operator names. Normally the use of O
kono
parents:
diff changeset
66 -- in other internal names is avoided, but it may be
kono
parents:
diff changeset
67 -- used in internal names (without this special meaning)
kono
parents:
diff changeset
68 -- if it is the last character of the name, or if it is
kono
parents:
diff changeset
69 -- followed by an upper case letter or an underscore.
kono
parents:
diff changeset
70
kono
parents:
diff changeset
71 -- Character literals Character literals have names that are used only for
kono
parents:
diff changeset
72 -- debugging and error message purposes. The form is an
kono
parents:
diff changeset
73 -- upper case Q followed by a single lower case letter,
kono
parents:
diff changeset
74 -- or by a Uxx/Wxxxx/WWxxxxxxx encoding as described for
kono
parents:
diff changeset
75 -- identifiers. The Set_Character_Literal_Name procedure
kono
parents:
diff changeset
76 -- should be used to construct these encodings. Normally
kono
parents:
diff changeset
77 -- the use of O in other internal names is avoided, but
kono
parents:
diff changeset
78 -- it may be used in internal names (without this special
kono
parents:
diff changeset
79 -- meaning) if it is the last character of the name, or
kono
parents:
diff changeset
80 -- if it is followed by an upper case letter or an
kono
parents:
diff changeset
81 -- underscore.
kono
parents:
diff changeset
82
kono
parents:
diff changeset
83 -- Unit names Stored with upper case letters folded to lower case,
kono
parents:
diff changeset
84 -- using Uhh/Whhhh/WWhhhhhhhh encoding as described for
kono
parents:
diff changeset
85 -- identifiers, and a %s or %b suffix for specs/bodies.
kono
parents:
diff changeset
86 -- See package Uname for further details.
kono
parents:
diff changeset
87
kono
parents:
diff changeset
88 -- File names Are stored in the form provided by Osint. Typically
kono
parents:
diff changeset
89 -- they may include wide character escape sequences and
kono
parents:
diff changeset
90 -- upper case characters (in non-encoded form). Casing
kono
parents:
diff changeset
91 -- is also derived from the external environment. Note
kono
parents:
diff changeset
92 -- that file names provided by Osint must generally be
kono
parents:
diff changeset
93 -- consistent with the names from Fname.Get_File_Name.
kono
parents:
diff changeset
94
kono
parents:
diff changeset
95 -- Other strings The names table is also used as a convenient storage
kono
parents:
diff changeset
96 -- location for other variable length strings such as
kono
parents:
diff changeset
97 -- error messages etc. There are no restrictions on what
kono
parents:
diff changeset
98 -- characters may appear for such entries.
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100 -- Note: the encodings Uhh (upper half characters), Whhhh (wide characters),
kono
parents:
diff changeset
101 -- WWhhhhhhhh (wide wide characters) and Qx (character literal names) are
kono
parents:
diff changeset
102 -- described in the spec, since they are visible throughout the system (e.g.
kono
parents:
diff changeset
103 -- in debugging output). However, no code should depend on these particular
kono
parents:
diff changeset
104 -- encodings, so it should be possible to change the encodings by making
kono
parents:
diff changeset
105 -- changes only to the Namet specification (to change these comments) and the
kono
parents:
diff changeset
106 -- body (which actually implements the encodings).
kono
parents:
diff changeset
107
kono
parents:
diff changeset
108 -- The names are hashed so that a given name appears only once in the table,
kono
parents:
diff changeset
109 -- except that names entered with Name_Enter as opposed to Name_Find are
kono
parents:
diff changeset
110 -- omitted from the hash table.
kono
parents:
diff changeset
111
kono
parents:
diff changeset
112 -- The first 26 entries in the names table (with Name_Id values in the range
kono
parents:
diff changeset
113 -- First_Name_Id .. First_Name_Id + 25) represent names which are the one
kono
parents:
diff changeset
114 -- character lower case letters in the range a-z, and these names are created
kono
parents:
diff changeset
115 -- and initialized by the Initialize procedure.
kono
parents:
diff changeset
116
kono
parents:
diff changeset
117 -- Five values, one of type Int, one of type Byte, and three of type Boolean,
kono
parents:
diff changeset
118 -- are stored with each names table entry and subprograms are provided for
kono
parents:
diff changeset
119 -- setting and retrieving these associated values. The usage of these values
kono
parents:
diff changeset
120 -- is up to the client:
kono
parents:
diff changeset
121
kono
parents:
diff changeset
122 -- In the compiler we have the following uses:
kono
parents:
diff changeset
123
kono
parents:
diff changeset
124 -- The Int field is used to point to a chain of potentially visible
kono
parents:
diff changeset
125 -- entities (see Sem.Ch8 for details).
kono
parents:
diff changeset
126
kono
parents:
diff changeset
127 -- The Byte field is used to hold the Token_Type value for reserved words
kono
parents:
diff changeset
128 -- (see Sem for details).
kono
parents:
diff changeset
129
kono
parents:
diff changeset
130 -- The Boolean1 field is used to mark address clauses to optimize the
kono
parents:
diff changeset
131 -- performance of the Exp_Util.Following_Address_Clause function.
kono
parents:
diff changeset
132
kono
parents:
diff changeset
133 -- The Boolean2 field is used to mark simple names that appear in
kono
parents:
diff changeset
134 -- Restriction[_Warning]s pragmas for No_Use_Of_Entity. This avoids most
kono
parents:
diff changeset
135 -- unnecessary searches of the No_Use_Of_Entity table.
kono
parents:
diff changeset
136
kono
parents:
diff changeset
137 -- The Boolean3 field is set for names of pragmas that are to be ignored
kono
parents:
diff changeset
138 -- because of the occurrence of a corresponding pragma Ignore_Pragma.
kono
parents:
diff changeset
139
kono
parents:
diff changeset
140 -- In the binder, we have the following uses:
kono
parents:
diff changeset
141
kono
parents:
diff changeset
142 -- The Int field is used in various ways depending on the name involved,
kono
parents:
diff changeset
143 -- see binder documentation for details.
kono
parents:
diff changeset
144
kono
parents:
diff changeset
145 -- The Byte and Boolean fields are unused.
kono
parents:
diff changeset
146
kono
parents:
diff changeset
147 -- Note that the value of the Int and Byte fields are initialized to zero,
kono
parents:
diff changeset
148 -- and the Boolean field is initialized to False, when a new Name table entry
kono
parents:
diff changeset
149 -- is created.
kono
parents:
diff changeset
150
kono
parents:
diff changeset
151 type Bounded_String (Max_Length : Natural := 2**12) is limited
kono
parents:
diff changeset
152 -- It's unlikely to have names longer than this. But we don't want to make
kono
parents:
diff changeset
153 -- it too big, because we declare these on the stack in recursive routines.
kono
parents:
diff changeset
154 record
kono
parents:
diff changeset
155 Length : Natural := 0;
kono
parents:
diff changeset
156 Chars : String (1 .. Max_Length);
kono
parents:
diff changeset
157 end record;
kono
parents:
diff changeset
158
kono
parents:
diff changeset
159 -- To create a Name_Id, you can declare a Bounded_String as a local
kono
parents:
diff changeset
160 -- variable, and Append things onto it, and finally call Name_Find.
kono
parents:
diff changeset
161 -- You can also use a String, as in:
kono
parents:
diff changeset
162 -- X := Name_Find (Some_String & "_some_suffix");
kono
parents:
diff changeset
163
kono
parents:
diff changeset
164 -- For historical reasons, we also have the Global_Name_Buffer below,
kono
parents:
diff changeset
165 -- which is used by most of the code via the renamings. New code ought
kono
parents:
diff changeset
166 -- to avoid the global.
kono
parents:
diff changeset
167
kono
parents:
diff changeset
168 Global_Name_Buffer : Bounded_String (Max_Length => 4 * Max_Line_Length);
kono
parents:
diff changeset
169 Name_Buffer : String renames Global_Name_Buffer.Chars;
kono
parents:
diff changeset
170 Name_Len : Natural renames Global_Name_Buffer.Length;
kono
parents:
diff changeset
171
kono
parents:
diff changeset
172 -- Note that there is some circuitry (e.g. Osint.Write_Program_Name) that
kono
parents:
diff changeset
173 -- does a save/restore on Name_Len and Name_Buffer (1 .. Name_Len). This
kono
parents:
diff changeset
174 -- works in part because Name_Len is default-initialized to 0.
kono
parents:
diff changeset
175
kono
parents:
diff changeset
176 -----------------------------
kono
parents:
diff changeset
177 -- Types for Namet Package --
kono
parents:
diff changeset
178 -----------------------------
kono
parents:
diff changeset
179
kono
parents:
diff changeset
180 -- Name_Id values are used to identify entries in the names table. Except
kono
parents:
diff changeset
181 -- for the special values No_Name and Error_Name, they are subscript values
kono
parents:
diff changeset
182 -- for the Names table defined in this package.
kono
parents:
diff changeset
183
kono
parents:
diff changeset
184 -- Note that with only a few exceptions, which are clearly documented, the
kono
parents:
diff changeset
185 -- type Name_Id should be regarded as a private type. In particular it is
kono
parents:
diff changeset
186 -- never appropriate to perform arithmetic operations using this type.
kono
parents:
diff changeset
187
kono
parents:
diff changeset
188 type Name_Id is range Names_Low_Bound .. Names_High_Bound;
kono
parents:
diff changeset
189 for Name_Id'Size use 32;
kono
parents:
diff changeset
190 -- Type used to identify entries in the names table
kono
parents:
diff changeset
191
kono
parents:
diff changeset
192 No_Name : constant Name_Id := Names_Low_Bound;
kono
parents:
diff changeset
193 -- The special Name_Id value No_Name is used in the parser to indicate
kono
parents:
diff changeset
194 -- a situation where no name is present (e.g. on a loop or block).
kono
parents:
diff changeset
195
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
196 Error_Name : constant Name_Id := Names_Low_Bound + 1;
111
kono
parents:
diff changeset
197 -- The special Name_Id value Error_Name is used in the parser to
kono
parents:
diff changeset
198 -- indicate that some kind of error was encountered in scanning out
kono
parents:
diff changeset
199 -- the relevant name, so it does not have a representable label.
kono
parents:
diff changeset
200
kono
parents:
diff changeset
201 First_Name_Id : constant Name_Id := Names_Low_Bound + 2;
kono
parents:
diff changeset
202 -- Subscript of first entry in names table
kono
parents:
diff changeset
203
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
204 subtype Valid_Name_Id is Name_Id range First_Name_Id .. Name_Id'Last;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
205 -- All but No_Name and Error_Name
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
206
111
kono
parents:
diff changeset
207 ------------------------------
kono
parents:
diff changeset
208 -- Name_Id Membership Tests --
kono
parents:
diff changeset
209 ------------------------------
kono
parents:
diff changeset
210
kono
parents:
diff changeset
211 -- The following functions allow a convenient notation for testing whether
kono
parents:
diff changeset
212 -- a Name_Id value matches any one of a list of possible values. In each
kono
parents:
diff changeset
213 -- case True is returned if the given T argument is equal to any of the V
kono
parents:
diff changeset
214 -- arguments. These essentially duplicate the Ada 2012 membership tests,
kono
parents:
diff changeset
215 -- but we cannot use the latter (yet) in the compiler front end, because
kono
parents:
diff changeset
216 -- of bootstrap considerations
kono
parents:
diff changeset
217
kono
parents:
diff changeset
218 function Nam_In
kono
parents:
diff changeset
219 (T : Name_Id;
kono
parents:
diff changeset
220 V1 : Name_Id;
kono
parents:
diff changeset
221 V2 : Name_Id) return Boolean;
kono
parents:
diff changeset
222
kono
parents:
diff changeset
223 function Nam_In
kono
parents:
diff changeset
224 (T : Name_Id;
kono
parents:
diff changeset
225 V1 : Name_Id;
kono
parents:
diff changeset
226 V2 : Name_Id;
kono
parents:
diff changeset
227 V3 : Name_Id) return Boolean;
kono
parents:
diff changeset
228
kono
parents:
diff changeset
229 function Nam_In
kono
parents:
diff changeset
230 (T : Name_Id;
kono
parents:
diff changeset
231 V1 : Name_Id;
kono
parents:
diff changeset
232 V2 : Name_Id;
kono
parents:
diff changeset
233 V3 : Name_Id;
kono
parents:
diff changeset
234 V4 : Name_Id) return Boolean;
kono
parents:
diff changeset
235
kono
parents:
diff changeset
236 function Nam_In
kono
parents:
diff changeset
237 (T : Name_Id;
kono
parents:
diff changeset
238 V1 : Name_Id;
kono
parents:
diff changeset
239 V2 : Name_Id;
kono
parents:
diff changeset
240 V3 : Name_Id;
kono
parents:
diff changeset
241 V4 : Name_Id;
kono
parents:
diff changeset
242 V5 : Name_Id) return Boolean;
kono
parents:
diff changeset
243
kono
parents:
diff changeset
244 function Nam_In
kono
parents:
diff changeset
245 (T : Name_Id;
kono
parents:
diff changeset
246 V1 : Name_Id;
kono
parents:
diff changeset
247 V2 : Name_Id;
kono
parents:
diff changeset
248 V3 : Name_Id;
kono
parents:
diff changeset
249 V4 : Name_Id;
kono
parents:
diff changeset
250 V5 : Name_Id;
kono
parents:
diff changeset
251 V6 : Name_Id) return Boolean;
kono
parents:
diff changeset
252
kono
parents:
diff changeset
253 function Nam_In
kono
parents:
diff changeset
254 (T : Name_Id;
kono
parents:
diff changeset
255 V1 : Name_Id;
kono
parents:
diff changeset
256 V2 : Name_Id;
kono
parents:
diff changeset
257 V3 : Name_Id;
kono
parents:
diff changeset
258 V4 : Name_Id;
kono
parents:
diff changeset
259 V5 : Name_Id;
kono
parents:
diff changeset
260 V6 : Name_Id;
kono
parents:
diff changeset
261 V7 : Name_Id) return Boolean;
kono
parents:
diff changeset
262
kono
parents:
diff changeset
263 function Nam_In
kono
parents:
diff changeset
264 (T : Name_Id;
kono
parents:
diff changeset
265 V1 : Name_Id;
kono
parents:
diff changeset
266 V2 : Name_Id;
kono
parents:
diff changeset
267 V3 : Name_Id;
kono
parents:
diff changeset
268 V4 : Name_Id;
kono
parents:
diff changeset
269 V5 : Name_Id;
kono
parents:
diff changeset
270 V6 : Name_Id;
kono
parents:
diff changeset
271 V7 : Name_Id;
kono
parents:
diff changeset
272 V8 : Name_Id) return Boolean;
kono
parents:
diff changeset
273
kono
parents:
diff changeset
274 function Nam_In
kono
parents:
diff changeset
275 (T : Name_Id;
kono
parents:
diff changeset
276 V1 : Name_Id;
kono
parents:
diff changeset
277 V2 : Name_Id;
kono
parents:
diff changeset
278 V3 : Name_Id;
kono
parents:
diff changeset
279 V4 : Name_Id;
kono
parents:
diff changeset
280 V5 : Name_Id;
kono
parents:
diff changeset
281 V6 : Name_Id;
kono
parents:
diff changeset
282 V7 : Name_Id;
kono
parents:
diff changeset
283 V8 : Name_Id;
kono
parents:
diff changeset
284 V9 : Name_Id) return Boolean;
kono
parents:
diff changeset
285
kono
parents:
diff changeset
286 function Nam_In
kono
parents:
diff changeset
287 (T : Name_Id;
kono
parents:
diff changeset
288 V1 : Name_Id;
kono
parents:
diff changeset
289 V2 : Name_Id;
kono
parents:
diff changeset
290 V3 : Name_Id;
kono
parents:
diff changeset
291 V4 : Name_Id;
kono
parents:
diff changeset
292 V5 : Name_Id;
kono
parents:
diff changeset
293 V6 : Name_Id;
kono
parents:
diff changeset
294 V7 : Name_Id;
kono
parents:
diff changeset
295 V8 : Name_Id;
kono
parents:
diff changeset
296 V9 : Name_Id;
kono
parents:
diff changeset
297 V10 : Name_Id) return Boolean;
kono
parents:
diff changeset
298
kono
parents:
diff changeset
299 function Nam_In
kono
parents:
diff changeset
300 (T : Name_Id;
kono
parents:
diff changeset
301 V1 : Name_Id;
kono
parents:
diff changeset
302 V2 : Name_Id;
kono
parents:
diff changeset
303 V3 : Name_Id;
kono
parents:
diff changeset
304 V4 : Name_Id;
kono
parents:
diff changeset
305 V5 : Name_Id;
kono
parents:
diff changeset
306 V6 : Name_Id;
kono
parents:
diff changeset
307 V7 : Name_Id;
kono
parents:
diff changeset
308 V8 : Name_Id;
kono
parents:
diff changeset
309 V9 : Name_Id;
kono
parents:
diff changeset
310 V10 : Name_Id;
kono
parents:
diff changeset
311 V11 : Name_Id) return Boolean;
kono
parents:
diff changeset
312
kono
parents:
diff changeset
313 function Nam_In
kono
parents:
diff changeset
314 (T : Name_Id;
kono
parents:
diff changeset
315 V1 : Name_Id;
kono
parents:
diff changeset
316 V2 : Name_Id;
kono
parents:
diff changeset
317 V3 : Name_Id;
kono
parents:
diff changeset
318 V4 : Name_Id;
kono
parents:
diff changeset
319 V5 : Name_Id;
kono
parents:
diff changeset
320 V6 : Name_Id;
kono
parents:
diff changeset
321 V7 : Name_Id;
kono
parents:
diff changeset
322 V8 : Name_Id;
kono
parents:
diff changeset
323 V9 : Name_Id;
kono
parents:
diff changeset
324 V10 : Name_Id;
kono
parents:
diff changeset
325 V11 : Name_Id;
kono
parents:
diff changeset
326 V12 : Name_Id) return Boolean;
kono
parents:
diff changeset
327
kono
parents:
diff changeset
328 pragma Inline (Nam_In);
kono
parents:
diff changeset
329 -- Inline all above functions
kono
parents:
diff changeset
330
kono
parents:
diff changeset
331 -----------------
kono
parents:
diff changeset
332 -- Subprograms --
kono
parents:
diff changeset
333 -----------------
kono
parents:
diff changeset
334
kono
parents:
diff changeset
335 function To_String (Buf : Bounded_String) return String;
kono
parents:
diff changeset
336 pragma Inline (To_String);
kono
parents:
diff changeset
337 function "+" (Buf : Bounded_String) return String renames To_String;
kono
parents:
diff changeset
338
kono
parents:
diff changeset
339 function Name_Find
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
340 (Buf : Bounded_String := Global_Name_Buffer) return Valid_Name_Id;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
341 function Name_Find (S : String) return Valid_Name_Id;
111
kono
parents:
diff changeset
342 -- Name_Find searches the names table to see if the string has already been
kono
parents:
diff changeset
343 -- stored. If so, the Id of the existing entry is returned. Otherwise a new
kono
parents:
diff changeset
344 -- entry is created with its Name_Table_Int fields set to zero/false. Note
kono
parents:
diff changeset
345 -- that it is permissible for Buf.Length to be zero to lookup the empty
kono
parents:
diff changeset
346 -- name string.
kono
parents:
diff changeset
347
kono
parents:
diff changeset
348 function Name_Enter
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
349 (Buf : Bounded_String := Global_Name_Buffer) return Valid_Name_Id;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
350 function Name_Enter (S : String) return Valid_Name_Id;
111
kono
parents:
diff changeset
351 -- Name_Enter is similar to Name_Find. The difference is that it does not
kono
parents:
diff changeset
352 -- search the table for an existing match, and also subsequent Name_Find
kono
parents:
diff changeset
353 -- calls using the same name will not locate the entry created by this
kono
parents:
diff changeset
354 -- call. Thus multiple calls to Name_Enter with the same name will create
kono
parents:
diff changeset
355 -- multiple entries in the name table with different Name_Id values. This
kono
parents:
diff changeset
356 -- is useful in the case of created names, which are never expected to be
kono
parents:
diff changeset
357 -- looked up. Note: Name_Enter should never be used for one character
kono
parents:
diff changeset
358 -- names, since these are efficiently located without hashing by Name_Find
kono
parents:
diff changeset
359 -- in any case.
kono
parents:
diff changeset
360
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
361 function Name_Equals
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
362 (N1 : Valid_Name_Id;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
363 N2 : Valid_Name_Id) return Boolean;
111
kono
parents:
diff changeset
364 -- Return whether N1 and N2 denote the same character sequence
kono
parents:
diff changeset
365
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
366 function Get_Name_String (Id : Valid_Name_Id) return String;
111
kono
parents:
diff changeset
367 -- Returns the characters of Id as a String. The lower bound is 1.
kono
parents:
diff changeset
368
kono
parents:
diff changeset
369 -- The following Append procedures ignore any characters that don't fit in
kono
parents:
diff changeset
370 -- Buf.
kono
parents:
diff changeset
371
kono
parents:
diff changeset
372 procedure Append (Buf : in out Bounded_String; C : Character);
kono
parents:
diff changeset
373 -- Append C onto Buf
kono
parents:
diff changeset
374 pragma Inline (Append);
kono
parents:
diff changeset
375
kono
parents:
diff changeset
376 procedure Append (Buf : in out Bounded_String; V : Nat);
kono
parents:
diff changeset
377 -- Append decimal representation of V onto Buf
kono
parents:
diff changeset
378
kono
parents:
diff changeset
379 procedure Append (Buf : in out Bounded_String; S : String);
kono
parents:
diff changeset
380 -- Append S onto Buf
kono
parents:
diff changeset
381
kono
parents:
diff changeset
382 procedure Append (Buf : in out Bounded_String; Buf2 : Bounded_String);
kono
parents:
diff changeset
383 -- Append Buf2 onto Buf
kono
parents:
diff changeset
384
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
385 procedure Append (Buf : in out Bounded_String; Id : Valid_Name_Id);
111
kono
parents:
diff changeset
386 -- Append the characters of Id onto Buf. It is an error to call this with
kono
parents:
diff changeset
387 -- one of the special name Id values (No_Name or Error_Name).
kono
parents:
diff changeset
388
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
389 procedure Append_Decoded (Buf : in out Bounded_String; Id : Valid_Name_Id);
111
kono
parents:
diff changeset
390 -- Same as Append, except that the result is decoded, so that upper half
kono
parents:
diff changeset
391 -- characters and wide characters appear as originally found in the source
kono
parents:
diff changeset
392 -- program text, operators have their source forms (special characters and
kono
parents:
diff changeset
393 -- enclosed in quotes), and character literals appear surrounded by
kono
parents:
diff changeset
394 -- apostrophes.
kono
parents:
diff changeset
395
kono
parents:
diff changeset
396 procedure Append_Decoded_With_Brackets
kono
parents:
diff changeset
397 (Buf : in out Bounded_String;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
398 Id : Valid_Name_Id);
111
kono
parents:
diff changeset
399 -- Same as Append_Decoded, except that the brackets notation (Uhh
kono
parents:
diff changeset
400 -- replaced by ["hh"], Whhhh replaced by ["hhhh"], WWhhhhhhhh replaced by
kono
parents:
diff changeset
401 -- ["hhhhhhhh"]) is used for all non-lower half characters, regardless of
kono
parents:
diff changeset
402 -- how Opt.Wide_Character_Encoding_Method is set, and also in that
kono
parents:
diff changeset
403 -- characters in the range 16#80# .. 16#FF# are converted to brackets
kono
parents:
diff changeset
404 -- notation in all cases. This routine can be used when there is a
kono
parents:
diff changeset
405 -- requirement for a canonical representation not affected by the
kono
parents:
diff changeset
406 -- character set options (e.g. in the binder generation of symbols).
kono
parents:
diff changeset
407
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
408 procedure Append_Unqualified
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
409 (Buf : in out Bounded_String; Id : Valid_Name_Id);
111
kono
parents:
diff changeset
410 -- Same as Append, except that qualification (as defined in unit
kono
parents:
diff changeset
411 -- Exp_Dbug) is removed (including both preceding __ delimited names, and
kono
parents:
diff changeset
412 -- also the suffixes used to indicate package body entities and to
kono
parents:
diff changeset
413 -- distinguish between overloaded entities). Note that names are not
kono
parents:
diff changeset
414 -- qualified until just before the call to gigi, so this routine is only
kono
parents:
diff changeset
415 -- needed by processing that occurs after gigi has been called. This
kono
parents:
diff changeset
416 -- includes all ASIS processing, since ASIS works on the tree written
kono
parents:
diff changeset
417 -- after gigi has been called.
kono
parents:
diff changeset
418
kono
parents:
diff changeset
419 procedure Append_Unqualified_Decoded
kono
parents:
diff changeset
420 (Buf : in out Bounded_String;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
421 Id : Valid_Name_Id);
111
kono
parents:
diff changeset
422 -- Same as Append_Unqualified, but decoded as for Append_Decoded
kono
parents:
diff changeset
423
kono
parents:
diff changeset
424 procedure Append_Encoded (Buf : in out Bounded_String; C : Char_Code);
kono
parents:
diff changeset
425 -- Appends given character code at the end of Buf. Lower case letters and
kono
parents:
diff changeset
426 -- digits are stored unchanged. Other 8-bit characters are stored using the
kono
parents:
diff changeset
427 -- Uhh encoding (hh = hex code), other 16-bit wide character values are
kono
parents:
diff changeset
428 -- stored using the Whhhh (hhhh = hex code) encoding, and other 32-bit wide
kono
parents:
diff changeset
429 -- wide character values are stored using the WWhhhhhhhh (hhhhhhhh = hex
kono
parents:
diff changeset
430 -- code). Note that this procedure does not fold upper case letters (they
kono
parents:
diff changeset
431 -- are stored using the Uhh encoding).
kono
parents:
diff changeset
432
kono
parents:
diff changeset
433 procedure Set_Character_Literal_Name
kono
parents:
diff changeset
434 (Buf : in out Bounded_String;
kono
parents:
diff changeset
435 C : Char_Code);
kono
parents:
diff changeset
436 -- This procedure sets the proper encoded name for the character literal
kono
parents:
diff changeset
437 -- for the given character code.
kono
parents:
diff changeset
438
kono
parents:
diff changeset
439 procedure Insert_Str
kono
parents:
diff changeset
440 (Buf : in out Bounded_String;
kono
parents:
diff changeset
441 S : String;
kono
parents:
diff changeset
442 Index : Positive);
kono
parents:
diff changeset
443 -- Inserts S in Buf, starting at Index. Any existing characters at or past
kono
parents:
diff changeset
444 -- this location get moved beyond the inserted string.
kono
parents:
diff changeset
445
kono
parents:
diff changeset
446 function Is_Internal_Name (Buf : Bounded_String) return Boolean;
kono
parents:
diff changeset
447
kono
parents:
diff changeset
448 procedure Get_Last_Two_Chars
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
449 (N : Valid_Name_Id;
111
kono
parents:
diff changeset
450 C1 : out Character;
kono
parents:
diff changeset
451 C2 : out Character);
kono
parents:
diff changeset
452 -- Obtains last two characters of a name. C1 is last but one character and
kono
parents:
diff changeset
453 -- C2 is last character. If name is less than two characters long then both
kono
parents:
diff changeset
454 -- C1 and C2 are set to ASCII.NUL on return.
kono
parents:
diff changeset
455
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
456 function Get_Name_Table_Boolean1 (Id : Valid_Name_Id) return Boolean;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
457 function Get_Name_Table_Boolean2 (Id : Valid_Name_Id) return Boolean;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
458 function Get_Name_Table_Boolean3 (Id : Valid_Name_Id) return Boolean;
111
kono
parents:
diff changeset
459 -- Fetches the Boolean values associated with the given name
kono
parents:
diff changeset
460
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
461 function Get_Name_Table_Byte (Id : Valid_Name_Id) return Byte;
111
kono
parents:
diff changeset
462 pragma Inline (Get_Name_Table_Byte);
kono
parents:
diff changeset
463 -- Fetches the Byte value associated with the given name
kono
parents:
diff changeset
464
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
465 function Get_Name_Table_Int (Id : Valid_Name_Id) return Int;
111
kono
parents:
diff changeset
466 pragma Inline (Get_Name_Table_Int);
kono
parents:
diff changeset
467 -- Fetches the Int value associated with the given name
kono
parents:
diff changeset
468
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
469 procedure Set_Name_Table_Boolean1 (Id : Valid_Name_Id; Val : Boolean);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
470 procedure Set_Name_Table_Boolean2 (Id : Valid_Name_Id; Val : Boolean);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
471 procedure Set_Name_Table_Boolean3 (Id : Valid_Name_Id; Val : Boolean);
111
kono
parents:
diff changeset
472 -- Sets the Boolean value associated with the given name
kono
parents:
diff changeset
473
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
474 procedure Set_Name_Table_Byte (Id : Valid_Name_Id; Val : Byte);
111
kono
parents:
diff changeset
475 pragma Inline (Set_Name_Table_Byte);
kono
parents:
diff changeset
476 -- Sets the Byte value associated with the given name
kono
parents:
diff changeset
477
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
478 procedure Set_Name_Table_Int (Id : Valid_Name_Id; Val : Int);
111
kono
parents:
diff changeset
479 pragma Inline (Set_Name_Table_Int);
kono
parents:
diff changeset
480 -- Sets the Int value associated with the given name
kono
parents:
diff changeset
481
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
482 function Is_Internal_Name (Id : Valid_Name_Id) return Boolean;
111
kono
parents:
diff changeset
483 -- Returns True if the name is an internal name, i.e. contains a character
kono
parents:
diff changeset
484 -- for which Is_OK_Internal_Letter is true, or if the name starts or ends
kono
parents:
diff changeset
485 -- with an underscore.
kono
parents:
diff changeset
486 --
kono
parents:
diff changeset
487 -- Note: if the name is qualified (has a double underscore), then only the
kono
parents:
diff changeset
488 -- final entity name is considered, not the qualifying names. Consider for
kono
parents:
diff changeset
489 -- example that the name:
kono
parents:
diff changeset
490 --
kono
parents:
diff changeset
491 -- pkg__B_1__xyz
kono
parents:
diff changeset
492 --
kono
parents:
diff changeset
493 -- is not an internal name, because the B comes from the internal name of
kono
parents:
diff changeset
494 -- a qualifying block, but the xyz means that this was indeed a declared
kono
parents:
diff changeset
495 -- identifier called "xyz" within this block and there is nothing internal
kono
parents:
diff changeset
496 -- about that name.
kono
parents:
diff changeset
497
kono
parents:
diff changeset
498 function Is_OK_Internal_Letter (C : Character) return Boolean;
kono
parents:
diff changeset
499 pragma Inline (Is_OK_Internal_Letter);
kono
parents:
diff changeset
500 -- Returns true if C is a suitable character for using as a prefix or a
kono
parents:
diff changeset
501 -- suffix of an internally generated name, i.e. it is an upper case letter
kono
parents:
diff changeset
502 -- other than one of the ones used for encoding source names (currently the
kono
parents:
diff changeset
503 -- set of reserved letters is O, Q, U, W) and also returns False for the
kono
parents:
diff changeset
504 -- letter X, which is reserved for debug output (see Exp_Dbug).
kono
parents:
diff changeset
505
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
506 function Is_Operator_Name (Id : Valid_Name_Id) return Boolean;
111
kono
parents:
diff changeset
507 -- Returns True if name given is of the form of an operator (that is, it
kono
parents:
diff changeset
508 -- starts with an upper case O).
kono
parents:
diff changeset
509
kono
parents:
diff changeset
510 function Is_Valid_Name (Id : Name_Id) return Boolean;
kono
parents:
diff changeset
511 -- True if Id is a valid name - points to a valid entry in the Name_Entries
kono
parents:
diff changeset
512 -- table.
kono
parents:
diff changeset
513
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
514 function Length_Of_Name (Id : Valid_Name_Id) return Nat;
111
kono
parents:
diff changeset
515 pragma Inline (Length_Of_Name);
kono
parents:
diff changeset
516 -- Returns length of given name in characters. This is the length of the
kono
parents:
diff changeset
517 -- encoded name, as stored in the names table.
kono
parents:
diff changeset
518
kono
parents:
diff changeset
519 procedure Initialize;
kono
parents:
diff changeset
520 -- This is a dummy procedure. It is retained for easy compatibility with
kono
parents:
diff changeset
521 -- clients who used to call Initialize when this call was required. Now
kono
parents:
diff changeset
522 -- initialization is performed automatically during package elaboration.
kono
parents:
diff changeset
523 -- Note that this change fixes problems which existed prior to the change
kono
parents:
diff changeset
524 -- of Initialize being called more than once. See also Reinitialize which
kono
parents:
diff changeset
525 -- allows reinitialization of the tables.
kono
parents:
diff changeset
526
kono
parents:
diff changeset
527 procedure Reinitialize;
kono
parents:
diff changeset
528 -- Clears the name tables and removes all existing entries from the table.
kono
parents:
diff changeset
529
kono
parents:
diff changeset
530 procedure Reset_Name_Table;
kono
parents:
diff changeset
531 -- This procedure is used when there are multiple source files to reset the
kono
parents:
diff changeset
532 -- name table info entries associated with current entries in the names
kono
parents:
diff changeset
533 -- table. There is no harm in keeping the names entries themselves from one
kono
parents:
diff changeset
534 -- compilation to another, but we can't keep the entity info, since this
kono
parents:
diff changeset
535 -- refers to tree nodes, which are destroyed between each main source file.
kono
parents:
diff changeset
536
kono
parents:
diff changeset
537 procedure Finalize;
kono
parents:
diff changeset
538 -- Called at the end of a use of the Namet package (before a subsequent
kono
parents:
diff changeset
539 -- call to Initialize). Currently this routine is only used to generate
kono
parents:
diff changeset
540 -- debugging output.
kono
parents:
diff changeset
541
kono
parents:
diff changeset
542 procedure Lock;
kono
parents:
diff changeset
543 -- Lock name tables before calling back end. We reserve some extra space
kono
parents:
diff changeset
544 -- before locking to avoid unnecessary inefficiencies when we unlock.
kono
parents:
diff changeset
545
kono
parents:
diff changeset
546 procedure Unlock;
kono
parents:
diff changeset
547 -- Unlocks the name table to allow use of the extra space reserved by the
kono
parents:
diff changeset
548 -- call to Lock. See gnat1drv for details of the need for this.
kono
parents:
diff changeset
549
kono
parents:
diff changeset
550 procedure Tree_Read;
kono
parents:
diff changeset
551 -- Initializes internal tables from current tree file using the relevant
kono
parents:
diff changeset
552 -- Table.Tree_Read routines. Note that Initialize should not be called if
kono
parents:
diff changeset
553 -- Tree_Read is used. Tree_Read includes all necessary initialization.
kono
parents:
diff changeset
554
kono
parents:
diff changeset
555 procedure Tree_Write;
kono
parents:
diff changeset
556 -- Writes out internal tables to current tree file using the relevant
kono
parents:
diff changeset
557 -- Table.Tree_Write routines.
kono
parents:
diff changeset
558
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
559 procedure Write_Name (Id : Valid_Name_Id);
111
kono
parents:
diff changeset
560 -- Write_Name writes the characters of the specified name using the
kono
parents:
diff changeset
561 -- standard output procedures in package Output. The name is written
kono
parents:
diff changeset
562 -- in encoded form (i.e. including Uhh, Whhh, Qx, _op as they appear in
kono
parents:
diff changeset
563 -- the name table). If Id is Error_Name, or No_Name, no text is output.
kono
parents:
diff changeset
564
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
565 procedure Write_Name_Decoded (Id : Valid_Name_Id);
111
kono
parents:
diff changeset
566 -- Like Write_Name, except that the name written is the decoded name, as
kono
parents:
diff changeset
567 -- described for Append_Decoded.
kono
parents:
diff changeset
568
kono
parents:
diff changeset
569 function Name_Entries_Count return Nat;
kono
parents:
diff changeset
570 -- Return current number of entries in the names table
kono
parents:
diff changeset
571
kono
parents:
diff changeset
572 --------------------------
kono
parents:
diff changeset
573 -- Obsolete Subprograms --
kono
parents:
diff changeset
574 --------------------------
kono
parents:
diff changeset
575
kono
parents:
diff changeset
576 -- The following routines operate on Global_Name_Buffer. New code should
kono
parents:
diff changeset
577 -- use the routines above, and declare Bounded_Strings as local
kono
parents:
diff changeset
578 -- variables. Existing code can be improved incrementally by removing calls
kono
parents:
diff changeset
579 -- to the following. ???If we eliminate all of these, we can remove
kono
parents:
diff changeset
580 -- Global_Name_Buffer. But be sure to look at namet.h first.
kono
parents:
diff changeset
581
kono
parents:
diff changeset
582 -- To see what these do, look at the bodies. They are all trivially defined
kono
parents:
diff changeset
583 -- in terms of routines above.
kono
parents:
diff changeset
584
kono
parents:
diff changeset
585 procedure Add_Char_To_Name_Buffer (C : Character);
kono
parents:
diff changeset
586 pragma Inline (Add_Char_To_Name_Buffer);
kono
parents:
diff changeset
587
kono
parents:
diff changeset
588 procedure Add_Nat_To_Name_Buffer (V : Nat);
kono
parents:
diff changeset
589
kono
parents:
diff changeset
590 procedure Add_Str_To_Name_Buffer (S : String);
kono
parents:
diff changeset
591
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
592 procedure Get_Decoded_Name_String (Id : Valid_Name_Id);
111
kono
parents:
diff changeset
593
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
594 procedure Get_Decoded_Name_String_With_Brackets (Id : Valid_Name_Id);
111
kono
parents:
diff changeset
595
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
596 procedure Get_Name_String (Id : Valid_Name_Id);
111
kono
parents:
diff changeset
597
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
598 procedure Get_Name_String_And_Append (Id : Valid_Name_Id);
111
kono
parents:
diff changeset
599
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
600 procedure Get_Unqualified_Decoded_Name_String (Id : Valid_Name_Id);
111
kono
parents:
diff changeset
601
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
602 procedure Get_Unqualified_Name_String (Id : Valid_Name_Id);
111
kono
parents:
diff changeset
603
kono
parents:
diff changeset
604 procedure Insert_Str_In_Name_Buffer (S : String; Index : Positive);
kono
parents:
diff changeset
605
kono
parents:
diff changeset
606 function Is_Internal_Name return Boolean;
kono
parents:
diff changeset
607
kono
parents:
diff changeset
608 procedure Set_Character_Literal_Name (C : Char_Code);
kono
parents:
diff changeset
609
kono
parents:
diff changeset
610 procedure Store_Encoded_Character (C : Char_Code);
kono
parents:
diff changeset
611
kono
parents:
diff changeset
612 ------------------------------
kono
parents:
diff changeset
613 -- File and Unit Name Types --
kono
parents:
diff changeset
614 ------------------------------
kono
parents:
diff changeset
615
kono
parents:
diff changeset
616 -- These are defined here in Namet rather than Fname and Uname to avoid
kono
parents:
diff changeset
617 -- problems with dependencies, and to avoid dragging in Fname and Uname
kono
parents:
diff changeset
618 -- into many more files, but it would be cleaner to move to Fname/Uname.
kono
parents:
diff changeset
619
kono
parents:
diff changeset
620 type File_Name_Type is new Name_Id;
kono
parents:
diff changeset
621 -- File names are stored in the names table and this type is used to
kono
parents:
diff changeset
622 -- indicate that a Name_Id value is being used to hold a simple file name
kono
parents:
diff changeset
623 -- (which does not include any directory information).
kono
parents:
diff changeset
624
kono
parents:
diff changeset
625 No_File : constant File_Name_Type := File_Name_Type (No_Name);
kono
parents:
diff changeset
626 -- Constant used to indicate no file is present (this is used for example
kono
parents:
diff changeset
627 -- when a search for a file indicates that no file of the name exists).
kono
parents:
diff changeset
628
kono
parents:
diff changeset
629 Error_File_Name : constant File_Name_Type := File_Name_Type (Error_Name);
kono
parents:
diff changeset
630 -- The special File_Name_Type value Error_File_Name is used to indicate
kono
parents:
diff changeset
631 -- a unit name where some previous processing has found an error.
kono
parents:
diff changeset
632
kono
parents:
diff changeset
633 subtype Error_File_Name_Or_No_File is
kono
parents:
diff changeset
634 File_Name_Type range No_File .. Error_File_Name;
kono
parents:
diff changeset
635 -- Used to test for either error file name or no file
kono
parents:
diff changeset
636
kono
parents:
diff changeset
637 type Path_Name_Type is new Name_Id;
kono
parents:
diff changeset
638 -- Path names are stored in the names table and this type is used to
kono
parents:
diff changeset
639 -- indicate that a Name_Id value is being used to hold a path name (that
kono
parents:
diff changeset
640 -- may contain directory information).
kono
parents:
diff changeset
641
kono
parents:
diff changeset
642 No_Path : constant Path_Name_Type := Path_Name_Type (No_Name);
kono
parents:
diff changeset
643 -- Constant used to indicate no path name is present
kono
parents:
diff changeset
644
kono
parents:
diff changeset
645 type Unit_Name_Type is new Name_Id;
kono
parents:
diff changeset
646 -- Unit names are stored in the names table and this type is used to
kono
parents:
diff changeset
647 -- indicate that a Name_Id value is being used to hold a unit name, which
kono
parents:
diff changeset
648 -- terminates in %b for a body or %s for a spec.
kono
parents:
diff changeset
649
kono
parents:
diff changeset
650 No_Unit_Name : constant Unit_Name_Type := Unit_Name_Type (No_Name);
kono
parents:
diff changeset
651 -- Constant used to indicate no file name present
kono
parents:
diff changeset
652
kono
parents:
diff changeset
653 Error_Unit_Name : constant Unit_Name_Type := Unit_Name_Type (Error_Name);
kono
parents:
diff changeset
654 -- The special Unit_Name_Type value Error_Unit_Name is used to indicate
kono
parents:
diff changeset
655 -- a unit name where some previous processing has found an error.
kono
parents:
diff changeset
656
kono
parents:
diff changeset
657 subtype Error_Unit_Name_Or_No_Unit_Name is
kono
parents:
diff changeset
658 Unit_Name_Type range No_Unit_Name .. Error_Unit_Name;
kono
parents:
diff changeset
659
kono
parents:
diff changeset
660 ------------------------
kono
parents:
diff changeset
661 -- Debugging Routines --
kono
parents:
diff changeset
662 ------------------------
kono
parents:
diff changeset
663
kono
parents:
diff changeset
664 procedure wn (Id : Name_Id);
kono
parents:
diff changeset
665 pragma Export (Ada, wn);
kono
parents:
diff changeset
666 -- This routine is intended for debugging use only (i.e. it is intended to
kono
parents:
diff changeset
667 -- be called from the debugger). It writes the characters of the specified
kono
parents:
diff changeset
668 -- name using the standard output procedures in package Output, followed by
kono
parents:
diff changeset
669 -- a new line. The name is written in encoded form (i.e. including Uhh,
kono
parents:
diff changeset
670 -- Whhh, Qx, _op as they appear in the name table). If Id is Error_Name,
kono
parents:
diff changeset
671 -- No_Name, or invalid an appropriate string is written (<Error_Name>,
kono
parents:
diff changeset
672 -- <No_Name>, <invalid name>). Unlike Write_Name, this call does not affect
kono
parents:
diff changeset
673 -- the contents of Name_Buffer or Name_Len.
kono
parents:
diff changeset
674
kono
parents:
diff changeset
675 private
kono
parents:
diff changeset
676
kono
parents:
diff changeset
677 ---------------------------
kono
parents:
diff changeset
678 -- Table Data Structures --
kono
parents:
diff changeset
679 ---------------------------
kono
parents:
diff changeset
680
kono
parents:
diff changeset
681 -- The following declarations define the data structures used to store
kono
parents:
diff changeset
682 -- names. The definitions are in the private part of the package spec,
kono
parents:
diff changeset
683 -- rather than the body, since they are referenced directly by gigi.
kono
parents:
diff changeset
684
kono
parents:
diff changeset
685 -- This table stores the actual string names. Although logically there is
kono
parents:
diff changeset
686 -- no need for a terminating character (since the length is stored in the
kono
parents:
diff changeset
687 -- name entry table), we still store a NUL character at the end of every
kono
parents:
diff changeset
688 -- name (for convenience in interfacing to the C world).
kono
parents:
diff changeset
689
kono
parents:
diff changeset
690 package Name_Chars is new Table.Table (
kono
parents:
diff changeset
691 Table_Component_Type => Character,
kono
parents:
diff changeset
692 Table_Index_Type => Int,
kono
parents:
diff changeset
693 Table_Low_Bound => 0,
kono
parents:
diff changeset
694 Table_Initial => Alloc.Name_Chars_Initial,
kono
parents:
diff changeset
695 Table_Increment => Alloc.Name_Chars_Increment,
kono
parents:
diff changeset
696 Table_Name => "Name_Chars");
kono
parents:
diff changeset
697
kono
parents:
diff changeset
698 type Name_Entry is record
kono
parents:
diff changeset
699 Name_Chars_Index : Int;
kono
parents:
diff changeset
700 -- Starting location of characters in the Name_Chars table minus one
kono
parents:
diff changeset
701 -- (i.e. pointer to character just before first character). The reason
kono
parents:
diff changeset
702 -- for the bias of one is that indexes in Name_Buffer are one's origin,
kono
parents:
diff changeset
703 -- so this avoids unnecessary adds and subtracts of 1.
kono
parents:
diff changeset
704
kono
parents:
diff changeset
705 Name_Len : Short;
kono
parents:
diff changeset
706 -- Length of this name in characters
kono
parents:
diff changeset
707
kono
parents:
diff changeset
708 Byte_Info : Byte;
kono
parents:
diff changeset
709 -- Byte value associated with this name
kono
parents:
diff changeset
710
kono
parents:
diff changeset
711 Boolean1_Info : Boolean;
kono
parents:
diff changeset
712 Boolean2_Info : Boolean;
kono
parents:
diff changeset
713 Boolean3_Info : Boolean;
kono
parents:
diff changeset
714 -- Boolean values associated with the name
kono
parents:
diff changeset
715
kono
parents:
diff changeset
716 Name_Has_No_Encodings : Boolean;
kono
parents:
diff changeset
717 -- This flag is set True if the name entry is known not to contain any
kono
parents:
diff changeset
718 -- special character encodings. This is used to speed up repeated calls
kono
parents:
diff changeset
719 -- to Append_Decoded. A value of False means that it is not known
kono
parents:
diff changeset
720 -- whether the name contains any such encodings.
kono
parents:
diff changeset
721
kono
parents:
diff changeset
722 Hash_Link : Name_Id;
kono
parents:
diff changeset
723 -- Link to next entry in names table for same hash code
kono
parents:
diff changeset
724
kono
parents:
diff changeset
725 Int_Info : Int;
kono
parents:
diff changeset
726 -- Int Value associated with this name
kono
parents:
diff changeset
727
kono
parents:
diff changeset
728 end record;
kono
parents:
diff changeset
729
kono
parents:
diff changeset
730 for Name_Entry use record
kono
parents:
diff changeset
731 Name_Chars_Index at 0 range 0 .. 31;
kono
parents:
diff changeset
732 Name_Len at 4 range 0 .. 15;
kono
parents:
diff changeset
733 Byte_Info at 6 range 0 .. 7;
kono
parents:
diff changeset
734 Boolean1_Info at 7 range 0 .. 0;
kono
parents:
diff changeset
735 Boolean2_Info at 7 range 1 .. 1;
kono
parents:
diff changeset
736 Boolean3_Info at 7 range 2 .. 2;
kono
parents:
diff changeset
737 Name_Has_No_Encodings at 7 range 3 .. 7;
kono
parents:
diff changeset
738 Hash_Link at 8 range 0 .. 31;
kono
parents:
diff changeset
739 Int_Info at 12 range 0 .. 31;
kono
parents:
diff changeset
740 end record;
kono
parents:
diff changeset
741
kono
parents:
diff changeset
742 for Name_Entry'Size use 16 * 8;
kono
parents:
diff changeset
743 -- This ensures that we did not leave out any fields
kono
parents:
diff changeset
744
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
745 -- This is the table that is referenced by Valid_Name_Id entries.
111
kono
parents:
diff changeset
746 -- It contains one entry for each unique name in the table.
kono
parents:
diff changeset
747
kono
parents:
diff changeset
748 package Name_Entries is new Table.Table (
kono
parents:
diff changeset
749 Table_Component_Type => Name_Entry,
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
750 Table_Index_Type => Valid_Name_Id'Base,
111
kono
parents:
diff changeset
751 Table_Low_Bound => First_Name_Id,
kono
parents:
diff changeset
752 Table_Initial => Alloc.Names_Initial,
kono
parents:
diff changeset
753 Table_Increment => Alloc.Names_Increment,
kono
parents:
diff changeset
754 Table_Name => "Name_Entries");
kono
parents:
diff changeset
755
kono
parents:
diff changeset
756 end Namet;