OSDN Git Service

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