8sa1-gcc/gcc/ada/types.ads
Arnaud Charlet 7324bf49ce [multiple changes]
2004-04-19  Arnaud Charlet  <charlet@act-europe.fr>

	* 5isystem.ads: Removed, unused.

	* gnat_rm.texi: Redo 1.13 change.

2004-04-19  Robert Dewar  <dewar@gnat.com>

	* s-stoele.ads: Clean up definition of Storage_Offset (the new
	definition is cleaner, avoids the kludge of explicit Standard operator
	references, and also is consistent with a visible System.Address with
	no visible operations.

	* s-geveop.adb: Add declarations to avoid assumption of visible
	operations on type System.Address (since these might not be available
	if Address is a non-private type for which the operations
	are made abstract).

	* sem_eval.adb: Minor reformatting

	* s-carsi8.ads, s-carun8.ads, s-casi16.ads, s-casi32.ads,
	s-casi64.ads, s-caun16.ads, s-caun32.ads, s-caun64.ads: Minor
	reformatting (new function spec format).

	* s-auxdec.adb, s-carsi8.adb, s-carun8.adb, s-casi16.adb,
	s-casi32.adb, s-casi64.adb, s-caun16.adb, s-caun32.adb,
	s-caun64.adb: Add declarations to avoid assumption of visible
	operations on type System.Address (since these might not be available
	if Address is a non-private type for which the operations are made
	abstract).

	* lib.ads, lib.adb (Synchronize_Serial_Number): New procedure.

	* exp_intr.adb: Minor comment update

	* exp_aggr.adb, exp_attr.adb, exp_ch13.adb: Minor reformatting.

	* 5omastop.adb: Add declarations to avoid assumption of visible
	operations on type System.Address (since these might not be available
	if Address is a non-private type for which the operations
	are made abstract).

2004-04-19  Vincent Celier  <celier@gnat.com>

	* switch-m.adb: (Scan_Make_Switches): Process new switch -eL

	* prj-pars.ads (Parse): New Boolean parameter Process_Languages,
	defaulted to Ada.

	* prj-proc.adb (Process): New Boolean parameter Process_Languages,
	defaulted to Ada.
	Call Check with Process_Languages.
	(Check): New Boolean parameter Process_Languages. Call Recursive_Check
	with Process_Languages.
	(Recursive_Check): New Boolean parameter Process_Languages. Call
	Nmsc.Ada_Check or Nmsc.Other_Languages_Check according to
	Process_Languages.

	* prj-proc.ads (Process): New Boolean parameter Process_Languages,

	* prj-util.ads, prj-util.adb (Executable_Of): New Boolean
	parameter Ada_Main, defaulted to True.
	Check for Ada specific characteristics only when Ada_Main is True.

	* opt.ads: (Follow_Links): New Boolean flag for gnatmake

	* prj.adb: (Project_Empty): Add new Project_Data components.

	* prj.ads: New types and tables for non Ada languages.
	(Project_Data): New components Languages, Impl_Suffixes,
	First_Other_Source, Last_Other_Source, Imported_Directories_Switches,
	Include_Path, Include_Data_Set.

	* prj-env.ads, prj-env.adb: Minor reformatting

	* prj-nmsc.ads, prj-nmsc.adb: (Other_Languages_Check): New procedure
	Put subprograms in alphabetical order

	* prj-pars.adb (Parse): New Boolean parameter Process_Languages,
	defaulted to Ada; Call Prj.Proc.Process with Process_Languages and
	Opt.Follow_Links.

	* mlib-prj.adb: Back out modification in last version, as they are
	incorrect.
	(Build_Library.Check_Libs): Remove useless pragma Warnings (Off)

	* make.adb: (Mains): Moved to package Makeutl
	(Linker_Opts): Moved to package Makeutl
	(Is_External_Assignment): Moved to package Makeutl
	(Test_If_Relative_Path): Moved to package Makeutl
	(Gnatmake): Move sorting of linker options to function
	Makeutl.Linker_Options_Switches.

	* Makefile.in: Add makeutl.o to the object files for gnatmake

	* makeusg.adb: Add line for new switch -eL.

	* gnatls.adb (Image): New function.
	(Output_Unit): If in verbose mode, output the list of restrictions
	specified by pragmas Restrictions.

	* 5bml-tgt.adb, 5vml-tgt.adb (Build_Dynamic_Library): Do not use
	Text_IO.

	* a-calend.adb (Split): Shift the date by multiple of 56 years, if
	needed, to put it in the range 1970 (included) - 2026 (excluded).
	(Time_Of): Do not shift Unix_Min_Year (1970).
	Shift the date by multiple of 56 years, if needed, to put it in the
	range 1970 (included) - 2026 (excluded).

	* adaint.h, adaint.c (__gnat_set_executable): New function.

2004-04-19  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>

	* trans.c (tree_transform, case N_Subprogram_Body): Temporarily push
	and pop GC context.
	(tree_transform, case N_Procedure_Call): Fix typo in setting TREE_TYPE.
	(tree_transform, case N_Label): Don't set LABEL_STMT_FIRST_IN_EH.
	(tree_transform, case N_Procedure_Call_Statement): Build a tree.
	(tree_transform, case N_Code_Statement): Likewise.
	(gnat_expand_stmt, case LABEL_STMT): Don't look at
	LABEL_STMT_FIRST_IN_EH.
	(gnat_expand_stmt, case ASM_STMT): New case.

	* utils2.c (build_unary_op): Properly set TREE_READONLY of
	UNCONSTRAINED_ARRAY_REF.

	* utils.c (poplevel): Temporarily push/pop GC context around inline
	function expansion.

	* decl.c (maybe_variable): Properly set TREE_READONLY of
	UNCONSTRAINED_ARRAY_REF.
	(make_packable_type): Only reference TYPE_IS_PADDING_P for RECORD_TYPE.

	* ada-tree.def: (ASM_STMT): New.

	* ada-tree.h: (LABEL_STMT_FIRST_IN_EH): Deleted.
	(ASM_STMT_TEMPLATE, ASM_STMT_OUTPUT, ASM_STMT_ORIG_OUT,
	ASM_STMT_INPUT): New.
	(ASM_STMT_CLOBBER): Likewise.

2004-04-19  Thomas Quinot  <quinot@act-europe.fr>

	* a-except.adb, s-parint.ads, s-parint.adb, types.ads, types.h: Use
	general rcheck mechanism to raise Program_Error for E.4(18), instead
	of a custom raiser in System.Partition_Interface.
	Part of general cleanup work before PolyORB integration.

	* snames.ads, snames.adb: Add new runtime library entities and names
	for PolyORB DSA.

	* sem_dist.ads, sem_dist.adb (Get_Subprogram_Id): Move from sem_dist to
	exp_dist.
	(Build_Subprogram_Id): New subprogram provided by exp_dist
	Code reorganisation in preparation for PolyORB integration.

	* exp_dist.ads, exp_dist.adb (Get_Subprogram_Id): Move from sem_dist to
	exp_dist.
	(Build_Subprogram_Id): New subprogram provided by exp_dist

	* sem_ch4.adb (Analyze_One_Call): Fix error message for mismatch in
	actual parameter types for call to dereference of an
	access-to-subprogram type.

	* rtsfind.ads: Add new runtime library entities and names for PolyORB
	DSA.

	* gnatlink.adb (Value): Remove. Use Interfaces.C.Strings.Value
	instead, which has the same behaviour here since we never pass it a
	NULL pointer.

	* link.c (run_path_option, Solaris case): Use -Wl, as for other
	platforms.

	* Makefile.in: adjust object file lists for gnatlink and gnatmake
	to account for new dependency upon Interfaces.C.Strings + link.o
	For x86 FreeBSD, use 86numaux.

	* make.adb, gnatcmd.adb: Linker_Library_Path_Option has been moved up
	from Mlib.Tgt to Mlib.

	* mlib.ads, mlib.adb (Linker_Library_Path_Option): New subprogram, now
	target-independent.

	* mlib-tgt.ads, mlib-tgt.adb (Linker_Library_Path_Option): Remove
	target-specific versions of this subprogram, now implemented as a
	target-independent function in Mlib.

	* 5aml-tgt.adb, 5bml-tgt.adb, 5gml-tgt.adb, 5hml-tgt.adb, 5lml-tgt.adb,
	5sml-tgt.adb, 5vml-tgt.adb, 5zml-tgt.adb, 5wml-tgt.adb
	(Linker_Library_Path_Option): Remove target-specific versions of this
	subprogram, now implemented as a target-independent function in Mlib.

	* atree.adb: (Allocate_Initialize_Node): New subprogram.
	Factors out node table slots allocation.
	(Fix_Parents): New subprogram.
	Encapsulate the pattern of fixing up parent pointers for syntactic
	children of a rewritten node.
	(New_Copy_Tree): Use New_Copy to copy non-entity nodes.
	(Rewrite): Use New_Copy when creating saved copy of original node.
	(Replace): Use Copy_Node to copy nodes.

2004-04-19  Javier Miranda  <miranda@gnat.com>

	* sprint.adb (Sprint_Node_Actual): Give support to the new
	Access_To_Subprogram node available in Access_Definition nodes. In
	addition, give support to the AI-231 node fields: null-exclusion,
	all-present, constant-present.

	* sem_util.ads, sem_util.adb: (Has_Declarations): New subprogram

	* sinfo.ads, sinfo.adb:
	New field Access_To_Subprogram_Definition in Access_Definition nodes

	* sem_ch6.adb (Process_Formals): Move here the code that creates and
	decorates internal subtype declaration corresponding to the
	null-excluding formal. This code was previously in Set_Actual_Subtypes.
	In addition, carry out some code cleanup on this code. In case of
	access to protected subprogram call
	Replace_Anonymous_Access_To_Protected_Subprogram.
	(Set_Actual_Subtypes): Code cleanup.

	* sem_ch8.adb (Analyze_Object_Renaming): Remove un-necessary call to
	Find_Type in case of anonymous access renamings. Add warning in case of
	null-excluding attribute used in anonymous access renaming.

	* sem_ch3.ads (Replace_Anonymous_Access_To_Protected_Subprogram): New
	subprogram

	* sem_ch3.adb (Replace_Anonymous_Access_To_Protected_Subprogram): New
	subprogram.
	(Access_Definition): In case of anonymous access to subprograms call
	the corresponding semantic routine to decorate the node.
	(Access_Subprogram_Declaration): Addition of some comments indicating
	some code that probably should be added here. Detected by comparison
	with the access_definition subprogram.
	(Analyze_Component_Declaration): In case of access to protected
	subprogram call Replace_Anonymous_Access_To_Protected.
	(Array_Type_Declaration): In case of access to protected subprogram call
	Replace_Anonymous_Access_To_Protected_Subprogram.
	(Process_Discriminants): In case of access to protected subprogram call
	Replace_Anonymous_Access_To_Protected_Subprogram.

	* par.adb (P_Access_Definition): New formal that indicates if the
	null-exclusion part was present.
	(P_Access_Type_Definition): New formal that indicates if the caller has
	already parsed the null-excluding part.

	* par-ch3.adb (P_Subtype_Declaration): Code cleanup.
	(P_Identifier_Declarations): Code cleanup and give support to renamings
	of anonymous access to subprogram types.
	(P_Derived_Type_Def_Or_Private_Ext_Decl): Code cleanup.
	(P_Array_Type_Definition): Give support to AI-254.
	(P_Component_Items): Give support to AI-254.
	(P_Access_Definition): New formal that indicates if the header was
	already parsed by the caller.
	(P_Access_Type_Definition): New formal that indicates if the caller has
	already parsed the null-excluding part.

	* par-ch6.adb (P_Formal_Part): Add the null-excluding parameter to the
	call to P_Access_Definition.

2004-04-19  Geert Bosch  <bosch@gnat.com>

	* checks.adb (Apply_Float_Conversion_Check): New procedure to implement
	the delicate semantics of floating-point to integer conversion.
	(Apply_Type_Conversion_Checks): Use Apply_Float_Conversion_Check.

	* eval_fat.adb (Machine_Mantissa): Moved to spec.
	(Machine_Radix): New function.

	* eval_fat.ads (Machine_Mantissa): Moved from body for use in
	conversion checks.
	(Machine_Radix): New function also for use in conversion checks.

2004-04-19  Ed Schonberg  <schonberg@gnat.com>

	* par-prag.adb (Source_File_Name_Project): Fix typo in error message.

	* exp_ch9.adb (Expand_Access_Protected_Subprogram_Type): Call analyze
	to decorate the access-to-protected subprogram and the equivalent type.

	* checks.adb (Null_Exclusion_Static_Checks): Code cleanup. Give support
	to anonymous access to subprogram types.

	* exp_ch4.adb (Expand_N_In): Preserve Static flag before
	constant-folding, for legality checks in contexts that require an RM
	static expression.

	* exp_ch6.adb (Expand_N_Function_Call): If call may generate large
	temporary but stack checking is not enabled, increment serial number
	to so that symbol generation is consistent with and without stack
	checking.

	* exp_util.ads, exp_util.adb (May_Generate_Large_Temp): Predicate is
	independent on whether stack checking is enabled, caller must check
	the corresponding flag.

	* sem_ch3.adb (Constrain_Index): Index bounds given by attributes need
	range checks.
	(Build_Derived_Concurrent_Type): Inherit Is_Constrained flag from
	parent if it has discriminants.
	(Build_Derived_Private_Type): Constructed full view does
	not come from source.
	(Process_Discriminants): Default discriminants on a tagged type are
	legal if this is the internal completion of a private untagged
	derivation.

	* sem_ch6.adb (Set_Actual_Subtypes): The generated declaration needs
	no constraint checks, because it corresponds to an existing object.

	* sem_prag.adb (Process_Convention): Pragma applies
	only to subprograms in the same declarative part, i.e. the same unit,
	not the same scope.

	* sem_res.adb (Valid_Conversion): In an instance or inlined body,
	ignore type mismatch on a numeric conversion if expression comes from
	expansion.

2004-04-19  Sergey Rybin  <rybin@act-europe.fr>

	* sem_elim.adb (Process_Eliminate_Pragma): Remove the processing for
	Homonym_Number parameter, add processing for Source_Location parameter
	corresponding.
	(Check_Eliminated): Remove the check for homonym numbers, add the check
	for source location traces.

	* sem_elim.ads (Process_Eliminate_Pragma): Replace Arg_Homonym_Number
	with Arg_Source_Location corresponding to the changes in the format of
	the pragma.

	* sem_prag.adb: (Analyze_Pragma): Changes in the processing of
	Eliminate pragma corresponding to the changes in the format of the
	pragma: Homonym_Number is replaced with Source_Location, two ways of
	distinguishing homonyms are mutially-exclusive.

2004-04-19  Joel Brobecker  <brobecker@gnat.com>

	* get_targ.ads (Get_No_Dollar_In_Label): Remove.

	* exp_dbug.adb (Output_Homonym_Numbers_Suffix): Remove use of
	No_Dollar_In_Label, no longer necessary, as it is always True.
	(Strip_Suffixes): Likewise.

2004-04-19  Gary Dismukes  <dismukes@gnat.com>

	* s-stalib.ads (type Exception_Code): Use Integer'Size for exponent of
	modulus for compatibility with size clause on targets with 16-bit
	Integer.

	* layout.adb (Discrimify): In the case of private types, set Vtyp to
	full type to fix type mismatches on calls to size functions for
	discriminant-dependent array components.

2004-04-19  Jerome Guitton  <guitton@act-europe.fr>

	* Makefile.in (gnatlib-zcx): New target, for building a ZCX run-time
	lib.

2004-04-19  Pascal Obry  <obry@gnat.com>

	* mdll-utl.adb (Locate): New version is idempotent.

From-SVN: r80856
2004-04-19 17:20:16 +02:00

809 lines
35 KiB
Ada

------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- T Y P E S --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2004 Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
-- MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Unchecked_Deallocation;
package Types is
pragma Preelaborate (Types);
-- This package contains host independent type definitions which are used
-- in more than one unit in the compiler. They are gathered here for easy
-- reference, though in some cases the full description is found in the
-- relevant module which implements the definition. The main reason that
-- they are not in their "natural" specs is that this would cause a lot of
-- inter-spec dependencies, and in particular some awkward circular
-- dependencies would have to be dealt with.
-- WARNING: There is a C version of this package. Any changes to this
-- source file must be properly reflected in the C header file a-types.h
-- Note: the declarations in this package reflect an expectation that the
-- host machine has an efficient integer base type with a range at least
-- 32 bits 2s-complement. If there are any machines for which this is not
-- a correct assumption, a significant number of changes will be required!
-------------------------------
-- General Use Integer Types --
-------------------------------
type Int is range -2 ** 31 .. +2 ** 31 - 1;
-- Signed 32-bit integer
type Dint is range -2 ** 63 .. +2 ** 63 - 1;
-- Double length (64-bit) integer
subtype Nat is Int range 0 .. Int'Last;
-- Non-negative Int values
subtype Pos is Int range 1 .. Int'Last;
-- Positive Int values
type Word is mod 2 ** 32;
-- Unsigned 32-bit integer
type Short is range -32768 .. +32767;
for Short'Size use 16;
-- 16-bit signed integer
type Byte is mod 2 ** 8;
for Byte'Size use 8;
-- 8-bit unsigned integer
type size_t is mod 2 ** Standard'Address_Size;
-- Memory size value, for use in calls to C routines
--------------------------------------
-- 8-Bit Character and String Types --
--------------------------------------
-- We use Standard.Character and Standard.String freely, since we are
-- compiling ourselves, and we properly implement the required 8-bit
-- character code as required in Ada 95. This section defines a few
-- general use constants and subtypes.
EOF : constant Character := ASCII.SUB;
-- The character SUB (16#1A#) is used in DOS and other systems derived
-- from DOS (OS/2, NT etc) to signal the end of a text file. Internally
-- all source files are ended by an EOF character, even on Unix systems.
-- An EOF character acts as the end of file only as the last character
-- of a source buffer, in any other position, it is treated as a blank
-- if it appears between tokens, and as an illegal character otherwise.
-- This makes life easier dealing with files that originated from DOS,
-- including concatenated files with interspersed EOF characters.
subtype Graphic_Character is Character range ' ' .. '~';
-- Graphic characters, as defined in ARM
subtype Line_Terminator is Character range ASCII.LF .. ASCII.CR;
-- Line terminator characters (LF, VT, FF, CR)
subtype Upper_Half_Character is
Character range Character'Val (16#80#) .. Character'Val (16#FF#);
-- Characters with the upper bit set
type Character_Ptr is access all Character;
type String_Ptr is access all String;
-- Standard character and string pointers
procedure Free is new Unchecked_Deallocation (String, String_Ptr);
-- Procedure for freeing dynamically allocated String values
subtype Word_Hex_String is String (1 .. 8);
-- Type used to represent Word value as 8 hex digits, with lower case
-- letters for the alphabetic cases.
function Get_Hex_String (W : Word) return Word_Hex_String;
-- Convert word value to 8-character hex string
-----------------------------------------
-- Types Used for Text Buffer Handling --
-----------------------------------------
-- We can't use type String for text buffers, since we must use the
-- standard 32-bit integer as an index value, since we count on all
-- index values being the same size.
type Text_Ptr is new Int;
-- Type used for subscripts in text buffer
type Text_Buffer is array (Text_Ptr range <>) of Character;
-- Text buffer used to hold source file or library information file
type Text_Buffer_Ptr is access all Text_Buffer;
-- Text buffers for input files are allocated dynamically and this type
-- is used to reference these text buffers.
procedure Free is new Unchecked_Deallocation (Text_Buffer, Text_Buffer_Ptr);
-- Procedure for freeing dynamically allocated text buffers
------------------------------------------
-- Types Used for Source Input Handling --
------------------------------------------
type Logical_Line_Number is range 0 .. Int'Last;
for Logical_Line_Number'Size use 32;
-- Line number type, used for storing logical line numbers (i.e. line
-- numbers that include effects of any Source_Reference pragmas in the
-- source file). The value zero indicates a line containing a source
-- reference pragma.
No_Line_Number : constant Logical_Line_Number := 0;
-- Special value used to indicate no line number
type Physical_Line_Number is range 1 .. Int'Last;
for Physical_Line_Number'Size use 32;
-- Line number type, used for storing physical line numbers (i.e.
-- line numbers in the physical file being compiled, unaffected by
-- the presence of source reference pragmas.
type Column_Number is range 0 .. 32767;
for Column_Number'Size use 16;
-- Column number (assume that 2**15 is large enough, see declaration of
-- Hostparm.Max_Line_Length, and also processing for -gnatyM in Stylesw)
No_Column_Number : constant Column_Number := 0;
-- Special value used to indicate no column number
subtype Source_Buffer is Text_Buffer;
-- Type used to store text of a source file . The buffer for the main
-- source (the source specified on the command line) has a lower bound
-- starting at zero. Subsequent subsidiary sources have lower bounds
-- which are one greater than the previous upper bound.
subtype Big_Source_Buffer is Text_Buffer (0 .. Text_Ptr'Last);
-- This is a virtual type used as the designated type of the access
-- type Source_Buffer_Ptr, see Osint.Read_Source_File for details.
type Source_Buffer_Ptr is access all Big_Source_Buffer;
-- Pointer to source buffer. We use virtual origin addressing for
-- source buffers, with thin pointers. The pointer points to a virtual
-- instance of type Big_Source_Buffer, where the actual type is in fact
-- of type Source_Buffer. The address is adjusted so that the virtual
-- origin addressing works correctly. See Osint.Read_Source_Buffer for
-- further details.
subtype Source_Ptr is Text_Ptr;
-- Type used to represent a source location, which is a subscript of a
-- character in the source buffer. As noted above, diffferent source
-- buffers have different ranges, so it is possible to tell from a
-- Source_Ptr value which source it refers to. Note that negative numbers
-- are allowed to accommodate the following special values.
No_Location : constant Source_Ptr := -1;
-- Value used to indicate no source position set in a node. A test for
-- a Source_Ptr value being >= No_Location is the apporoved way to test
-- for a standard value that does not include No_Location or any of the
-- following special definitions.
Standard_Location : constant Source_Ptr := -2;
-- Used for all nodes in the representation of package Standard other
-- than nodes representing the contents of Standard.ASCII. Note that
-- testing for <= Standard_Location tests for both Standard_Location
-- and for Standard_ASCII_Location.
Standard_ASCII_Location : constant Source_Ptr := -3;
-- Used for all nodes in the presentation of package Standard.ASCII
System_Location : constant Source_Ptr := -4;
-- Used to identify locations of pragmas scanned by Targparm, where we
-- know the location is in System, but we don't know exactly what line.
First_Source_Ptr : constant Source_Ptr := 0;
-- Starting source pointer index value for first source program
-------------------------------------
-- Range Definitions for Tree Data --
-------------------------------------
-- The tree has fields that can hold any of the following types:
-- Pointers to other tree nodes (type Node_Id)
-- List pointers (type List_Id)
-- Element list pointers (type Elist_Id)
-- Names (type Name_Id)
-- Strings (type String_Id)
-- Universal integers (type Uint)
-- Universal reals (type Ureal)
-- Character codes (type Char_Code stored with a bias)
-- In most contexts, the strongly typed interface determines which of
-- these types is present. However, there are some situations (involving
-- untyped traversals of the tree), where it is convenient to be easily
-- able to distinguish these values. The underlying representation in all
-- cases is an integer type Union_Id, and we ensure that the range of
-- the various possible values for each of the above types is disjoint
-- so that this distinction is possible.
type Union_Id is new Int;
-- The type in the tree for a union of possible ID values
-- Note: it is also helpful for debugging purposes to make these ranges
-- distinct. If a bug leads to misidentification of a value, then it will
-- typically result in an out of range value and a Constraint_Error.
List_Low_Bound : constant := -100_000_000;
-- The List_Id values are subscripts into an array of list headers which
-- has List_Low_Bound as its lower bound. This value is chosen so that all
-- List_Id values are negative, and the value zero is in the range of both
-- List_Id and Node_Id values (see further description below).
List_High_Bound : constant := 0;
-- Maximum List_Id subscript value. This allows up to 100 million list
-- Id values, which is in practice infinite, and there is no need to
-- check the range. The range overlaps the node range by one element
-- (with value zero), which is used both for the Empty node, and for
-- indicating no list. The fact that the same value is used is convenient
-- because it means that the default value of Empty applies to both nodes
-- and lists, and also is more efficient to test for.
Node_Low_Bound : constant := 0;
-- The tree Id values start at zero, because we use zero for Empty (to
-- allow a zero test for Empty). Actual tree node subscripts start at 0
-- since Empty is a legitimate node value.
Node_High_Bound : constant := 099_999_999;
-- Maximum number of nodes that can be allocated is 100 million, which
-- is in practice infinite, and there is no need to check the range.
Elist_Low_Bound : constant := 100_000_000;
-- The Elist_Id values are subscripts into an array of elist headers which
-- has Elist_Low_Bound as its lower bound.
Elist_High_Bound : constant := 199_999_999;
-- Maximum Elist_Id subscript value. This allows up to 100 million Elists,
-- which is in practice infinite and there is no need to check the range.
Elmt_Low_Bound : constant := 200_000_000;
-- Low bound of element Id values. The use of these values is internal to
-- the Elists package, but the definition of the range is included here
-- since it must be disjoint from other Id values. The Elmt_Id values are
-- subscripts into an array of list elements which has this as lower bound.
Elmt_High_Bound : constant := 299_999_999;
-- Upper bound of Elmt_Id values. This allows up to 100 million element
-- list members, which is in practice infinite (no range check needed).
Names_Low_Bound : constant := 300_000_000;
-- Low bound for name Id values
Names_High_Bound : constant := 399_999_999;
-- Maximum number of names that can be allocated is 100 million, which is
-- in practice infinite and there is no need to check the range.
Strings_Low_Bound : constant := 400_000_000;
-- Low bound for string Id values
Strings_High_Bound : constant := 499_999_999;
-- Maximum number of strings that can be allocated is 100 million, which
-- is in practice infinite and there is no need to check the range.
Ureal_Low_Bound : constant := 500_000_000;
-- Low bound for Ureal values.
Ureal_High_Bound : constant := 599_999_999;
-- Maximum number of Ureal values stored is 100_000_000 which is in
-- practice infinite so that no check is required.
Uint_Low_Bound : constant := 600_000_000;
-- Low bound for Uint values.
Uint_Table_Start : constant := 2_000_000_000;
-- Location where table entries for universal integers start (see
-- Uintp spec for details of the representation of Uint values).
Uint_High_Bound : constant := 2_099_999_999;
-- The range of Uint values is very large, since a substantial part
-- of this range is used to store direct values, see Uintp for details.
Char_Code_Bias : constant := 2_100_000_000;
-- A bias value added to character code values stored in the tree which
-- ensures that they have different values from any of the above types.
-- The following subtype definitions are used to provide convenient names
-- for membership tests on Int values to see what data type range they
-- lie in. Such tests appear only in the lowest level packages.
subtype List_Range is Union_Id
range List_Low_Bound .. List_High_Bound;
subtype Node_Range is Union_Id
range Node_Low_Bound .. Node_High_Bound;
subtype Elist_Range is Union_Id
range Elist_Low_Bound .. Elist_High_Bound;
subtype Elmt_Range is Union_Id
range Elmt_Low_Bound .. Elmt_High_Bound;
subtype Names_Range is Union_Id
range Names_Low_Bound .. Names_High_Bound;
subtype Strings_Range is Union_Id
range Strings_Low_Bound .. Strings_High_Bound;
subtype Uint_Range is Union_Id
range Uint_Low_Bound .. Uint_High_Bound;
subtype Ureal_Range is Union_Id
range Ureal_Low_Bound .. Ureal_High_Bound;
subtype Char_Code_Range is Union_Id
range Char_Code_Bias .. Char_Code_Bias + 2**16 - 1;
-----------------------------
-- Types for Namet Package --
-----------------------------
-- Name_Id values are used to identify entries in the names table. Except
-- for the special values No_Name, and Error_Name, they are subscript
-- values for the Names table defined in package Namet.
-- Note that with only a few exceptions, which are clearly documented, the
-- type Name_Id should be regarded as a private type. In particular it is
-- never appropriate to perform arithmetic operations using this type.
type Name_Id is range Names_Low_Bound .. Names_High_Bound;
for Name_Id'Size use 32;
-- Type used to identify entries in the names table
No_Name : constant Name_Id := Names_Low_Bound;
-- The special Name_Id value No_Name is used in the parser to indicate
-- a situation where no name is present (e.g. on a loop or block).
Error_Name : constant Name_Id := Names_Low_Bound + 1;
-- The special Name_Id value Error_Name is used in the parser to
-- indicate that some kind of error was encountered in scanning out
-- the relevant name, so it does not have a representable label.
subtype Error_Name_Or_No_Name is Name_Id range No_Name .. Error_Name;
-- Used to test for either error name or no name
First_Name_Id : constant Name_Id := Names_Low_Bound + 2;
-- Subscript of first entry in names table
----------------------------
-- Types for Atree Package --
----------------------------
-- Node_Id values are used to identify nodes in the tree. They are
-- subscripts into the Node table declared in package Tree. Note that
-- the special values Empty and Error are subscripts into this table,
-- See package Atree for further details.
type Node_Id is range Node_Low_Bound .. Node_High_Bound;
-- Type used to identify nodes in the tree
subtype Entity_Id is Node_Id;
-- A synonym for node types, used in the entity package to refer to
-- nodes that are entities (i.e. nodes with an Nkind of N_Defining_xxx)
-- All such nodes are extended nodes and these are the only extended
-- nodes, so that in practice entity and extended nodes are synonymous.
subtype Node_Or_Entity_Id is Node_Id;
-- A synonym for node types, used in cases where a given value may be used
-- to represent either a node or an entity. We like to minimize such uses
-- for obvious reasons of logical type consistency, but where such uses
-- occur, they should be documented by use of this type.
Empty : constant Node_Id := Node_Low_Bound;
-- Used to indicate null node. A node is actually allocated with this
-- Id value, so that Nkind (Empty) = N_Empty. Note that Node_Low_Bound
-- is zero, so Empty = No_List = zero.
Empty_List_Or_Node : constant := 0;
-- This constant is used in situations (e.g. initializing empty fields)
-- where the value set will be used to represent either an empty node
-- or a non-existent list, depending on the context.
Error : constant Node_Id := Node_Low_Bound + 1;
-- Used to indicate that there was an error in the source program. A node
-- is actually allocated at this address, so that Nkind (Error) = N_Error.
Empty_Or_Error : constant Node_Id := Error;
-- Since Empty and Error are the first two Node_Id values, the test for
-- N <= Empty_Or_Error tests to see if N is Empty or Error. This definition
-- provides convenient self-documentation for such tests.
First_Node_Id : constant Node_Id := Node_Low_Bound;
-- Subscript of first allocated node. Note that Empty and Error are both
-- allocated nodes, whose Nkind fields can be accessed without error.
------------------------------
-- Types for Nlists Package --
------------------------------
-- List_Id values are used to identify node lists in the tree. They are
-- subscripts into the Lists table declared in package Tree. Note that
-- the special value Error_List is a subscript in this table, but the
-- value No_List is *not* a valid subscript, and any attempt to apply
-- list operations to No_List will cause a (detected) error.
type List_Id is range List_Low_Bound .. List_High_Bound;
-- Type used to identify a node list
No_List : constant List_Id := List_High_Bound;
-- Used to indicate absence of a list. Note that the value is zero, which
-- is the same as Empty, which is helpful in intializing nodes where a
-- value of zero can represent either an empty node or an empty list.
Error_List : constant List_Id := List_Low_Bound;
-- Used to indicate that there was an error in the source program in a
-- context which would normally require a list. This node appears to be
-- an empty list to the list operations (a null list is actually allocated
-- which has this Id value).
First_List_Id : constant List_Id := Error_List;
-- Subscript of first allocated list header
------------------------------
-- Types for Elists Package --
------------------------------
-- Element list Id values are used to identify element lists stored in
-- the tree (see package Tree for further details). They are formed by
-- adding a bias (Element_List_Bias) to subscript values in the same
-- array that is used for node list headers.
type Elist_Id is range Elist_Low_Bound .. Elist_High_Bound;
-- Type used to identify an element list (Elist header table subscript)
No_Elist : constant Elist_Id := Elist_Low_Bound;
-- Used to indicate absense of an element list. Note that this is not
-- an actual Elist header, so element list operations on this value
-- are not valid.
First_Elist_Id : constant Elist_Id := No_Elist + 1;
-- Subscript of first allocated Elist header.
-- Element Id values are used to identify individual elements of an
-- element list (see package Elists for further details).
type Elmt_Id is range Elmt_Low_Bound .. Elmt_High_Bound;
-- Type used to identify an element list
No_Elmt : constant Elmt_Id := Elmt_Low_Bound;
-- Used to represent empty element
First_Elmt_Id : constant Elmt_Id := No_Elmt + 1;
-- Subscript of first allocated Elmt table entry
-------------------------------
-- Types for Stringt Package --
-------------------------------
-- String_Id values are used to identify entries in the strings table.
-- They are subscripts into the strings table defined in package Strings.
-- Note that with only a few exceptions, which are clearly documented, the
-- type String_Id should be regarded as a private type. In particular it is
-- never appropriate to perform arithmetic operations using this type.
type String_Id is range Strings_Low_Bound .. Strings_High_Bound;
-- Type used to identify entries in the strings table
No_String : constant String_Id := Strings_Low_Bound;
-- Used to indicate missing string Id. Note that the value zero is used
-- to indicate a missing data value for all the Int types in this section.
First_String_Id : constant String_Id := No_String + 1;
-- First subscript allocated in string table
-------------------------
-- Character Code Type --
-------------------------
-- The type Char is used for character data internally in the compiler,
-- but character codes in the source are represented by the Char_Code
-- type. Each character literal in the source is interpreted as being one
-- of the 2**16 possible Wide_Character codes, and a unique integer value
-- is assigned, corresponding to the POS value in the Wide_Character type.
-- String literals are similarly interpreted as a sequence of such codes.
-- Note: when character code values are stored in the tree, they are stored
-- by adding a bias value (Char_Code_Bias) that results in values that can
-- be distinguished from other types of values stored in the tree.
type Char_Code is mod 2 ** 16;
for Char_Code'Size use 16;
function Get_Char_Code (C : Character) return Char_Code;
pragma Inline (Get_Char_Code);
-- Function to obtain internal character code from source character. For
-- the moment, the internal character code is simply the Pos value of the
-- input source character, but we provide this interface for possible
-- later support of alternative character sets.
function In_Character_Range (C : Char_Code) return Boolean;
pragma Inline (In_Character_Range);
-- Determines if the given character code is in range of type Character,
-- and if so, returns True. If not, returns False.
function Get_Character (C : Char_Code) return Character;
pragma Inline (Get_Character);
-- For a character C that is in character range (see above function), this
-- function returns the corresponding Character value. It is an error to
-- call Get_Character if C is not in character range
---------------------------------------
-- Types used for Library Management --
---------------------------------------
type Unit_Number_Type is new Int;
-- Unit number. The main source is unit 0, and subsidiary sources have
-- non-zero numbers starting with 1. Unit numbers are used to index the
-- file table in Lib.
Main_Unit : constant Unit_Number_Type := 0;
-- Unit number value for main unit
No_Unit : constant Unit_Number_Type := -1;
-- Special value used to signal no unit
type Source_File_Index is new Int range -1 .. Int'Last;
-- Type used to index the source file table (see package Sinput)
Internal_Source_File : constant Source_File_Index :=
Source_File_Index'First;
-- Value used to indicate the buffer for the source-code-like strings
-- internally created withing the compiler (see package Sinput)
No_Source_File : constant Source_File_Index := 0;
-- Value used to indicate no source file present
subtype File_Name_Type is Name_Id;
-- File names are stored in the names table and this synonym is used to
-- indicate that a Name_Id value is being used to hold a simple file
-- name (which does not include any directory information).
No_File : constant File_Name_Type := File_Name_Type (No_Name);
-- Constant used to indicate no file found
subtype Unit_Name_Type is Name_Id;
-- Unit names are stored in the names table and this synonym is used to
-- indicate that a Name_Id value is being used to hold a unit name.
-----------------------------------
-- Representation of Time Stamps --
-----------------------------------
-- All compiled units are marked with a time stamp which is derived from
-- the source file (we assume that the host system has the concept of a
-- file time stamp which is modified when a file is modified). These
-- time stamps are used to ensure consistency of the set of units that
-- constitutes a library. Time stamps are 12 character strings with
-- with the following format:
-- YYYYMMDDHHMMSS
-- YYYY year
-- MM month (2 digits 01-12)
-- DD day (2 digits 01-31)
-- HH hour (2 digits 00-23)
-- MM minutes (2 digits 00-59)
-- SS seconds (2 digits 00-59)
-- In the case of Unix systems (and other systems which keep the time in
-- GMT), the time stamp is the GMT time of the file, not the local time.
-- This solves problems in using libraries across networks with clients
-- spread across multiple time-zones.
Time_Stamp_Length : constant := 14;
-- Length of time stamp value
subtype Time_Stamp_Index is Natural range 1 .. Time_Stamp_Length;
type Time_Stamp_Type is new String (Time_Stamp_Index);
-- Type used to represent time stamp
Empty_Time_Stamp : constant Time_Stamp_Type := (others => ' ');
-- Type used to represent an empty or missing time stamp. Looks less
-- than any real time stamp if two time stamps are compared. Note that
-- although this is not a private type, clients should not rely on the
-- exact way in which this string is represented, and instead should
-- use the subprograms below.
Dummy_Time_Stamp : constant Time_Stamp_Type := (others => '0');
-- This is used for dummy time stamp values used in the D lines for
-- non-existant files, and is intended to be an impossible value.
function "=" (Left, Right : Time_Stamp_Type) return Boolean;
function "<=" (Left, Right : Time_Stamp_Type) return Boolean;
function ">=" (Left, Right : Time_Stamp_Type) return Boolean;
function "<" (Left, Right : Time_Stamp_Type) return Boolean;
function ">" (Left, Right : Time_Stamp_Type) return Boolean;
-- Comparison functions on time stamps. Note that two time stamps
-- are defined as being equal if they have the same day/month/year
-- and the hour/minutes/seconds values are within 2 seconds of one
-- another. This deals with rounding effects in library file time
-- stamps caused by copying operations during installation. We have
-- particularly noticed that WinNT seems susceptible to such changes.
-- Note: the Empty_Time_Stamp value looks equal to itself, and less
-- than any non-empty time stamp value.
procedure Split_Time_Stamp
(TS : Time_Stamp_Type;
Year : out Nat;
Month : out Nat;
Day : out Nat;
Hour : out Nat;
Minutes : out Nat;
Seconds : out Nat);
-- Given a time stamp, decompose it into its components
procedure Make_Time_Stamp
(Year : Nat;
Month : Nat;
Day : Nat;
Hour : Nat;
Minutes : Nat;
Seconds : Nat;
TS : out Time_Stamp_Type);
-- Given the components of a time stamp, initialize the value
-----------------------------------------------
-- Types used for Pragma Suppress Management --
-----------------------------------------------
type Check_Id is (
Access_Check,
Accessibility_Check,
Discriminant_Check,
Division_Check,
Elaboration_Check,
Index_Check,
Length_Check,
Overflow_Check,
Range_Check,
Storage_Check,
Tag_Check,
All_Checks);
-- The following record contains an entry for each recognized check name
-- for pragma Suppress. It is used to represent current settings of scope
-- based suppress actions from pragma Suppress or command line settings.
type Suppress_Array is
array (Check_Id range Access_Check .. Tag_Check) of Boolean;
pragma Pack (Suppress_Array);
-- To add a new check type to GNAT, the following steps are required:
-- 1. Add an entry to Snames spec and body for the new name
-- 2. Add an entry to the definition of Check_Id above
-- 3. Add a new function to Checks to handle the new check test
-- 4. Add a new Do_xxx_Check flag to Sinfo (if required)
-- 5. Add appropriate checks for the new test
-----------------------------------
-- Global Exception Declarations --
-----------------------------------
-- This section contains declarations of exceptions that are used
-- throughout the compiler.
Unrecoverable_Error : exception;
-- This exception is raised to immediately terminate the compilation
-- of the current source program. Used in situations where things are
-- bad enough that it doesn't seem worth continuing (e.g. max errors
-- reached, or a required file is not found). Also raised when the
-- compiler finds itself in trouble after an error (see Comperr).
---------------------------------
-- Parameter Mechanism Control --
---------------------------------
-- Function and parameter entities have a field that records the
-- passing mechanism. See specification of Sem_Mech for full details.
-- The following subtype is used to represent values of this type:
subtype Mechanism_Type is Int range -10 .. Int'Last;
-- Type used to represent a mechanism value. This is a subtype rather
-- than a type to avoid some annoying processing problems with certain
-- routines in Einfo (processing them to create the corresponding C).
------------------------------
-- Run-Time Exception Codes --
------------------------------
-- When the code generator generates a run-time exception, it provides
-- a reason code which is one of the following. This reason code is used
-- to select the appropriate run-time routine to be called, determining
-- both the exception to be raised, and the message text to be added.
-- The prefix CE/PE/SE indicates the exception to be raised
-- CE = Constraint_Error
-- PE = Program_Error
-- SE = Storage_Error
-- The remaining part of the name indicates the message text to be added,
-- where all letters are lower case, and underscores are converted to
-- spaces (for example CE_Invalid_Data adds the text "invalid data").
-- To add a new code, you need to do the following:
-- 1. Modify the type and subtype declarations below appropriately,
-- keeping things in alphabetical order.
-- 2. Modify the corresponding definitions in types.h, including
-- the definition of last_reason_code.
-- 3. Add a new routine in Ada.Exceptions with the appropriate call
-- and static string constant
type RT_Exception_Code is (
CE_Access_Check_Failed,
CE_Access_Parameter_Is_Null,
CE_Discriminant_Check_Failed,
CE_Divide_By_Zero,
CE_Explicit_Raise,
CE_Index_Check_Failed,
CE_Invalid_Data,
CE_Length_Check_Failed,
CE_Overflow_Check_Failed,
CE_Partition_Check_Failed,
CE_Range_Check_Failed,
CE_Tag_Check_Failed,
PE_Access_Before_Elaboration,
PE_Accessibility_Check_Failed,
PE_All_Guards_Closed,
PE_Duplicated_Entry_Address,
PE_Explicit_Raise,
PE_Finalize_Raised_Exception,
PE_Misaligned_Address_Value,
PE_Missing_Return,
PE_Overlaid_Controlled_Object,
PE_Potentially_Blocking_Operation,
PE_Stubbed_Subprogram_Called,
PE_Unchecked_Union_Restriction,
PE_Illegal_RACW_E_4_18,
SE_Empty_Storage_Pool,
SE_Explicit_Raise,
SE_Infinite_Recursion,
SE_Object_Too_Large,
SE_Restriction_Violation);
subtype RT_CE_Exceptions is RT_Exception_Code range
CE_Access_Check_Failed ..
CE_Tag_Check_Failed;
subtype RT_PE_Exceptions is RT_Exception_Code range
PE_Access_Before_Elaboration ..
PE_Illegal_RACW_E_4_18;
subtype RT_SE_Exceptions is RT_Exception_Code range
SE_Empty_Storage_Pool ..
SE_Restriction_Violation;
end Types;