1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2007, Free Software Foundation, Inc. --
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. --
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. --
29 -- GNAT was originally developed by the GNAT team at New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
32 ------------------------------------------------------------------------------
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
39 -- of inter-spec dependencies, and in particular some awkward circular
40 -- dependencies would have to be dealt with.
42 -- WARNING: There is a C version of this package. Any changes to this source
43 -- file must be properly reflected in the C header file types.h declarations.
45 -- Note: the declarations in this package reflect an expectation that the host
46 -- machine has an efficient integer base type with a range at least 32 bits
47 -- 2s-complement. If there are any machines for which this is not a correct
48 -- assumption, a significant number of changes will be required!
50 with Unchecked_Deallocation;
55 -------------------------------
56 -- General Use Integer Types --
57 -------------------------------
59 type Int is range -2 ** 31 .. +2 ** 31 - 1;
60 -- Signed 32-bit integer
62 type Dint is range -2 ** 63 .. +2 ** 63 - 1;
63 -- Double length (64-bit) integer
65 subtype Nat is Int range 0 .. Int'Last;
66 -- Non-negative Int values
68 subtype Pos is Int range 1 .. Int'Last;
69 -- Positive Int values
71 type Word is mod 2 ** 32;
72 -- Unsigned 32-bit integer
74 type Short is range -32768 .. +32767;
75 for Short'Size use 16;
76 -- 16-bit signed integer
78 type Byte is mod 2 ** 8;
80 -- 8-bit unsigned integer
82 type size_t is mod 2 ** Standard'Address_Size;
83 -- Memory size value, for use in calls to C routines
85 --------------------------------------
86 -- 8-Bit Character and String Types --
87 --------------------------------------
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.
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.
104 subtype Graphic_Character is Character range ' ' .. '~';
105 -- Graphic characters, as defined in ARM
107 subtype Line_Terminator is Character range ASCII.LF .. ASCII.CR;
108 -- Line terminator characters (LF, VT, FF, CR)
110 -- This definition is dubious now that we have two more wide character
111 -- sequences that constitute a line terminator. Every reference to
112 -- this subtype needs checking to make sure the wide character case
113 -- is handled appropriately. ???
115 subtype Upper_Half_Character is
116 Character range Character'Val (16#80#) .. Character'Val (16#FF#);
117 -- Characters with the upper bit set
119 type Character_Ptr is access all Character;
120 type String_Ptr is access all String;
121 -- Standard character and string pointers
123 procedure Free is new Unchecked_Deallocation (String, String_Ptr);
124 -- Procedure for freeing dynamically allocated String values
126 subtype Word_Hex_String is String (1 .. 8);
127 -- Type used to represent Word value as 8 hex digits, with lower case
128 -- letters for the alphabetic cases.
130 function Get_Hex_String (W : Word) return Word_Hex_String;
131 -- Convert word value to 8-character hex string
133 -----------------------------------------
134 -- Types Used for Text Buffer Handling --
135 -----------------------------------------
137 -- We can't use type String for text buffers, since we must use the
138 -- standard 32-bit integer as an index value, since we count on all
139 -- index values being the same size.
141 type Text_Ptr is new Int;
142 -- Type used for subscripts in text buffer
144 type Text_Buffer is array (Text_Ptr range <>) of Character;
145 -- Text buffer used to hold source file or library information file
147 type Text_Buffer_Ptr is access all Text_Buffer;
148 -- Text buffers for input files are allocated dynamically and this type
149 -- is used to reference these text buffers.
151 procedure Free is new Unchecked_Deallocation (Text_Buffer, Text_Buffer_Ptr);
152 -- Procedure for freeing dynamically allocated text buffers
154 ------------------------------------------
155 -- Types Used for Source Input Handling --
156 ------------------------------------------
158 type Logical_Line_Number is range 0 .. Int'Last;
159 for Logical_Line_Number'Size use 32;
160 -- Line number type, used for storing logical line numbers (i.e. line
161 -- numbers that include effects of any Source_Reference pragmas in the
162 -- source file). The value zero indicates a line containing a source
165 No_Line_Number : constant Logical_Line_Number := 0;
166 -- Special value used to indicate no line number
168 type Physical_Line_Number is range 1 .. Int'Last;
169 for Physical_Line_Number'Size use 32;
170 -- Line number type, used for storing physical line numbers (i.e.
171 -- line numbers in the physical file being compiled, unaffected by
172 -- the presence of source reference pragmas.
174 type Column_Number is range 0 .. 32767;
175 for Column_Number'Size use 16;
176 -- Column number (assume that 2**15 - 1 is large enough). The range for
177 -- this type is used to compute Hostparm.Max_Line_Length. See also the
178 -- processing for -gnatyM in Stylesw).
180 No_Column_Number : constant Column_Number := 0;
181 -- Special value used to indicate no column number
183 subtype Source_Buffer is Text_Buffer;
184 -- Type used to store text of a source file . The buffer for the main
185 -- source (the source specified on the command line) has a lower bound
186 -- starting at zero. Subsequent subsidiary sources have lower bounds
187 -- which are one greater than the previous upper bound.
189 subtype Big_Source_Buffer is Text_Buffer (0 .. Text_Ptr'Last);
190 -- This is a virtual type used as the designated type of the access
191 -- type Source_Buffer_Ptr, see Osint.Read_Source_File for details.
193 type Source_Buffer_Ptr is access all Big_Source_Buffer;
194 -- Pointer to source buffer. We use virtual origin addressing for
195 -- source buffers, with thin pointers. The pointer points to a virtual
196 -- instance of type Big_Source_Buffer, where the actual type is in fact
197 -- of type Source_Buffer. The address is adjusted so that the virtual
198 -- origin addressing works correctly. See Osint.Read_Source_Buffer for
201 subtype Source_Ptr is Text_Ptr;
202 -- Type used to represent a source location, which is a subscript of a
203 -- character in the source buffer. As noted above, diffferent source
204 -- buffers have different ranges, so it is possible to tell from a
205 -- Source_Ptr value which source it refers to. Note that negative numbers
206 -- are allowed to accommodate the following special values.
208 No_Location : constant Source_Ptr := -1;
209 -- Value used to indicate no source position set in a node. A test for
210 -- a Source_Ptr value being > No_Location is the approved way to test
211 -- for a standard value that does not include No_Location or any of the
212 -- following special definitions. One important use of No_Location is to
213 -- label generated nodes that we don't want the debugger to see in normal
214 -- mode (very often we conditionalize so that we set No_Location in normal
215 -- mode and the corresponding source line in -gnatD mode).
217 Standard_Location : constant Source_Ptr := -2;
218 -- Used for all nodes in the representation of package Standard other
219 -- than nodes representing the contents of Standard.ASCII. Note that
220 -- testing for <= Standard_Location tests for both Standard_Location
221 -- and for Standard_ASCII_Location.
223 Standard_ASCII_Location : constant Source_Ptr := -3;
224 -- Used for all nodes in the presentation of package Standard.ASCII
226 System_Location : constant Source_Ptr := -4;
227 -- Used to identify locations of pragmas scanned by Targparm, where we
228 -- know the location is in System, but we don't know exactly what line.
230 First_Source_Ptr : constant Source_Ptr := 0;
231 -- Starting source pointer index value for first source program
233 -------------------------------------
234 -- Range Definitions for Tree Data --
235 -------------------------------------
237 -- The tree has fields that can hold any of the following types:
239 -- Pointers to other tree nodes (type Node_Id)
240 -- List pointers (type List_Id)
241 -- Element list pointers (type Elist_Id)
242 -- Names (type Name_Id)
243 -- Strings (type String_Id)
244 -- Universal integers (type Uint)
245 -- Universal reals (type Ureal)
247 -- In most contexts, the strongly typed interface determines which of
248 -- these types is present. However, there are some situations (involving
249 -- untyped traversals of the tree), where it is convenient to be easily
250 -- able to distinguish these values. The underlying representation in all
251 -- cases is an integer type Union_Id, and we ensure that the range of
252 -- the various possible values for each of the above types is disjoint
253 -- so that this distinction is possible.
255 type Union_Id is new Int;
256 -- The type in the tree for a union of possible ID values
258 -- Note: it is also helpful for debugging purposes to make these ranges
259 -- distinct. If a bug leads to misidentification of a value, then it will
260 -- typically result in an out of range value and a Constraint_Error.
262 List_Low_Bound : constant := -100_000_000;
263 -- The List_Id values are subscripts into an array of list headers which
264 -- has List_Low_Bound as its lower bound. This value is chosen so that all
265 -- List_Id values are negative, and the value zero is in the range of both
266 -- List_Id and Node_Id values (see further description below).
268 List_High_Bound : constant := 0;
269 -- Maximum List_Id subscript value. This allows up to 100 million list
270 -- Id values, which is in practice infinite, and there is no need to
271 -- check the range. The range overlaps the node range by one element
272 -- (with value zero), which is used both for the Empty node, and for
273 -- indicating no list. The fact that the same value is used is convenient
274 -- because it means that the default value of Empty applies to both nodes
275 -- and lists, and also is more efficient to test for.
277 Node_Low_Bound : constant := 0;
278 -- The tree Id values start at zero, because we use zero for Empty (to
279 -- allow a zero test for Empty). Actual tree node subscripts start at 0
280 -- since Empty is a legitimate node value.
282 Node_High_Bound : constant := 099_999_999;
283 -- Maximum number of nodes that can be allocated is 100 million, which
284 -- is in practice infinite, and there is no need to check the range.
286 Elist_Low_Bound : constant := 100_000_000;
287 -- The Elist_Id values are subscripts into an array of elist headers which
288 -- has Elist_Low_Bound as its lower bound.
290 Elist_High_Bound : constant := 199_999_999;
291 -- Maximum Elist_Id subscript value. This allows up to 100 million Elists,
292 -- which is in practice infinite and there is no need to check the range.
294 Elmt_Low_Bound : constant := 200_000_000;
295 -- Low bound of element Id values. The use of these values is internal to
296 -- the Elists package, but the definition of the range is included here
297 -- since it must be disjoint from other Id values. The Elmt_Id values are
298 -- subscripts into an array of list elements which has this as lower bound.
300 Elmt_High_Bound : constant := 299_999_999;
301 -- Upper bound of Elmt_Id values. This allows up to 100 million element
302 -- list members, which is in practice infinite (no range check needed).
304 Names_Low_Bound : constant := 300_000_000;
305 -- Low bound for name Id values
307 Names_High_Bound : constant := 399_999_999;
308 -- Maximum number of names that can be allocated is 100 million, which is
309 -- in practice infinite and there is no need to check the range.
311 Strings_Low_Bound : constant := 400_000_000;
312 -- Low bound for string Id values
314 Strings_High_Bound : constant := 499_999_999;
315 -- Maximum number of strings that can be allocated is 100 million, which
316 -- is in practice infinite and there is no need to check the range.
318 Ureal_Low_Bound : constant := 500_000_000;
319 -- Low bound for Ureal values
321 Ureal_High_Bound : constant := 599_999_999;
322 -- Maximum number of Ureal values stored is 100_000_000 which is in
323 -- practice infinite so that no check is required.
325 Uint_Low_Bound : constant := 600_000_000;
326 -- Low bound for Uint values
328 Uint_Table_Start : constant := 2_000_000_000;
329 -- Location where table entries for universal integers start (see
330 -- Uintp spec for details of the representation of Uint values).
332 Uint_High_Bound : constant := 2_099_999_999;
333 -- The range of Uint values is very large, since a substantial part
334 -- of this range is used to store direct values, see Uintp for details.
336 -- The following subtype definitions are used to provide convenient names
337 -- for membership tests on Int values to see what data type range they
338 -- lie in. Such tests appear only in the lowest level packages.
340 subtype List_Range is Union_Id
341 range List_Low_Bound .. List_High_Bound;
343 subtype Node_Range is Union_Id
344 range Node_Low_Bound .. Node_High_Bound;
346 subtype Elist_Range is Union_Id
347 range Elist_Low_Bound .. Elist_High_Bound;
349 subtype Elmt_Range is Union_Id
350 range Elmt_Low_Bound .. Elmt_High_Bound;
352 subtype Names_Range is Union_Id
353 range Names_Low_Bound .. Names_High_Bound;
355 subtype Strings_Range is Union_Id
356 range Strings_Low_Bound .. Strings_High_Bound;
358 subtype Uint_Range is Union_Id
359 range Uint_Low_Bound .. Uint_High_Bound;
361 subtype Ureal_Range is Union_Id
362 range Ureal_Low_Bound .. Ureal_High_Bound;
364 ----------------------------
365 -- Types for Atree Package --
366 ----------------------------
368 -- Node_Id values are used to identify nodes in the tree. They are
369 -- subscripts into the Node table declared in package Tree. Note that
370 -- the special values Empty and Error are subscripts into this table,
371 -- See package Atree for further details.
373 type Node_Id is range Node_Low_Bound .. Node_High_Bound;
374 -- Type used to identify nodes in the tree
376 subtype Entity_Id is Node_Id;
377 -- A synonym for node types, used in the entity package to refer to
378 -- nodes that are entities (i.e. nodes with an Nkind of N_Defining_xxx)
379 -- All such nodes are extended nodes and these are the only extended
380 -- nodes, so that in practice entity and extended nodes are synonymous.
382 subtype Node_Or_Entity_Id is Node_Id;
383 -- A synonym for node types, used in cases where a given value may be used
384 -- to represent either a node or an entity. We like to minimize such uses
385 -- for obvious reasons of logical type consistency, but where such uses
386 -- occur, they should be documented by use of this type.
388 Empty : constant Node_Id := Node_Low_Bound;
389 -- Used to indicate null node. A node is actually allocated with this
390 -- Id value, so that Nkind (Empty) = N_Empty. Note that Node_Low_Bound
391 -- is zero, so Empty = No_List = zero.
393 Empty_List_Or_Node : constant := 0;
394 -- This constant is used in situations (e.g. initializing empty fields)
395 -- where the value set will be used to represent either an empty node
396 -- or a non-existent list, depending on the context.
398 Error : constant Node_Id := Node_Low_Bound + 1;
399 -- Used to indicate that there was an error in the source program. A node
400 -- is actually allocated at this address, so that Nkind (Error) = N_Error.
402 Empty_Or_Error : constant Node_Id := Error;
403 -- Since Empty and Error are the first two Node_Id values, the test for
404 -- N <= Empty_Or_Error tests to see if N is Empty or Error. This definition
405 -- provides convenient self-documentation for such tests.
407 First_Node_Id : constant Node_Id := Node_Low_Bound;
408 -- Subscript of first allocated node. Note that Empty and Error are both
409 -- allocated nodes, whose Nkind fields can be accessed without error.
411 ------------------------------
412 -- Types for Nlists Package --
413 ------------------------------
415 -- List_Id values are used to identify node lists in the tree. They are
416 -- subscripts into the Lists table declared in package Tree. Note that
417 -- the special value Error_List is a subscript in this table, but the
418 -- value No_List is *not* a valid subscript, and any attempt to apply
419 -- list operations to No_List will cause a (detected) error.
421 type List_Id is range List_Low_Bound .. List_High_Bound;
422 -- Type used to identify a node list
424 No_List : constant List_Id := List_High_Bound;
425 -- Used to indicate absence of a list. Note that the value is zero, which
426 -- is the same as Empty, which is helpful in intializing nodes where a
427 -- value of zero can represent either an empty node or an empty list.
429 Error_List : constant List_Id := List_Low_Bound;
430 -- Used to indicate that there was an error in the source program in a
431 -- context which would normally require a list. This node appears to be
432 -- an empty list to the list operations (a null list is actually allocated
433 -- which has this Id value).
435 First_List_Id : constant List_Id := Error_List;
436 -- Subscript of first allocated list header
438 ------------------------------
439 -- Types for Elists Package --
440 ------------------------------
442 -- Element list Id values are used to identify element lists stored in
443 -- the tree (see package Tree for further details). They are formed by
444 -- adding a bias (Element_List_Bias) to subscript values in the same
445 -- array that is used for node list headers.
447 type Elist_Id is range Elist_Low_Bound .. Elist_High_Bound;
448 -- Type used to identify an element list (Elist header table subscript)
450 No_Elist : constant Elist_Id := Elist_Low_Bound;
451 -- Used to indicate absense of an element list. Note that this is not
452 -- an actual Elist header, so element list operations on this value
455 First_Elist_Id : constant Elist_Id := No_Elist + 1;
456 -- Subscript of first allocated Elist header
458 -- Element Id values are used to identify individual elements of an
459 -- element list (see package Elists for further details).
461 type Elmt_Id is range Elmt_Low_Bound .. Elmt_High_Bound;
462 -- Type used to identify an element list
464 No_Elmt : constant Elmt_Id := Elmt_Low_Bound;
465 -- Used to represent empty element
467 First_Elmt_Id : constant Elmt_Id := No_Elmt + 1;
468 -- Subscript of first allocated Elmt table entry
470 -------------------------------
471 -- Types for Stringt Package --
472 -------------------------------
474 -- String_Id values are used to identify entries in the strings table.
475 -- They are subscripts into the strings table defined in package Strings.
477 -- Note that with only a few exceptions, which are clearly documented, the
478 -- type String_Id should be regarded as a private type. In particular it is
479 -- never appropriate to perform arithmetic operations using this type.
481 type String_Id is range Strings_Low_Bound .. Strings_High_Bound;
482 -- Type used to identify entries in the strings table
484 No_String : constant String_Id := Strings_Low_Bound;
485 -- Used to indicate missing string Id. Note that the value zero is used
486 -- to indicate a missing data value for all the Int types in this section.
488 First_String_Id : constant String_Id := No_String + 1;
489 -- First subscript allocated in string table
491 -------------------------
492 -- Character Code Type --
493 -------------------------
495 -- The type Char is used for character data internally in the compiler,
496 -- but character codes in the source are represented by the Char_Code
497 -- type. Each character literal in the source is interpreted as being one
498 -- of the 16#8000_0000 possible Wide_Wide_Character codes, and a unique
499 -- Integer Value is assigned, corresponding to the UTF_32 value, which
500 -- also correspondds to the POS value in the Wide_Wide_Character type,
501 -- and also corresponds to the POS value in the Wide_Character and
502 -- Character types for values that are in appropriate range. String
503 -- literals are similarly interpreted as a sequence of such codes.
505 type Char_Code_Base is mod 2 ** 32;
506 for Char_Code_Base'Size use 32;
508 subtype Char_Code is Char_Code_Base range 0 .. 16#7FFF_FFFF#;
509 for Char_Code'Value_Size use 32;
510 for Char_Code'Object_Size use 32;
512 function Get_Char_Code (C : Character) return Char_Code;
513 pragma Inline (Get_Char_Code);
514 -- Function to obtain internal character code from source character. For
515 -- the moment, the internal character code is simply the Pos value of the
516 -- input source character, but we provide this interface for possible
517 -- later support of alternative character sets.
519 function In_Character_Range (C : Char_Code) return Boolean;
520 pragma Inline (In_Character_Range);
521 -- Determines if the given character code is in range of type Character,
522 -- and if so, returns True. If not, returns False.
524 function In_Wide_Character_Range (C : Char_Code) return Boolean;
525 pragma Inline (In_Wide_Character_Range);
526 -- Determines if the given character code is in range of the type
527 -- Wide_Character, and if so, returns True. If not, returns False.
529 function Get_Character (C : Char_Code) return Character;
530 pragma Inline (Get_Character);
531 -- For a character C that is in Character range (see above function), this
532 -- function returns the corresponding Character value. It is an error to
533 -- call Get_Character if C is not in C haracter range
535 function Get_Wide_Character (C : Char_Code) return Wide_Character;
536 -- For a character C that is in Wide_Character range (see above function),
537 -- this function returns the corresponding Wide_Character value. It is an
538 -- error to call Get_Wide_Character if C is not in Wide_Character range.
540 ---------------------------------------
541 -- Types used for Library Management --
542 ---------------------------------------
544 type Unit_Number_Type is new Int;
545 -- Unit number. The main source is unit 0, and subsidiary sources have
546 -- non-zero numbers starting with 1. Unit numbers are used to index the
547 -- file table in Lib.
549 Main_Unit : constant Unit_Number_Type := 0;
550 -- Unit number value for main unit
552 No_Unit : constant Unit_Number_Type := -1;
553 -- Special value used to signal no unit
555 type Source_File_Index is new Int range -1 .. Int'Last;
556 -- Type used to index the source file table (see package Sinput)
558 Internal_Source_File : constant Source_File_Index :=
559 Source_File_Index'First;
560 -- Value used to indicate the buffer for the source-code-like strings
561 -- internally created withing the compiler (see package Sinput)
563 No_Source_File : constant Source_File_Index := 0;
564 -- Value used to indicate no source file present
566 -----------------------------------
567 -- Representation of Time Stamps --
568 -----------------------------------
570 -- All compiled units are marked with a time stamp which is derived from
571 -- the source file (we assume that the host system has the concept of a
572 -- file time stamp which is modified when a file is modified). These
573 -- time stamps are used to ensure consistency of the set of units that
574 -- constitutes a library. Time stamps are 12 character strings with
575 -- with the following format:
580 -- MM month (2 digits 01-12)
581 -- DD day (2 digits 01-31)
582 -- HH hour (2 digits 00-23)
583 -- MM minutes (2 digits 00-59)
584 -- SS seconds (2 digits 00-59)
586 -- In the case of Unix systems (and other systems which keep the time in
587 -- GMT), the time stamp is the GMT time of the file, not the local time.
588 -- This solves problems in using libraries across networks with clients
589 -- spread across multiple time-zones.
591 Time_Stamp_Length : constant := 14;
592 -- Length of time stamp value
594 subtype Time_Stamp_Index is Natural range 1 .. Time_Stamp_Length;
595 type Time_Stamp_Type is new String (Time_Stamp_Index);
596 -- Type used to represent time stamp
598 Empty_Time_Stamp : constant Time_Stamp_Type := (others => ' ');
599 -- Type used to represent an empty or missing time stamp. Looks less
600 -- than any real time stamp if two time stamps are compared. Note that
601 -- although this is not a private type, clients should not rely on the
602 -- exact way in which this string is represented, and instead should
603 -- use the subprograms below.
605 Dummy_Time_Stamp : constant Time_Stamp_Type := (others => '0');
606 -- This is used for dummy time stamp values used in the D lines for
607 -- non-existant files, and is intended to be an impossible value.
609 function "=" (Left, Right : Time_Stamp_Type) return Boolean;
610 function "<=" (Left, Right : Time_Stamp_Type) return Boolean;
611 function ">=" (Left, Right : Time_Stamp_Type) return Boolean;
612 function "<" (Left, Right : Time_Stamp_Type) return Boolean;
613 function ">" (Left, Right : Time_Stamp_Type) return Boolean;
614 -- Comparison functions on time stamps. Note that two time stamps
615 -- are defined as being equal if they have the same day/month/year
616 -- and the hour/minutes/seconds values are within 2 seconds of one
617 -- another. This deals with rounding effects in library file time
618 -- stamps caused by copying operations during installation. We have
619 -- particularly noticed that WinNT seems susceptible to such changes.
620 -- Note: the Empty_Time_Stamp value looks equal to itself, and less
621 -- than any non-empty time stamp value.
623 procedure Split_Time_Stamp
624 (TS : Time_Stamp_Type;
631 -- Given a time stamp, decompose it into its components
633 procedure Make_Time_Stamp
640 TS : out Time_Stamp_Type);
641 -- Given the components of a time stamp, initialize the value
643 -----------------------------------------------
644 -- Types used for Pragma Suppress Management --
645 -----------------------------------------------
663 -- The following array contains an entry for each recognized check name
664 -- for pragma Suppress. It is used to represent current settings of scope
665 -- based suppress actions from pragma Suppress or command line settings.
667 -- Note: when Suppress_Array (All_Checks) is True, then generally all other
668 -- specific check entries are set True, except for the Elaboration_Check
669 -- entry which is set only if an explicit Suppress for this check is given.
670 -- The reason for this non-uniformity is that we do not want All_Checks to
671 -- suppress elaboration checking when using the static elaboration model.
672 -- We recognize only an explicit suppress of Elaboration_Check as a signal
673 -- that the static elaboration checking should skip a compile time check.
675 type Suppress_Array is array (Check_Id) of Boolean;
676 pragma Pack (Suppress_Array);
678 -- To add a new check type to GNAT, the following steps are required:
680 -- 1. Add an entry to Snames spec and body for the new name
681 -- 2. Add an entry to the definition of Check_Id above
682 -- 3. Add a new function to Checks to handle the new check test
683 -- 4. Add a new Do_xxx_Check flag to Sinfo (if required)
684 -- 5. Add appropriate checks for the new test
686 -----------------------------------
687 -- Global Exception Declarations --
688 -----------------------------------
690 -- This section contains declarations of exceptions that are used
691 -- throughout the compiler or in other GNAT tools.
693 Unrecoverable_Error : exception;
694 -- This exception is raised to immediately terminate the compilation
695 -- of the current source program. Used in situations where things are
696 -- bad enough that it doesn't seem worth continuing (e.g. max errors
697 -- reached, or a required file is not found). Also raised when the
698 -- compiler finds itself in trouble after an error (see Comperr).
700 Terminate_Program : exception;
701 -- This exception is raised to immediately terminate the tool being
702 -- executed. Each tool where this exception may be raised must have
703 -- a single exception handler that contains only a null statement and
704 -- that is the last statement of the program. If needed, procedure
705 -- Set_Exit_Status is called with the appropriate exit status before
706 -- raising Terminate_Program.
708 ---------------------------------
709 -- Parameter Mechanism Control --
710 ---------------------------------
712 -- Function and parameter entities have a field that records the
713 -- passing mechanism. See specification of Sem_Mech for full details.
714 -- The following subtype is used to represent values of this type:
716 subtype Mechanism_Type is Int range -10 .. Int'Last;
717 -- Type used to represent a mechanism value. This is a subtype rather
718 -- than a type to avoid some annoying processing problems with certain
719 -- routines in Einfo (processing them to create the corresponding C).
721 ------------------------------
722 -- Run-Time Exception Codes --
723 ------------------------------
725 -- When the code generator generates a run-time exception, it provides
726 -- a reason code which is one of the following. This reason code is used
727 -- to select the appropriate run-time routine to be called, determining
728 -- both the exception to be raised, and the message text to be added.
730 -- The prefix CE/PE/SE indicates the exception to be raised
731 -- CE = Constraint_Error
732 -- PE = Program_Error
733 -- SE = Storage_Error
735 -- The remaining part of the name indicates the message text to be added,
736 -- where all letters are lower case, and underscores are converted to
737 -- spaces (for example CE_Invalid_Data adds the text "invalid data").
739 -- To add a new code, you need to do the following:
741 -- 1. Modify the type and subtype declarations below appropriately,
742 -- keeping things in alphabetical order.
744 -- 2. Modify the corresponding definitions in types.h, including
745 -- the definition of last_reason_code.
747 -- 3. Add a new routine in Ada.Exceptions with the appropriate call
748 -- and static string constant. Note that there is more than one
749 -- version of a-except.adb which must be modified.
751 type RT_Exception_Code is
752 (CE_Access_Check_Failed, -- 00
753 CE_Access_Parameter_Is_Null, -- 01
754 CE_Discriminant_Check_Failed, -- 02
755 CE_Divide_By_Zero, -- 03
756 CE_Explicit_Raise, -- 04
757 CE_Index_Check_Failed, -- 05
758 CE_Invalid_Data, -- 06
759 CE_Length_Check_Failed, -- 07
760 CE_Null_Exception_Id, -- 08
761 CE_Null_Not_Allowed, -- 09
762 CE_Overflow_Check_Failed, -- 10
763 CE_Partition_Check_Failed, -- 11
764 CE_Range_Check_Failed, -- 12
765 CE_Tag_Check_Failed, -- 13
767 PE_Access_Before_Elaboration, -- 14
768 PE_Accessibility_Check_Failed, -- 15
769 PE_All_Guards_Closed, -- 16
770 PE_Current_Task_In_Entry_Body, -- 17
771 PE_Duplicated_Entry_Address, -- 18
772 PE_Explicit_Raise, -- 19
773 PE_Finalize_Raised_Exception, -- 20
774 PE_Implicit_Return, -- 21
775 PE_Misaligned_Address_Value, -- 22
776 PE_Missing_Return, -- 23
777 PE_Overlaid_Controlled_Object, -- 24
778 PE_Potentially_Blocking_Operation, -- 25
779 PE_Stubbed_Subprogram_Called, -- 26
780 PE_Unchecked_Union_Restriction, -- 27
781 PE_Non_Transportable_Actual, -- 28
783 SE_Empty_Storage_Pool, -- 29
784 SE_Explicit_Raise, -- 30
785 SE_Infinite_Recursion, -- 31
786 SE_Object_Too_Large); -- 32
788 subtype RT_CE_Exceptions is RT_Exception_Code range
789 CE_Access_Check_Failed ..
792 subtype RT_PE_Exceptions is RT_Exception_Code range
793 PE_Access_Before_Elaboration ..
794 PE_Non_Transportable_Actual;
796 subtype RT_SE_Exceptions is RT_Exception_Code range
797 SE_Empty_Storage_Pool ..