OSDN Git Service

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