* builtins.def (BUILT_IN_STACK_ALLOC): Remove.
[official-gcc.git] / gcc / ada / types.ads
blob75a2acbc16d3c9c2f1eec3ad9469c0d8ab74d4bc
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- T Y P E S --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1992-2004 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, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, 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 ------------------------------------------------------------------------------
34 with Unchecked_Deallocation;
36 package Types is
37 pragma Preelaborate (Types);
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.
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
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!
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;
79 for Byte'Size use 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 subtype Upper_Half_Character is
111 Character range Character'Val (16#80#) .. Character'Val (16#FF#);
112 -- Characters with the upper bit set
114 type Character_Ptr is access all Character;
115 type String_Ptr is access all String;
116 -- Standard character and string pointers
118 procedure Free is new Unchecked_Deallocation (String, String_Ptr);
119 -- Procedure for freeing dynamically allocated String values
121 subtype Word_Hex_String is String (1 .. 8);
122 -- Type used to represent Word value as 8 hex digits, with lower case
123 -- letters for the alphabetic cases.
125 function Get_Hex_String (W : Word) return Word_Hex_String;
126 -- Convert word value to 8-character hex string
128 -----------------------------------------
129 -- Types Used for Text Buffer Handling --
130 -----------------------------------------
132 -- We can't use type String for text buffers, since we must use the
133 -- standard 32-bit integer as an index value, since we count on all
134 -- index values being the same size.
136 type Text_Ptr is new Int;
137 -- Type used for subscripts in text buffer
139 type Text_Buffer is array (Text_Ptr range <>) of Character;
140 -- Text buffer used to hold source file or library information file
142 type Text_Buffer_Ptr is access all Text_Buffer;
143 -- Text buffers for input files are allocated dynamically and this type
144 -- is used to reference these text buffers.
146 procedure Free is new Unchecked_Deallocation (Text_Buffer, Text_Buffer_Ptr);
147 -- Procedure for freeing dynamically allocated text buffers
149 ------------------------------------------
150 -- Types Used for Source Input Handling --
151 ------------------------------------------
153 type Logical_Line_Number is range 0 .. Int'Last;
154 for Logical_Line_Number'Size use 32;
155 -- Line number type, used for storing logical line numbers (i.e. line
156 -- numbers that include effects of any Source_Reference pragmas in the
157 -- source file). The value zero indicates a line containing a source
158 -- reference pragma.
160 No_Line_Number : constant Logical_Line_Number := 0;
161 -- Special value used to indicate no line number
163 type Physical_Line_Number is range 1 .. Int'Last;
164 for Physical_Line_Number'Size use 32;
165 -- Line number type, used for storing physical line numbers (i.e.
166 -- line numbers in the physical file being compiled, unaffected by
167 -- the presence of source reference pragmas.
169 type Column_Number is range 0 .. 32767;
170 for Column_Number'Size use 16;
171 -- Column number (assume that 2**15 is large enough, see declaration of
172 -- Hostparm.Max_Line_Length, and also processing for -gnatyM in Stylesw)
174 No_Column_Number : constant Column_Number := 0;
175 -- Special value used to indicate no column number
177 subtype Source_Buffer is Text_Buffer;
178 -- Type used to store text of a source file . The buffer for the main
179 -- source (the source specified on the command line) has a lower bound
180 -- starting at zero. Subsequent subsidiary sources have lower bounds
181 -- which are one greater than the previous upper bound.
183 subtype Big_Source_Buffer is Text_Buffer (0 .. Text_Ptr'Last);
184 -- This is a virtual type used as the designated type of the access
185 -- type Source_Buffer_Ptr, see Osint.Read_Source_File for details.
187 type Source_Buffer_Ptr is access all Big_Source_Buffer;
188 -- Pointer to source buffer. We use virtual origin addressing for
189 -- source buffers, with thin pointers. The pointer points to a virtual
190 -- instance of type Big_Source_Buffer, where the actual type is in fact
191 -- of type Source_Buffer. The address is adjusted so that the virtual
192 -- origin addressing works correctly. See Osint.Read_Source_Buffer for
193 -- further details.
195 subtype Source_Ptr is Text_Ptr;
196 -- Type used to represent a source location, which is a subscript of a
197 -- character in the source buffer. As noted above, diffferent source
198 -- buffers have different ranges, so it is possible to tell from a
199 -- Source_Ptr value which source it refers to. Note that negative numbers
200 -- are allowed to accommodate the following special values.
202 No_Location : constant Source_Ptr := -1;
203 -- Value used to indicate no source position set in a node. A test for
204 -- a Source_Ptr value being >= No_Location is the apporoved way to test
205 -- for a standard value that does not include No_Location or any of the
206 -- following special definitions.
208 Standard_Location : constant Source_Ptr := -2;
209 -- Used for all nodes in the representation of package Standard other
210 -- than nodes representing the contents of Standard.ASCII. Note that
211 -- testing for <= Standard_Location tests for both Standard_Location
212 -- and for Standard_ASCII_Location.
214 Standard_ASCII_Location : constant Source_Ptr := -3;
215 -- Used for all nodes in the presentation of package Standard.ASCII
217 System_Location : constant Source_Ptr := -4;
218 -- Used to identify locations of pragmas scanned by Targparm, where we
219 -- know the location is in System, but we don't know exactly what line.
221 First_Source_Ptr : constant Source_Ptr := 0;
222 -- Starting source pointer index value for first source program
224 -------------------------------------
225 -- Range Definitions for Tree Data --
226 -------------------------------------
228 -- The tree has fields that can hold any of the following types:
230 -- Pointers to other tree nodes (type Node_Id)
231 -- List pointers (type List_Id)
232 -- Element list pointers (type Elist_Id)
233 -- Names (type Name_Id)
234 -- Strings (type String_Id)
235 -- Universal integers (type Uint)
236 -- Universal reals (type Ureal)
237 -- Character codes (type Char_Code stored with a bias)
239 -- In most contexts, the strongly typed interface determines which of
240 -- these types is present. However, there are some situations (involving
241 -- untyped traversals of the tree), where it is convenient to be easily
242 -- able to distinguish these values. The underlying representation in all
243 -- cases is an integer type Union_Id, and we ensure that the range of
244 -- the various possible values for each of the above types is disjoint
245 -- so that this distinction is possible.
247 type Union_Id is new Int;
248 -- The type in the tree for a union of possible ID values
250 -- Note: it is also helpful for debugging purposes to make these ranges
251 -- distinct. If a bug leads to misidentification of a value, then it will
252 -- typically result in an out of range value and a Constraint_Error.
254 List_Low_Bound : constant := -100_000_000;
255 -- The List_Id values are subscripts into an array of list headers which
256 -- has List_Low_Bound as its lower bound. This value is chosen so that all
257 -- List_Id values are negative, and the value zero is in the range of both
258 -- List_Id and Node_Id values (see further description below).
260 List_High_Bound : constant := 0;
261 -- Maximum List_Id subscript value. This allows up to 100 million list
262 -- Id values, which is in practice infinite, and there is no need to
263 -- check the range. The range overlaps the node range by one element
264 -- (with value zero), which is used both for the Empty node, and for
265 -- indicating no list. The fact that the same value is used is convenient
266 -- because it means that the default value of Empty applies to both nodes
267 -- and lists, and also is more efficient to test for.
269 Node_Low_Bound : constant := 0;
270 -- The tree Id values start at zero, because we use zero for Empty (to
271 -- allow a zero test for Empty). Actual tree node subscripts start at 0
272 -- since Empty is a legitimate node value.
274 Node_High_Bound : constant := 099_999_999;
275 -- Maximum number of nodes that can be allocated is 100 million, which
276 -- is in practice infinite, and there is no need to check the range.
278 Elist_Low_Bound : constant := 100_000_000;
279 -- The Elist_Id values are subscripts into an array of elist headers which
280 -- has Elist_Low_Bound as its lower bound.
282 Elist_High_Bound : constant := 199_999_999;
283 -- Maximum Elist_Id subscript value. This allows up to 100 million Elists,
284 -- which is in practice infinite and there is no need to check the range.
286 Elmt_Low_Bound : constant := 200_000_000;
287 -- Low bound of element Id values. The use of these values is internal to
288 -- the Elists package, but the definition of the range is included here
289 -- since it must be disjoint from other Id values. The Elmt_Id values are
290 -- subscripts into an array of list elements which has this as lower bound.
292 Elmt_High_Bound : constant := 299_999_999;
293 -- Upper bound of Elmt_Id values. This allows up to 100 million element
294 -- list members, which is in practice infinite (no range check needed).
296 Names_Low_Bound : constant := 300_000_000;
297 -- Low bound for name Id values
299 Names_High_Bound : constant := 399_999_999;
300 -- Maximum number of names that can be allocated is 100 million, which is
301 -- in practice infinite and there is no need to check the range.
303 Strings_Low_Bound : constant := 400_000_000;
304 -- Low bound for string Id values
306 Strings_High_Bound : constant := 499_999_999;
307 -- Maximum number of strings that can be allocated is 100 million, which
308 -- is in practice infinite and there is no need to check the range.
310 Ureal_Low_Bound : constant := 500_000_000;
311 -- Low bound for Ureal values.
313 Ureal_High_Bound : constant := 599_999_999;
314 -- Maximum number of Ureal values stored is 100_000_000 which is in
315 -- practice infinite so that no check is required.
317 Uint_Low_Bound : constant := 600_000_000;
318 -- Low bound for Uint values.
320 Uint_Table_Start : constant := 2_000_000_000;
321 -- Location where table entries for universal integers start (see
322 -- Uintp spec for details of the representation of Uint values).
324 Uint_High_Bound : constant := 2_099_999_999;
325 -- The range of Uint values is very large, since a substantial part
326 -- of this range is used to store direct values, see Uintp for details.
328 Char_Code_Bias : constant := 2_100_000_000;
329 -- A bias value added to character code values stored in the tree which
330 -- ensures that they have different values from any of the above types.
332 -- The following subtype definitions are used to provide convenient names
333 -- for membership tests on Int values to see what data type range they
334 -- lie in. Such tests appear only in the lowest level packages.
336 subtype List_Range is Union_Id
337 range List_Low_Bound .. List_High_Bound;
339 subtype Node_Range is Union_Id
340 range Node_Low_Bound .. Node_High_Bound;
342 subtype Elist_Range is Union_Id
343 range Elist_Low_Bound .. Elist_High_Bound;
345 subtype Elmt_Range is Union_Id
346 range Elmt_Low_Bound .. Elmt_High_Bound;
348 subtype Names_Range is Union_Id
349 range Names_Low_Bound .. Names_High_Bound;
351 subtype Strings_Range is Union_Id
352 range Strings_Low_Bound .. Strings_High_Bound;
354 subtype Uint_Range is Union_Id
355 range Uint_Low_Bound .. Uint_High_Bound;
357 subtype Ureal_Range is Union_Id
358 range Ureal_Low_Bound .. Ureal_High_Bound;
360 subtype Char_Code_Range is Union_Id
361 range Char_Code_Bias .. Char_Code_Bias + 2**16 - 1;
363 -----------------------------
364 -- Types for Namet Package --
365 -----------------------------
367 -- Name_Id values are used to identify entries in the names table. Except
368 -- for the special values No_Name, and Error_Name, they are subscript
369 -- values for the Names table defined in package Namet.
371 -- Note that with only a few exceptions, which are clearly documented, the
372 -- type Name_Id should be regarded as a private type. In particular it is
373 -- never appropriate to perform arithmetic operations using this type.
375 type Name_Id is range Names_Low_Bound .. Names_High_Bound;
376 for Name_Id'Size use 32;
377 -- Type used to identify entries in the names table
379 No_Name : constant Name_Id := Names_Low_Bound;
380 -- The special Name_Id value No_Name is used in the parser to indicate
381 -- a situation where no name is present (e.g. on a loop or block).
383 Error_Name : constant Name_Id := Names_Low_Bound + 1;
384 -- The special Name_Id value Error_Name is used in the parser to
385 -- indicate that some kind of error was encountered in scanning out
386 -- the relevant name, so it does not have a representable label.
388 subtype Error_Name_Or_No_Name is Name_Id range No_Name .. Error_Name;
389 -- Used to test for either error name or no name
391 First_Name_Id : constant Name_Id := Names_Low_Bound + 2;
392 -- Subscript of first entry in names table
394 ----------------------------
395 -- Types for Atree Package --
396 ----------------------------
398 -- Node_Id values are used to identify nodes in the tree. They are
399 -- subscripts into the Node table declared in package Tree. Note that
400 -- the special values Empty and Error are subscripts into this table,
401 -- See package Atree for further details.
403 type Node_Id is range Node_Low_Bound .. Node_High_Bound;
404 -- Type used to identify nodes in the tree
406 subtype Entity_Id is Node_Id;
407 -- A synonym for node types, used in the entity package to refer to
408 -- nodes that are entities (i.e. nodes with an Nkind of N_Defining_xxx)
409 -- All such nodes are extended nodes and these are the only extended
410 -- nodes, so that in practice entity and extended nodes are synonymous.
412 subtype Node_Or_Entity_Id is Node_Id;
413 -- A synonym for node types, used in cases where a given value may be used
414 -- to represent either a node or an entity. We like to minimize such uses
415 -- for obvious reasons of logical type consistency, but where such uses
416 -- occur, they should be documented by use of this type.
418 Empty : constant Node_Id := Node_Low_Bound;
419 -- Used to indicate null node. A node is actually allocated with this
420 -- Id value, so that Nkind (Empty) = N_Empty. Note that Node_Low_Bound
421 -- is zero, so Empty = No_List = zero.
423 Empty_List_Or_Node : constant := 0;
424 -- This constant is used in situations (e.g. initializing empty fields)
425 -- where the value set will be used to represent either an empty node
426 -- or a non-existent list, depending on the context.
428 Error : constant Node_Id := Node_Low_Bound + 1;
429 -- Used to indicate that there was an error in the source program. A node
430 -- is actually allocated at this address, so that Nkind (Error) = N_Error.
432 Empty_Or_Error : constant Node_Id := Error;
433 -- Since Empty and Error are the first two Node_Id values, the test for
434 -- N <= Empty_Or_Error tests to see if N is Empty or Error. This definition
435 -- provides convenient self-documentation for such tests.
437 First_Node_Id : constant Node_Id := Node_Low_Bound;
438 -- Subscript of first allocated node. Note that Empty and Error are both
439 -- allocated nodes, whose Nkind fields can be accessed without error.
441 ------------------------------
442 -- Types for Nlists Package --
443 ------------------------------
445 -- List_Id values are used to identify node lists in the tree. They are
446 -- subscripts into the Lists table declared in package Tree. Note that
447 -- the special value Error_List is a subscript in this table, but the
448 -- value No_List is *not* a valid subscript, and any attempt to apply
449 -- list operations to No_List will cause a (detected) error.
451 type List_Id is range List_Low_Bound .. List_High_Bound;
452 -- Type used to identify a node list
454 No_List : constant List_Id := List_High_Bound;
455 -- Used to indicate absence of a list. Note that the value is zero, which
456 -- is the same as Empty, which is helpful in intializing nodes where a
457 -- value of zero can represent either an empty node or an empty list.
459 Error_List : constant List_Id := List_Low_Bound;
460 -- Used to indicate that there was an error in the source program in a
461 -- context which would normally require a list. This node appears to be
462 -- an empty list to the list operations (a null list is actually allocated
463 -- which has this Id value).
465 First_List_Id : constant List_Id := Error_List;
466 -- Subscript of first allocated list header
468 ------------------------------
469 -- Types for Elists Package --
470 ------------------------------
472 -- Element list Id values are used to identify element lists stored in
473 -- the tree (see package Tree for further details). They are formed by
474 -- adding a bias (Element_List_Bias) to subscript values in the same
475 -- array that is used for node list headers.
477 type Elist_Id is range Elist_Low_Bound .. Elist_High_Bound;
478 -- Type used to identify an element list (Elist header table subscript)
480 No_Elist : constant Elist_Id := Elist_Low_Bound;
481 -- Used to indicate absense of an element list. Note that this is not
482 -- an actual Elist header, so element list operations on this value
483 -- are not valid.
485 First_Elist_Id : constant Elist_Id := No_Elist + 1;
486 -- Subscript of first allocated Elist header.
488 -- Element Id values are used to identify individual elements of an
489 -- element list (see package Elists for further details).
491 type Elmt_Id is range Elmt_Low_Bound .. Elmt_High_Bound;
492 -- Type used to identify an element list
494 No_Elmt : constant Elmt_Id := Elmt_Low_Bound;
495 -- Used to represent empty element
497 First_Elmt_Id : constant Elmt_Id := No_Elmt + 1;
498 -- Subscript of first allocated Elmt table entry
500 -------------------------------
501 -- Types for Stringt Package --
502 -------------------------------
504 -- String_Id values are used to identify entries in the strings table.
505 -- They are subscripts into the strings table defined in package Strings.
507 -- Note that with only a few exceptions, which are clearly documented, the
508 -- type String_Id should be regarded as a private type. In particular it is
509 -- never appropriate to perform arithmetic operations using this type.
511 type String_Id is range Strings_Low_Bound .. Strings_High_Bound;
512 -- Type used to identify entries in the strings table
514 No_String : constant String_Id := Strings_Low_Bound;
515 -- Used to indicate missing string Id. Note that the value zero is used
516 -- to indicate a missing data value for all the Int types in this section.
518 First_String_Id : constant String_Id := No_String + 1;
519 -- First subscript allocated in string table
521 -------------------------
522 -- Character Code Type --
523 -------------------------
525 -- The type Char is used for character data internally in the compiler,
526 -- but character codes in the source are represented by the Char_Code
527 -- type. Each character literal in the source is interpreted as being one
528 -- of the 2**16 possible Wide_Character codes, and a unique integer value
529 -- is assigned, corresponding to the POS value in the Wide_Character type.
530 -- String literals are similarly interpreted as a sequence of such codes.
532 -- Note: when character code values are stored in the tree, they are stored
533 -- by adding a bias value (Char_Code_Bias) that results in values that can
534 -- be distinguished from other types of values stored in the tree.
536 type Char_Code is mod 2 ** 16;
537 for Char_Code'Size use 16;
539 function Get_Char_Code (C : Character) return Char_Code;
540 pragma Inline (Get_Char_Code);
541 -- Function to obtain internal character code from source character. For
542 -- the moment, the internal character code is simply the Pos value of the
543 -- input source character, but we provide this interface for possible
544 -- later support of alternative character sets.
546 function In_Character_Range (C : Char_Code) return Boolean;
547 pragma Inline (In_Character_Range);
548 -- Determines if the given character code is in range of type Character,
549 -- and if so, returns True. If not, returns False.
551 function Get_Character (C : Char_Code) return Character;
552 pragma Inline (Get_Character);
553 -- For a character C that is in character range (see above function), this
554 -- function returns the corresponding Character value. It is an error to
555 -- call Get_Character if C is not in character range
557 ---------------------------------------
558 -- Types used for Library Management --
559 ---------------------------------------
561 type Unit_Number_Type is new Int;
562 -- Unit number. The main source is unit 0, and subsidiary sources have
563 -- non-zero numbers starting with 1. Unit numbers are used to index the
564 -- file table in Lib.
566 Main_Unit : constant Unit_Number_Type := 0;
567 -- Unit number value for main unit
569 No_Unit : constant Unit_Number_Type := -1;
570 -- Special value used to signal no unit
572 type Source_File_Index is new Int range -1 .. Int'Last;
573 -- Type used to index the source file table (see package Sinput)
575 Internal_Source_File : constant Source_File_Index :=
576 Source_File_Index'First;
577 -- Value used to indicate the buffer for the source-code-like strings
578 -- internally created withing the compiler (see package Sinput)
580 No_Source_File : constant Source_File_Index := 0;
581 -- Value used to indicate no source file present
583 subtype File_Name_Type is Name_Id;
584 -- File names are stored in the names table and this synonym is used to
585 -- indicate that a Name_Id value is being used to hold a simple file
586 -- name (which does not include any directory information).
588 No_File : constant File_Name_Type := File_Name_Type (No_Name);
589 -- Constant used to indicate no file found
591 subtype Unit_Name_Type is Name_Id;
592 -- Unit names are stored in the names table and this synonym is used to
593 -- indicate that a Name_Id value is being used to hold a unit name.
595 -----------------------------------
596 -- Representation of Time Stamps --
597 -----------------------------------
599 -- All compiled units are marked with a time stamp which is derived from
600 -- the source file (we assume that the host system has the concept of a
601 -- file time stamp which is modified when a file is modified). These
602 -- time stamps are used to ensure consistency of the set of units that
603 -- constitutes a library. Time stamps are 12 character strings with
604 -- with the following format:
606 -- YYYYMMDDHHMMSS
608 -- YYYY year
609 -- MM month (2 digits 01-12)
610 -- DD day (2 digits 01-31)
611 -- HH hour (2 digits 00-23)
612 -- MM minutes (2 digits 00-59)
613 -- SS seconds (2 digits 00-59)
615 -- In the case of Unix systems (and other systems which keep the time in
616 -- GMT), the time stamp is the GMT time of the file, not the local time.
617 -- This solves problems in using libraries across networks with clients
618 -- spread across multiple time-zones.
620 Time_Stamp_Length : constant := 14;
621 -- Length of time stamp value
623 subtype Time_Stamp_Index is Natural range 1 .. Time_Stamp_Length;
624 type Time_Stamp_Type is new String (Time_Stamp_Index);
625 -- Type used to represent time stamp
627 Empty_Time_Stamp : constant Time_Stamp_Type := (others => ' ');
628 -- Type used to represent an empty or missing time stamp. Looks less
629 -- than any real time stamp if two time stamps are compared. Note that
630 -- although this is not a private type, clients should not rely on the
631 -- exact way in which this string is represented, and instead should
632 -- use the subprograms below.
634 Dummy_Time_Stamp : constant Time_Stamp_Type := (others => '0');
635 -- This is used for dummy time stamp values used in the D lines for
636 -- non-existant files, and is intended to be an impossible value.
638 function "=" (Left, Right : Time_Stamp_Type) return Boolean;
639 function "<=" (Left, Right : Time_Stamp_Type) return Boolean;
640 function ">=" (Left, Right : Time_Stamp_Type) return Boolean;
641 function "<" (Left, Right : Time_Stamp_Type) return Boolean;
642 function ">" (Left, Right : Time_Stamp_Type) return Boolean;
643 -- Comparison functions on time stamps. Note that two time stamps
644 -- are defined as being equal if they have the same day/month/year
645 -- and the hour/minutes/seconds values are within 2 seconds of one
646 -- another. This deals with rounding effects in library file time
647 -- stamps caused by copying operations during installation. We have
648 -- particularly noticed that WinNT seems susceptible to such changes.
649 -- Note: the Empty_Time_Stamp value looks equal to itself, and less
650 -- than any non-empty time stamp value.
652 procedure Split_Time_Stamp
653 (TS : Time_Stamp_Type;
654 Year : out Nat;
655 Month : out Nat;
656 Day : out Nat;
657 Hour : out Nat;
658 Minutes : out Nat;
659 Seconds : out Nat);
660 -- Given a time stamp, decompose it into its components
662 procedure Make_Time_Stamp
663 (Year : Nat;
664 Month : Nat;
665 Day : Nat;
666 Hour : Nat;
667 Minutes : Nat;
668 Seconds : Nat;
669 TS : out Time_Stamp_Type);
670 -- Given the components of a time stamp, initialize the value
672 -----------------------------------------------
673 -- Types used for Pragma Suppress Management --
674 -----------------------------------------------
676 type Check_Id is (
677 Access_Check,
678 Accessibility_Check,
679 Discriminant_Check,
680 Division_Check,
681 Elaboration_Check,
682 Index_Check,
683 Length_Check,
684 Overflow_Check,
685 Range_Check,
686 Storage_Check,
687 Tag_Check,
688 All_Checks);
690 -- The following record contains an entry for each recognized check name
691 -- for pragma Suppress. It is used to represent current settings of scope
692 -- based suppress actions from pragma Suppress or command line settings.
694 type Suppress_Array is
695 array (Check_Id range Access_Check .. Tag_Check) of Boolean;
696 pragma Pack (Suppress_Array);
698 -- To add a new check type to GNAT, the following steps are required:
700 -- 1. Add an entry to Snames spec and body for the new name
701 -- 2. Add an entry to the definition of Check_Id above
702 -- 3. Add a new function to Checks to handle the new check test
703 -- 4. Add a new Do_xxx_Check flag to Sinfo (if required)
704 -- 5. Add appropriate checks for the new test
706 -----------------------------------
707 -- Global Exception Declarations --
708 -----------------------------------
710 -- This section contains declarations of exceptions that are used
711 -- throughout the compiler.
713 Unrecoverable_Error : exception;
714 -- This exception is raised to immediately terminate the compilation
715 -- of the current source program. Used in situations where things are
716 -- bad enough that it doesn't seem worth continuing (e.g. max errors
717 -- reached, or a required file is not found). Also raised when the
718 -- compiler finds itself in trouble after an error (see Comperr).
720 ---------------------------------
721 -- Parameter Mechanism Control --
722 ---------------------------------
724 -- Function and parameter entities have a field that records the
725 -- passing mechanism. See specification of Sem_Mech for full details.
726 -- The following subtype is used to represent values of this type:
728 subtype Mechanism_Type is Int range -10 .. Int'Last;
729 -- Type used to represent a mechanism value. This is a subtype rather
730 -- than a type to avoid some annoying processing problems with certain
731 -- routines in Einfo (processing them to create the corresponding C).
733 ------------------------------
734 -- Run-Time Exception Codes --
735 ------------------------------
737 -- When the code generator generates a run-time exception, it provides
738 -- a reason code which is one of the following. This reason code is used
739 -- to select the appropriate run-time routine to be called, determining
740 -- both the exception to be raised, and the message text to be added.
742 -- The prefix CE/PE/SE indicates the exception to be raised
743 -- CE = Constraint_Error
744 -- PE = Program_Error
745 -- SE = Storage_Error
747 -- The remaining part of the name indicates the message text to be added,
748 -- where all letters are lower case, and underscores are converted to
749 -- spaces (for example CE_Invalid_Data adds the text "invalid data").
751 -- To add a new code, you need to do the following:
753 -- 1. Modify the type and subtype declarations below appropriately,
754 -- keeping things in alphabetical order.
756 -- 2. Modify the corresponding definitions in types.h, including
757 -- the definition of last_reason_code.
759 -- 3. Add a new routine in Ada.Exceptions with the appropriate call
760 -- and static string constant
762 type RT_Exception_Code is (
763 CE_Access_Check_Failed,
764 CE_Access_Parameter_Is_Null,
765 CE_Discriminant_Check_Failed,
766 CE_Divide_By_Zero,
767 CE_Explicit_Raise,
768 CE_Index_Check_Failed,
769 CE_Invalid_Data,
770 CE_Length_Check_Failed,
771 CE_Overflow_Check_Failed,
772 CE_Partition_Check_Failed,
773 CE_Range_Check_Failed,
774 CE_Tag_Check_Failed,
776 PE_Access_Before_Elaboration,
777 PE_Accessibility_Check_Failed,
778 PE_All_Guards_Closed,
779 PE_Duplicated_Entry_Address,
780 PE_Explicit_Raise,
781 PE_Finalize_Raised_Exception,
782 PE_Misaligned_Address_Value,
783 PE_Missing_Return,
784 PE_Overlaid_Controlled_Object,
785 PE_Potentially_Blocking_Operation,
786 PE_Stubbed_Subprogram_Called,
787 PE_Unchecked_Union_Restriction,
788 PE_Illegal_RACW_E_4_18,
790 SE_Empty_Storage_Pool,
791 SE_Explicit_Raise,
792 SE_Infinite_Recursion,
793 SE_Object_Too_Large,
794 SE_Restriction_Violation);
796 subtype RT_CE_Exceptions is RT_Exception_Code range
797 CE_Access_Check_Failed ..
798 CE_Tag_Check_Failed;
800 subtype RT_PE_Exceptions is RT_Exception_Code range
801 PE_Access_Before_Elaboration ..
802 PE_Illegal_RACW_E_4_18;
804 subtype RT_SE_Exceptions is RT_Exception_Code range
805 SE_Empty_Storage_Pool ..
806 SE_Restriction_Violation;
808 end Types;