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