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