OSDN Git Service

2006-02-13 Arnaud Charlet <charlet@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / types.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                                T Y P E S                                 --
6 --                                                                          --
7 --                                 S p e c                                  --
8 --                                                                          --
9 --          Copyright (C) 1992-2006, 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 2,  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.  See the GNU General Public License --
17 -- for  more details.  You should have  received  a copy of the GNU General --
18 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
19 -- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
20 -- Boston, MA 02110-1301, USA.                                              --
21 --                                                                          --
22 -- As a special exception,  if other files  instantiate  generics from this --
23 -- unit, or you link  this unit with other files  to produce an executable, --
24 -- this  unit  does not  by itself cause  the resulting  executable  to  be --
25 -- covered  by the  GNU  General  Public  License.  This exception does not --
26 -- however invalidate  any other reasons why  the executable file  might be --
27 -- covered by the  GNU Public License.                                      --
28 --                                                                          --
29 -- GNAT was originally developed  by the GNAT team at  New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
31 --                                                                          --
32 ------------------------------------------------------------------------------
33
34 --  This package contains host independent type definitions which are used
35 --  in more than one unit in the compiler. They are gathered here for easy
36 --  reference, though in some cases the full description is found in the
37 --  relevant module which implements the definition. The main reason that
38 --  they are not in their "natural" specs is that this would cause a lot of
39 --  inter-spec dependencies, and in particular some awkward circular
40 --  dependencies would have to be dealt with.
41
42 --  WARNING: There is a C version of this package. Any changes to this
43 --  source file must be properly reflected in the C header file types.h
44
45 --  Note: the declarations in this package reflect an expectation that the
46 --  host machine has an efficient integer base type with a range at least
47 --  32 bits 2s-complement. If there are any machines for which this is not
48 --  a correct assumption, a significant number of changes will be required!
49
50 with Unchecked_Deallocation;
51
52 package Types is
53    pragma Preelaborate;
54
55    -------------------------------
56    -- General Use Integer Types --
57    -------------------------------
58
59    type Int is range -2 ** 31 .. +2 ** 31 - 1;
60    --  Signed 32-bit integer
61
62    type Dint is range -2 ** 63 .. +2 ** 63 - 1;
63    --  Double length (64-bit) integer
64
65    subtype Nat is Int range 0 .. Int'Last;
66    --  Non-negative Int values
67
68    subtype Pos is Int range 1 .. Int'Last;
69    --  Positive Int values
70
71    type Word is mod 2 ** 32;
72    --  Unsigned 32-bit integer
73
74    type Short is range -32768 .. +32767;
75    for Short'Size use 16;
76    --  16-bit signed integer
77
78    type Byte is mod 2 ** 8;
79    for Byte'Size use 8;
80    --  8-bit unsigned integer
81
82    type size_t is mod 2 ** Standard'Address_Size;
83    --  Memory size value, for use in calls to C routines
84
85    --------------------------------------
86    -- 8-Bit Character and String Types --
87    --------------------------------------
88
89    --  We use Standard.Character and Standard.String freely, since we are
90    --  compiling ourselves, and we properly implement the required 8-bit
91    --  character code as required in Ada 95. This section defines a few
92    --  general use constants and subtypes.
93
94    EOF : constant Character := ASCII.SUB;
95    --  The character SUB (16#1A#) is used in DOS and other systems derived
96    --  from DOS (OS/2, NT etc) to signal the end of a text file. Internally
97    --  all source files are ended by an EOF character, even on Unix systems.
98    --  An EOF character acts as the end of file only as the last character
99    --  of a source buffer, in any other position, it is treated as a blank
100    --  if it appears between tokens, and as an illegal character otherwise.
101    --  This makes life easier dealing with files that originated from DOS,
102    --  including concatenated files with interspersed EOF characters.
103
104    subtype Graphic_Character is Character range ' ' .. '~';
105    --  Graphic characters, as defined in ARM
106
107    subtype Line_Terminator is Character range ASCII.LF .. ASCII.CR;
108    --  Line terminator characters (LF, VT, FF, CR)
109    --  This definition is dubious now that we have two more wide character
110    --  sequences that constitute a line terminator. Every reference to
111    --  this subtype needs checking to make sure the wide character case
112    --  is handled appropriately.
113
114    subtype Upper_Half_Character is
115      Character range Character'Val (16#80#) .. Character'Val (16#FF#);
116    --  Characters with the upper bit set
117
118    type Character_Ptr is access all Character;
119    type String_Ptr    is access all String;
120    --  Standard character and string pointers
121
122    procedure Free is new Unchecked_Deallocation (String, String_Ptr);
123    --  Procedure for freeing dynamically allocated String values
124
125    subtype Word_Hex_String is String (1 .. 8);
126    --  Type used to represent Word value as 8 hex digits, with lower case
127    --  letters for the alphabetic cases.
128
129    function Get_Hex_String (W : Word) return Word_Hex_String;
130    --  Convert word value to 8-character hex string
131
132    -----------------------------------------
133    -- Types Used for Text Buffer Handling --
134    -----------------------------------------
135
136    --  We can't use type String for text buffers, since we must use the
137    --  standard 32-bit integer as an index value, since we count on all
138    --  index values being the same size.
139
140    type Text_Ptr is new Int;
141    --  Type used for subscripts in text buffer
142
143    type Text_Buffer is array (Text_Ptr range <>) of Character;
144    --  Text buffer used to hold source file or library information file
145
146    type Text_Buffer_Ptr is access all Text_Buffer;
147    --  Text buffers for input files are allocated dynamically and this type
148    --  is used to reference these text buffers.
149
150    procedure Free is new Unchecked_Deallocation (Text_Buffer, Text_Buffer_Ptr);
151    --  Procedure for freeing dynamically allocated text buffers
152
153    ------------------------------------------
154    -- Types Used for Source Input Handling --
155    ------------------------------------------
156
157    type Logical_Line_Number is range 0 .. Int'Last;
158    for Logical_Line_Number'Size use 32;
159    --  Line number type, used for storing logical line numbers (i.e. line
160    --  numbers that include effects of any Source_Reference pragmas in the
161    --  source file). The value zero indicates a line containing a source
162    --  reference pragma.
163
164    No_Line_Number : constant Logical_Line_Number := 0;
165    --  Special value used to indicate no line number
166
167    type Physical_Line_Number is range 1 .. Int'Last;
168    for Physical_Line_Number'Size use 32;
169    --  Line number type, used for storing physical line numbers (i.e.
170    --  line numbers in the physical file being compiled, unaffected by
171    --  the presence of source reference pragmas.
172
173    type Column_Number is range 0 .. 32767;
174    for Column_Number'Size use 16;
175    --  Column number (assume that 2**15 - 1 is large enough). The range for
176    --  this type is used to compute Hostparm.Max_Line_Length. See also the
177    --  processing for -gnatyM in Stylesw).
178
179    No_Column_Number : constant Column_Number := 0;
180    --  Special value used to indicate no column number
181
182    subtype Source_Buffer is Text_Buffer;
183    --  Type used to store text of a source file . The buffer for the main
184    --  source (the source specified on the command line) has a lower bound
185    --  starting at zero. Subsequent subsidiary sources have lower bounds
186    --  which are one greater than the previous upper bound.
187
188    subtype Big_Source_Buffer is Text_Buffer (0 .. Text_Ptr'Last);
189    --  This is a virtual type used as the designated type of the access
190    --  type Source_Buffer_Ptr, see Osint.Read_Source_File for details.
191
192    type Source_Buffer_Ptr is access all Big_Source_Buffer;
193    --  Pointer to source buffer. We use virtual origin addressing for
194    --  source buffers, with thin pointers. The pointer points to a virtual
195    --  instance of type Big_Source_Buffer, where the actual type is in fact
196    --  of type Source_Buffer. The address is adjusted so that the virtual
197    --  origin addressing works correctly. See Osint.Read_Source_Buffer for
198    --  further details.
199
200    subtype Source_Ptr is Text_Ptr;
201    --  Type used to represent a source location, which is a subscript of a
202    --  character in the source buffer. As noted above, diffferent source
203    --  buffers have different ranges, so it is possible to tell from a
204    --  Source_Ptr value which source it refers to. Note that negative numbers
205    --  are allowed to accommodate the following special values.
206
207    No_Location : constant Source_Ptr := -1;
208    --  Value used to indicate no source position set in a node. A test for
209    --  a Source_Ptr value being >= No_Location is the apporoved way to test
210    --  for a standard value that does not include No_Location or any of the
211    --  following special definitions.
212
213    Standard_Location : constant Source_Ptr := -2;
214    --  Used for all nodes in the representation of package Standard other
215    --  than nodes representing the contents of Standard.ASCII. Note that
216    --  testing for <= Standard_Location tests for both Standard_Location
217    --  and for Standard_ASCII_Location.
218
219    Standard_ASCII_Location : constant Source_Ptr := -3;
220    --  Used for all nodes in the presentation of package Standard.ASCII
221
222    System_Location : constant Source_Ptr := -4;
223    --  Used to identify locations of pragmas scanned by Targparm, where we
224    --  know the location is in System, but we don't know exactly what line.
225
226    First_Source_Ptr : constant Source_Ptr := 0;
227    --  Starting source pointer index value for first source program
228
229    -------------------------------------
230    -- Range Definitions for Tree Data --
231    -------------------------------------
232
233    --  The tree has fields that can hold any of the following types:
234
235    --    Pointers to other tree nodes (type Node_Id)
236    --    List pointers (type List_Id)
237    --    Element list pointers (type Elist_Id)
238    --    Names (type Name_Id)
239    --    Strings (type String_Id)
240    --    Universal integers (type Uint)
241    --    Universal reals (type Ureal)
242
243    --  In most contexts, the strongly typed interface determines which of
244    --  these types is present. However, there are some situations (involving
245    --  untyped traversals of the tree), where it is convenient to be easily
246    --  able to distinguish these values. The underlying representation in all
247    --  cases is an integer type Union_Id, and we ensure that the range of
248    --  the various possible values for each of the above types is disjoint
249    --  so that this distinction is possible.
250
251    type Union_Id is new Int;
252    --  The type in the tree for a union of possible ID values
253
254    --  Note: it is also helpful for debugging purposes to make these ranges
255    --  distinct. If a bug leads to misidentification of a value, then it will
256    --  typically result in an out of range value and a Constraint_Error.
257
258    List_Low_Bound : constant := -100_000_000;
259    --  The List_Id values are subscripts into an array of list headers which
260    --  has List_Low_Bound as its lower bound. This value is chosen so that all
261    --  List_Id values are negative, and the value zero is in the range of both
262    --  List_Id and Node_Id values (see further description below).
263
264    List_High_Bound : constant := 0;
265    --  Maximum List_Id subscript value. This allows up to 100 million list
266    --  Id values, which is in practice infinite, and there is no need to
267    --  check the range. The range overlaps the node range by one element
268    --  (with value zero), which is used both for the Empty node, and for
269    --  indicating no list. The fact that the same value is used is convenient
270    --  because it means that the default value of Empty applies to both nodes
271    --  and lists, and also is more efficient to test for.
272
273    Node_Low_Bound : constant := 0;
274    --  The tree Id values start at zero, because we use zero for Empty (to
275    --  allow a zero test for Empty). Actual tree node subscripts start at 0
276    --  since Empty is a legitimate node value.
277
278    Node_High_Bound : constant := 099_999_999;
279    --  Maximum number of nodes that can be allocated is 100 million, which
280    --  is in practice infinite, and there is no need to check the range.
281
282    Elist_Low_Bound : constant := 100_000_000;
283    --  The Elist_Id values are subscripts into an array of elist headers which
284    --  has Elist_Low_Bound as its lower bound.
285
286    Elist_High_Bound : constant := 199_999_999;
287    --  Maximum Elist_Id subscript value. This allows up to 100 million Elists,
288    --  which is in practice infinite and there is no need to check the range.
289
290    Elmt_Low_Bound : constant := 200_000_000;
291    --  Low bound of element Id values. The use of these values is internal to
292    --  the Elists package, but the definition of the range is included here
293    --  since it must be disjoint from other Id values. The Elmt_Id values are
294    --  subscripts into an array of list elements which has this as lower bound.
295
296    Elmt_High_Bound : constant := 299_999_999;
297    --  Upper bound of Elmt_Id values. This allows up to 100 million element
298    --  list members, which is in practice infinite (no range check needed).
299
300    Names_Low_Bound : constant := 300_000_000;
301    --  Low bound for name Id values
302
303    Names_High_Bound : constant := 399_999_999;
304    --  Maximum number of names that can be allocated is 100 million, which is
305    --  in practice infinite and there is no need to check the range.
306
307    Strings_Low_Bound : constant := 400_000_000;
308    --  Low bound for string Id values
309
310    Strings_High_Bound : constant := 499_999_999;
311    --  Maximum number of strings that can be allocated is 100 million, which
312    --  is in practice infinite and there is no need to check the range.
313
314    Ureal_Low_Bound : constant := 500_000_000;
315    --  Low bound for Ureal values
316
317    Ureal_High_Bound : constant := 599_999_999;
318    --  Maximum number of Ureal values stored is 100_000_000 which is in
319    --  practice infinite so that no check is required.
320
321    Uint_Low_Bound : constant := 600_000_000;
322    --  Low bound for Uint values
323
324    Uint_Table_Start : constant := 2_000_000_000;
325    --  Location where table entries for universal integers start (see
326    --  Uintp spec for details of the representation of Uint values).
327
328    Uint_High_Bound : constant := 2_099_999_999;
329    --  The range of Uint values is very large, since a substantial part
330    --  of this range is used to store direct values, see Uintp for details.
331
332    --  The following subtype definitions are used to provide convenient names
333    --  for membership tests on Int values to see what data type range they
334    --  lie in. Such tests appear only in the lowest level packages.
335
336    subtype List_Range      is Union_Id
337      range List_Low_Bound   .. List_High_Bound;
338
339    subtype Node_Range      is Union_Id
340      range Node_Low_Bound   .. Node_High_Bound;
341
342    subtype Elist_Range     is Union_Id
343      range Elist_Low_Bound  .. Elist_High_Bound;
344
345    subtype Elmt_Range      is Union_Id
346      range Elmt_Low_Bound   .. Elmt_High_Bound;
347
348    subtype Names_Range     is Union_Id
349      range Names_Low_Bound   .. Names_High_Bound;
350
351    subtype Strings_Range   is Union_Id
352      range Strings_Low_Bound .. Strings_High_Bound;
353
354    subtype Uint_Range      is Union_Id
355      range Uint_Low_Bound    .. Uint_High_Bound;
356
357    subtype Ureal_Range     is Union_Id
358      range Ureal_Low_Bound    .. Ureal_High_Bound;
359
360    -----------------------------
361    -- Types for Namet Package --
362    -----------------------------
363
364    --  Name_Id values are used to identify entries in the names table. Except
365    --  for the special values No_Name, and Error_Name, they are subscript
366    --  values for the Names table defined in package Namet.
367
368    --  Note that with only a few exceptions, which are clearly documented, the
369    --  type Name_Id should be regarded as a private type. In particular it is
370    --  never appropriate to perform arithmetic operations using this type.
371
372    type Name_Id is range Names_Low_Bound .. Names_High_Bound;
373    for Name_Id'Size use 32;
374    --  Type used to identify entries in the names table
375
376    No_Name : constant Name_Id := Names_Low_Bound;
377    --  The special Name_Id value No_Name is used in the parser to indicate
378    --  a situation where no name is present (e.g. on a loop or block).
379
380    Error_Name : constant Name_Id := Names_Low_Bound +  1;
381    --  The special Name_Id value Error_Name is used in the parser to
382    --  indicate that some kind of error was encountered in scanning out
383    --  the relevant name, so it does not have a representable label.
384
385    subtype Error_Name_Or_No_Name is Name_Id range No_Name .. Error_Name;
386    --  Used to test for either error name or no name
387
388    First_Name_Id : constant Name_Id := Names_Low_Bound + 2;
389    --  Subscript of first entry in names table
390
391    ----------------------------
392    -- Types for Atree Package --
393    ----------------------------
394
395    --  Node_Id values are used to identify nodes in the tree. They are
396    --  subscripts into the Node table declared in package Tree. Note that
397    --  the special values Empty and Error are subscripts into this table,
398    --  See package Atree for further details.
399
400    type Node_Id is range Node_Low_Bound .. Node_High_Bound;
401    --  Type used to identify nodes in the tree
402
403    subtype Entity_Id is Node_Id;
404    --  A synonym for node types, used in the entity package to refer to
405    --  nodes that are entities (i.e. nodes with an Nkind of N_Defining_xxx)
406    --  All such nodes are extended nodes and these are the only extended
407    --  nodes, so that in practice entity and extended nodes are synonymous.
408
409    subtype Node_Or_Entity_Id is Node_Id;
410    --  A synonym for node types, used in cases where a given value may be used
411    --  to represent either a node or an entity. We like to minimize such uses
412    --  for obvious reasons of logical type consistency, but where such uses
413    --  occur, they should be documented by use of this type.
414
415    Empty : constant Node_Id := Node_Low_Bound;
416    --  Used to indicate null node. A node is actually allocated with this
417    --  Id value, so that Nkind (Empty) = N_Empty. Note that Node_Low_Bound
418    --  is zero, so Empty = No_List = zero.
419
420    Empty_List_Or_Node : constant := 0;
421    --  This constant is used in situations (e.g. initializing empty fields)
422    --  where the value set will be used to represent either an empty node
423    --  or a non-existent list, depending on the context.
424
425    Error : constant Node_Id := Node_Low_Bound + 1;
426    --  Used to indicate that there was an error in the source program. A node
427    --  is actually allocated at this address, so that Nkind (Error) = N_Error.
428
429    Empty_Or_Error : constant Node_Id := Error;
430    --  Since Empty and Error are the first two Node_Id values, the test for
431    --  N <= Empty_Or_Error tests to see if N is Empty or Error. This definition
432    --  provides convenient self-documentation for such tests.
433
434    First_Node_Id  : constant Node_Id := Node_Low_Bound;
435    --  Subscript of first allocated node. Note that Empty and Error are both
436    --  allocated nodes, whose Nkind fields can be accessed without error.
437
438    ------------------------------
439    -- Types for Nlists Package --
440    ------------------------------
441
442    --  List_Id values are used to identify node lists in the tree. They are
443    --  subscripts into the Lists table declared in package Tree. Note that
444    --  the special value Error_List is a subscript in this table, but the
445    --  value No_List is *not* a valid subscript, and any attempt to apply
446    --  list operations to No_List will cause a (detected) error.
447
448    type List_Id is range List_Low_Bound .. List_High_Bound;
449    --  Type used to identify a node list
450
451    No_List : constant List_Id := List_High_Bound;
452    --  Used to indicate absence of a list. Note that the value is zero, which
453    --  is the same as Empty, which is helpful in intializing nodes where a
454    --  value of zero can represent either an empty node or an empty list.
455
456    Error_List : constant List_Id := List_Low_Bound;
457    --  Used to indicate that there was an error in the source program in a
458    --  context which would normally require a list. This node appears to be
459    --  an empty list to the list operations (a null list is actually allocated
460    --  which has this Id value).
461
462    First_List_Id : constant List_Id := Error_List;
463    --  Subscript of first allocated list header
464
465    ------------------------------
466    -- Types for Elists Package --
467    ------------------------------
468
469    --  Element list Id values are used to identify element lists stored in
470    --  the tree (see package Tree for further details). They are formed by
471    --  adding a bias (Element_List_Bias) to subscript values in the same
472    --  array that is used for node list headers.
473
474    type Elist_Id is range Elist_Low_Bound .. Elist_High_Bound;
475    --  Type used to identify an element list (Elist header table subscript)
476
477    No_Elist : constant Elist_Id := Elist_Low_Bound;
478    --  Used to indicate absense of an element list. Note that this is not
479    --  an actual Elist header, so element list operations on this value
480    --  are not valid.
481
482    First_Elist_Id : constant Elist_Id := No_Elist + 1;
483    --  Subscript of first allocated Elist header
484
485    --  Element Id values are used to identify individual elements of an
486    --  element list (see package Elists for further details).
487
488    type Elmt_Id is range Elmt_Low_Bound .. Elmt_High_Bound;
489    --  Type used to identify an element list
490
491    No_Elmt : constant Elmt_Id := Elmt_Low_Bound;
492    --  Used to represent empty element
493
494    First_Elmt_Id : constant Elmt_Id := No_Elmt + 1;
495    --  Subscript of first allocated Elmt table entry
496
497    -------------------------------
498    -- Types for Stringt Package --
499    -------------------------------
500
501    --  String_Id values are used to identify entries in the strings table.
502    --  They are subscripts into the strings table defined in package Strings.
503
504    --  Note that with only a few exceptions, which are clearly documented, the
505    --  type String_Id should be regarded as a private type. In particular it is
506    --  never appropriate to perform arithmetic operations using this type.
507
508    type String_Id is range Strings_Low_Bound .. Strings_High_Bound;
509    --  Type used to identify entries in the strings table
510
511    No_String : constant String_Id := Strings_Low_Bound;
512    --  Used to indicate missing string Id. Note that the value zero is used
513    --  to indicate a missing data value for all the Int types in this section.
514
515    First_String_Id : constant String_Id := No_String + 1;
516    --  First subscript allocated in string table
517
518    -------------------------
519    -- Character Code Type --
520    -------------------------
521
522    --  The type Char is used for character data internally in the compiler,
523    --  but character codes in the source are represented by the Char_Code
524    --  type. Each character literal in the source is interpreted as being one
525    --  of the 16#8000_0000 possible Wide_Wide_Character codes, and a unique
526    --  Integer Value is assigned, corresponding to the UTF_32 value, which
527    --  also correspondds to the POS value in the Wide_Wide_Character type,
528    --  and also corresponds to the POS value in the Wide_Character and
529    --  Character types for values that are in appropriate range. String
530    --  literals are similarly interpreted as a sequence of such codes.
531
532    type Char_Code_Base is mod 2 ** 32;
533    for Char_Code_Base'Size use 32;
534
535    subtype Char_Code is Char_Code_Base range 0 .. 16#7FFF_FFFF#;
536    for Char_Code'Value_Size use 32;
537    for Char_Code'Object_Size use 32;
538
539    function Get_Char_Code (C : Character) return Char_Code;
540    pragma Inline (Get_Char_Code);
541    --  Function to obtain internal character code from source character. For
542    --  the moment, the internal character code is simply the Pos value of the
543    --  input source character, but we provide this interface for possible
544    --  later support of alternative character sets.
545
546    function In_Character_Range (C : Char_Code) return Boolean;
547    pragma Inline (In_Character_Range);
548    --  Determines if the given character code is in range of type Character,
549    --  and if so, returns True. If not, returns False.
550
551    function In_Wide_Character_Range (C : Char_Code) return Boolean;
552    pragma Inline (In_Wide_Character_Range);
553    --  Determines if the given character code is in range of the type
554    --  Wide_Character, and if so, returns True. If not, returns False.
555
556    function Get_Character (C : Char_Code) return Character;
557    pragma Inline (Get_Character);
558    --  For a character C that is in Character range (see above function), this
559    --  function returns the corresponding Character value. It is an error to
560    --  call Get_Character if C is not in C haracter range
561
562    function Get_Wide_Character (C : Char_Code) return Wide_Character;
563    --  For a character C that is in Wide_Character range (see above function),
564    --  this function returns the corresponding Wide_Character value. It is an
565    --  error to call Get_Wide_Character if C is not in Wide_Character range.
566
567    ---------------------------------------
568    -- Types used for Library Management --
569    ---------------------------------------
570
571    type Unit_Number_Type is new Int;
572    --  Unit number. The main source is unit 0, and subsidiary sources have
573    --  non-zero numbers starting with 1. Unit numbers are used to index the
574    --  file table in Lib.
575
576    Main_Unit : constant Unit_Number_Type := 0;
577    --  Unit number value for main unit
578
579    No_Unit : constant Unit_Number_Type := -1;
580    --  Special value used to signal no unit
581
582    type Source_File_Index is new Int range -1 .. Int'Last;
583    --  Type used to index the source file table (see package Sinput)
584
585    Internal_Source_File : constant Source_File_Index :=
586                             Source_File_Index'First;
587    --  Value used to indicate the buffer for the source-code-like strings
588    --  internally created withing the compiler (see package Sinput)
589
590    No_Source_File : constant Source_File_Index := 0;
591    --  Value used to indicate no source file present
592
593    subtype File_Name_Type is Name_Id;
594    --  File names are stored in the names table and this synonym is used to
595    --  indicate that a Name_Id value is being used to hold a simple file
596    --  name (which does not include any directory information).
597
598    No_File : constant File_Name_Type := File_Name_Type (No_Name);
599    --  Constant used to indicate no file found
600
601    subtype Unit_Name_Type is Name_Id;
602    --  Unit names are stored in the names table and this synonym is used to
603    --  indicate that a Name_Id value is being used to hold a unit name.
604
605    -----------------------------------
606    -- Representation of Time Stamps --
607    -----------------------------------
608
609    --  All compiled units are marked with a time stamp which is derived from
610    --  the source file (we assume that the host system has the concept of a
611    --  file time stamp which is modified when a file is modified). These
612    --  time stamps are used to ensure consistency of the set of units that
613    --  constitutes a library. Time stamps are 12 character strings with
614    --  with the following format:
615
616    --     YYYYMMDDHHMMSS
617
618    --       YYYY   year
619    --       MM     month (2 digits 01-12)
620    --       DD     day (2 digits 01-31)
621    --       HH     hour (2 digits 00-23)
622    --       MM     minutes (2 digits 00-59)
623    --       SS     seconds (2 digits 00-59)
624
625    --  In the case of Unix systems (and other systems which keep the time in
626    --  GMT), the time stamp is the GMT time of the file, not the local time.
627    --  This solves problems in using libraries across networks with clients
628    --  spread across multiple time-zones.
629
630    Time_Stamp_Length : constant := 14;
631    --  Length of time stamp value
632
633    subtype Time_Stamp_Index is Natural range 1 .. Time_Stamp_Length;
634    type Time_Stamp_Type is new String (Time_Stamp_Index);
635    --  Type used to represent time stamp
636
637    Empty_Time_Stamp : constant Time_Stamp_Type := (others => ' ');
638    --  Type used to represent an empty or missing time stamp. Looks less
639    --  than any real time stamp if two time stamps are compared. Note that
640    --  although this is not a private type, clients should not rely on the
641    --  exact way in which this string is represented, and instead should
642    --  use the subprograms below.
643
644    Dummy_Time_Stamp : constant Time_Stamp_Type := (others => '0');
645    --  This is used for dummy time stamp values used in the D lines for
646    --  non-existant files, and is intended to be an impossible value.
647
648    function "="  (Left, Right : Time_Stamp_Type) return Boolean;
649    function "<=" (Left, Right : Time_Stamp_Type) return Boolean;
650    function ">=" (Left, Right : Time_Stamp_Type) return Boolean;
651    function "<"  (Left, Right : Time_Stamp_Type) return Boolean;
652    function ">"  (Left, Right : Time_Stamp_Type) return Boolean;
653    --  Comparison functions on time stamps. Note that two time stamps
654    --  are defined as being equal if they have the same day/month/year
655    --  and the hour/minutes/seconds values are within 2 seconds of one
656    --  another. This deals with rounding effects in library file time
657    --  stamps caused by copying operations during installation. We have
658    --  particularly noticed that WinNT seems susceptible to such changes.
659    --  Note: the Empty_Time_Stamp value looks equal to itself, and less
660    --  than any non-empty time stamp value.
661
662    procedure Split_Time_Stamp
663      (TS      : Time_Stamp_Type;
664       Year    : out Nat;
665       Month   : out Nat;
666       Day     : out Nat;
667       Hour    : out Nat;
668       Minutes : out Nat;
669       Seconds : out Nat);
670    --  Given a time stamp, decompose it into its components
671
672    procedure Make_Time_Stamp
673      (Year    : Nat;
674       Month   : Nat;
675       Day     : Nat;
676       Hour    : Nat;
677       Minutes : Nat;
678       Seconds : Nat;
679       TS      : out Time_Stamp_Type);
680    --  Given the components of a time stamp, initialize the value
681
682    -----------------------------------------------
683    -- Types used for Pragma Suppress Management --
684    -----------------------------------------------
685
686    type Check_Id is (
687       Access_Check,
688       Accessibility_Check,
689       Discriminant_Check,
690       Division_Check,
691       Elaboration_Check,
692       Index_Check,
693       Length_Check,
694       Overflow_Check,
695       Range_Check,
696       Storage_Check,
697       Tag_Check,
698       All_Checks);
699
700    --  The following array contains an entry for each recognized check name
701    --  for pragma Suppress. It is used to represent current settings of scope
702    --  based suppress actions from pragma Suppress or command line settings.
703
704    --  Note: when Suppress_Array (All_Checks) is True, then generally all other
705    --  specific check entries are set True, except for the Elaboration_Check
706    --  entry which is set only if an explicit Suppress for this check is given.
707    --  The reason for this non-uniformity is that we do not want All_Checks to
708    --  suppress elaboration checking when using the static elaboration model.
709    --  We recognize only an explicit suppress of Elaboration_Check as a signal
710    --  that the static elaboration checking should skip a compile time check.
711
712    type Suppress_Array is array (Check_Id) of Boolean;
713    pragma Pack (Suppress_Array);
714
715    --  To add a new check type to GNAT, the following steps are required:
716
717    --    1.  Add an entry to Snames spec and body for the new name
718    --    2.  Add an entry to the definition of Check_Id above
719    --    3.  Add a new function to Checks to handle the new check test
720    --    4.  Add a new Do_xxx_Check flag to Sinfo (if required)
721    --    5.  Add appropriate checks for the new test
722
723    -----------------------------------
724    -- Global Exception Declarations --
725    -----------------------------------
726
727    --  This section contains declarations of exceptions that are used
728    --  throughout the compiler or in other GNAT tools.
729
730    Unrecoverable_Error : exception;
731    --  This exception is raised to immediately terminate the compilation
732    --  of the current source program. Used in situations where things are
733    --  bad enough that it doesn't seem worth continuing (e.g. max errors
734    --  reached, or a required file is not found). Also raised when the
735    --  compiler finds itself in trouble after an error (see Comperr).
736
737    Terminate_Program : exception;
738    --  This exception is raised to immediately terminate the tool being
739    --  executed. Each tool where this exception may be raised must have
740    --  a single exception handler that contains only a null statement and
741    --  that is the last statement of the program. If needed, procedure
742    --  Set_Exit_Status is called with the appropriate exit status before
743    --  raising Terminate_Program.
744
745    ---------------------------------
746    -- Parameter Mechanism Control --
747    ---------------------------------
748
749    --  Function and parameter entities have a field that records the
750    --  passing mechanism. See specification of Sem_Mech for full details.
751    --  The following subtype is used to represent values of this type:
752
753    subtype Mechanism_Type is Int range -10 .. Int'Last;
754    --  Type used to represent a mechanism value. This is a subtype rather
755    --  than a type to avoid some annoying processing problems with certain
756    --  routines in Einfo (processing them to create the corresponding C).
757
758    ------------------------------
759    -- Run-Time Exception Codes --
760    ------------------------------
761
762    --  When the code generator generates a run-time exception, it provides
763    --  a reason code which is one of the following. This reason code is used
764    --  to select the appropriate run-time routine to be called, determining
765    --  both the exception to be raised, and the message text to be added.
766
767    --  The prefix CE/PE/SE indicates the exception to be raised
768    --    CE = Constraint_Error
769    --    PE = Program_Error
770    --    SE = Storage_Error
771
772    --  The remaining part of the name indicates the message text to be added,
773    --  where all letters are lower case, and underscores are converted to
774    --  spaces (for example CE_Invalid_Data adds the text "invalid data").
775
776    --  To add a new code, you need to do the following:
777
778    --    1. Modify the type and subtype declarations below appropriately,
779    --       keeping things in alphabetical order.
780
781    --    2. Modify the corresponding definitions in types.h, including
782    --       the definition of last_reason_code.
783
784    --    3. Add a new routine in Ada.Exceptions with the appropriate call
785    --       and static string constant. Note that there is more than one
786    --       version of a-except.adb which must be modified.
787
788    type RT_Exception_Code is
789      (CE_Access_Check_Failed,            -- 00
790       CE_Access_Parameter_Is_Null,       -- 01
791       CE_Discriminant_Check_Failed,      -- 02
792       CE_Divide_By_Zero,                 -- 03
793       CE_Explicit_Raise,                 -- 04
794       CE_Index_Check_Failed,             -- 05
795       CE_Invalid_Data,                   -- 06
796       CE_Length_Check_Failed,            -- 07
797       CE_Null_Exception_Id,              -- 08
798       CE_Null_Not_Allowed,               -- 09
799       CE_Overflow_Check_Failed,          -- 10
800       CE_Partition_Check_Failed,         -- 11
801       CE_Range_Check_Failed,             -- 12
802       CE_Tag_Check_Failed,               -- 13
803
804       PE_Access_Before_Elaboration,      -- 14
805       PE_Accessibility_Check_Failed,     -- 15
806       PE_All_Guards_Closed,              -- 16
807       PE_Duplicated_Entry_Address,       -- 17
808       PE_Explicit_Raise,                 -- 18
809       PE_Finalize_Raised_Exception,      -- 19
810       PE_Implicit_Return,                -- 20
811       PE_Misaligned_Address_Value,       -- 21
812       PE_Missing_Return,                 -- 22
813       PE_Overlaid_Controlled_Object,     -- 23
814       PE_Potentially_Blocking_Operation, -- 24
815       PE_Stubbed_Subprogram_Called,      -- 25
816       PE_Unchecked_Union_Restriction,    -- 26
817       PE_Illegal_RACW_E_4_18,            -- 27
818
819       SE_Empty_Storage_Pool,             -- 28
820       SE_Explicit_Raise,                 -- 29
821       SE_Infinite_Recursion,             -- 30
822       SE_Object_Too_Large,               -- 31
823       SE_Restriction_Violation);         -- 32
824
825    subtype RT_CE_Exceptions is RT_Exception_Code range
826      CE_Access_Check_Failed ..
827      CE_Tag_Check_Failed;
828
829    subtype RT_PE_Exceptions is RT_Exception_Code range
830      PE_Access_Before_Elaboration ..
831      PE_Illegal_RACW_E_4_18;
832
833    subtype RT_SE_Exceptions is RT_Exception_Code range
834      SE_Empty_Storage_Pool ..
835      SE_Restriction_Violation;
836
837 end Types;