1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2014, Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. 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 COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
26 with Atree
; use Atree
;
27 with Csets
; use Csets
;
28 with Debug
; use Debug
;
29 with Einfo
; use Einfo
;
30 with Elists
; use Elists
;
31 with Layout
; use Layout
;
32 with Namet
; use Namet
;
33 with Nlists
; use Nlists
;
34 with Nmake
; use Nmake
;
36 with Output
; use Output
;
37 with Set_Targ
; use Set_Targ
;
38 with Targparm
; use Targparm
;
39 with Tbuild
; use Tbuild
;
40 with Ttypes
; use Ttypes
;
42 with Sem_Mech
; use Sem_Mech
;
43 with Sem_Util
; use Sem_Util
;
44 with Sinfo
; use Sinfo
;
45 with Snames
; use Snames
;
46 with Stand
; use Stand
;
47 with Uintp
; use Uintp
;
48 with Urealp
; use Urealp
;
50 package body CStand
is
52 Stloc
: constant Source_Ptr
:= Standard_Location
;
53 Staloc
: constant Source_Ptr
:= Standard_ASCII_Location
;
54 -- Standard abbreviations used throughout this package
56 Back_End_Float_Types
: Elist_Id
:= No_Elist
;
57 -- List used for any floating point supported by the back end. This needs
58 -- to be at the library level, because the call back procedures retrieving
59 -- this information are at that level.
61 -----------------------
62 -- Local Subprograms --
63 -----------------------
65 procedure Build_Float_Type
70 -- Procedure to build standard predefined float base type. The first
71 -- parameter is the entity for the type, and the second parameter is the
72 -- size in bits. The third parameter indicates the kind of representation
73 -- to be used. The fourth parameter is the digits value. Each type
74 -- is added to the list of predefined floating point types.
76 procedure Build_Signed_Integer_Type
(E
: Entity_Id
; Siz
: Nat
);
77 -- Procedure to build standard predefined signed integer subtype. The
78 -- first parameter is the entity for the subtype. The second parameter
79 -- is the size in bits. The corresponding base type is not built by
80 -- this routine but instead must be built by the caller where needed.
82 procedure Build_Unsigned_Integer_Type
86 -- Procedure to build standard predefined unsigned integer subtype. These
87 -- subtypes are not user visible, but they are used internally. The first
88 -- parameter is the entity for the subtype. The second parameter is the
89 -- size in bits. The third parameter is an identifying name.
91 procedure Copy_Float_Type
(To
: Entity_Id
; From
: Entity_Id
);
92 -- Build a floating point type, copying representation details from From.
93 -- This is used to create predefined floating point types based on
94 -- available types in the back end.
96 procedure Create_Operators
;
97 -- Make entries for each of the predefined operators in Standard
99 procedure Create_Unconstrained_Base_Type
102 -- The predefined signed integer types are constrained subtypes which
103 -- must have a corresponding unconstrained base type. This type is almost
104 -- useless. The only place it has semantics is Subtypes_Statically_Match.
105 -- Consequently, we arrange for it to be identical apart from the setting
106 -- of the constrained bit. This routine takes an entity E for the Type,
107 -- copies it to estabish the base type, then resets the Ekind of the
108 -- original entity to K (the Ekind for the subtype). The Etype field of
109 -- E is set by the call (to point to the created base type entity), and
110 -- also the Is_Constrained flag of E is set.
112 -- To understand the exact requirement for this, see RM 3.5.4(11) which
113 -- makes it clear that Integer, for example, is constrained, with the
114 -- constraint bounds matching the bounds of the (unconstrained) base
115 -- type. The point is that Integer and Integer'Base have identical
116 -- bounds, but do not statically match, since a subtype with constraints
117 -- never matches a subtype with no constraints.
119 function Find_Back_End_Float_Type
(Name
: String) return Entity_Id
;
120 -- Return the first float type in Back_End_Float_Types with the given name.
121 -- Names of entities in back end types, are either type names of C
122 -- predefined types (all lower case), or mode names (upper case).
123 -- These are not generally valid identifier names.
125 function Identifier_For
(S
: Standard_Entity_Type
) return Node_Id
;
126 -- Returns an identifier node with the same name as the defining
127 -- identifier corresponding to the given Standard_Entity_Type value
129 procedure Make_Component
133 -- Build a record component with the given type and name, and append to
134 -- the list of components of Rec.
138 Formal_Name
: String) return Entity_Id
;
139 -- Construct entity for subprogram formal with given name and type
141 function Make_Integer
(V
: Uint
) return Node_Id
;
142 -- Builds integer literal with given value
144 procedure Make_Name
(Id
: Entity_Id
; Nam
: String);
145 -- Make an entry in the names table for Nam, and set as Chars field of Id
147 function New_Operator
(Op
: Name_Id
; Typ
: Entity_Id
) return Entity_Id
;
148 -- Build entity for standard operator with given name and type
150 function New_Standard_Entity
151 (New_Node_Kind
: Node_Kind
:= N_Defining_Identifier
) return Entity_Id
;
152 -- Builds a new entity for Standard
154 procedure Print_Standard
;
155 -- Print representation of package Standard if switch set
157 procedure Register_Float_Type
160 Float_Rep
: Float_Rep_Kind
;
161 Precision
: Positive;
163 Alignment
: Natural);
164 -- Registers a single back end floating-point type (from FPT_Mode_Table in
165 -- Set_Targ). This will create a predefined floating-point base type for
166 -- one of the floating point types reported by the back end, and add it
167 -- to the list of predefined float types. Name is the name of the type
168 -- as a normal format (non-null-terminated) string. Digs is the number of
169 -- digits, which is always non-zero, since non-floating-point types were
170 -- filtered out earlier. Float_Rep indicates the kind of floating-point
171 -- type, and Precision, Size and Alignment are the precision, size and
172 -- alignment in bits.
174 procedure Set_Integer_Bounds
179 -- Procedure to set bounds for integer type or subtype. Id is the entity
180 -- whose bounds and type are to be set. The Typ parameter is the Etype
181 -- value for the entity (which will be the same as Id for all predefined
182 -- integer base types. The third and fourth parameters are the bounds.
184 ----------------------
185 -- Build_Float_Type --
186 ----------------------
188 procedure Build_Float_Type
191 Rep
: Float_Rep_Kind
;
195 Set_Type_Definition
(Parent
(E
),
196 Make_Floating_Point_Definition
(Stloc
,
197 Digits_Expression
=> Make_Integer
(UI_From_Int
(Digs
))));
199 Set_Ekind
(E
, E_Floating_Point_Type
);
201 Set_Float_Rep
(E
, Rep
);
203 Set_Elem_Alignment
(E
);
204 Init_Digits_Value
(E
, Digs
);
205 Set_Float_Bounds
(E
);
208 Set_Size_Known_At_Compile_Time
(E
);
209 end Build_Float_Type
;
211 ------------------------------
212 -- Find_Back_End_Float_Type --
213 ------------------------------
215 function Find_Back_End_Float_Type
(Name
: String) return Entity_Id
is
219 N
:= First_Elmt
(Back_End_Float_Types
);
220 while Present
(N
) and then Get_Name_String
(Chars
(Node
(N
))) /= Name
226 end Find_Back_End_Float_Type
;
228 -------------------------------
229 -- Build_Signed_Integer_Type --
230 -------------------------------
232 procedure Build_Signed_Integer_Type
(E
: Entity_Id
; Siz
: Nat
) is
233 U2Siz1
: constant Uint
:= 2 ** (Siz
- 1);
234 Lbound
: constant Uint
:= -U2Siz1
;
235 Ubound
: constant Uint
:= U2Siz1
- 1;
238 Set_Type_Definition
(Parent
(E
),
239 Make_Signed_Integer_Type_Definition
(Stloc
,
240 Low_Bound
=> Make_Integer
(Lbound
),
241 High_Bound
=> Make_Integer
(Ubound
)));
243 Set_Ekind
(E
, E_Signed_Integer_Type
);
246 Set_Elem_Alignment
(E
);
247 Set_Integer_Bounds
(E
, E
, Lbound
, Ubound
);
250 Set_Is_Known_Valid
(E
);
251 Set_Size_Known_At_Compile_Time
(E
);
252 end Build_Signed_Integer_Type
;
254 ---------------------------------
255 -- Build_Unsigned_Integer_Type --
256 ---------------------------------
258 procedure Build_Unsigned_Integer_Type
267 Decl
:= New_Node
(N_Full_Type_Declaration
, Stloc
);
268 Set_Defining_Identifier
(Decl
, Uns
);
269 Make_Name
(Uns
, Nam
);
271 Set_Ekind
(Uns
, E_Modular_Integer_Type
);
272 Set_Scope
(Uns
, Standard_Standard
);
273 Set_Etype
(Uns
, Uns
);
274 Init_Size
(Uns
, Siz
);
275 Set_Elem_Alignment
(Uns
);
276 Set_Modulus
(Uns
, Uint_2
** Siz
);
277 Set_Is_Unsigned_Type
(Uns
);
278 Set_Size_Known_At_Compile_Time
(Uns
);
279 Set_Is_Known_Valid
(Uns
, True);
281 R_Node
:= New_Node
(N_Range
, Stloc
);
282 Set_Low_Bound
(R_Node
, Make_Integer
(Uint_0
));
283 Set_High_Bound
(R_Node
, Make_Integer
(Modulus
(Uns
) - 1));
284 Set_Etype
(Low_Bound
(R_Node
), Uns
);
285 Set_Etype
(High_Bound
(R_Node
), Uns
);
286 Set_Scalar_Range
(Uns
, R_Node
);
287 end Build_Unsigned_Integer_Type
;
289 ---------------------
290 -- Copy_Float_Type --
291 ---------------------
293 procedure Copy_Float_Type
(To
: Entity_Id
; From
: Entity_Id
) is
295 Build_Float_Type
(To
, UI_To_Int
(Esize
(From
)), Float_Rep
(From
),
296 UI_To_Int
(Digits_Value
(From
)));
299 ----------------------
300 -- Create_Operators --
301 ----------------------
303 -- Each operator has an abbreviated signature. The formals have the names
304 -- LEFT and RIGHT. Their types are not actually used for resolution.
306 procedure Create_Operators
is
309 -- The following tables define the binary and unary operators and their
310 -- corresponding result type.
312 Binary_Ops
: constant array (S_Binary_Ops
) of Name_Id
:=
314 -- There is one entry here for each binary operator, except for the
315 -- case of concatenation, where there are three entries, one for a
316 -- String result, one for Wide_String, and one for Wide_Wide_String.
338 Bin_Op_Types
: constant array (S_Binary_Ops
) of Entity_Id
:=
340 -- This table has the corresponding result types. The entries are
341 -- ordered so they correspond to the Binary_Ops array above.
343 (Universal_Integer
, -- Add
344 Standard_Boolean
, -- And
345 Standard_String
, -- Concat (String)
346 Standard_Wide_String
, -- Concat (Wide_String)
347 Standard_Wide_Wide_String
, -- Concat (Wide_Wide_String)
348 Universal_Integer
, -- Divide
349 Standard_Boolean
, -- Eq
350 Universal_Integer
, -- Expon
351 Standard_Boolean
, -- Ge
352 Standard_Boolean
, -- Gt
353 Standard_Boolean
, -- Le
354 Standard_Boolean
, -- Lt
355 Universal_Integer
, -- Mod
356 Universal_Integer
, -- Multiply
357 Standard_Boolean
, -- Ne
358 Standard_Boolean
, -- Or
359 Universal_Integer
, -- Rem
360 Universal_Integer
, -- Subtract
361 Standard_Boolean
); -- Xor
363 Unary_Ops
: constant array (S_Unary_Ops
) of Name_Id
:=
365 -- There is one entry here for each unary operator
372 Unary_Op_Types
: constant array (S_Unary_Ops
) of Entity_Id
:=
374 -- This table has the corresponding result types. The entries are
375 -- ordered so they correspond to the Unary_Ops array above.
377 (Universal_Integer
, -- Abs
378 Universal_Integer
, -- Subtract
379 Standard_Boolean
, -- Not
380 Universal_Integer
); -- Add
383 for J
in S_Binary_Ops
loop
384 Op_Node
:= New_Operator
(Binary_Ops
(J
), Bin_Op_Types
(J
));
386 Append_Entity
(Make_Formal
(Any_Type
, "LEFT"), Op_Node
);
387 Append_Entity
(Make_Formal
(Any_Type
, "RIGHT"), Op_Node
);
390 for J
in S_Unary_Ops
loop
391 Op_Node
:= New_Operator
(Unary_Ops
(J
), Unary_Op_Types
(J
));
393 Append_Entity
(Make_Formal
(Any_Type
, "RIGHT"), Op_Node
);
396 -- For concatenation, we create a separate operator for each
397 -- array type. This simplifies the resolution of the component-
398 -- component concatenation operation. In Standard, we set the types
399 -- of the formals for string, wide [wide]_string, concatenations.
401 Set_Etype
(First_Entity
(Standard_Op_Concat
), Standard_String
);
402 Set_Etype
(Last_Entity
(Standard_Op_Concat
), Standard_String
);
404 Set_Etype
(First_Entity
(Standard_Op_Concatw
), Standard_Wide_String
);
405 Set_Etype
(Last_Entity
(Standard_Op_Concatw
), Standard_Wide_String
);
407 Set_Etype
(First_Entity
(Standard_Op_Concatww
),
408 Standard_Wide_Wide_String
);
410 Set_Etype
(Last_Entity
(Standard_Op_Concatww
),
411 Standard_Wide_Wide_String
);
412 end Create_Operators
;
414 ---------------------
415 -- Create_Standard --
416 ---------------------
418 -- The tree for the package Standard is prefixed to all compilations.
419 -- Several entities required by semantic analysis are denoted by global
420 -- variables that are initialized to point to the corresponding occurrences
421 -- in Standard. The visible entities of Standard are created here. Special
422 -- entities maybe created here as well or may be created from the semantics
423 -- module. By not adding them to the Decls list of Standard they will not
424 -- be visible to Ada programs.
426 procedure Create_Standard
is
427 Decl_S
: constant List_Id
:= New_List
;
428 -- List of declarations in Standard
430 Decl_A
: constant List_Id
:= New_List
;
431 -- List of declarations in ASCII
436 Ident_Node
: Node_Id
;
442 procedure Build_Exception
(S
: Standard_Entity_Type
);
443 -- Procedure to declare given entity as an exception
445 procedure Create_Back_End_Float_Types
;
446 -- Initialize the Back_End_Float_Types list by having the back end
447 -- enumerate all available types and building type entities for them.
449 procedure Create_Float_Types
;
450 -- Creates entities for all predefined floating point types, and
451 -- adds these to the Predefined_Float_Types list in package Standard.
453 procedure Pack_String_Type
(String_Type
: Entity_Id
);
454 -- Generate proper tree for pragma Pack that applies to given type, and
455 -- mark type as having the pragma.
457 ---------------------
458 -- Build_Exception --
459 ---------------------
461 procedure Build_Exception
(S
: Standard_Entity_Type
) is
463 Set_Ekind
(Standard_Entity
(S
), E_Exception
);
464 Set_Etype
(Standard_Entity
(S
), Standard_Exception_Type
);
465 Set_Exception_Code
(Standard_Entity
(S
), Uint_0
);
466 Set_Is_Public
(Standard_Entity
(S
), True);
469 Make_Exception_Declaration
(Stloc
,
470 Defining_Identifier
=> Standard_Entity
(S
));
471 Append
(Decl
, Decl_S
);
474 ---------------------------------
475 -- Create_Back_End_Float_Types --
476 ---------------------------------
478 procedure Create_Back_End_Float_Types
is
480 for J
in 1 .. Num_FPT_Modes
loop
482 E
: FPT_Mode_Entry
renames FPT_Mode_Table
(J
);
485 (E
.NAME
.all, E
.DIGS
, E
.FLOAT_REP
, E
.PRECISION
, E
.SIZE
,
489 end Create_Back_End_Float_Types
;
491 ------------------------
492 -- Create_Float_Types --
493 ------------------------
495 procedure Create_Float_Types
is
497 -- Create type definition nodes for predefined float types
500 (Standard_Short_Float
,
501 Find_Back_End_Float_Type
("float"));
502 Set_Is_Implementation_Defined
(Standard_Short_Float
);
504 Copy_Float_Type
(Standard_Float
, Standard_Short_Float
);
506 Copy_Float_Type
(Standard_Long_Float
,
507 Find_Back_End_Float_Type
("double"));
509 Predefined_Float_Types
:= New_Elmt_List
;
510 Append_Elmt
(Standard_Short_Float
, Predefined_Float_Types
);
511 Append_Elmt
(Standard_Float
, Predefined_Float_Types
);
512 Append_Elmt
(Standard_Long_Float
, Predefined_Float_Types
);
514 -- ??? For now, we don't have a good way to tell the widest float
515 -- type with hardware support. Basically, GCC knows the size of that
516 -- type, but on x86-64 there often are two or three 128-bit types,
517 -- one double extended that has 18 decimal digits, a 128-bit quad
518 -- precision type with 33 digits and possibly a 128-bit decimal float
519 -- type with 34 digits. As a workaround, we define Long_Long_Float as
520 -- C's "long double" if that type exists and has at most 18 digits,
521 -- or otherwise the same as Long_Float.
524 Max_HW_Digs
: constant := 18;
525 -- Maximum hardware digits supported
527 LLF
: Entity_Id
:= Find_Back_End_Float_Type
("long double");
528 -- Entity for long double type
531 if No
(LLF
) or else Digits_Value
(LLF
) > Max_HW_Digs
then
532 LLF
:= Standard_Long_Float
;
535 Set_Is_Implementation_Defined
(Standard_Long_Long_Float
);
536 Copy_Float_Type
(Standard_Long_Long_Float
, LLF
);
538 Append_Elmt
(Standard_Long_Long_Float
, Predefined_Float_Types
);
541 -- Any other back end types are appended at the end of the list of
542 -- predefined float types, and will only be selected if the none of
543 -- the types in Standard is suitable, or if a specific named type is
544 -- requested through a pragma Import.
546 while not Is_Empty_Elmt_List
(Back_End_Float_Types
) loop
548 E
: constant Elmt_Id
:= First_Elmt
(Back_End_Float_Types
);
550 Append_Elmt
(Node
(E
), To
=> Predefined_Float_Types
);
551 Remove_Elmt
(Back_End_Float_Types
, E
);
554 end Create_Float_Types
;
556 ----------------------
557 -- Pack_String_Type --
558 ----------------------
560 procedure Pack_String_Type
(String_Type
: Entity_Id
) is
561 Prag
: constant Node_Id
:=
564 Pragma_Argument_Associations
=>
566 Make_Pragma_Argument_Association
(Stloc
,
567 Expression
=> New_Occurrence_Of
(String_Type
, Stloc
))));
569 Append
(Prag
, Decl_S
);
570 Record_Rep_Item
(String_Type
, Prag
);
571 Set_Has_Pragma_Pack
(String_Type
, True);
572 end Pack_String_Type
;
574 -- Start of processing for Create_Standard
577 -- Initialize scanner for internal scans of literals
579 Scn
.Initialize_Scanner
(No_Unit
, Internal_Source_File
);
581 -- First step is to create defining identifiers for each entity
583 for S
in Standard_Entity_Type
loop
585 S_Name
: constant String := Standard_Entity_Type
'Image (S
);
586 -- Name of entity (note we skip S_ at the start)
588 Ident_Node
: Node_Id
;
589 -- Defining identifier node
592 Ident_Node
:= New_Standard_Entity
;
593 Make_Name
(Ident_Node
, S_Name
(3 .. S_Name
'Length));
594 Standard_Entity
(S
) := Ident_Node
;
598 -- Create package declaration node for package Standard
600 Standard_Package_Node
:= New_Node
(N_Package_Declaration
, Stloc
);
602 Pspec
:= New_Node
(N_Package_Specification
, Stloc
);
603 Set_Specification
(Standard_Package_Node
, Pspec
);
605 Set_Defining_Unit_Name
(Pspec
, Standard_Standard
);
606 Set_Visible_Declarations
(Pspec
, Decl_S
);
608 Set_Ekind
(Standard_Standard
, E_Package
);
609 Set_Is_Pure
(Standard_Standard
);
610 Set_Is_Compilation_Unit
(Standard_Standard
);
612 -- Create type/subtype declaration nodes for standard types
614 for S
in S_Types
loop
616 -- Subtype declaration case
618 if S
= S_Natural
or else S
= S_Positive
then
619 Decl
:= New_Node
(N_Subtype_Declaration
, Stloc
);
620 Set_Subtype_Indication
(Decl
,
621 New_Occurrence_Of
(Standard_Integer
, Stloc
));
623 -- Full type declaration case
626 Decl
:= New_Node
(N_Full_Type_Declaration
, Stloc
);
629 Set_Is_Frozen
(Standard_Entity
(S
));
630 Set_Is_Public
(Standard_Entity
(S
));
631 Set_Defining_Identifier
(Decl
, Standard_Entity
(S
));
632 Append
(Decl
, Decl_S
);
635 Create_Back_End_Float_Types
;
637 -- Create type definition node for type Boolean. The Size is set to
638 -- 1 as required by Ada 95 and current ARG interpretations for Ada/83.
640 -- Note: Object_Size of Boolean is 8. This means that we do NOT in
641 -- general know that Boolean variables have valid values, so we do
642 -- not set the Is_Known_Valid flag.
644 Tdef_Node
:= New_Node
(N_Enumeration_Type_Definition
, Stloc
);
645 Set_Literals
(Tdef_Node
, New_List
);
646 Append
(Standard_False
, Literals
(Tdef_Node
));
647 Append
(Standard_True
, Literals
(Tdef_Node
));
648 Set_Type_Definition
(Parent
(Standard_Boolean
), Tdef_Node
);
650 Set_Ekind
(Standard_Boolean
, E_Enumeration_Type
);
651 Set_First_Literal
(Standard_Boolean
, Standard_False
);
652 Set_Etype
(Standard_Boolean
, Standard_Boolean
);
653 Init_Esize
(Standard_Boolean
, Standard_Character_Size
);
654 Init_RM_Size
(Standard_Boolean
, 1);
655 Set_Elem_Alignment
(Standard_Boolean
);
657 Set_Is_Unsigned_Type
(Standard_Boolean
);
658 Set_Size_Known_At_Compile_Time
(Standard_Boolean
);
659 Set_Has_Pragma_Ordered
(Standard_Boolean
);
661 Set_Ekind
(Standard_True
, E_Enumeration_Literal
);
662 Set_Etype
(Standard_True
, Standard_Boolean
);
663 Set_Enumeration_Pos
(Standard_True
, Uint_1
);
664 Set_Enumeration_Rep
(Standard_True
, Uint_1
);
665 Set_Is_Known_Valid
(Standard_True
, True);
667 Set_Ekind
(Standard_False
, E_Enumeration_Literal
);
668 Set_Etype
(Standard_False
, Standard_Boolean
);
669 Set_Enumeration_Pos
(Standard_False
, Uint_0
);
670 Set_Enumeration_Rep
(Standard_False
, Uint_0
);
671 Set_Is_Known_Valid
(Standard_False
, True);
673 -- For the bounds of Boolean, we create a range node corresponding to
675 -- range False .. True
677 -- where the occurrences of the literals must point to the
678 -- corresponding definition.
680 R_Node
:= New_Node
(N_Range
, Stloc
);
681 B_Node
:= New_Node
(N_Identifier
, Stloc
);
682 Set_Chars
(B_Node
, Chars
(Standard_False
));
683 Set_Entity
(B_Node
, Standard_False
);
684 Set_Etype
(B_Node
, Standard_Boolean
);
685 Set_Is_Static_Expression
(B_Node
);
686 Set_Low_Bound
(R_Node
, B_Node
);
688 B_Node
:= New_Node
(N_Identifier
, Stloc
);
689 Set_Chars
(B_Node
, Chars
(Standard_True
));
690 Set_Entity
(B_Node
, Standard_True
);
691 Set_Etype
(B_Node
, Standard_Boolean
);
692 Set_Is_Static_Expression
(B_Node
);
693 Set_High_Bound
(R_Node
, B_Node
);
695 Set_Scalar_Range
(Standard_Boolean
, R_Node
);
696 Set_Etype
(R_Node
, Standard_Boolean
);
697 Set_Parent
(R_Node
, Standard_Boolean
);
699 -- Record entity identifiers for boolean literals in the
700 -- Boolean_Literals array, for easy reference during expansion.
702 Boolean_Literals
:= (False => Standard_False
, True => Standard_True
);
704 -- Create type definition nodes for predefined integer types
706 Build_Signed_Integer_Type
707 (Standard_Short_Short_Integer
, Standard_Short_Short_Integer_Size
);
709 Build_Signed_Integer_Type
710 (Standard_Short_Integer
, Standard_Short_Integer_Size
);
712 Build_Signed_Integer_Type
713 (Standard_Integer
, Standard_Integer_Size
);
721 LIS
:= Standard_Long_Integer_Size
;
724 Build_Signed_Integer_Type
(Standard_Long_Integer
, LIS
);
727 Build_Signed_Integer_Type
728 (Standard_Long_Long_Integer
, Standard_Long_Long_Integer_Size
);
729 Set_Is_Implementation_Defined
(Standard_Long_Long_Integer
);
731 Create_Unconstrained_Base_Type
732 (Standard_Short_Short_Integer
, E_Signed_Integer_Subtype
);
733 Set_Is_Implementation_Defined
(Standard_Short_Short_Integer
);
735 Create_Unconstrained_Base_Type
736 (Standard_Short_Integer
, E_Signed_Integer_Subtype
);
738 Create_Unconstrained_Base_Type
739 (Standard_Integer
, E_Signed_Integer_Subtype
);
741 Create_Unconstrained_Base_Type
742 (Standard_Long_Integer
, E_Signed_Integer_Subtype
);
744 Create_Unconstrained_Base_Type
745 (Standard_Long_Long_Integer
, E_Signed_Integer_Subtype
);
746 Set_Is_Implementation_Defined
(Standard_Short_Short_Integer
);
750 -- Create type definition node for type Character. Note that we do not
751 -- set the Literals field, since type Character is handled with special
752 -- routine that do not need a literal list.
754 Tdef_Node
:= New_Node
(N_Enumeration_Type_Definition
, Stloc
);
755 Set_Type_Definition
(Parent
(Standard_Character
), Tdef_Node
);
757 Set_Ekind
(Standard_Character
, E_Enumeration_Type
);
758 Set_Etype
(Standard_Character
, Standard_Character
);
759 Init_Esize
(Standard_Character
, Standard_Character_Size
);
760 Init_RM_Size
(Standard_Character
, 8);
761 Set_Elem_Alignment
(Standard_Character
);
763 Set_Has_Pragma_Ordered
(Standard_Character
);
764 Set_Is_Unsigned_Type
(Standard_Character
);
765 Set_Is_Character_Type
(Standard_Character
);
766 Set_Is_Known_Valid
(Standard_Character
);
767 Set_Size_Known_At_Compile_Time
(Standard_Character
);
769 -- Create the bounds for type Character
771 R_Node
:= New_Node
(N_Range
, Stloc
);
773 -- Low bound for type Character (Standard.Nul)
775 B_Node
:= New_Node
(N_Character_Literal
, Stloc
);
776 Set_Is_Static_Expression
(B_Node
);
777 Set_Chars
(B_Node
, No_Name
);
778 Set_Char_Literal_Value
(B_Node
, Uint_0
);
779 Set_Entity
(B_Node
, Empty
);
780 Set_Etype
(B_Node
, Standard_Character
);
781 Set_Low_Bound
(R_Node
, B_Node
);
783 -- High bound for type Character
785 B_Node
:= New_Node
(N_Character_Literal
, Stloc
);
786 Set_Is_Static_Expression
(B_Node
);
787 Set_Chars
(B_Node
, No_Name
);
788 Set_Char_Literal_Value
(B_Node
, UI_From_Int
(16#FF#
));
789 Set_Entity
(B_Node
, Empty
);
790 Set_Etype
(B_Node
, Standard_Character
);
791 Set_High_Bound
(R_Node
, B_Node
);
793 Set_Scalar_Range
(Standard_Character
, R_Node
);
794 Set_Etype
(R_Node
, Standard_Character
);
795 Set_Parent
(R_Node
, Standard_Character
);
797 -- Create type definition for type Wide_Character. Note that we do not
798 -- set the Literals field, since type Wide_Character is handled with
799 -- special routines that do not need a literal list.
801 Tdef_Node
:= New_Node
(N_Enumeration_Type_Definition
, Stloc
);
802 Set_Type_Definition
(Parent
(Standard_Wide_Character
), Tdef_Node
);
804 Set_Ekind
(Standard_Wide_Character
, E_Enumeration_Type
);
805 Set_Etype
(Standard_Wide_Character
, Standard_Wide_Character
);
806 Init_Size
(Standard_Wide_Character
, Standard_Wide_Character_Size
);
808 Set_Elem_Alignment
(Standard_Wide_Character
);
809 Set_Has_Pragma_Ordered
(Standard_Wide_Character
);
810 Set_Is_Unsigned_Type
(Standard_Wide_Character
);
811 Set_Is_Character_Type
(Standard_Wide_Character
);
812 Set_Is_Known_Valid
(Standard_Wide_Character
);
813 Set_Size_Known_At_Compile_Time
(Standard_Wide_Character
);
815 -- Create the bounds for type Wide_Character
817 R_Node
:= New_Node
(N_Range
, Stloc
);
819 -- Low bound for type Wide_Character
821 B_Node
:= New_Node
(N_Character_Literal
, Stloc
);
822 Set_Is_Static_Expression
(B_Node
);
823 Set_Chars
(B_Node
, No_Name
); -- ???
824 Set_Char_Literal_Value
(B_Node
, Uint_0
);
825 Set_Entity
(B_Node
, Empty
);
826 Set_Etype
(B_Node
, Standard_Wide_Character
);
827 Set_Low_Bound
(R_Node
, B_Node
);
829 -- High bound for type Wide_Character
831 B_Node
:= New_Node
(N_Character_Literal
, Stloc
);
832 Set_Is_Static_Expression
(B_Node
);
833 Set_Chars
(B_Node
, No_Name
); -- ???
834 Set_Char_Literal_Value
(B_Node
, UI_From_Int
(16#FFFF#
));
835 Set_Entity
(B_Node
, Empty
);
836 Set_Etype
(B_Node
, Standard_Wide_Character
);
837 Set_High_Bound
(R_Node
, B_Node
);
839 Set_Scalar_Range
(Standard_Wide_Character
, R_Node
);
840 Set_Etype
(R_Node
, Standard_Wide_Character
);
841 Set_Parent
(R_Node
, Standard_Wide_Character
);
843 -- Create type definition for type Wide_Wide_Character. Note that we
844 -- do not set the Literals field, since type Wide_Wide_Character is
845 -- handled with special routines that do not need a literal list.
847 Tdef_Node
:= New_Node
(N_Enumeration_Type_Definition
, Stloc
);
848 Set_Type_Definition
(Parent
(Standard_Wide_Wide_Character
), Tdef_Node
);
850 Set_Ekind
(Standard_Wide_Wide_Character
, E_Enumeration_Type
);
851 Set_Etype
(Standard_Wide_Wide_Character
,
852 Standard_Wide_Wide_Character
);
853 Init_Size
(Standard_Wide_Wide_Character
,
854 Standard_Wide_Wide_Character_Size
);
856 Set_Elem_Alignment
(Standard_Wide_Wide_Character
);
857 Set_Has_Pragma_Ordered
(Standard_Wide_Wide_Character
);
858 Set_Is_Unsigned_Type
(Standard_Wide_Wide_Character
);
859 Set_Is_Character_Type
(Standard_Wide_Wide_Character
);
860 Set_Is_Known_Valid
(Standard_Wide_Wide_Character
);
861 Set_Size_Known_At_Compile_Time
(Standard_Wide_Wide_Character
);
862 Set_Is_Ada_2005_Only
(Standard_Wide_Wide_Character
);
864 -- Create the bounds for type Wide_Wide_Character
866 R_Node
:= New_Node
(N_Range
, Stloc
);
868 -- Low bound for type Wide_Wide_Character
870 B_Node
:= New_Node
(N_Character_Literal
, Stloc
);
871 Set_Is_Static_Expression
(B_Node
);
872 Set_Chars
(B_Node
, No_Name
); -- ???
873 Set_Char_Literal_Value
(B_Node
, Uint_0
);
874 Set_Entity
(B_Node
, Empty
);
875 Set_Etype
(B_Node
, Standard_Wide_Wide_Character
);
876 Set_Low_Bound
(R_Node
, B_Node
);
878 -- High bound for type Wide_Wide_Character
880 B_Node
:= New_Node
(N_Character_Literal
, Stloc
);
881 Set_Is_Static_Expression
(B_Node
);
882 Set_Chars
(B_Node
, No_Name
); -- ???
883 Set_Char_Literal_Value
(B_Node
, UI_From_Int
(16#
7FFF_FFFF#
));
884 Set_Entity
(B_Node
, Empty
);
885 Set_Etype
(B_Node
, Standard_Wide_Wide_Character
);
886 Set_High_Bound
(R_Node
, B_Node
);
888 Set_Scalar_Range
(Standard_Wide_Wide_Character
, R_Node
);
889 Set_Etype
(R_Node
, Standard_Wide_Wide_Character
);
890 Set_Parent
(R_Node
, Standard_Wide_Wide_Character
);
892 -- Create type definition node for type String
894 Tdef_Node
:= New_Node
(N_Unconstrained_Array_Definition
, Stloc
);
897 CompDef_Node
: Node_Id
;
899 CompDef_Node
:= New_Node
(N_Component_Definition
, Stloc
);
900 Set_Aliased_Present
(CompDef_Node
, False);
901 Set_Access_Definition
(CompDef_Node
, Empty
);
902 Set_Subtype_Indication
(CompDef_Node
, Identifier_For
(S_Character
));
903 Set_Component_Definition
(Tdef_Node
, CompDef_Node
);
906 Set_Subtype_Marks
(Tdef_Node
, New_List
);
907 Append
(Identifier_For
(S_Positive
), Subtype_Marks
(Tdef_Node
));
908 Set_Type_Definition
(Parent
(Standard_String
), Tdef_Node
);
910 Set_Ekind
(Standard_String
, E_String_Type
);
911 Set_Etype
(Standard_String
, Standard_String
);
912 Set_Component_Type
(Standard_String
, Standard_Character
);
913 Set_Component_Size
(Standard_String
, Uint_8
);
914 Init_Size_Align
(Standard_String
);
915 Set_Alignment
(Standard_String
, Uint_1
);
916 Pack_String_Type
(Standard_String
);
918 -- On targets where a storage unit is larger than a byte (such as AAMP),
919 -- pragma Pack has a real effect on the representation of type String,
920 -- and the type must be marked as having a nonstandard representation.
922 if System_Storage_Unit
> Uint_8
then
923 Set_Has_Non_Standard_Rep
(Standard_String
);
924 Set_Has_Pragma_Pack
(Standard_String
);
927 -- Set index type of String
930 (Subtype_Marks
(Type_Definition
(Parent
(Standard_String
))));
931 Set_First_Index
(Standard_String
, E_Id
);
932 Set_Entity
(E_Id
, Standard_Positive
);
933 Set_Etype
(E_Id
, Standard_Positive
);
935 -- Create type definition node for type Wide_String
937 Tdef_Node
:= New_Node
(N_Unconstrained_Array_Definition
, Stloc
);
940 CompDef_Node
: Node_Id
;
942 CompDef_Node
:= New_Node
(N_Component_Definition
, Stloc
);
943 Set_Aliased_Present
(CompDef_Node
, False);
944 Set_Access_Definition
(CompDef_Node
, Empty
);
945 Set_Subtype_Indication
(CompDef_Node
,
946 Identifier_For
(S_Wide_Character
));
947 Set_Component_Definition
(Tdef_Node
, CompDef_Node
);
950 Set_Subtype_Marks
(Tdef_Node
, New_List
);
951 Append
(Identifier_For
(S_Positive
), Subtype_Marks
(Tdef_Node
));
952 Set_Type_Definition
(Parent
(Standard_Wide_String
), Tdef_Node
);
954 Set_Ekind
(Standard_Wide_String
, E_String_Type
);
955 Set_Etype
(Standard_Wide_String
, Standard_Wide_String
);
956 Set_Component_Type
(Standard_Wide_String
, Standard_Wide_Character
);
957 Set_Component_Size
(Standard_Wide_String
, Uint_16
);
958 Init_Size_Align
(Standard_Wide_String
);
959 Pack_String_Type
(Standard_Wide_String
);
961 -- Set index type of Wide_String
964 (Subtype_Marks
(Type_Definition
(Parent
(Standard_Wide_String
))));
965 Set_First_Index
(Standard_Wide_String
, E_Id
);
966 Set_Entity
(E_Id
, Standard_Positive
);
967 Set_Etype
(E_Id
, Standard_Positive
);
969 -- Create type definition node for type Wide_Wide_String
971 Tdef_Node
:= New_Node
(N_Unconstrained_Array_Definition
, Stloc
);
974 CompDef_Node
: Node_Id
;
976 CompDef_Node
:= New_Node
(N_Component_Definition
, Stloc
);
977 Set_Aliased_Present
(CompDef_Node
, False);
978 Set_Access_Definition
(CompDef_Node
, Empty
);
979 Set_Subtype_Indication
(CompDef_Node
,
980 Identifier_For
(S_Wide_Wide_Character
));
981 Set_Component_Definition
(Tdef_Node
, CompDef_Node
);
984 Set_Subtype_Marks
(Tdef_Node
, New_List
);
985 Append
(Identifier_For
(S_Positive
), Subtype_Marks
(Tdef_Node
));
986 Set_Type_Definition
(Parent
(Standard_Wide_Wide_String
), Tdef_Node
);
988 Set_Ekind
(Standard_Wide_Wide_String
, E_String_Type
);
989 Set_Etype
(Standard_Wide_Wide_String
,
990 Standard_Wide_Wide_String
);
991 Set_Component_Type
(Standard_Wide_Wide_String
,
992 Standard_Wide_Wide_Character
);
993 Set_Component_Size
(Standard_Wide_Wide_String
, Uint_32
);
994 Init_Size_Align
(Standard_Wide_Wide_String
);
995 Set_Is_Ada_2005_Only
(Standard_Wide_Wide_String
);
996 Pack_String_Type
(Standard_Wide_Wide_String
);
998 -- Set index type of Wide_Wide_String
1001 (Subtype_Marks
(Type_Definition
(Parent
(Standard_Wide_Wide_String
))));
1002 Set_First_Index
(Standard_Wide_Wide_String
, E_Id
);
1003 Set_Entity
(E_Id
, Standard_Positive
);
1004 Set_Etype
(E_Id
, Standard_Positive
);
1006 -- Setup entity for Natural
1008 Set_Ekind
(Standard_Natural
, E_Signed_Integer_Subtype
);
1009 Set_Etype
(Standard_Natural
, Base_Type
(Standard_Integer
));
1010 Init_Esize
(Standard_Natural
, Standard_Integer_Size
);
1011 Init_RM_Size
(Standard_Natural
, Standard_Integer_Size
- 1);
1012 Set_Elem_Alignment
(Standard_Natural
);
1013 Set_Size_Known_At_Compile_Time
1015 Set_Integer_Bounds
(Standard_Natural
,
1016 Typ
=> Base_Type
(Standard_Integer
),
1018 Hb
=> Intval
(High_Bound
(Scalar_Range
(Standard_Integer
))));
1019 Set_Is_Constrained
(Standard_Natural
);
1021 -- Setup entity for Positive
1023 Set_Ekind
(Standard_Positive
, E_Signed_Integer_Subtype
);
1024 Set_Etype
(Standard_Positive
, Base_Type
(Standard_Integer
));
1025 Init_Esize
(Standard_Positive
, Standard_Integer_Size
);
1026 Init_RM_Size
(Standard_Positive
, Standard_Integer_Size
- 1);
1027 Set_Elem_Alignment
(Standard_Positive
);
1029 Set_Size_Known_At_Compile_Time
(Standard_Positive
);
1031 Set_Integer_Bounds
(Standard_Positive
,
1032 Typ
=> Base_Type
(Standard_Integer
),
1034 Hb
=> Intval
(High_Bound
(Scalar_Range
(Standard_Integer
))));
1035 Set_Is_Constrained
(Standard_Positive
);
1037 -- Create declaration for package ASCII
1039 Decl
:= New_Node
(N_Package_Declaration
, Stloc
);
1040 Append
(Decl
, Decl_S
);
1042 Pspec
:= New_Node
(N_Package_Specification
, Stloc
);
1043 Set_Specification
(Decl
, Pspec
);
1045 Set_Defining_Unit_Name
(Pspec
, Standard_Entity
(S_ASCII
));
1046 Set_Ekind
(Standard_Entity
(S_ASCII
), E_Package
);
1047 Set_Visible_Declarations
(Pspec
, Decl_A
);
1049 -- Create control character definitions in package ASCII. Note that
1050 -- the character literal entries created here correspond to literal
1051 -- values that are impossible in the source, but can be represented
1052 -- internally with no difficulties.
1056 for S
in S_ASCII_Names
loop
1057 Decl
:= New_Node
(N_Object_Declaration
, Staloc
);
1058 Set_Constant_Present
(Decl
, True);
1061 A_Char
: constant Entity_Id
:= Standard_Entity
(S
);
1062 Expr_Decl
: Node_Id
;
1065 Set_Sloc
(A_Char
, Staloc
);
1066 Set_Ekind
(A_Char
, E_Constant
);
1067 Set_Never_Set_In_Source
(A_Char
, True);
1068 Set_Is_True_Constant
(A_Char
, True);
1069 Set_Etype
(A_Char
, Standard_Character
);
1070 Set_Scope
(A_Char
, Standard_Entity
(S_ASCII
));
1071 Set_Is_Immediately_Visible
(A_Char
, False);
1072 Set_Is_Public
(A_Char
, True);
1073 Set_Is_Known_Valid
(A_Char
, True);
1075 Append_Entity
(A_Char
, Standard_Entity
(S_ASCII
));
1076 Set_Defining_Identifier
(Decl
, A_Char
);
1078 Set_Object_Definition
(Decl
, Identifier_For
(S_Character
));
1079 Expr_Decl
:= New_Node
(N_Character_Literal
, Staloc
);
1080 Set_Expression
(Decl
, Expr_Decl
);
1082 Set_Is_Static_Expression
(Expr_Decl
);
1083 Set_Chars
(Expr_Decl
, No_Name
);
1084 Set_Etype
(Expr_Decl
, Standard_Character
);
1085 Set_Char_Literal_Value
(Expr_Decl
, UI_From_Int
(Int
(Ccode
)));
1088 Append
(Decl
, Decl_A
);
1090 -- Increment character code, dealing with non-contiguities
1094 if Ccode
= 16#
20#
then
1096 elsif Ccode
= 16#
27#
then
1098 elsif Ccode
= 16#
3C#
then
1100 elsif Ccode
= 16#
41#
then
1105 -- Create semantic phase entities
1107 Standard_Void_Type
:= New_Standard_Entity
;
1108 Set_Ekind
(Standard_Void_Type
, E_Void
);
1109 Set_Etype
(Standard_Void_Type
, Standard_Void_Type
);
1110 Set_Scope
(Standard_Void_Type
, Standard_Standard
);
1111 Make_Name
(Standard_Void_Type
, "_void_type");
1113 -- The type field of packages is set to void
1115 Set_Etype
(Standard_Standard
, Standard_Void_Type
);
1116 Set_Etype
(Standard_ASCII
, Standard_Void_Type
);
1118 -- Standard_A_String is actually used in generated code, so it has a
1119 -- type name that is reasonable, but does not overlap any Ada name.
1121 Standard_A_String
:= New_Standard_Entity
;
1122 Set_Ekind
(Standard_A_String
, E_Access_Type
);
1123 Set_Scope
(Standard_A_String
, Standard_Standard
);
1124 Set_Etype
(Standard_A_String
, Standard_A_String
);
1126 if Debug_Flag_6
then
1127 Init_Size
(Standard_A_String
, System_Address_Size
);
1129 Init_Size
(Standard_A_String
, System_Address_Size
* 2);
1132 Init_Alignment
(Standard_A_String
);
1134 Set_Directly_Designated_Type
1135 (Standard_A_String
, Standard_String
);
1136 Make_Name
(Standard_A_String
, "access_string");
1138 Standard_A_Char
:= New_Standard_Entity
;
1139 Set_Ekind
(Standard_A_Char
, E_Access_Type
);
1140 Set_Scope
(Standard_A_Char
, Standard_Standard
);
1141 Set_Etype
(Standard_A_Char
, Standard_A_String
);
1142 Init_Size
(Standard_A_Char
, System_Address_Size
);
1143 Set_Elem_Alignment
(Standard_A_Char
);
1145 Set_Directly_Designated_Type
(Standard_A_Char
, Standard_Character
);
1146 Make_Name
(Standard_A_Char
, "access_character");
1148 -- Standard_Debug_Renaming_Type is used for the special objects created
1149 -- to encode the names occurring in renaming declarations for use by the
1150 -- debugger (see exp_dbug.adb). The type is a zero-sized subtype of
1151 -- Standard.Integer.
1153 Standard_Debug_Renaming_Type
:= New_Standard_Entity
;
1155 Set_Ekind
(Standard_Debug_Renaming_Type
, E_Signed_Integer_Subtype
);
1156 Set_Scope
(Standard_Debug_Renaming_Type
, Standard_Standard
);
1157 Set_Etype
(Standard_Debug_Renaming_Type
, Base_Type
(Standard_Integer
));
1158 Init_Esize
(Standard_Debug_Renaming_Type
, 0);
1159 Init_RM_Size
(Standard_Debug_Renaming_Type
, 0);
1160 Set_Size_Known_At_Compile_Time
(Standard_Debug_Renaming_Type
);
1161 Set_Integer_Bounds
(Standard_Debug_Renaming_Type
,
1162 Typ
=> Base_Type
(Standard_Debug_Renaming_Type
),
1165 Set_Is_Constrained
(Standard_Debug_Renaming_Type
);
1166 Set_Has_Size_Clause
(Standard_Debug_Renaming_Type
);
1168 Make_Name
(Standard_Debug_Renaming_Type
, "_renaming_type");
1170 -- Note on type names. The type names for the following special types
1171 -- are constructed so that they will look reasonable should they ever
1172 -- appear in error messages etc, although in practice the use of the
1173 -- special insertion character } for types results in special handling
1174 -- of these type names in any case. The blanks in these names would
1175 -- trouble in Gigi, but that's OK here, since none of these types
1176 -- should ever get through to Gigi. Attributes of these types are
1177 -- filled out to minimize problems with cascaded errors (for example,
1178 -- Any_Integer is given reasonable and consistent type and size values)
1180 Any_Type
:= New_Standard_Entity
;
1181 Decl
:= New_Node
(N_Full_Type_Declaration
, Stloc
);
1182 Set_Defining_Identifier
(Decl
, Any_Type
);
1183 Set_Scope
(Any_Type
, Standard_Standard
);
1184 Build_Signed_Integer_Type
(Any_Type
, Standard_Integer_Size
);
1185 Make_Name
(Any_Type
, "any type");
1187 Any_Id
:= New_Standard_Entity
;
1188 Set_Ekind
(Any_Id
, E_Variable
);
1189 Set_Scope
(Any_Id
, Standard_Standard
);
1190 Set_Etype
(Any_Id
, Any_Type
);
1191 Init_Esize
(Any_Id
);
1192 Init_Alignment
(Any_Id
);
1193 Make_Name
(Any_Id
, "any id");
1195 Any_Access
:= New_Standard_Entity
;
1196 Set_Ekind
(Any_Access
, E_Access_Type
);
1197 Set_Scope
(Any_Access
, Standard_Standard
);
1198 Set_Etype
(Any_Access
, Any_Access
);
1199 Init_Size
(Any_Access
, System_Address_Size
);
1200 Set_Elem_Alignment
(Any_Access
);
1201 Make_Name
(Any_Access
, "an access type");
1203 Any_Character
:= New_Standard_Entity
;
1204 Set_Ekind
(Any_Character
, E_Enumeration_Type
);
1205 Set_Scope
(Any_Character
, Standard_Standard
);
1206 Set_Etype
(Any_Character
, Any_Character
);
1207 Set_Is_Unsigned_Type
(Any_Character
);
1208 Set_Is_Character_Type
(Any_Character
);
1209 Init_Esize
(Any_Character
, Standard_Character_Size
);
1210 Init_RM_Size
(Any_Character
, 8);
1211 Set_Elem_Alignment
(Any_Character
);
1212 Set_Scalar_Range
(Any_Character
, Scalar_Range
(Standard_Character
));
1213 Make_Name
(Any_Character
, "a character type");
1215 Any_Array
:= New_Standard_Entity
;
1216 Set_Ekind
(Any_Array
, E_String_Type
);
1217 Set_Scope
(Any_Array
, Standard_Standard
);
1218 Set_Etype
(Any_Array
, Any_Array
);
1219 Set_Component_Type
(Any_Array
, Any_Character
);
1220 Init_Size_Align
(Any_Array
);
1221 Make_Name
(Any_Array
, "an array type");
1223 Any_Boolean
:= New_Standard_Entity
;
1224 Set_Ekind
(Any_Boolean
, E_Enumeration_Type
);
1225 Set_Scope
(Any_Boolean
, Standard_Standard
);
1226 Set_Etype
(Any_Boolean
, Standard_Boolean
);
1227 Init_Esize
(Any_Boolean
, Standard_Character_Size
);
1228 Init_RM_Size
(Any_Boolean
, 1);
1229 Set_Elem_Alignment
(Any_Boolean
);
1230 Set_Is_Unsigned_Type
(Any_Boolean
);
1231 Set_Scalar_Range
(Any_Boolean
, Scalar_Range
(Standard_Boolean
));
1232 Make_Name
(Any_Boolean
, "a boolean type");
1234 Any_Composite
:= New_Standard_Entity
;
1235 Set_Ekind
(Any_Composite
, E_Array_Type
);
1236 Set_Scope
(Any_Composite
, Standard_Standard
);
1237 Set_Etype
(Any_Composite
, Any_Composite
);
1238 Set_Component_Size
(Any_Composite
, Uint_0
);
1239 Set_Component_Type
(Any_Composite
, Standard_Integer
);
1240 Init_Size_Align
(Any_Composite
);
1241 Make_Name
(Any_Composite
, "a composite type");
1243 Any_Discrete
:= New_Standard_Entity
;
1244 Set_Ekind
(Any_Discrete
, E_Signed_Integer_Type
);
1245 Set_Scope
(Any_Discrete
, Standard_Standard
);
1246 Set_Etype
(Any_Discrete
, Any_Discrete
);
1247 Init_Size
(Any_Discrete
, Standard_Integer_Size
);
1248 Set_Elem_Alignment
(Any_Discrete
);
1249 Make_Name
(Any_Discrete
, "a discrete type");
1251 Any_Fixed
:= New_Standard_Entity
;
1252 Set_Ekind
(Any_Fixed
, E_Ordinary_Fixed_Point_Type
);
1253 Set_Scope
(Any_Fixed
, Standard_Standard
);
1254 Set_Etype
(Any_Fixed
, Any_Fixed
);
1255 Init_Size
(Any_Fixed
, Standard_Integer_Size
);
1256 Set_Elem_Alignment
(Any_Fixed
);
1257 Make_Name
(Any_Fixed
, "a fixed-point type");
1259 Any_Integer
:= New_Standard_Entity
;
1260 Set_Ekind
(Any_Integer
, E_Signed_Integer_Type
);
1261 Set_Scope
(Any_Integer
, Standard_Standard
);
1262 Set_Etype
(Any_Integer
, Standard_Long_Long_Integer
);
1263 Init_Size
(Any_Integer
, Standard_Long_Long_Integer_Size
);
1264 Set_Elem_Alignment
(Any_Integer
);
1268 Typ
=> Base_Type
(Standard_Integer
),
1270 Hb
=> Intval
(High_Bound
(Scalar_Range
(Standard_Integer
))));
1271 Make_Name
(Any_Integer
, "an integer type");
1273 Any_Modular
:= New_Standard_Entity
;
1274 Set_Ekind
(Any_Modular
, E_Modular_Integer_Type
);
1275 Set_Scope
(Any_Modular
, Standard_Standard
);
1276 Set_Etype
(Any_Modular
, Standard_Long_Long_Integer
);
1277 Init_Size
(Any_Modular
, Standard_Long_Long_Integer_Size
);
1278 Set_Elem_Alignment
(Any_Modular
);
1279 Set_Is_Unsigned_Type
(Any_Modular
);
1280 Make_Name
(Any_Modular
, "a modular type");
1282 Any_Numeric
:= New_Standard_Entity
;
1283 Set_Ekind
(Any_Numeric
, E_Signed_Integer_Type
);
1284 Set_Scope
(Any_Numeric
, Standard_Standard
);
1285 Set_Etype
(Any_Numeric
, Standard_Long_Long_Integer
);
1286 Init_Size
(Any_Numeric
, Standard_Long_Long_Integer_Size
);
1287 Set_Elem_Alignment
(Any_Numeric
);
1288 Make_Name
(Any_Numeric
, "a numeric type");
1290 Any_Real
:= New_Standard_Entity
;
1291 Set_Ekind
(Any_Real
, E_Floating_Point_Type
);
1292 Set_Scope
(Any_Real
, Standard_Standard
);
1293 Set_Etype
(Any_Real
, Standard_Long_Long_Float
);
1294 Init_Size
(Any_Real
,
1295 UI_To_Int
(Esize
(Standard_Long_Long_Float
)));
1296 Set_Elem_Alignment
(Any_Real
);
1297 Make_Name
(Any_Real
, "a real type");
1299 Any_Scalar
:= New_Standard_Entity
;
1300 Set_Ekind
(Any_Scalar
, E_Signed_Integer_Type
);
1301 Set_Scope
(Any_Scalar
, Standard_Standard
);
1302 Set_Etype
(Any_Scalar
, Any_Scalar
);
1303 Init_Size
(Any_Scalar
, Standard_Integer_Size
);
1304 Set_Elem_Alignment
(Any_Scalar
);
1305 Make_Name
(Any_Scalar
, "a scalar type");
1307 Any_String
:= New_Standard_Entity
;
1308 Set_Ekind
(Any_String
, E_String_Type
);
1309 Set_Scope
(Any_String
, Standard_Standard
);
1310 Set_Etype
(Any_String
, Any_String
);
1311 Set_Component_Type
(Any_String
, Any_Character
);
1312 Init_Size_Align
(Any_String
);
1313 Make_Name
(Any_String
, "a string type");
1321 Low_Bound
=> Make_Integer
(Uint_0
),
1322 High_Bound
=> Make_Integer
(Uint_2
** Standard_Integer_Size
));
1323 Set_Etype
(Index
, Standard_Integer
);
1324 Set_First_Index
(Any_String
, Index
);
1327 Raise_Type
:= New_Standard_Entity
;
1328 Decl
:= New_Node
(N_Full_Type_Declaration
, Stloc
);
1329 Set_Defining_Identifier
(Decl
, Raise_Type
);
1330 Set_Scope
(Raise_Type
, Standard_Standard
);
1331 Build_Signed_Integer_Type
(Raise_Type
, Standard_Integer_Size
);
1332 Make_Name
(Raise_Type
, "any type");
1334 Standard_Integer_8
:= New_Standard_Entity
;
1335 Decl
:= New_Node
(N_Full_Type_Declaration
, Stloc
);
1336 Set_Defining_Identifier
(Decl
, Standard_Integer_8
);
1337 Make_Name
(Standard_Integer_8
, "integer_8");
1338 Set_Scope
(Standard_Integer_8
, Standard_Standard
);
1339 Build_Signed_Integer_Type
(Standard_Integer_8
, 8);
1341 Standard_Integer_16
:= New_Standard_Entity
;
1342 Decl
:= New_Node
(N_Full_Type_Declaration
, Stloc
);
1343 Set_Defining_Identifier
(Decl
, Standard_Integer_16
);
1344 Make_Name
(Standard_Integer_16
, "integer_16");
1345 Set_Scope
(Standard_Integer_16
, Standard_Standard
);
1346 Build_Signed_Integer_Type
(Standard_Integer_16
, 16);
1348 Standard_Integer_32
:= New_Standard_Entity
;
1349 Decl
:= New_Node
(N_Full_Type_Declaration
, Stloc
);
1350 Set_Defining_Identifier
(Decl
, Standard_Integer_32
);
1351 Make_Name
(Standard_Integer_32
, "integer_32");
1352 Set_Scope
(Standard_Integer_32
, Standard_Standard
);
1353 Build_Signed_Integer_Type
(Standard_Integer_32
, 32);
1355 Standard_Integer_64
:= New_Standard_Entity
;
1356 Decl
:= New_Node
(N_Full_Type_Declaration
, Stloc
);
1357 Set_Defining_Identifier
(Decl
, Standard_Integer_64
);
1358 Make_Name
(Standard_Integer_64
, "integer_64");
1359 Set_Scope
(Standard_Integer_64
, Standard_Standard
);
1360 Build_Signed_Integer_Type
(Standard_Integer_64
, 64);
1362 -- Standard_*_Unsigned subtypes are not user visible, but they are
1363 -- used internally. They are unsigned types with the same length as
1364 -- the correspondingly named signed integer types.
1366 Standard_Short_Short_Unsigned
:= New_Standard_Entity
;
1367 Build_Unsigned_Integer_Type
1368 (Standard_Short_Short_Unsigned
,
1369 Standard_Short_Short_Integer_Size
,
1370 "short_short_unsigned");
1372 Standard_Short_Unsigned
:= New_Standard_Entity
;
1373 Build_Unsigned_Integer_Type
1374 (Standard_Short_Unsigned
,
1375 Standard_Short_Integer_Size
,
1378 Standard_Unsigned
:= New_Standard_Entity
;
1379 Build_Unsigned_Integer_Type
1381 Standard_Integer_Size
,
1384 Standard_Long_Unsigned
:= New_Standard_Entity
;
1385 Build_Unsigned_Integer_Type
1386 (Standard_Long_Unsigned
,
1387 Standard_Long_Integer_Size
,
1390 Standard_Long_Long_Unsigned
:= New_Standard_Entity
;
1391 Build_Unsigned_Integer_Type
1392 (Standard_Long_Long_Unsigned
,
1393 Standard_Long_Long_Integer_Size
,
1394 "long_long_unsigned");
1396 -- Standard_Unsigned_64 is not user visible, but is used internally. It
1397 -- is an unsigned type mod 2**64, 64-bits unsigned, size is 64.
1399 Standard_Unsigned_64
:= New_Standard_Entity
;
1400 Build_Unsigned_Integer_Type
(Standard_Unsigned_64
, 64, "unsigned_64");
1402 -- Note: universal integer and universal real are constructed as fully
1403 -- formed signed numeric types, with parameters corresponding to the
1404 -- longest runtime types (Long_Long_Integer and Long_Long_Float). This
1405 -- allows Gigi to properly process references to universal types that
1406 -- are not folded at compile time.
1408 Universal_Integer
:= New_Standard_Entity
;
1409 Decl
:= New_Node
(N_Full_Type_Declaration
, Stloc
);
1410 Set_Defining_Identifier
(Decl
, Universal_Integer
);
1411 Make_Name
(Universal_Integer
, "universal_integer");
1412 Set_Scope
(Universal_Integer
, Standard_Standard
);
1413 Build_Signed_Integer_Type
1414 (Universal_Integer
, Standard_Long_Long_Integer_Size
);
1416 Universal_Real
:= New_Standard_Entity
;
1417 Decl
:= New_Node
(N_Full_Type_Declaration
, Stloc
);
1418 Set_Defining_Identifier
(Decl
, Universal_Real
);
1419 Make_Name
(Universal_Real
, "universal_real");
1420 Set_Scope
(Universal_Real
, Standard_Standard
);
1421 Copy_Float_Type
(Universal_Real
, Standard_Long_Long_Float
);
1423 -- Note: universal fixed, unlike universal integer and universal real,
1424 -- is never used at runtime, so it does not need to have bounds set.
1426 Universal_Fixed
:= New_Standard_Entity
;
1427 Decl
:= New_Node
(N_Full_Type_Declaration
, Stloc
);
1428 Set_Defining_Identifier
(Decl
, Universal_Fixed
);
1429 Make_Name
(Universal_Fixed
, "universal_fixed");
1430 Set_Ekind
(Universal_Fixed
, E_Ordinary_Fixed_Point_Type
);
1431 Set_Etype
(Universal_Fixed
, Universal_Fixed
);
1432 Set_Scope
(Universal_Fixed
, Standard_Standard
);
1433 Init_Size
(Universal_Fixed
, Standard_Long_Long_Integer_Size
);
1434 Set_Elem_Alignment
(Universal_Fixed
);
1435 Set_Size_Known_At_Compile_Time
1438 -- Create type declaration for Duration, using a 64-bit size. The
1439 -- delta and size values depend on the mode set in system.ads.
1441 Build_Duration
: declare
1447 -- In 32 bit mode, the size is 32 bits, and the delta and
1448 -- small values are set to 20 milliseconds (20.0*(10.0**(-3)).
1450 if Duration_32_Bits_On_Target
then
1451 Dlo
:= Intval
(Type_Low_Bound
(Standard_Integer_32
));
1452 Dhi
:= Intval
(Type_High_Bound
(Standard_Integer_32
));
1453 Delta_Val
:= UR_From_Components
(UI_From_Int
(20), Uint_3
, 10);
1455 -- In standard 64-bit mode, the size is 64-bits and the delta and
1456 -- small values are set to nanoseconds (1.0*(10.0**(-9))
1459 Dlo
:= Intval
(Type_Low_Bound
(Standard_Integer_64
));
1460 Dhi
:= Intval
(Type_High_Bound
(Standard_Integer_64
));
1461 Delta_Val
:= UR_From_Components
(Uint_1
, Uint_9
, 10);
1464 Tdef_Node
:= Make_Ordinary_Fixed_Point_Definition
(Stloc
,
1465 Delta_Expression
=> Make_Real_Literal
(Stloc
, Delta_Val
),
1466 Real_Range_Specification
=>
1467 Make_Real_Range_Specification
(Stloc
,
1468 Low_Bound
=> Make_Real_Literal
(Stloc
,
1469 Realval
=> Dlo
* Delta_Val
),
1470 High_Bound
=> Make_Real_Literal
(Stloc
,
1471 Realval
=> Dhi
* Delta_Val
)));
1473 Set_Type_Definition
(Parent
(Standard_Duration
), Tdef_Node
);
1475 Set_Ekind
(Standard_Duration
, E_Ordinary_Fixed_Point_Type
);
1476 Set_Etype
(Standard_Duration
, Standard_Duration
);
1478 if Duration_32_Bits_On_Target
then
1479 Init_Size
(Standard_Duration
, 32);
1481 Init_Size
(Standard_Duration
, 64);
1484 Set_Elem_Alignment
(Standard_Duration
);
1485 Set_Delta_Value
(Standard_Duration
, Delta_Val
);
1486 Set_Small_Value
(Standard_Duration
, Delta_Val
);
1487 Set_Scalar_Range
(Standard_Duration
,
1488 Real_Range_Specification
1489 (Type_Definition
(Parent
(Standard_Duration
))));
1491 -- Normally it does not matter that nodes in package Standard are
1492 -- not marked as analyzed. The Scalar_Range of the fixed-point type
1493 -- Standard_Duration is an exception, because of the special test
1494 -- made in Freeze.Freeze_Fixed_Point_Type.
1496 Set_Analyzed
(Scalar_Range
(Standard_Duration
));
1498 Set_Etype
(Type_High_Bound
(Standard_Duration
), Standard_Duration
);
1499 Set_Etype
(Type_Low_Bound
(Standard_Duration
), Standard_Duration
);
1501 Set_Is_Static_Expression
(Type_High_Bound
(Standard_Duration
));
1502 Set_Is_Static_Expression
(Type_Low_Bound
(Standard_Duration
));
1504 Set_Corresponding_Integer_Value
1505 (Type_High_Bound
(Standard_Duration
), Dhi
);
1507 Set_Corresponding_Integer_Value
1508 (Type_Low_Bound
(Standard_Duration
), Dlo
);
1510 Set_Size_Known_At_Compile_Time
(Standard_Duration
);
1513 -- Build standard exception type. Note that the type name here is
1514 -- actually used in the generated code, so it must be set correctly.
1515 -- The type Standard_Exception_Type must be consistent with the type
1516 -- System.Standard_Library.Exception_Data, as the latter is what is
1517 -- known by the run-time. Components of the record are documented in
1518 -- the declaration in System.Standard_Library.
1520 Standard_Exception_Type
:= New_Standard_Entity
;
1521 Set_Ekind
(Standard_Exception_Type
, E_Record_Type
);
1522 Set_Etype
(Standard_Exception_Type
, Standard_Exception_Type
);
1523 Set_Scope
(Standard_Exception_Type
, Standard_Standard
);
1524 Set_Stored_Constraint
1525 (Standard_Exception_Type
, No_Elist
);
1526 Init_Size_Align
(Standard_Exception_Type
);
1527 Set_Size_Known_At_Compile_Time
1528 (Standard_Exception_Type
, True);
1529 Make_Name
(Standard_Exception_Type
, "exception");
1532 (Standard_Exception_Type
, Standard_Boolean
, "Not_Handled_By_Others");
1534 (Standard_Exception_Type
, Standard_Character
, "Lang");
1536 (Standard_Exception_Type
, Standard_Natural
, "Name_Length");
1538 (Standard_Exception_Type
, Standard_A_Char
, "Full_Name");
1540 (Standard_Exception_Type
, Standard_A_Char
, "HTable_Ptr");
1542 (Standard_Exception_Type
, Standard_A_Char
, "Foreign_Data");
1544 (Standard_Exception_Type
, Standard_A_Char
, "Raise_Hook");
1546 -- Build tree for record declaration, for use by the back-end
1549 Comp_List
: List_Id
;
1553 Comp
:= First_Entity
(Standard_Exception_Type
);
1554 Comp_List
:= New_List
;
1555 while Present
(Comp
) loop
1557 Make_Component_Declaration
(Stloc
,
1558 Defining_Identifier
=> Comp
,
1559 Component_Definition
=>
1560 Make_Component_Definition
(Stloc
,
1561 Aliased_Present
=> False,
1562 Subtype_Indication
=> New_Occurrence_Of
(Etype
(Comp
),
1569 Decl
:= Make_Full_Type_Declaration
(Stloc
,
1570 Defining_Identifier
=> Standard_Exception_Type
,
1572 Make_Record_Definition
(Stloc
,
1575 Make_Component_List
(Stloc
,
1576 Component_Items
=> Comp_List
)));
1579 Append
(Decl
, Decl_S
);
1581 Layout_Type
(Standard_Exception_Type
);
1583 -- Create declarations of standard exceptions
1585 Build_Exception
(S_Constraint_Error
);
1586 Build_Exception
(S_Program_Error
);
1587 Build_Exception
(S_Storage_Error
);
1588 Build_Exception
(S_Tasking_Error
);
1590 -- Numeric_Error is a normal exception in Ada 83, but in Ada 95
1591 -- it is a renaming of Constraint_Error. Is this test too early???
1593 if Ada_Version
= Ada_83
then
1594 Build_Exception
(S_Numeric_Error
);
1597 Decl
:= New_Node
(N_Exception_Renaming_Declaration
, Stloc
);
1598 E_Id
:= Standard_Entity
(S_Numeric_Error
);
1600 Set_Ekind
(E_Id
, E_Exception
);
1601 Set_Exception_Code
(E_Id
, Uint_0
);
1602 Set_Etype
(E_Id
, Standard_Exception_Type
);
1603 Set_Is_Public
(E_Id
);
1604 Set_Renamed_Entity
(E_Id
, Standard_Entity
(S_Constraint_Error
));
1606 Set_Defining_Identifier
(Decl
, E_Id
);
1607 Append
(Decl
, Decl_S
);
1609 Ident_Node
:= New_Node
(N_Identifier
, Stloc
);
1610 Set_Chars
(Ident_Node
, Chars
(Standard_Entity
(S_Constraint_Error
)));
1611 Set_Entity
(Ident_Node
, Standard_Entity
(S_Constraint_Error
));
1612 Set_Name
(Decl
, Ident_Node
);
1615 -- Abort_Signal is an entity that does not get made visible
1617 Abort_Signal
:= New_Standard_Entity
;
1618 Set_Chars
(Abort_Signal
, Name_uAbort_Signal
);
1619 Set_Ekind
(Abort_Signal
, E_Exception
);
1620 Set_Exception_Code
(Abort_Signal
, Uint_0
);
1621 Set_Etype
(Abort_Signal
, Standard_Exception_Type
);
1622 Set_Scope
(Abort_Signal
, Standard_Standard
);
1623 Set_Is_Public
(Abort_Signal
, True);
1625 Make_Exception_Declaration
(Stloc
,
1626 Defining_Identifier
=> Abort_Signal
);
1628 -- Create defining identifiers for shift operator entities. Note
1629 -- that these entities are used only for marking shift operators
1630 -- generated internally, and hence need no structure, just a name
1631 -- and a unique identity.
1633 Standard_Op_Rotate_Left
:= New_Standard_Entity
;
1634 Set_Chars
(Standard_Op_Rotate_Left
, Name_Rotate_Left
);
1635 Set_Ekind
(Standard_Op_Rotate_Left
, E_Operator
);
1637 Standard_Op_Rotate_Right
:= New_Standard_Entity
;
1638 Set_Chars
(Standard_Op_Rotate_Right
, Name_Rotate_Right
);
1639 Set_Ekind
(Standard_Op_Rotate_Right
, E_Operator
);
1641 Standard_Op_Shift_Left
:= New_Standard_Entity
;
1642 Set_Chars
(Standard_Op_Shift_Left
, Name_Shift_Left
);
1643 Set_Ekind
(Standard_Op_Shift_Left
, E_Operator
);
1645 Standard_Op_Shift_Right
:= New_Standard_Entity
;
1646 Set_Chars
(Standard_Op_Shift_Right
, Name_Shift_Right
);
1647 Set_Ekind
(Standard_Op_Shift_Right
, E_Operator
);
1649 Standard_Op_Shift_Right_Arithmetic
:= New_Standard_Entity
;
1650 Set_Chars
(Standard_Op_Shift_Right_Arithmetic
,
1651 Name_Shift_Right_Arithmetic
);
1652 Set_Ekind
(Standard_Op_Shift_Right_Arithmetic
,
1655 -- Create standard operator declarations
1659 -- Initialize visibility table with entities in Standard
1661 for E
in Standard_Entity_Type
loop
1662 if Ekind
(Standard_Entity
(E
)) /= E_Operator
then
1664 (Chars
(Standard_Entity
(E
)), Standard_Entity
(E
));
1665 Set_Homonym
(Standard_Entity
(E
), Empty
);
1668 if E
not in S_ASCII_Names
then
1669 Set_Scope
(Standard_Entity
(E
), Standard_Standard
);
1670 Set_Is_Immediately_Visible
(Standard_Entity
(E
));
1674 -- The predefined package Standard itself does not have a scope;
1675 -- it is the only entity in the system not to have one, and this
1676 -- is what identifies the package to Gigi.
1678 Set_Scope
(Standard_Standard
, Empty
);
1680 -- Set global variables indicating last Id values and version
1682 Last_Standard_Node_Id
:= Last_Node_Id
;
1683 Last_Standard_List_Id
:= Last_List_Id
;
1685 -- The Error node has an Etype of Any_Type to help error recovery
1687 Set_Etype
(Error
, Any_Type
);
1689 -- Print representation of standard if switch set
1691 if Opt
.Print_Standard
then
1694 end Create_Standard
;
1696 ------------------------------------
1697 -- Create_Unconstrained_Base_Type --
1698 ------------------------------------
1700 procedure Create_Unconstrained_Base_Type
1704 New_Ent
: constant Entity_Id
:= New_Copy
(E
);
1708 Set_Is_Constrained
(E
, True);
1709 Set_Is_First_Subtype
(E
, True);
1710 Set_Etype
(E
, New_Ent
);
1712 Append_Entity
(New_Ent
, Standard_Standard
);
1713 Set_Is_Constrained
(New_Ent
, False);
1714 Set_Etype
(New_Ent
, New_Ent
);
1715 Set_Is_Known_Valid
(New_Ent
, True);
1717 if K
= E_Signed_Integer_Subtype
then
1718 Set_Etype
(Low_Bound
(Scalar_Range
(E
)), New_Ent
);
1719 Set_Etype
(High_Bound
(Scalar_Range
(E
)), New_Ent
);
1722 end Create_Unconstrained_Base_Type
;
1724 --------------------
1725 -- Identifier_For --
1726 --------------------
1728 function Identifier_For
(S
: Standard_Entity_Type
) return Node_Id
is
1729 Ident_Node
: Node_Id
;
1731 Ident_Node
:= New_Node
(N_Identifier
, Stloc
);
1732 Set_Chars
(Ident_Node
, Chars
(Standard_Entity
(S
)));
1733 Set_Entity
(Ident_Node
, Standard_Entity
(S
));
1737 --------------------
1738 -- Make_Component --
1739 --------------------
1741 procedure Make_Component
1746 Id
: constant Entity_Id
:= New_Standard_Entity
;
1749 Set_Ekind
(Id
, E_Component
);
1750 Set_Etype
(Id
, Typ
);
1751 Set_Scope
(Id
, Rec
);
1752 Init_Component_Location
(Id
);
1754 Set_Original_Record_Component
(Id
, Id
);
1755 Make_Name
(Id
, Nam
);
1756 Append_Entity
(Id
, Rec
);
1763 function Make_Formal
1765 Formal_Name
: String) return Entity_Id
1770 Formal
:= New_Standard_Entity
;
1772 Set_Ekind
(Formal
, E_In_Parameter
);
1773 Set_Mechanism
(Formal
, Default_Mechanism
);
1774 Set_Scope
(Formal
, Standard_Standard
);
1775 Set_Etype
(Formal
, Typ
);
1776 Make_Name
(Formal
, Formal_Name
);
1785 function Make_Integer
(V
: Uint
) return Node_Id
is
1786 N
: constant Node_Id
:= Make_Integer_Literal
(Stloc
, V
);
1788 Set_Is_Static_Expression
(N
);
1796 procedure Make_Name
(Id
: Entity_Id
; Nam
: String) is
1798 for J
in 1 .. Nam
'Length loop
1799 Name_Buffer
(J
) := Fold_Lower
(Nam
(Nam
'First + (J
- 1)));
1802 Name_Len
:= Nam
'Length;
1803 Set_Chars
(Id
, Name_Find
);
1810 function New_Operator
(Op
: Name_Id
; Typ
: Entity_Id
) return Entity_Id
is
1811 Ident_Node
: Entity_Id
;
1814 Ident_Node
:= Make_Defining_Identifier
(Stloc
, Op
);
1816 Set_Is_Pure
(Ident_Node
, True);
1817 Set_Ekind
(Ident_Node
, E_Operator
);
1818 Set_Etype
(Ident_Node
, Typ
);
1819 Set_Scope
(Ident_Node
, Standard_Standard
);
1820 Set_Homonym
(Ident_Node
, Get_Name_Entity_Id
(Op
));
1821 Set_Convention
(Ident_Node
, Convention_Intrinsic
);
1823 Set_Is_Immediately_Visible
(Ident_Node
, True);
1824 Set_Is_Intrinsic_Subprogram
(Ident_Node
, True);
1826 Set_Name_Entity_Id
(Op
, Ident_Node
);
1827 Append_Entity
(Ident_Node
, Standard_Standard
);
1831 -------------------------
1832 -- New_Standard_Entity --
1833 -------------------------
1835 function New_Standard_Entity
1836 (New_Node_Kind
: Node_Kind
:= N_Defining_Identifier
) return Entity_Id
1838 E
: constant Entity_Id
:= New_Entity
(New_Node_Kind
, Stloc
);
1841 -- All standard entities are Pure and Public
1846 -- All standard entity names are analyzed manually, and are thus
1847 -- frozen as soon as they are created.
1851 -- Set debug information required for all standard types
1853 Set_Needs_Debug_Info
(E
);
1855 -- All standard entities are built with fully qualified names, so
1856 -- set the flag to prevent an abortive attempt at requalification.
1858 Set_Has_Qualified_Name
(E
);
1860 -- Return newly created entity to be completed by caller
1863 end New_Standard_Entity
;
1865 --------------------
1866 -- Print_Standard --
1867 --------------------
1869 procedure Print_Standard
is
1871 procedure P
(Item
: String) renames Output
.Write_Line
;
1872 -- Short-hand, since we do a lot of line writes here
1874 procedure P_Int_Range
(Size
: Pos
);
1875 -- Prints the range of an integer based on its Size
1877 procedure P_Float_Range
(Id
: Entity_Id
);
1878 -- Prints the bounds range for the given float type entity
1880 procedure P_Float_Type
(Id
: Entity_Id
);
1881 -- Prints the type declaration of the given float type entity
1883 procedure P_Mixed_Name
(Id
: Name_Id
);
1884 -- Prints Id in mixed case
1890 procedure P_Float_Range
(Id
: Entity_Id
) is
1892 Write_Str
(" range ");
1893 UR_Write
(Realval
(Type_Low_Bound
(Id
)));
1895 UR_Write
(Realval
(Type_High_Bound
(Id
)));
1904 procedure P_Float_Type
(Id
: Entity_Id
) is
1906 Write_Str
(" type ");
1907 P_Mixed_Name
(Chars
(Id
));
1908 Write_Str
(" is digits ");
1909 Write_Int
(UI_To_Int
(Digits_Value
(Id
)));
1912 Write_Str
(" for ");
1913 P_Mixed_Name
(Chars
(Id
));
1914 Write_Str
("'Size use ");
1915 Write_Int
(UI_To_Int
(RM_Size
(Id
)));
1924 procedure P_Int_Range
(Size
: Pos
) is
1926 Write_Str
(" is range -(2 **");
1927 Write_Int
(Size
- 1);
1929 Write_Str
(" .. +(2 **");
1930 Write_Int
(Size
- 1);
1931 Write_Str
(" - 1);");
1939 procedure P_Mixed_Name
(Id
: Name_Id
) is
1941 Get_Name_String
(Id
);
1943 for J
in 1 .. Name_Len
loop
1944 if J
= 1 or else Name_Buffer
(J
- 1) = '_' then
1945 Name_Buffer
(J
) := Fold_Upper
(Name_Buffer
(J
));
1949 Write_Str
(Name_Buffer
(1 .. Name_Len
));
1952 -- Start of processing for Print_Standard
1955 P
("-- Representation of package Standard");
1957 P
("-- This is not accurate Ada, since new base types cannot be ");
1958 P
("-- created, but the listing shows the target dependent");
1959 P
("-- characteristics of the Standard types for this compiler");
1962 P
("package Standard is");
1963 P
("pragma Pure (Standard);");
1966 P
(" type Boolean is (False, True);");
1967 P
(" for Boolean'Size use 1;");
1968 P
(" for Boolean use (False => 0, True => 1);");
1973 Write_Str
(" type Integer");
1974 P_Int_Range
(Standard_Integer_Size
);
1975 Write_Str
(" for Integer'Size use ");
1976 Write_Int
(Standard_Integer_Size
);
1980 P
(" subtype Natural is Integer range 0 .. Integer'Last;");
1981 P
(" subtype Positive is Integer range 1 .. Integer'Last;");
1984 Write_Str
(" type Short_Short_Integer");
1985 P_Int_Range
(Standard_Short_Short_Integer_Size
);
1986 Write_Str
(" for Short_Short_Integer'Size use ");
1987 Write_Int
(Standard_Short_Short_Integer_Size
);
1991 Write_Str
(" type Short_Integer");
1992 P_Int_Range
(Standard_Short_Integer_Size
);
1993 Write_Str
(" for Short_Integer'Size use ");
1994 Write_Int
(Standard_Short_Integer_Size
);
1998 Write_Str
(" type Long_Integer");
1999 P_Int_Range
(Standard_Long_Integer_Size
);
2000 Write_Str
(" for Long_Integer'Size use ");
2001 Write_Int
(Standard_Long_Integer_Size
);
2005 Write_Str
(" type Long_Long_Integer");
2006 P_Int_Range
(Standard_Long_Long_Integer_Size
);
2007 Write_Str
(" for Long_Long_Integer'Size use ");
2008 Write_Int
(Standard_Long_Long_Integer_Size
);
2012 -- Floating point types
2014 P_Float_Type
(Standard_Short_Float
);
2015 P_Float_Type
(Standard_Float
);
2016 P_Float_Type
(Standard_Long_Float
);
2017 P_Float_Type
(Standard_Long_Long_Float
);
2019 P
(" type Character is (...)");
2020 Write_Str
(" for Character'Size use ");
2021 Write_Int
(Standard_Character_Size
);
2023 P
(" -- See RM A.1(35) for details of this type");
2026 P
(" type Wide_Character is (...)");
2027 Write_Str
(" for Wide_Character'Size use ");
2028 Write_Int
(Standard_Wide_Character_Size
);
2030 P
(" -- See RM A.1(36) for details of this type");
2033 P
(" type Wide_Wide_Character is (...)");
2034 Write_Str
(" for Wide_Wide_Character'Size use ");
2035 Write_Int
(Standard_Wide_Wide_Character_Size
);
2037 P
(" -- See RM A.1(36) for details of this type");
2039 P
(" type String is array (Positive range <>) of Character;");
2040 P
(" pragma Pack (String);");
2043 P
(" type Wide_String is array (Positive range <>)" &
2044 " of Wide_Character;");
2045 P
(" pragma Pack (Wide_String);");
2048 P
(" type Wide_Wide_String is array (Positive range <>)" &
2049 " of Wide_Wide_Character;");
2050 P
(" pragma Pack (Wide_Wide_String);");
2053 -- We only have one representation each for 32-bit and 64-bit sizes,
2054 -- so select the right one based on Duration_32_Bits_On_Target.
2056 if Duration_32_Bits_On_Target
then
2057 P
(" type Duration is delta 0.020");
2058 P
(" range -((2 ** 31 - 1) * 0.020) ..");
2059 P
(" +((2 ** 31 - 1) * 0.020);");
2060 P
(" for Duration'Small use 0.020;");
2063 P
(" type Duration is delta 0.000000001");
2064 P
(" range -((2 ** 63 - 1) * 0.000000001) ..");
2065 P
(" +((2 ** 63 - 1) * 0.000000001);");
2066 P
(" for Duration'Small use 0.000000001;");
2071 P
(" Constraint_Error : exception;");
2072 P
(" Program_Error : exception;");
2073 P
(" Storage_Error : exception;");
2074 P
(" Tasking_Error : exception;");
2075 P
(" Numeric_Error : exception renames Constraint_Error;");
2078 P
("end Standard;");
2081 -------------------------
2082 -- Register_Float_Type --
2083 -------------------------
2085 procedure Register_Float_Type
2088 Float_Rep
: Float_Rep_Kind
;
2089 Precision
: Positive;
2091 Alignment
: Natural)
2093 Ent
: constant Entity_Id
:= New_Standard_Entity
;
2096 Set_Defining_Identifier
(New_Node
(N_Full_Type_Declaration
, Stloc
), Ent
);
2097 Make_Name
(Ent
, Name
);
2098 Set_Scope
(Ent
, Standard_Standard
);
2099 Build_Float_Type
(Ent
, Int
(Size
), Float_Rep
, Pos
(Digs
));
2100 Set_RM_Size
(Ent
, UI_From_Int
(Int
(Precision
)));
2101 Set_Alignment
(Ent
, UI_From_Int
(Int
(Alignment
/ 8)));
2103 if No
(Back_End_Float_Types
) then
2104 Back_End_Float_Types
:= New_Elmt_List
;
2107 Append_Elmt
(Ent
, Back_End_Float_Types
);
2108 end Register_Float_Type
;
2110 ----------------------
2111 -- Set_Float_Bounds --
2112 ----------------------
2114 procedure Set_Float_Bounds
(Id
: Entity_Id
) is
2117 -- Low and high bounds of literal value
2120 -- Range specification
2122 Radix
: constant Uint
:= Machine_Radix_Value
(Id
);
2123 Mantissa
: constant Uint
:= Machine_Mantissa_Value
(Id
);
2124 Emax
: constant Uint
:= Machine_Emax_Value
(Id
);
2125 Significand
: constant Uint
:= Radix
** Mantissa
- 1;
2126 Exponent
: constant Uint
:= Emax
- Mantissa
;
2129 -- Note: for the call from Cstand to initially create the types in
2130 -- Standard, Float_Rep will never be VAX_Native. Circuitry in Sem_Vfpt
2131 -- will adjust these types appropriately VAX_Native if a pragma
2132 -- Float_Representation (VAX_Float) is used.
2134 H
:= Make_Float_Literal
(Stloc
, Radix
, Significand
, Exponent
);
2135 L
:= Make_Float_Literal
(Stloc
, Radix
, -Significand
, Exponent
);
2138 Set_Is_Static_Expression
(L
);
2141 Set_Is_Static_Expression
(H
);
2143 R
:= New_Node
(N_Range
, Stloc
);
2144 Set_Low_Bound
(R
, L
);
2145 Set_High_Bound
(R
, H
);
2146 Set_Includes_Infinities
(R
, True);
2147 Set_Scalar_Range
(Id
, R
);
2150 end Set_Float_Bounds
;
2152 ------------------------
2153 -- Set_Integer_Bounds --
2154 ------------------------
2156 procedure Set_Integer_Bounds
2164 -- Low and high bounds of literal value
2167 -- Range specification
2170 L
:= Make_Integer
(Lb
);
2171 H
:= Make_Integer
(Hb
);
2176 R
:= New_Node
(N_Range
, Stloc
);
2177 Set_Low_Bound
(R
, L
);
2178 Set_High_Bound
(R
, H
);
2179 Set_Scalar_Range
(Id
, R
);
2182 Set_Is_Unsigned_Type
(Id
, Lb
>= 0);
2183 end Set_Integer_Bounds
;