1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2013, 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
: Int
);
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 Copy_Float_Type
(To
: Entity_Id
; From
: Entity_Id
);
83 -- Build a floating point type, copying representation details from From.
84 -- This is used to create predefined floating point types based on
85 -- available types in the back end.
87 procedure Create_Operators
;
88 -- Make entries for each of the predefined operators in Standard
90 procedure Create_Unconstrained_Base_Type
93 -- The predefined signed integer types are constrained subtypes which
94 -- must have a corresponding unconstrained base type. This type is almost
95 -- useless. The only place it has semantics is Subtypes_Statically_Match.
96 -- Consequently, we arrange for it to be identical apart from the setting
97 -- of the constrained bit. This routine takes an entity E for the Type,
98 -- copies it to estabish the base type, then resets the Ekind of the
99 -- original entity to K (the Ekind for the subtype). The Etype field of
100 -- E is set by the call (to point to the created base type entity), and
101 -- also the Is_Constrained flag of E is set.
103 -- To understand the exact requirement for this, see RM 3.5.4(11) which
104 -- makes it clear that Integer, for example, is constrained, with the
105 -- constraint bounds matching the bounds of the (unconstrained) base
106 -- type. The point is that Integer and Integer'Base have identical
107 -- bounds, but do not statically match, since a subtype with constraints
108 -- never matches a subtype with no constraints.
110 function Find_Back_End_Float_Type
(Name
: String) return Entity_Id
;
111 -- Return the first float type in Back_End_Float_Types with the given name.
112 -- Names of entities in back end types, are either type names of C
113 -- predefined types (all lower case), or mode names (upper case).
114 -- These are not generally valid identifier names.
116 function Identifier_For
(S
: Standard_Entity_Type
) return Node_Id
;
117 -- Returns an identifier node with the same name as the defining
118 -- identifier corresponding to the given Standard_Entity_Type value
120 procedure Make_Component
124 -- Build a record component with the given type and name, and append to
125 -- the list of components of Rec.
129 Formal_Name
: String) return Entity_Id
;
130 -- Construct entity for subprogram formal with given name and type
132 function Make_Integer
(V
: Uint
) return Node_Id
;
133 -- Builds integer literal with given value
135 procedure Make_Name
(Id
: Entity_Id
; Nam
: String);
136 -- Make an entry in the names table for Nam, and set as Chars field of Id
138 function New_Operator
(Op
: Name_Id
; Typ
: Entity_Id
) return Entity_Id
;
139 -- Build entity for standard operator with given name and type
141 function New_Standard_Entity
142 (New_Node_Kind
: Node_Kind
:= N_Defining_Identifier
) return Entity_Id
;
143 -- Builds a new entity for Standard
145 procedure Print_Standard
;
146 -- Print representation of package Standard if switch set
148 procedure Register_Float_Type
151 Float_Rep
: Float_Rep_Kind
;
153 Alignment
: Natural);
154 -- Registers a single back end floating-point type (from FPT_Mode_Table in
155 -- Set_Targ). This will create a predefined floating-point base type for
156 -- one of the floating point types reported by the back end, and add it
157 -- to the list of predefined float types. Name is the name of the type
158 -- as a normal format (non-null-terminated) string. Digs is the number of
159 -- digits, which is always non-zero, since non-floating-point types were
160 -- filtered out earlier. Float_Rep indicates the kind of floating-point
161 -- type, and Size and Alignment are the size and alignment in bits.
163 procedure Set_Integer_Bounds
168 -- Procedure to set bounds for integer type or subtype. Id is the entity
169 -- whose bounds and type are to be set. The Typ parameter is the Etype
170 -- value for the entity (which will be the same as Id for all predefined
171 -- integer base types. The third and fourth parameters are the bounds.
173 ----------------------
174 -- Build_Float_Type --
175 ----------------------
177 procedure Build_Float_Type
180 Rep
: Float_Rep_Kind
;
184 Set_Type_Definition
(Parent
(E
),
185 Make_Floating_Point_Definition
(Stloc
,
186 Digits_Expression
=> Make_Integer
(UI_From_Int
(Digs
))));
188 Set_Ekind
(E
, E_Floating_Point_Type
);
190 Set_Float_Rep
(E
, Rep
);
192 Set_Elem_Alignment
(E
);
193 Init_Digits_Value
(E
, Digs
);
194 Set_Float_Bounds
(E
);
197 Set_Size_Known_At_Compile_Time
(E
);
198 end Build_Float_Type
;
200 ------------------------------
201 -- Find_Back_End_Float_Type --
202 ------------------------------
204 function Find_Back_End_Float_Type
(Name
: String) return Entity_Id
is
208 N
:= First_Elmt
(Back_End_Float_Types
);
209 while Present
(N
) and then Get_Name_String
(Chars
(Node
(N
))) /= Name
215 end Find_Back_End_Float_Type
;
217 -------------------------------
218 -- Build_Signed_Integer_Type --
219 -------------------------------
221 procedure Build_Signed_Integer_Type
(E
: Entity_Id
; Siz
: Int
) is
222 U2Siz1
: constant Uint
:= 2 ** (Siz
- 1);
223 Lbound
: constant Uint
:= -U2Siz1
;
224 Ubound
: constant Uint
:= U2Siz1
- 1;
227 Set_Type_Definition
(Parent
(E
),
228 Make_Signed_Integer_Type_Definition
(Stloc
,
229 Low_Bound
=> Make_Integer
(Lbound
),
230 High_Bound
=> Make_Integer
(Ubound
)));
232 Set_Ekind
(E
, E_Signed_Integer_Type
);
235 Set_Elem_Alignment
(E
);
236 Set_Integer_Bounds
(E
, E
, Lbound
, Ubound
);
239 Set_Is_Known_Valid
(E
);
240 Set_Size_Known_At_Compile_Time
(E
);
241 end Build_Signed_Integer_Type
;
243 ---------------------
244 -- Copy_Float_Type --
245 ---------------------
247 procedure Copy_Float_Type
(To
: Entity_Id
; From
: Entity_Id
) is
249 Build_Float_Type
(To
, UI_To_Int
(Esize
(From
)), Float_Rep
(From
),
250 UI_To_Int
(Digits_Value
(From
)));
253 ----------------------
254 -- Create_Operators --
255 ----------------------
257 -- Each operator has an abbreviated signature. The formals have the names
258 -- LEFT and RIGHT. Their types are not actually used for resolution.
260 procedure Create_Operators
is
263 -- The following tables define the binary and unary operators and their
264 -- corresponding result type.
266 Binary_Ops
: constant array (S_Binary_Ops
) of Name_Id
:=
268 -- There is one entry here for each binary operator, except for the
269 -- case of concatenation, where there are three entries, one for a
270 -- String result, one for Wide_String, and one for Wide_Wide_String.
292 Bin_Op_Types
: constant array (S_Binary_Ops
) of Entity_Id
:=
294 -- This table has the corresponding result types. The entries are
295 -- ordered so they correspond to the Binary_Ops array above.
297 (Universal_Integer
, -- Add
298 Standard_Boolean
, -- And
299 Standard_String
, -- Concat (String)
300 Standard_Wide_String
, -- Concat (Wide_String)
301 Standard_Wide_Wide_String
, -- Concat (Wide_Wide_String)
302 Universal_Integer
, -- Divide
303 Standard_Boolean
, -- Eq
304 Universal_Integer
, -- Expon
305 Standard_Boolean
, -- Ge
306 Standard_Boolean
, -- Gt
307 Standard_Boolean
, -- Le
308 Standard_Boolean
, -- Lt
309 Universal_Integer
, -- Mod
310 Universal_Integer
, -- Multiply
311 Standard_Boolean
, -- Ne
312 Standard_Boolean
, -- Or
313 Universal_Integer
, -- Rem
314 Universal_Integer
, -- Subtract
315 Standard_Boolean
); -- Xor
317 Unary_Ops
: constant array (S_Unary_Ops
) of Name_Id
:=
319 -- There is one entry here for each unary operator
326 Unary_Op_Types
: constant array (S_Unary_Ops
) of Entity_Id
:=
328 -- This table has the corresponding result types. The entries are
329 -- ordered so they correspond to the Unary_Ops array above.
331 (Universal_Integer
, -- Abs
332 Universal_Integer
, -- Subtract
333 Standard_Boolean
, -- Not
334 Universal_Integer
); -- Add
337 for J
in S_Binary_Ops
loop
338 Op_Node
:= New_Operator
(Binary_Ops
(J
), Bin_Op_Types
(J
));
340 Append_Entity
(Make_Formal
(Any_Type
, "LEFT"), Op_Node
);
341 Append_Entity
(Make_Formal
(Any_Type
, "RIGHT"), Op_Node
);
344 for J
in S_Unary_Ops
loop
345 Op_Node
:= New_Operator
(Unary_Ops
(J
), Unary_Op_Types
(J
));
347 Append_Entity
(Make_Formal
(Any_Type
, "RIGHT"), Op_Node
);
350 -- For concatenation, we create a separate operator for each
351 -- array type. This simplifies the resolution of the component-
352 -- component concatenation operation. In Standard, we set the types
353 -- of the formals for string, wide [wide]_string, concatenations.
355 Set_Etype
(First_Entity
(Standard_Op_Concat
), Standard_String
);
356 Set_Etype
(Last_Entity
(Standard_Op_Concat
), Standard_String
);
358 Set_Etype
(First_Entity
(Standard_Op_Concatw
), Standard_Wide_String
);
359 Set_Etype
(Last_Entity
(Standard_Op_Concatw
), Standard_Wide_String
);
361 Set_Etype
(First_Entity
(Standard_Op_Concatww
),
362 Standard_Wide_Wide_String
);
364 Set_Etype
(Last_Entity
(Standard_Op_Concatww
),
365 Standard_Wide_Wide_String
);
366 end Create_Operators
;
368 ---------------------
369 -- Create_Standard --
370 ---------------------
372 -- The tree for the package Standard is prefixed to all compilations.
373 -- Several entities required by semantic analysis are denoted by global
374 -- variables that are initialized to point to the corresponding occurrences
375 -- in Standard. The visible entities of Standard are created here. Special
376 -- entities maybe created here as well or may be created from the semantics
377 -- module. By not adding them to the Decls list of Standard they will not
378 -- be visible to Ada programs.
380 procedure Create_Standard
is
381 Decl_S
: constant List_Id
:= New_List
;
382 -- List of declarations in Standard
384 Decl_A
: constant List_Id
:= New_List
;
385 -- List of declarations in ASCII
390 Ident_Node
: Node_Id
;
396 procedure Build_Exception
(S
: Standard_Entity_Type
);
397 -- Procedure to declare given entity as an exception
399 procedure Create_Back_End_Float_Types
;
400 -- Initialize the Back_End_Float_Types list by having the back end
401 -- enumerate all available types and building type entities for them.
403 procedure Create_Float_Types
;
404 -- Creates entities for all predefined floating point types, and
405 -- adds these to the Predefined_Float_Types list in package Standard.
407 procedure Pack_String_Type
(String_Type
: Entity_Id
);
408 -- Generate proper tree for pragma Pack that applies to given type, and
409 -- mark type as having the pragma.
411 ---------------------
412 -- Build_Exception --
413 ---------------------
415 procedure Build_Exception
(S
: Standard_Entity_Type
) is
417 Set_Ekind
(Standard_Entity
(S
), E_Exception
);
418 Set_Etype
(Standard_Entity
(S
), Standard_Exception_Type
);
419 Set_Exception_Code
(Standard_Entity
(S
), Uint_0
);
420 Set_Is_Public
(Standard_Entity
(S
), True);
423 Make_Exception_Declaration
(Stloc
,
424 Defining_Identifier
=> Standard_Entity
(S
));
425 Append
(Decl
, Decl_S
);
428 ---------------------------------
429 -- Create_Back_End_Float_Types --
430 ---------------------------------
432 procedure Create_Back_End_Float_Types
is
434 for J
in 1 .. Num_FPT_Modes
loop
436 E
: FPT_Mode_Entry
renames FPT_Mode_Table
(J
);
439 (E
.NAME
.all, E
.DIGS
, E
.FLOAT_REP
, E
.SIZE
, E
.ALIGNMENT
);
442 end Create_Back_End_Float_Types
;
444 ------------------------
445 -- Create_Float_Types --
446 ------------------------
448 procedure Create_Float_Types
is
450 -- Create type definition nodes for predefined float types
453 (Standard_Short_Float
,
454 Find_Back_End_Float_Type
("float"));
455 Set_Is_Implementation_Defined
(Standard_Short_Float
);
457 Copy_Float_Type
(Standard_Float
, Standard_Short_Float
);
459 Copy_Float_Type
(Standard_Long_Float
,
460 Find_Back_End_Float_Type
("double"));
462 Predefined_Float_Types
:= New_Elmt_List
;
463 Append_Elmt
(Standard_Short_Float
, Predefined_Float_Types
);
464 Append_Elmt
(Standard_Float
, Predefined_Float_Types
);
465 Append_Elmt
(Standard_Long_Float
, Predefined_Float_Types
);
467 -- ??? For now, we don't have a good way to tell the widest float
468 -- type with hardware support. Basically, GCC knows the size of that
469 -- type, but on x86-64 there often are two or three 128-bit types,
470 -- one double extended that has 18 decimal digits, a 128-bit quad
471 -- precision type with 33 digits and possibly a 128-bit decimal float
472 -- type with 34 digits. As a workaround, we define Long_Long_Float as
473 -- C's "long double" if that type exists and has at most 18 digits,
474 -- or otherwise the same as Long_Float.
477 Max_HW_Digs
: constant := 18;
478 -- Maximum hardware digits supported
480 LLF
: Entity_Id
:= Find_Back_End_Float_Type
("long double");
481 -- Entity for long double type
484 if No
(LLF
) or else Digits_Value
(LLF
) > Max_HW_Digs
then
485 LLF
:= Standard_Long_Float
;
488 Set_Is_Implementation_Defined
(Standard_Long_Long_Float
);
489 Copy_Float_Type
(Standard_Long_Long_Float
, LLF
);
491 Append_Elmt
(Standard_Long_Long_Float
, Predefined_Float_Types
);
494 -- Any other back end types are appended at the end of the list of
495 -- predefined float types, and will only be selected if the none of
496 -- the types in Standard is suitable, or if a specific named type is
497 -- requested through a pragma Import.
499 while not Is_Empty_Elmt_List
(Back_End_Float_Types
) loop
501 E
: constant Elmt_Id
:= First_Elmt
(Back_End_Float_Types
);
503 Append_Elmt
(Node
(E
), To
=> Predefined_Float_Types
);
504 Remove_Elmt
(Back_End_Float_Types
, E
);
507 end Create_Float_Types
;
509 ----------------------
510 -- Pack_String_Type --
511 ----------------------
513 procedure Pack_String_Type
(String_Type
: Entity_Id
) is
514 Prag
: constant Node_Id
:=
517 Pragma_Argument_Associations
=>
519 Make_Pragma_Argument_Association
(Stloc
,
520 Expression
=> New_Occurrence_Of
(String_Type
, Stloc
))));
522 Append
(Prag
, Decl_S
);
523 Record_Rep_Item
(String_Type
, Prag
);
524 Set_Has_Pragma_Pack
(String_Type
, True);
525 end Pack_String_Type
;
527 -- Start of processing for Create_Standard
530 -- Initialize scanner for internal scans of literals
532 Scn
.Initialize_Scanner
(No_Unit
, Internal_Source_File
);
534 -- First step is to create defining identifiers for each entity
536 for S
in Standard_Entity_Type
loop
538 S_Name
: constant String := Standard_Entity_Type
'Image (S
);
539 -- Name of entity (note we skip S_ at the start)
541 Ident_Node
: Node_Id
;
542 -- Defining identifier node
545 Ident_Node
:= New_Standard_Entity
;
546 Make_Name
(Ident_Node
, S_Name
(3 .. S_Name
'Length));
547 Standard_Entity
(S
) := Ident_Node
;
551 -- Create package declaration node for package Standard
553 Standard_Package_Node
:= New_Node
(N_Package_Declaration
, Stloc
);
555 Pspec
:= New_Node
(N_Package_Specification
, Stloc
);
556 Set_Specification
(Standard_Package_Node
, Pspec
);
558 Set_Defining_Unit_Name
(Pspec
, Standard_Standard
);
559 Set_Visible_Declarations
(Pspec
, Decl_S
);
561 Set_Ekind
(Standard_Standard
, E_Package
);
562 Set_Is_Pure
(Standard_Standard
);
563 Set_Is_Compilation_Unit
(Standard_Standard
);
565 -- Create type/subtype declaration nodes for standard types
567 for S
in S_Types
loop
569 -- Subtype declaration case
571 if S
= S_Natural
or else S
= S_Positive
then
572 Decl
:= New_Node
(N_Subtype_Declaration
, Stloc
);
573 Set_Subtype_Indication
(Decl
,
574 New_Occurrence_Of
(Standard_Integer
, Stloc
));
576 -- Full type declaration case
579 Decl
:= New_Node
(N_Full_Type_Declaration
, Stloc
);
582 Set_Is_Frozen
(Standard_Entity
(S
));
583 Set_Is_Public
(Standard_Entity
(S
));
584 Set_Defining_Identifier
(Decl
, Standard_Entity
(S
));
585 Append
(Decl
, Decl_S
);
588 Create_Back_End_Float_Types
;
590 -- Create type definition node for type Boolean. The Size is set to
591 -- 1 as required by Ada 95 and current ARG interpretations for Ada/83.
593 -- Note: Object_Size of Boolean is 8. This means that we do NOT in
594 -- general know that Boolean variables have valid values, so we do
595 -- not set the Is_Known_Valid flag.
597 Tdef_Node
:= New_Node
(N_Enumeration_Type_Definition
, Stloc
);
598 Set_Literals
(Tdef_Node
, New_List
);
599 Append
(Standard_False
, Literals
(Tdef_Node
));
600 Append
(Standard_True
, Literals
(Tdef_Node
));
601 Set_Type_Definition
(Parent
(Standard_Boolean
), Tdef_Node
);
603 Set_Ekind
(Standard_Boolean
, E_Enumeration_Type
);
604 Set_First_Literal
(Standard_Boolean
, Standard_False
);
605 Set_Etype
(Standard_Boolean
, Standard_Boolean
);
606 Init_Esize
(Standard_Boolean
, Standard_Character_Size
);
607 Init_RM_Size
(Standard_Boolean
, 1);
608 Set_Elem_Alignment
(Standard_Boolean
);
610 Set_Is_Unsigned_Type
(Standard_Boolean
);
611 Set_Size_Known_At_Compile_Time
(Standard_Boolean
);
612 Set_Has_Pragma_Ordered
(Standard_Boolean
);
614 Set_Ekind
(Standard_True
, E_Enumeration_Literal
);
615 Set_Etype
(Standard_True
, Standard_Boolean
);
616 Set_Enumeration_Pos
(Standard_True
, Uint_1
);
617 Set_Enumeration_Rep
(Standard_True
, Uint_1
);
618 Set_Is_Known_Valid
(Standard_True
, True);
620 Set_Ekind
(Standard_False
, E_Enumeration_Literal
);
621 Set_Etype
(Standard_False
, Standard_Boolean
);
622 Set_Enumeration_Pos
(Standard_False
, Uint_0
);
623 Set_Enumeration_Rep
(Standard_False
, Uint_0
);
624 Set_Is_Known_Valid
(Standard_False
, True);
626 -- For the bounds of Boolean, we create a range node corresponding to
628 -- range False .. True
630 -- where the occurrences of the literals must point to the
631 -- corresponding definition.
633 R_Node
:= New_Node
(N_Range
, Stloc
);
634 B_Node
:= New_Node
(N_Identifier
, Stloc
);
635 Set_Chars
(B_Node
, Chars
(Standard_False
));
636 Set_Entity
(B_Node
, Standard_False
);
637 Set_Etype
(B_Node
, Standard_Boolean
);
638 Set_Is_Static_Expression
(B_Node
);
639 Set_Low_Bound
(R_Node
, B_Node
);
641 B_Node
:= New_Node
(N_Identifier
, Stloc
);
642 Set_Chars
(B_Node
, Chars
(Standard_True
));
643 Set_Entity
(B_Node
, Standard_True
);
644 Set_Etype
(B_Node
, Standard_Boolean
);
645 Set_Is_Static_Expression
(B_Node
);
646 Set_High_Bound
(R_Node
, B_Node
);
648 Set_Scalar_Range
(Standard_Boolean
, R_Node
);
649 Set_Etype
(R_Node
, Standard_Boolean
);
650 Set_Parent
(R_Node
, Standard_Boolean
);
652 -- Record entity identifiers for boolean literals in the
653 -- Boolean_Literals array, for easy reference during expansion.
655 Boolean_Literals
:= (False => Standard_False
, True => Standard_True
);
657 -- Create type definition nodes for predefined integer types
659 Build_Signed_Integer_Type
660 (Standard_Short_Short_Integer
, Standard_Short_Short_Integer_Size
);
662 Build_Signed_Integer_Type
663 (Standard_Short_Integer
, Standard_Short_Integer_Size
);
665 Build_Signed_Integer_Type
666 (Standard_Integer
, Standard_Integer_Size
);
674 LIS
:= Standard_Long_Integer_Size
;
677 Build_Signed_Integer_Type
(Standard_Long_Integer
, LIS
);
680 Build_Signed_Integer_Type
681 (Standard_Long_Long_Integer
, Standard_Long_Long_Integer_Size
);
682 Set_Is_Implementation_Defined
(Standard_Long_Long_Integer
);
684 Create_Unconstrained_Base_Type
685 (Standard_Short_Short_Integer
, E_Signed_Integer_Subtype
);
686 Set_Is_Implementation_Defined
(Standard_Short_Short_Integer
);
688 Create_Unconstrained_Base_Type
689 (Standard_Short_Integer
, E_Signed_Integer_Subtype
);
691 Create_Unconstrained_Base_Type
692 (Standard_Integer
, E_Signed_Integer_Subtype
);
694 Create_Unconstrained_Base_Type
695 (Standard_Long_Integer
, E_Signed_Integer_Subtype
);
697 Create_Unconstrained_Base_Type
698 (Standard_Long_Long_Integer
, E_Signed_Integer_Subtype
);
699 Set_Is_Implementation_Defined
(Standard_Short_Short_Integer
);
703 -- Create type definition node for type Character. Note that we do not
704 -- set the Literals field, since type Character is handled with special
705 -- routine that do not need a literal list.
707 Tdef_Node
:= New_Node
(N_Enumeration_Type_Definition
, Stloc
);
708 Set_Type_Definition
(Parent
(Standard_Character
), Tdef_Node
);
710 Set_Ekind
(Standard_Character
, E_Enumeration_Type
);
711 Set_Etype
(Standard_Character
, Standard_Character
);
712 Init_Esize
(Standard_Character
, Standard_Character_Size
);
713 Init_RM_Size
(Standard_Character
, 8);
714 Set_Elem_Alignment
(Standard_Character
);
716 Set_Has_Pragma_Ordered
(Standard_Character
);
717 Set_Is_Unsigned_Type
(Standard_Character
);
718 Set_Is_Character_Type
(Standard_Character
);
719 Set_Is_Known_Valid
(Standard_Character
);
720 Set_Size_Known_At_Compile_Time
(Standard_Character
);
722 -- Create the bounds for type Character
724 R_Node
:= New_Node
(N_Range
, Stloc
);
726 -- Low bound for type Character (Standard.Nul)
728 B_Node
:= New_Node
(N_Character_Literal
, Stloc
);
729 Set_Is_Static_Expression
(B_Node
);
730 Set_Chars
(B_Node
, No_Name
);
731 Set_Char_Literal_Value
(B_Node
, Uint_0
);
732 Set_Entity
(B_Node
, Empty
);
733 Set_Etype
(B_Node
, Standard_Character
);
734 Set_Low_Bound
(R_Node
, B_Node
);
736 -- High bound for type Character
738 B_Node
:= New_Node
(N_Character_Literal
, Stloc
);
739 Set_Is_Static_Expression
(B_Node
);
740 Set_Chars
(B_Node
, No_Name
);
741 Set_Char_Literal_Value
(B_Node
, UI_From_Int
(16#FF#
));
742 Set_Entity
(B_Node
, Empty
);
743 Set_Etype
(B_Node
, Standard_Character
);
744 Set_High_Bound
(R_Node
, B_Node
);
746 Set_Scalar_Range
(Standard_Character
, R_Node
);
747 Set_Etype
(R_Node
, Standard_Character
);
748 Set_Parent
(R_Node
, Standard_Character
);
750 -- Create type definition for type Wide_Character. Note that we do not
751 -- set the Literals field, since type Wide_Character is handled with
752 -- special routines that do not need a literal list.
754 Tdef_Node
:= New_Node
(N_Enumeration_Type_Definition
, Stloc
);
755 Set_Type_Definition
(Parent
(Standard_Wide_Character
), Tdef_Node
);
757 Set_Ekind
(Standard_Wide_Character
, E_Enumeration_Type
);
758 Set_Etype
(Standard_Wide_Character
, Standard_Wide_Character
);
759 Init_Size
(Standard_Wide_Character
, Standard_Wide_Character_Size
);
761 Set_Elem_Alignment
(Standard_Wide_Character
);
762 Set_Has_Pragma_Ordered
(Standard_Wide_Character
);
763 Set_Is_Unsigned_Type
(Standard_Wide_Character
);
764 Set_Is_Character_Type
(Standard_Wide_Character
);
765 Set_Is_Known_Valid
(Standard_Wide_Character
);
766 Set_Size_Known_At_Compile_Time
(Standard_Wide_Character
);
768 -- Create the bounds for type Wide_Character
770 R_Node
:= New_Node
(N_Range
, Stloc
);
772 -- Low bound for type Wide_Character
774 B_Node
:= New_Node
(N_Character_Literal
, Stloc
);
775 Set_Is_Static_Expression
(B_Node
);
776 Set_Chars
(B_Node
, No_Name
); -- ???
777 Set_Char_Literal_Value
(B_Node
, Uint_0
);
778 Set_Entity
(B_Node
, Empty
);
779 Set_Etype
(B_Node
, Standard_Wide_Character
);
780 Set_Low_Bound
(R_Node
, B_Node
);
782 -- High bound for type Wide_Character
784 B_Node
:= New_Node
(N_Character_Literal
, Stloc
);
785 Set_Is_Static_Expression
(B_Node
);
786 Set_Chars
(B_Node
, No_Name
); -- ???
787 Set_Char_Literal_Value
(B_Node
, UI_From_Int
(16#FFFF#
));
788 Set_Entity
(B_Node
, Empty
);
789 Set_Etype
(B_Node
, Standard_Wide_Character
);
790 Set_High_Bound
(R_Node
, B_Node
);
792 Set_Scalar_Range
(Standard_Wide_Character
, R_Node
);
793 Set_Etype
(R_Node
, Standard_Wide_Character
);
794 Set_Parent
(R_Node
, Standard_Wide_Character
);
796 -- Create type definition for type Wide_Wide_Character. Note that we
797 -- do not set the Literals field, since type Wide_Wide_Character is
798 -- handled with special routines that do not need a literal list.
800 Tdef_Node
:= New_Node
(N_Enumeration_Type_Definition
, Stloc
);
801 Set_Type_Definition
(Parent
(Standard_Wide_Wide_Character
), Tdef_Node
);
803 Set_Ekind
(Standard_Wide_Wide_Character
, E_Enumeration_Type
);
804 Set_Etype
(Standard_Wide_Wide_Character
,
805 Standard_Wide_Wide_Character
);
806 Init_Size
(Standard_Wide_Wide_Character
,
807 Standard_Wide_Wide_Character_Size
);
809 Set_Elem_Alignment
(Standard_Wide_Wide_Character
);
810 Set_Has_Pragma_Ordered
(Standard_Wide_Wide_Character
);
811 Set_Is_Unsigned_Type
(Standard_Wide_Wide_Character
);
812 Set_Is_Character_Type
(Standard_Wide_Wide_Character
);
813 Set_Is_Known_Valid
(Standard_Wide_Wide_Character
);
814 Set_Size_Known_At_Compile_Time
(Standard_Wide_Wide_Character
);
815 Set_Is_Ada_2005_Only
(Standard_Wide_Wide_Character
);
817 -- Create the bounds for type Wide_Wide_Character
819 R_Node
:= New_Node
(N_Range
, Stloc
);
821 -- Low bound for type Wide_Wide_Character
823 B_Node
:= New_Node
(N_Character_Literal
, Stloc
);
824 Set_Is_Static_Expression
(B_Node
);
825 Set_Chars
(B_Node
, No_Name
); -- ???
826 Set_Char_Literal_Value
(B_Node
, Uint_0
);
827 Set_Entity
(B_Node
, Empty
);
828 Set_Etype
(B_Node
, Standard_Wide_Wide_Character
);
829 Set_Low_Bound
(R_Node
, B_Node
);
831 -- High bound for type Wide_Wide_Character
833 B_Node
:= New_Node
(N_Character_Literal
, Stloc
);
834 Set_Is_Static_Expression
(B_Node
);
835 Set_Chars
(B_Node
, No_Name
); -- ???
836 Set_Char_Literal_Value
(B_Node
, UI_From_Int
(16#
7FFF_FFFF#
));
837 Set_Entity
(B_Node
, Empty
);
838 Set_Etype
(B_Node
, Standard_Wide_Wide_Character
);
839 Set_High_Bound
(R_Node
, B_Node
);
841 Set_Scalar_Range
(Standard_Wide_Wide_Character
, R_Node
);
842 Set_Etype
(R_Node
, Standard_Wide_Wide_Character
);
843 Set_Parent
(R_Node
, Standard_Wide_Wide_Character
);
845 -- Create type definition node for type String
847 Tdef_Node
:= New_Node
(N_Unconstrained_Array_Definition
, Stloc
);
850 CompDef_Node
: Node_Id
;
852 CompDef_Node
:= New_Node
(N_Component_Definition
, Stloc
);
853 Set_Aliased_Present
(CompDef_Node
, False);
854 Set_Access_Definition
(CompDef_Node
, Empty
);
855 Set_Subtype_Indication
(CompDef_Node
, Identifier_For
(S_Character
));
856 Set_Component_Definition
(Tdef_Node
, CompDef_Node
);
859 Set_Subtype_Marks
(Tdef_Node
, New_List
);
860 Append
(Identifier_For
(S_Positive
), Subtype_Marks
(Tdef_Node
));
861 Set_Type_Definition
(Parent
(Standard_String
), Tdef_Node
);
863 Set_Ekind
(Standard_String
, E_String_Type
);
864 Set_Etype
(Standard_String
, Standard_String
);
865 Set_Component_Type
(Standard_String
, Standard_Character
);
866 Set_Component_Size
(Standard_String
, Uint_8
);
867 Init_Size_Align
(Standard_String
);
868 Set_Alignment
(Standard_String
, Uint_1
);
869 Pack_String_Type
(Standard_String
);
871 -- On targets where a storage unit is larger than a byte (such as AAMP),
872 -- pragma Pack has a real effect on the representation of type String,
873 -- and the type must be marked as having a nonstandard representation.
875 if System_Storage_Unit
> Uint_8
then
876 Set_Has_Non_Standard_Rep
(Standard_String
);
877 Set_Has_Pragma_Pack
(Standard_String
);
880 -- Set index type of String
883 (Subtype_Marks
(Type_Definition
(Parent
(Standard_String
))));
884 Set_First_Index
(Standard_String
, E_Id
);
885 Set_Entity
(E_Id
, Standard_Positive
);
886 Set_Etype
(E_Id
, Standard_Positive
);
888 -- Create type definition node for type Wide_String
890 Tdef_Node
:= New_Node
(N_Unconstrained_Array_Definition
, Stloc
);
893 CompDef_Node
: Node_Id
;
895 CompDef_Node
:= New_Node
(N_Component_Definition
, Stloc
);
896 Set_Aliased_Present
(CompDef_Node
, False);
897 Set_Access_Definition
(CompDef_Node
, Empty
);
898 Set_Subtype_Indication
(CompDef_Node
,
899 Identifier_For
(S_Wide_Character
));
900 Set_Component_Definition
(Tdef_Node
, CompDef_Node
);
903 Set_Subtype_Marks
(Tdef_Node
, New_List
);
904 Append
(Identifier_For
(S_Positive
), Subtype_Marks
(Tdef_Node
));
905 Set_Type_Definition
(Parent
(Standard_Wide_String
), Tdef_Node
);
907 Set_Ekind
(Standard_Wide_String
, E_String_Type
);
908 Set_Etype
(Standard_Wide_String
, Standard_Wide_String
);
909 Set_Component_Type
(Standard_Wide_String
, Standard_Wide_Character
);
910 Set_Component_Size
(Standard_Wide_String
, Uint_16
);
911 Init_Size_Align
(Standard_Wide_String
);
912 Pack_String_Type
(Standard_Wide_String
);
914 -- Set index type of Wide_String
917 (Subtype_Marks
(Type_Definition
(Parent
(Standard_Wide_String
))));
918 Set_First_Index
(Standard_Wide_String
, E_Id
);
919 Set_Entity
(E_Id
, Standard_Positive
);
920 Set_Etype
(E_Id
, Standard_Positive
);
922 -- Create type definition node for type Wide_Wide_String
924 Tdef_Node
:= New_Node
(N_Unconstrained_Array_Definition
, Stloc
);
927 CompDef_Node
: Node_Id
;
929 CompDef_Node
:= New_Node
(N_Component_Definition
, Stloc
);
930 Set_Aliased_Present
(CompDef_Node
, False);
931 Set_Access_Definition
(CompDef_Node
, Empty
);
932 Set_Subtype_Indication
(CompDef_Node
,
933 Identifier_For
(S_Wide_Wide_Character
));
934 Set_Component_Definition
(Tdef_Node
, CompDef_Node
);
937 Set_Subtype_Marks
(Tdef_Node
, New_List
);
938 Append
(Identifier_For
(S_Positive
), Subtype_Marks
(Tdef_Node
));
939 Set_Type_Definition
(Parent
(Standard_Wide_Wide_String
), Tdef_Node
);
941 Set_Ekind
(Standard_Wide_Wide_String
, E_String_Type
);
942 Set_Etype
(Standard_Wide_Wide_String
,
943 Standard_Wide_Wide_String
);
944 Set_Component_Type
(Standard_Wide_Wide_String
,
945 Standard_Wide_Wide_Character
);
946 Set_Component_Size
(Standard_Wide_Wide_String
, Uint_32
);
947 Init_Size_Align
(Standard_Wide_Wide_String
);
948 Set_Is_Ada_2005_Only
(Standard_Wide_Wide_String
);
949 Pack_String_Type
(Standard_Wide_Wide_String
);
951 -- Set index type of Wide_Wide_String
954 (Subtype_Marks
(Type_Definition
(Parent
(Standard_Wide_Wide_String
))));
955 Set_First_Index
(Standard_Wide_Wide_String
, E_Id
);
956 Set_Entity
(E_Id
, Standard_Positive
);
957 Set_Etype
(E_Id
, Standard_Positive
);
959 -- Setup entity for Natural
961 Set_Ekind
(Standard_Natural
, E_Signed_Integer_Subtype
);
962 Set_Etype
(Standard_Natural
, Base_Type
(Standard_Integer
));
963 Init_Esize
(Standard_Natural
, Standard_Integer_Size
);
964 Init_RM_Size
(Standard_Natural
, Standard_Integer_Size
- 1);
965 Set_Elem_Alignment
(Standard_Natural
);
966 Set_Size_Known_At_Compile_Time
968 Set_Integer_Bounds
(Standard_Natural
,
969 Typ
=> Base_Type
(Standard_Integer
),
971 Hb
=> Intval
(High_Bound
(Scalar_Range
(Standard_Integer
))));
972 Set_Is_Constrained
(Standard_Natural
);
974 -- Setup entity for Positive
976 Set_Ekind
(Standard_Positive
, E_Signed_Integer_Subtype
);
977 Set_Etype
(Standard_Positive
, Base_Type
(Standard_Integer
));
978 Init_Esize
(Standard_Positive
, Standard_Integer_Size
);
979 Init_RM_Size
(Standard_Positive
, Standard_Integer_Size
- 1);
980 Set_Elem_Alignment
(Standard_Positive
);
982 Set_Size_Known_At_Compile_Time
(Standard_Positive
);
984 Set_Integer_Bounds
(Standard_Positive
,
985 Typ
=> Base_Type
(Standard_Integer
),
987 Hb
=> Intval
(High_Bound
(Scalar_Range
(Standard_Integer
))));
988 Set_Is_Constrained
(Standard_Positive
);
990 -- Create declaration for package ASCII
992 Decl
:= New_Node
(N_Package_Declaration
, Stloc
);
993 Append
(Decl
, Decl_S
);
995 Pspec
:= New_Node
(N_Package_Specification
, Stloc
);
996 Set_Specification
(Decl
, Pspec
);
998 Set_Defining_Unit_Name
(Pspec
, Standard_Entity
(S_ASCII
));
999 Set_Ekind
(Standard_Entity
(S_ASCII
), E_Package
);
1000 Set_Visible_Declarations
(Pspec
, Decl_A
);
1002 -- Create control character definitions in package ASCII. Note that
1003 -- the character literal entries created here correspond to literal
1004 -- values that are impossible in the source, but can be represented
1005 -- internally with no difficulties.
1009 for S
in S_ASCII_Names
loop
1010 Decl
:= New_Node
(N_Object_Declaration
, Staloc
);
1011 Set_Constant_Present
(Decl
, True);
1014 A_Char
: constant Entity_Id
:= Standard_Entity
(S
);
1015 Expr_Decl
: Node_Id
;
1018 Set_Sloc
(A_Char
, Staloc
);
1019 Set_Ekind
(A_Char
, E_Constant
);
1020 Set_Never_Set_In_Source
(A_Char
, True);
1021 Set_Is_True_Constant
(A_Char
, True);
1022 Set_Etype
(A_Char
, Standard_Character
);
1023 Set_Scope
(A_Char
, Standard_Entity
(S_ASCII
));
1024 Set_Is_Immediately_Visible
(A_Char
, False);
1025 Set_Is_Public
(A_Char
, True);
1026 Set_Is_Known_Valid
(A_Char
, True);
1028 Append_Entity
(A_Char
, Standard_Entity
(S_ASCII
));
1029 Set_Defining_Identifier
(Decl
, A_Char
);
1031 Set_Object_Definition
(Decl
, Identifier_For
(S_Character
));
1032 Expr_Decl
:= New_Node
(N_Character_Literal
, Staloc
);
1033 Set_Expression
(Decl
, Expr_Decl
);
1035 Set_Is_Static_Expression
(Expr_Decl
);
1036 Set_Chars
(Expr_Decl
, No_Name
);
1037 Set_Etype
(Expr_Decl
, Standard_Character
);
1038 Set_Char_Literal_Value
(Expr_Decl
, UI_From_Int
(Int
(Ccode
)));
1041 Append
(Decl
, Decl_A
);
1043 -- Increment character code, dealing with non-contiguities
1047 if Ccode
= 16#
20#
then
1049 elsif Ccode
= 16#
27#
then
1051 elsif Ccode
= 16#
3C#
then
1053 elsif Ccode
= 16#
41#
then
1058 -- Create semantic phase entities
1060 Standard_Void_Type
:= New_Standard_Entity
;
1061 Set_Ekind
(Standard_Void_Type
, E_Void
);
1062 Set_Etype
(Standard_Void_Type
, Standard_Void_Type
);
1063 Set_Scope
(Standard_Void_Type
, Standard_Standard
);
1064 Make_Name
(Standard_Void_Type
, "_void_type");
1066 -- The type field of packages is set to void
1068 Set_Etype
(Standard_Standard
, Standard_Void_Type
);
1069 Set_Etype
(Standard_ASCII
, Standard_Void_Type
);
1071 -- Standard_A_String is actually used in generated code, so it has a
1072 -- type name that is reasonable, but does not overlap any Ada name.
1074 Standard_A_String
:= New_Standard_Entity
;
1075 Set_Ekind
(Standard_A_String
, E_Access_Type
);
1076 Set_Scope
(Standard_A_String
, Standard_Standard
);
1077 Set_Etype
(Standard_A_String
, Standard_A_String
);
1079 if Debug_Flag_6
then
1080 Init_Size
(Standard_A_String
, System_Address_Size
);
1082 Init_Size
(Standard_A_String
, System_Address_Size
* 2);
1085 Init_Alignment
(Standard_A_String
);
1087 Set_Directly_Designated_Type
1088 (Standard_A_String
, Standard_String
);
1089 Make_Name
(Standard_A_String
, "access_string");
1091 Standard_A_Char
:= New_Standard_Entity
;
1092 Set_Ekind
(Standard_A_Char
, E_Access_Type
);
1093 Set_Scope
(Standard_A_Char
, Standard_Standard
);
1094 Set_Etype
(Standard_A_Char
, Standard_A_String
);
1095 Init_Size
(Standard_A_Char
, System_Address_Size
);
1096 Set_Elem_Alignment
(Standard_A_Char
);
1098 Set_Directly_Designated_Type
(Standard_A_Char
, Standard_Character
);
1099 Make_Name
(Standard_A_Char
, "access_character");
1101 -- Standard_Debug_Renaming_Type is used for the special objects created
1102 -- to encode the names occurring in renaming declarations for use by the
1103 -- debugger (see exp_dbug.adb). The type is a zero-sized subtype of
1104 -- Standard.Integer.
1106 Standard_Debug_Renaming_Type
:= New_Standard_Entity
;
1108 Set_Ekind
(Standard_Debug_Renaming_Type
, E_Signed_Integer_Subtype
);
1109 Set_Scope
(Standard_Debug_Renaming_Type
, Standard_Standard
);
1110 Set_Etype
(Standard_Debug_Renaming_Type
, Base_Type
(Standard_Integer
));
1111 Init_Esize
(Standard_Debug_Renaming_Type
, 0);
1112 Init_RM_Size
(Standard_Debug_Renaming_Type
, 0);
1113 Set_Size_Known_At_Compile_Time
(Standard_Debug_Renaming_Type
);
1114 Set_Integer_Bounds
(Standard_Debug_Renaming_Type
,
1115 Typ
=> Base_Type
(Standard_Debug_Renaming_Type
),
1118 Set_Is_Constrained
(Standard_Debug_Renaming_Type
);
1119 Set_Has_Size_Clause
(Standard_Debug_Renaming_Type
);
1121 Make_Name
(Standard_Debug_Renaming_Type
, "_renaming_type");
1123 -- Note on type names. The type names for the following special types
1124 -- are constructed so that they will look reasonable should they ever
1125 -- appear in error messages etc, although in practice the use of the
1126 -- special insertion character } for types results in special handling
1127 -- of these type names in any case. The blanks in these names would
1128 -- trouble in Gigi, but that's OK here, since none of these types
1129 -- should ever get through to Gigi! Attributes of these types are
1130 -- filled out to minimize problems with cascaded errors (for example,
1131 -- Any_Integer is given reasonable and consistent type and size values)
1133 Any_Type
:= New_Standard_Entity
;
1134 Decl
:= New_Node
(N_Full_Type_Declaration
, Stloc
);
1135 Set_Defining_Identifier
(Decl
, Any_Type
);
1136 Set_Scope
(Any_Type
, Standard_Standard
);
1137 Build_Signed_Integer_Type
(Any_Type
, Standard_Integer_Size
);
1138 Make_Name
(Any_Type
, "any type");
1140 Any_Id
:= New_Standard_Entity
;
1141 Set_Ekind
(Any_Id
, E_Variable
);
1142 Set_Scope
(Any_Id
, Standard_Standard
);
1143 Set_Etype
(Any_Id
, Any_Type
);
1144 Init_Esize
(Any_Id
);
1145 Init_Alignment
(Any_Id
);
1146 Make_Name
(Any_Id
, "any id");
1148 Any_Access
:= New_Standard_Entity
;
1149 Set_Ekind
(Any_Access
, E_Access_Type
);
1150 Set_Scope
(Any_Access
, Standard_Standard
);
1151 Set_Etype
(Any_Access
, Any_Access
);
1152 Init_Size
(Any_Access
, System_Address_Size
);
1153 Set_Elem_Alignment
(Any_Access
);
1154 Make_Name
(Any_Access
, "an access type");
1156 Any_Character
:= New_Standard_Entity
;
1157 Set_Ekind
(Any_Character
, E_Enumeration_Type
);
1158 Set_Scope
(Any_Character
, Standard_Standard
);
1159 Set_Etype
(Any_Character
, Any_Character
);
1160 Set_Is_Unsigned_Type
(Any_Character
);
1161 Set_Is_Character_Type
(Any_Character
);
1162 Init_Esize
(Any_Character
, Standard_Character_Size
);
1163 Init_RM_Size
(Any_Character
, 8);
1164 Set_Elem_Alignment
(Any_Character
);
1165 Set_Scalar_Range
(Any_Character
, Scalar_Range
(Standard_Character
));
1166 Make_Name
(Any_Character
, "a character type");
1168 Any_Array
:= New_Standard_Entity
;
1169 Set_Ekind
(Any_Array
, E_String_Type
);
1170 Set_Scope
(Any_Array
, Standard_Standard
);
1171 Set_Etype
(Any_Array
, Any_Array
);
1172 Set_Component_Type
(Any_Array
, Any_Character
);
1173 Init_Size_Align
(Any_Array
);
1174 Make_Name
(Any_Array
, "an array type");
1176 Any_Boolean
:= New_Standard_Entity
;
1177 Set_Ekind
(Any_Boolean
, E_Enumeration_Type
);
1178 Set_Scope
(Any_Boolean
, Standard_Standard
);
1179 Set_Etype
(Any_Boolean
, Standard_Boolean
);
1180 Init_Esize
(Any_Boolean
, Standard_Character_Size
);
1181 Init_RM_Size
(Any_Boolean
, 1);
1182 Set_Elem_Alignment
(Any_Boolean
);
1183 Set_Is_Unsigned_Type
(Any_Boolean
);
1184 Set_Scalar_Range
(Any_Boolean
, Scalar_Range
(Standard_Boolean
));
1185 Make_Name
(Any_Boolean
, "a boolean type");
1187 Any_Composite
:= New_Standard_Entity
;
1188 Set_Ekind
(Any_Composite
, E_Array_Type
);
1189 Set_Scope
(Any_Composite
, Standard_Standard
);
1190 Set_Etype
(Any_Composite
, Any_Composite
);
1191 Set_Component_Size
(Any_Composite
, Uint_0
);
1192 Set_Component_Type
(Any_Composite
, Standard_Integer
);
1193 Init_Size_Align
(Any_Composite
);
1194 Make_Name
(Any_Composite
, "a composite type");
1196 Any_Discrete
:= New_Standard_Entity
;
1197 Set_Ekind
(Any_Discrete
, E_Signed_Integer_Type
);
1198 Set_Scope
(Any_Discrete
, Standard_Standard
);
1199 Set_Etype
(Any_Discrete
, Any_Discrete
);
1200 Init_Size
(Any_Discrete
, Standard_Integer_Size
);
1201 Set_Elem_Alignment
(Any_Discrete
);
1202 Make_Name
(Any_Discrete
, "a discrete type");
1204 Any_Fixed
:= New_Standard_Entity
;
1205 Set_Ekind
(Any_Fixed
, E_Ordinary_Fixed_Point_Type
);
1206 Set_Scope
(Any_Fixed
, Standard_Standard
);
1207 Set_Etype
(Any_Fixed
, Any_Fixed
);
1208 Init_Size
(Any_Fixed
, Standard_Integer_Size
);
1209 Set_Elem_Alignment
(Any_Fixed
);
1210 Make_Name
(Any_Fixed
, "a fixed-point type");
1212 Any_Integer
:= New_Standard_Entity
;
1213 Set_Ekind
(Any_Integer
, E_Signed_Integer_Type
);
1214 Set_Scope
(Any_Integer
, Standard_Standard
);
1215 Set_Etype
(Any_Integer
, Standard_Long_Long_Integer
);
1216 Init_Size
(Any_Integer
, Standard_Long_Long_Integer_Size
);
1217 Set_Elem_Alignment
(Any_Integer
);
1221 Typ
=> Base_Type
(Standard_Integer
),
1223 Hb
=> Intval
(High_Bound
(Scalar_Range
(Standard_Integer
))));
1224 Make_Name
(Any_Integer
, "an integer type");
1226 Any_Modular
:= New_Standard_Entity
;
1227 Set_Ekind
(Any_Modular
, E_Modular_Integer_Type
);
1228 Set_Scope
(Any_Modular
, Standard_Standard
);
1229 Set_Etype
(Any_Modular
, Standard_Long_Long_Integer
);
1230 Init_Size
(Any_Modular
, Standard_Long_Long_Integer_Size
);
1231 Set_Elem_Alignment
(Any_Modular
);
1232 Set_Is_Unsigned_Type
(Any_Modular
);
1233 Make_Name
(Any_Modular
, "a modular type");
1235 Any_Numeric
:= New_Standard_Entity
;
1236 Set_Ekind
(Any_Numeric
, E_Signed_Integer_Type
);
1237 Set_Scope
(Any_Numeric
, Standard_Standard
);
1238 Set_Etype
(Any_Numeric
, Standard_Long_Long_Integer
);
1239 Init_Size
(Any_Numeric
, Standard_Long_Long_Integer_Size
);
1240 Set_Elem_Alignment
(Any_Numeric
);
1241 Make_Name
(Any_Numeric
, "a numeric type");
1243 Any_Real
:= New_Standard_Entity
;
1244 Set_Ekind
(Any_Real
, E_Floating_Point_Type
);
1245 Set_Scope
(Any_Real
, Standard_Standard
);
1246 Set_Etype
(Any_Real
, Standard_Long_Long_Float
);
1247 Init_Size
(Any_Real
,
1248 UI_To_Int
(Esize
(Standard_Long_Long_Float
)));
1249 Set_Elem_Alignment
(Any_Real
);
1250 Make_Name
(Any_Real
, "a real type");
1252 Any_Scalar
:= New_Standard_Entity
;
1253 Set_Ekind
(Any_Scalar
, E_Signed_Integer_Type
);
1254 Set_Scope
(Any_Scalar
, Standard_Standard
);
1255 Set_Etype
(Any_Scalar
, Any_Scalar
);
1256 Init_Size
(Any_Scalar
, Standard_Integer_Size
);
1257 Set_Elem_Alignment
(Any_Scalar
);
1258 Make_Name
(Any_Scalar
, "a scalar type");
1260 Any_String
:= New_Standard_Entity
;
1261 Set_Ekind
(Any_String
, E_String_Type
);
1262 Set_Scope
(Any_String
, Standard_Standard
);
1263 Set_Etype
(Any_String
, Any_String
);
1264 Set_Component_Type
(Any_String
, Any_Character
);
1265 Init_Size_Align
(Any_String
);
1266 Make_Name
(Any_String
, "a string type");
1274 Low_Bound
=> Make_Integer
(Uint_0
),
1275 High_Bound
=> Make_Integer
(Uint_2
** Standard_Integer_Size
));
1276 Set_Etype
(Index
, Standard_Integer
);
1277 Set_First_Index
(Any_String
, Index
);
1280 Standard_Integer_8
:= New_Standard_Entity
;
1281 Decl
:= New_Node
(N_Full_Type_Declaration
, Stloc
);
1282 Set_Defining_Identifier
(Decl
, Standard_Integer_8
);
1283 Make_Name
(Standard_Integer_8
, "integer_8");
1284 Set_Scope
(Standard_Integer_8
, Standard_Standard
);
1285 Build_Signed_Integer_Type
(Standard_Integer_8
, 8);
1287 Standard_Integer_16
:= New_Standard_Entity
;
1288 Decl
:= New_Node
(N_Full_Type_Declaration
, Stloc
);
1289 Set_Defining_Identifier
(Decl
, Standard_Integer_16
);
1290 Make_Name
(Standard_Integer_16
, "integer_16");
1291 Set_Scope
(Standard_Integer_16
, Standard_Standard
);
1292 Build_Signed_Integer_Type
(Standard_Integer_16
, 16);
1294 Standard_Integer_32
:= New_Standard_Entity
;
1295 Decl
:= New_Node
(N_Full_Type_Declaration
, Stloc
);
1296 Set_Defining_Identifier
(Decl
, Standard_Integer_32
);
1297 Make_Name
(Standard_Integer_32
, "integer_32");
1298 Set_Scope
(Standard_Integer_32
, Standard_Standard
);
1299 Build_Signed_Integer_Type
(Standard_Integer_32
, 32);
1301 Standard_Integer_64
:= New_Standard_Entity
;
1302 Decl
:= New_Node
(N_Full_Type_Declaration
, Stloc
);
1303 Set_Defining_Identifier
(Decl
, Standard_Integer_64
);
1304 Make_Name
(Standard_Integer_64
, "integer_64");
1305 Set_Scope
(Standard_Integer_64
, Standard_Standard
);
1306 Build_Signed_Integer_Type
(Standard_Integer_64
, 64);
1308 -- Standard_Unsigned is not user visible, but is used internally. It
1309 -- is an unsigned type with the same length as Standard.Integer.
1311 Standard_Unsigned
:= New_Standard_Entity
;
1312 Decl
:= New_Node
(N_Full_Type_Declaration
, Stloc
);
1313 Set_Defining_Identifier
(Decl
, Standard_Unsigned
);
1314 Make_Name
(Standard_Unsigned
, "unsigned");
1316 Set_Ekind
(Standard_Unsigned
, E_Modular_Integer_Type
);
1317 Set_Scope
(Standard_Unsigned
, Standard_Standard
);
1318 Set_Etype
(Standard_Unsigned
, Standard_Unsigned
);
1319 Init_Size
(Standard_Unsigned
, Standard_Integer_Size
);
1320 Set_Elem_Alignment
(Standard_Unsigned
);
1321 Set_Modulus
(Standard_Unsigned
,
1322 Uint_2
** Standard_Integer_Size
);
1323 Set_Is_Unsigned_Type
(Standard_Unsigned
);
1324 Set_Size_Known_At_Compile_Time
1325 (Standard_Unsigned
);
1326 Set_Is_Known_Valid
(Standard_Unsigned
, True);
1328 R_Node
:= New_Node
(N_Range
, Stloc
);
1329 Set_Low_Bound
(R_Node
, Make_Integer
(Uint_0
));
1330 Set_High_Bound
(R_Node
, Make_Integer
(Modulus
(Standard_Unsigned
) - 1));
1331 Set_Etype
(Low_Bound
(R_Node
), Standard_Unsigned
);
1332 Set_Etype
(High_Bound
(R_Node
), Standard_Unsigned
);
1333 Set_Scalar_Range
(Standard_Unsigned
, R_Node
);
1335 -- Standard_Unsigned_64 is not user visible, but is used internally. It
1336 -- is an unsigned type mod 2**64, 64-bits unsigned, size is 64.
1338 Standard_Unsigned_64
:= New_Standard_Entity
;
1339 Decl
:= New_Node
(N_Full_Type_Declaration
, Stloc
);
1340 Set_Defining_Identifier
(Decl
, Standard_Unsigned_64
);
1341 Make_Name
(Standard_Unsigned_64
, "unsigned_64");
1343 Set_Ekind
(Standard_Unsigned_64
, E_Modular_Integer_Type
);
1344 Set_Scope
(Standard_Unsigned_64
, Standard_Standard
);
1345 Set_Etype
(Standard_Unsigned_64
, Standard_Unsigned_64
);
1346 Init_Size
(Standard_Unsigned_64
, 64);
1347 Set_Elem_Alignment
(Standard_Unsigned_64
);
1348 Set_Modulus
(Standard_Unsigned_64
, Uint_2
** 64);
1349 Set_Is_Unsigned_Type
(Standard_Unsigned_64
);
1350 Set_Size_Known_At_Compile_Time
1351 (Standard_Unsigned_64
);
1352 Set_Is_Known_Valid
(Standard_Unsigned_64
, True);
1354 R_Node
:= New_Node
(N_Range
, Stloc
);
1355 Set_Low_Bound
(R_Node
, Make_Integer
(Uint_0
));
1356 Set_High_Bound
(R_Node
, Make_Integer
(Uint_2
** 64 - 1));
1357 Set_Etype
(Low_Bound
(R_Node
), Standard_Unsigned_64
);
1358 Set_Etype
(High_Bound
(R_Node
), Standard_Unsigned_64
);
1359 Set_Scalar_Range
(Standard_Unsigned_64
, R_Node
);
1361 -- Note: universal integer and universal real are constructed as fully
1362 -- formed signed numeric types, with parameters corresponding to the
1363 -- longest runtime types (Long_Long_Integer and Long_Long_Float). This
1364 -- allows Gigi to properly process references to universal types that
1365 -- are not folded at compile time.
1367 Universal_Integer
:= New_Standard_Entity
;
1368 Decl
:= New_Node
(N_Full_Type_Declaration
, Stloc
);
1369 Set_Defining_Identifier
(Decl
, Universal_Integer
);
1370 Make_Name
(Universal_Integer
, "universal_integer");
1371 Set_Scope
(Universal_Integer
, Standard_Standard
);
1372 Build_Signed_Integer_Type
1373 (Universal_Integer
, Standard_Long_Long_Integer_Size
);
1375 Universal_Real
:= New_Standard_Entity
;
1376 Decl
:= New_Node
(N_Full_Type_Declaration
, Stloc
);
1377 Set_Defining_Identifier
(Decl
, Universal_Real
);
1378 Make_Name
(Universal_Real
, "universal_real");
1379 Set_Scope
(Universal_Real
, Standard_Standard
);
1380 Copy_Float_Type
(Universal_Real
, Standard_Long_Long_Float
);
1382 -- Note: universal fixed, unlike universal integer and universal real,
1383 -- is never used at runtime, so it does not need to have bounds set.
1385 Universal_Fixed
:= New_Standard_Entity
;
1386 Decl
:= New_Node
(N_Full_Type_Declaration
, Stloc
);
1387 Set_Defining_Identifier
(Decl
, Universal_Fixed
);
1388 Make_Name
(Universal_Fixed
, "universal_fixed");
1389 Set_Ekind
(Universal_Fixed
, E_Ordinary_Fixed_Point_Type
);
1390 Set_Etype
(Universal_Fixed
, Universal_Fixed
);
1391 Set_Scope
(Universal_Fixed
, Standard_Standard
);
1392 Init_Size
(Universal_Fixed
, Standard_Long_Long_Integer_Size
);
1393 Set_Elem_Alignment
(Universal_Fixed
);
1394 Set_Size_Known_At_Compile_Time
1397 -- Create type declaration for Duration, using a 64-bit size. The
1398 -- delta and size values depend on the mode set in system.ads.
1400 Build_Duration
: declare
1406 -- In 32 bit mode, the size is 32 bits, and the delta and
1407 -- small values are set to 20 milliseconds (20.0*(10.0**(-3)).
1409 if Duration_32_Bits_On_Target
then
1410 Dlo
:= Intval
(Type_Low_Bound
(Standard_Integer_32
));
1411 Dhi
:= Intval
(Type_High_Bound
(Standard_Integer_32
));
1412 Delta_Val
:= UR_From_Components
(UI_From_Int
(20), Uint_3
, 10);
1414 -- In standard 64-bit mode, the size is 64-bits and the delta and
1415 -- small values are set to nanoseconds (1.0*(10.0**(-9))
1418 Dlo
:= Intval
(Type_Low_Bound
(Standard_Integer_64
));
1419 Dhi
:= Intval
(Type_High_Bound
(Standard_Integer_64
));
1420 Delta_Val
:= UR_From_Components
(Uint_1
, Uint_9
, 10);
1423 Tdef_Node
:= Make_Ordinary_Fixed_Point_Definition
(Stloc
,
1424 Delta_Expression
=> Make_Real_Literal
(Stloc
, Delta_Val
),
1425 Real_Range_Specification
=>
1426 Make_Real_Range_Specification
(Stloc
,
1427 Low_Bound
=> Make_Real_Literal
(Stloc
,
1428 Realval
=> Dlo
* Delta_Val
),
1429 High_Bound
=> Make_Real_Literal
(Stloc
,
1430 Realval
=> Dhi
* Delta_Val
)));
1432 Set_Type_Definition
(Parent
(Standard_Duration
), Tdef_Node
);
1434 Set_Ekind
(Standard_Duration
, E_Ordinary_Fixed_Point_Type
);
1435 Set_Etype
(Standard_Duration
, Standard_Duration
);
1437 if Duration_32_Bits_On_Target
then
1438 Init_Size
(Standard_Duration
, 32);
1440 Init_Size
(Standard_Duration
, 64);
1443 Set_Elem_Alignment
(Standard_Duration
);
1444 Set_Delta_Value
(Standard_Duration
, Delta_Val
);
1445 Set_Small_Value
(Standard_Duration
, Delta_Val
);
1446 Set_Scalar_Range
(Standard_Duration
,
1447 Real_Range_Specification
1448 (Type_Definition
(Parent
(Standard_Duration
))));
1450 -- Normally it does not matter that nodes in package Standard are
1451 -- not marked as analyzed. The Scalar_Range of the fixed-point type
1452 -- Standard_Duration is an exception, because of the special test
1453 -- made in Freeze.Freeze_Fixed_Point_Type.
1455 Set_Analyzed
(Scalar_Range
(Standard_Duration
));
1457 Set_Etype
(Type_High_Bound
(Standard_Duration
), Standard_Duration
);
1458 Set_Etype
(Type_Low_Bound
(Standard_Duration
), Standard_Duration
);
1460 Set_Is_Static_Expression
(Type_High_Bound
(Standard_Duration
));
1461 Set_Is_Static_Expression
(Type_Low_Bound
(Standard_Duration
));
1463 Set_Corresponding_Integer_Value
1464 (Type_High_Bound
(Standard_Duration
), Dhi
);
1466 Set_Corresponding_Integer_Value
1467 (Type_Low_Bound
(Standard_Duration
), Dlo
);
1469 Set_Size_Known_At_Compile_Time
(Standard_Duration
);
1472 -- Build standard exception type. Note that the type name here is
1473 -- actually used in the generated code, so it must be set correctly.
1474 -- The type Standard_Exception_Type must be consistent with the type
1475 -- System.Standard_Library.Exception_Data, as the latter is what is
1476 -- known by the run-time. Components of the record are documented in
1477 -- the declaration in System.Standard_Library.
1479 Standard_Exception_Type
:= New_Standard_Entity
;
1480 Set_Ekind
(Standard_Exception_Type
, E_Record_Type
);
1481 Set_Etype
(Standard_Exception_Type
, Standard_Exception_Type
);
1482 Set_Scope
(Standard_Exception_Type
, Standard_Standard
);
1483 Set_Stored_Constraint
1484 (Standard_Exception_Type
, No_Elist
);
1485 Init_Size_Align
(Standard_Exception_Type
);
1486 Set_Size_Known_At_Compile_Time
1487 (Standard_Exception_Type
, True);
1488 Make_Name
(Standard_Exception_Type
, "exception");
1491 (Standard_Exception_Type
, Standard_Boolean
, "Not_Handled_By_Others");
1493 (Standard_Exception_Type
, Standard_Character
, "Lang");
1495 (Standard_Exception_Type
, Standard_Natural
, "Name_Length");
1497 (Standard_Exception_Type
, Standard_A_Char
, "Full_Name");
1499 (Standard_Exception_Type
, Standard_A_Char
, "HTable_Ptr");
1501 (Standard_Exception_Type
, Standard_A_Char
, "Foreign_Data");
1503 (Standard_Exception_Type
, Standard_A_Char
, "Raise_Hook");
1505 -- Build tree for record declaration, for use by the back-end
1508 Comp_List
: List_Id
;
1512 Comp
:= First_Entity
(Standard_Exception_Type
);
1513 Comp_List
:= New_List
;
1514 while Present
(Comp
) loop
1516 Make_Component_Declaration
(Stloc
,
1517 Defining_Identifier
=> Comp
,
1518 Component_Definition
=>
1519 Make_Component_Definition
(Stloc
,
1520 Aliased_Present
=> False,
1521 Subtype_Indication
=> New_Occurrence_Of
(Etype
(Comp
),
1528 Decl
:= Make_Full_Type_Declaration
(Stloc
,
1529 Defining_Identifier
=> Standard_Exception_Type
,
1531 Make_Record_Definition
(Stloc
,
1534 Make_Component_List
(Stloc
,
1535 Component_Items
=> Comp_List
)));
1538 Append
(Decl
, Decl_S
);
1540 Layout_Type
(Standard_Exception_Type
);
1542 -- Create declarations of standard exceptions
1544 Build_Exception
(S_Constraint_Error
);
1545 Build_Exception
(S_Program_Error
);
1546 Build_Exception
(S_Storage_Error
);
1547 Build_Exception
(S_Tasking_Error
);
1549 -- Numeric_Error is a normal exception in Ada 83, but in Ada 95
1550 -- it is a renaming of Constraint_Error. Is this test too early???
1552 if Ada_Version
= Ada_83
then
1553 Build_Exception
(S_Numeric_Error
);
1556 Decl
:= New_Node
(N_Exception_Renaming_Declaration
, Stloc
);
1557 E_Id
:= Standard_Entity
(S_Numeric_Error
);
1559 Set_Ekind
(E_Id
, E_Exception
);
1560 Set_Exception_Code
(E_Id
, Uint_0
);
1561 Set_Etype
(E_Id
, Standard_Exception_Type
);
1562 Set_Is_Public
(E_Id
);
1563 Set_Renamed_Entity
(E_Id
, Standard_Entity
(S_Constraint_Error
));
1565 Set_Defining_Identifier
(Decl
, E_Id
);
1566 Append
(Decl
, Decl_S
);
1568 Ident_Node
:= New_Node
(N_Identifier
, Stloc
);
1569 Set_Chars
(Ident_Node
, Chars
(Standard_Entity
(S_Constraint_Error
)));
1570 Set_Entity
(Ident_Node
, Standard_Entity
(S_Constraint_Error
));
1571 Set_Name
(Decl
, Ident_Node
);
1574 -- Abort_Signal is an entity that does not get made visible
1576 Abort_Signal
:= New_Standard_Entity
;
1577 Set_Chars
(Abort_Signal
, Name_uAbort_Signal
);
1578 Set_Ekind
(Abort_Signal
, E_Exception
);
1579 Set_Exception_Code
(Abort_Signal
, Uint_0
);
1580 Set_Etype
(Abort_Signal
, Standard_Exception_Type
);
1581 Set_Scope
(Abort_Signal
, Standard_Standard
);
1582 Set_Is_Public
(Abort_Signal
, True);
1584 Make_Exception_Declaration
(Stloc
,
1585 Defining_Identifier
=> Abort_Signal
);
1587 -- Create defining identifiers for shift operator entities. Note
1588 -- that these entities are used only for marking shift operators
1589 -- generated internally, and hence need no structure, just a name
1590 -- and a unique identity.
1592 Standard_Op_Rotate_Left
:= New_Standard_Entity
;
1593 Set_Chars
(Standard_Op_Rotate_Left
, Name_Rotate_Left
);
1594 Set_Ekind
(Standard_Op_Rotate_Left
, E_Operator
);
1596 Standard_Op_Rotate_Right
:= New_Standard_Entity
;
1597 Set_Chars
(Standard_Op_Rotate_Right
, Name_Rotate_Right
);
1598 Set_Ekind
(Standard_Op_Rotate_Right
, E_Operator
);
1600 Standard_Op_Shift_Left
:= New_Standard_Entity
;
1601 Set_Chars
(Standard_Op_Shift_Left
, Name_Shift_Left
);
1602 Set_Ekind
(Standard_Op_Shift_Left
, E_Operator
);
1604 Standard_Op_Shift_Right
:= New_Standard_Entity
;
1605 Set_Chars
(Standard_Op_Shift_Right
, Name_Shift_Right
);
1606 Set_Ekind
(Standard_Op_Shift_Right
, E_Operator
);
1608 Standard_Op_Shift_Right_Arithmetic
:= New_Standard_Entity
;
1609 Set_Chars
(Standard_Op_Shift_Right_Arithmetic
,
1610 Name_Shift_Right_Arithmetic
);
1611 Set_Ekind
(Standard_Op_Shift_Right_Arithmetic
,
1614 -- Create standard operator declarations
1618 -- Initialize visibility table with entities in Standard
1620 for E
in Standard_Entity_Type
loop
1621 if Ekind
(Standard_Entity
(E
)) /= E_Operator
then
1623 (Chars
(Standard_Entity
(E
)), Standard_Entity
(E
));
1624 Set_Homonym
(Standard_Entity
(E
), Empty
);
1627 if E
not in S_ASCII_Names
then
1628 Set_Scope
(Standard_Entity
(E
), Standard_Standard
);
1629 Set_Is_Immediately_Visible
(Standard_Entity
(E
));
1633 -- The predefined package Standard itself does not have a scope;
1634 -- it is the only entity in the system not to have one, and this
1635 -- is what identifies the package to Gigi.
1637 Set_Scope
(Standard_Standard
, Empty
);
1639 -- Set global variables indicating last Id values and version
1641 Last_Standard_Node_Id
:= Last_Node_Id
;
1642 Last_Standard_List_Id
:= Last_List_Id
;
1644 -- The Error node has an Etype of Any_Type to help error recovery
1646 Set_Etype
(Error
, Any_Type
);
1648 -- Print representation of standard if switch set
1650 if Opt
.Print_Standard
then
1653 end Create_Standard
;
1655 ------------------------------------
1656 -- Create_Unconstrained_Base_Type --
1657 ------------------------------------
1659 procedure Create_Unconstrained_Base_Type
1663 New_Ent
: constant Entity_Id
:= New_Copy
(E
);
1667 Set_Is_Constrained
(E
, True);
1668 Set_Is_First_Subtype
(E
, True);
1669 Set_Etype
(E
, New_Ent
);
1671 Append_Entity
(New_Ent
, Standard_Standard
);
1672 Set_Is_Constrained
(New_Ent
, False);
1673 Set_Etype
(New_Ent
, New_Ent
);
1674 Set_Is_Known_Valid
(New_Ent
, True);
1676 if K
= E_Signed_Integer_Subtype
then
1677 Set_Etype
(Low_Bound
(Scalar_Range
(E
)), New_Ent
);
1678 Set_Etype
(High_Bound
(Scalar_Range
(E
)), New_Ent
);
1681 end Create_Unconstrained_Base_Type
;
1683 --------------------
1684 -- Identifier_For --
1685 --------------------
1687 function Identifier_For
(S
: Standard_Entity_Type
) return Node_Id
is
1688 Ident_Node
: Node_Id
;
1690 Ident_Node
:= New_Node
(N_Identifier
, Stloc
);
1691 Set_Chars
(Ident_Node
, Chars
(Standard_Entity
(S
)));
1692 Set_Entity
(Ident_Node
, Standard_Entity
(S
));
1696 --------------------
1697 -- Make_Component --
1698 --------------------
1700 procedure Make_Component
1705 Id
: constant Entity_Id
:= New_Standard_Entity
;
1708 Set_Ekind
(Id
, E_Component
);
1709 Set_Etype
(Id
, Typ
);
1710 Set_Scope
(Id
, Rec
);
1711 Init_Component_Location
(Id
);
1713 Set_Original_Record_Component
(Id
, Id
);
1714 Make_Name
(Id
, Nam
);
1715 Append_Entity
(Id
, Rec
);
1722 function Make_Formal
1724 Formal_Name
: String) return Entity_Id
1729 Formal
:= New_Standard_Entity
;
1731 Set_Ekind
(Formal
, E_In_Parameter
);
1732 Set_Mechanism
(Formal
, Default_Mechanism
);
1733 Set_Scope
(Formal
, Standard_Standard
);
1734 Set_Etype
(Formal
, Typ
);
1735 Make_Name
(Formal
, Formal_Name
);
1744 function Make_Integer
(V
: Uint
) return Node_Id
is
1745 N
: constant Node_Id
:= Make_Integer_Literal
(Stloc
, V
);
1747 Set_Is_Static_Expression
(N
);
1755 procedure Make_Name
(Id
: Entity_Id
; Nam
: String) is
1757 for J
in 1 .. Nam
'Length loop
1758 Name_Buffer
(J
) := Fold_Lower
(Nam
(Nam
'First + (J
- 1)));
1761 Name_Len
:= Nam
'Length;
1762 Set_Chars
(Id
, Name_Find
);
1769 function New_Operator
(Op
: Name_Id
; Typ
: Entity_Id
) return Entity_Id
is
1770 Ident_Node
: Entity_Id
;
1773 Ident_Node
:= Make_Defining_Identifier
(Stloc
, Op
);
1775 Set_Is_Pure
(Ident_Node
, True);
1776 Set_Ekind
(Ident_Node
, E_Operator
);
1777 Set_Etype
(Ident_Node
, Typ
);
1778 Set_Scope
(Ident_Node
, Standard_Standard
);
1779 Set_Homonym
(Ident_Node
, Get_Name_Entity_Id
(Op
));
1780 Set_Convention
(Ident_Node
, Convention_Intrinsic
);
1782 Set_Is_Immediately_Visible
(Ident_Node
, True);
1783 Set_Is_Intrinsic_Subprogram
(Ident_Node
, True);
1785 Set_Name_Entity_Id
(Op
, Ident_Node
);
1786 Append_Entity
(Ident_Node
, Standard_Standard
);
1790 -------------------------
1791 -- New_Standard_Entity --
1792 -------------------------
1794 function New_Standard_Entity
1795 (New_Node_Kind
: Node_Kind
:= N_Defining_Identifier
) return Entity_Id
1797 E
: constant Entity_Id
:= New_Entity
(New_Node_Kind
, Stloc
);
1800 -- All standard entities are Pure and Public
1805 -- All standard entity names are analyzed manually, and are thus
1806 -- frozen as soon as they are created.
1810 -- Set debug information required for all standard types
1812 Set_Needs_Debug_Info
(E
);
1814 -- All standard entities are built with fully qualified names, so
1815 -- set the flag to prevent an abortive attempt at requalification!
1817 Set_Has_Qualified_Name
(E
);
1819 -- Return newly created entity to be completed by caller
1822 end New_Standard_Entity
;
1824 --------------------
1825 -- Print_Standard --
1826 --------------------
1828 procedure Print_Standard
is
1830 procedure P
(Item
: String) renames Output
.Write_Line
;
1831 -- Short-hand, since we do a lot of line writes here!
1833 procedure P_Int_Range
(Size
: Pos
);
1834 -- Prints the range of an integer based on its Size
1836 procedure P_Float_Range
(Id
: Entity_Id
);
1837 -- Prints the bounds range for the given float type entity
1839 procedure P_Float_Type
(Id
: Entity_Id
);
1840 -- Prints the type declaration of the given float type entity
1842 procedure P_Mixed_Name
(Id
: Name_Id
);
1843 -- Prints Id in mixed case
1849 procedure P_Float_Range
(Id
: Entity_Id
) is
1851 Write_Str
(" range ");
1852 UR_Write
(Realval
(Type_Low_Bound
(Id
)));
1854 UR_Write
(Realval
(Type_High_Bound
(Id
)));
1863 procedure P_Float_Type
(Id
: Entity_Id
) is
1865 Write_Str
(" type ");
1866 P_Mixed_Name
(Chars
(Id
));
1867 Write_Str
(" is digits ");
1868 Write_Int
(UI_To_Int
(Digits_Value
(Id
)));
1871 Write_Str
(" for ");
1872 P_Mixed_Name
(Chars
(Id
));
1873 Write_Str
("'Size use ");
1874 Write_Int
(UI_To_Int
(RM_Size
(Id
)));
1883 procedure P_Int_Range
(Size
: Pos
) is
1885 Write_Str
(" is range -(2 **");
1886 Write_Int
(Size
- 1);
1888 Write_Str
(" .. +(2 **");
1889 Write_Int
(Size
- 1);
1890 Write_Str
(" - 1);");
1898 procedure P_Mixed_Name
(Id
: Name_Id
) is
1900 Get_Name_String
(Id
);
1902 for J
in 1 .. Name_Len
loop
1903 if J
= 1 or else Name_Buffer
(J
- 1) = '_' then
1904 Name_Buffer
(J
) := Fold_Upper
(Name_Buffer
(J
));
1908 Write_Str
(Name_Buffer
(1 .. Name_Len
));
1911 -- Start of processing for Print_Standard
1914 P
("-- Representation of package Standard");
1916 P
("-- This is not accurate Ada, since new base types cannot be ");
1917 P
("-- created, but the listing shows the target dependent");
1918 P
("-- characteristics of the Standard types for this compiler");
1921 P
("package Standard is");
1922 P
("pragma Pure (Standard);");
1925 P
(" type Boolean is (False, True);");
1926 P
(" for Boolean'Size use 1;");
1927 P
(" for Boolean use (False => 0, True => 1);");
1932 Write_Str
(" type Integer");
1933 P_Int_Range
(Standard_Integer_Size
);
1934 Write_Str
(" for Integer'Size use ");
1935 Write_Int
(Standard_Integer_Size
);
1939 P
(" subtype Natural is Integer range 0 .. Integer'Last;");
1940 P
(" subtype Positive is Integer range 1 .. Integer'Last;");
1943 Write_Str
(" type Short_Short_Integer");
1944 P_Int_Range
(Standard_Short_Short_Integer_Size
);
1945 Write_Str
(" for Short_Short_Integer'Size use ");
1946 Write_Int
(Standard_Short_Short_Integer_Size
);
1950 Write_Str
(" type Short_Integer");
1951 P_Int_Range
(Standard_Short_Integer_Size
);
1952 Write_Str
(" for Short_Integer'Size use ");
1953 Write_Int
(Standard_Short_Integer_Size
);
1957 Write_Str
(" type Long_Integer");
1958 P_Int_Range
(Standard_Long_Integer_Size
);
1959 Write_Str
(" for Long_Integer'Size use ");
1960 Write_Int
(Standard_Long_Integer_Size
);
1964 Write_Str
(" type Long_Long_Integer");
1965 P_Int_Range
(Standard_Long_Long_Integer_Size
);
1966 Write_Str
(" for Long_Long_Integer'Size use ");
1967 Write_Int
(Standard_Long_Long_Integer_Size
);
1971 -- Floating point types
1973 P_Float_Type
(Standard_Short_Float
);
1974 P_Float_Type
(Standard_Float
);
1975 P_Float_Type
(Standard_Long_Float
);
1976 P_Float_Type
(Standard_Long_Long_Float
);
1978 P
(" type Character is (...)");
1979 Write_Str
(" for Character'Size use ");
1980 Write_Int
(Standard_Character_Size
);
1982 P
(" -- See RM A.1(35) for details of this type");
1985 P
(" type Wide_Character is (...)");
1986 Write_Str
(" for Wide_Character'Size use ");
1987 Write_Int
(Standard_Wide_Character_Size
);
1989 P
(" -- See RM A.1(36) for details of this type");
1992 P
(" type Wide_Wide_Character is (...)");
1993 Write_Str
(" for Wide_Wide_Character'Size use ");
1994 Write_Int
(Standard_Wide_Wide_Character_Size
);
1996 P
(" -- See RM A.1(36) for details of this type");
1998 P
(" type String is array (Positive range <>) of Character;");
1999 P
(" pragma Pack (String);");
2002 P
(" type Wide_String is array (Positive range <>)" &
2003 " of Wide_Character;");
2004 P
(" pragma Pack (Wide_String);");
2007 P
(" type Wide_Wide_String is array (Positive range <>)" &
2008 " of Wide_Wide_Character;");
2009 P
(" pragma Pack (Wide_Wide_String);");
2012 -- We only have one representation each for 32-bit and 64-bit sizes,
2013 -- so select the right one based on Duration_32_Bits_On_Target.
2015 if Duration_32_Bits_On_Target
then
2016 P
(" type Duration is delta 0.020");
2017 P
(" range -((2 ** 31 - 1) * 0.020) ..");
2018 P
(" +((2 ** 31 - 1) * 0.020);");
2019 P
(" for Duration'Small use 0.020;");
2022 P
(" type Duration is delta 0.000000001");
2023 P
(" range -((2 ** 63 - 1) * 0.000000001) ..");
2024 P
(" +((2 ** 63 - 1) * 0.000000001);");
2025 P
(" for Duration'Small use 0.000000001;");
2030 P
(" Constraint_Error : exception;");
2031 P
(" Program_Error : exception;");
2032 P
(" Storage_Error : exception;");
2033 P
(" Tasking_Error : exception;");
2034 P
(" Numeric_Error : exception renames Constraint_Error;");
2037 P
("end Standard;");
2040 -------------------------
2041 -- Register_Float_Type --
2042 -------------------------
2044 procedure Register_Float_Type
2047 Float_Rep
: Float_Rep_Kind
;
2049 Alignment
: Natural)
2051 Ent
: constant Entity_Id
:= New_Standard_Entity
;
2052 Esize
: constant Pos
:=
2053 Pos
((Size
+ Alignment
- 1) / Alignment
* Alignment
);
2056 Set_Defining_Identifier
(New_Node
(N_Full_Type_Declaration
, Stloc
), Ent
);
2057 Make_Name
(Ent
, Name
);
2058 Set_Scope
(Ent
, Standard_Standard
);
2059 Build_Float_Type
(Ent
, Esize
, Float_Rep
, Pos
(Digs
));
2060 Set_RM_Size
(Ent
, UI_From_Int
(Int
(Size
)));
2061 Set_Alignment
(Ent
, UI_From_Int
(Int
(Alignment
/ 8)));
2063 if No
(Back_End_Float_Types
) then
2064 Back_End_Float_Types
:= New_Elmt_List
;
2067 Append_Elmt
(Ent
, Back_End_Float_Types
);
2068 end Register_Float_Type
;
2070 ----------------------
2071 -- Set_Float_Bounds --
2072 ----------------------
2074 procedure Set_Float_Bounds
(Id
: Entity_Id
) is
2077 -- Low and high bounds of literal value
2080 -- Range specification
2082 Radix
: constant Uint
:= Machine_Radix_Value
(Id
);
2083 Mantissa
: constant Uint
:= Machine_Mantissa_Value
(Id
);
2084 Emax
: constant Uint
:= Machine_Emax_Value
(Id
);
2085 Significand
: constant Uint
:= Radix
** Mantissa
- 1;
2086 Exponent
: constant Uint
:= Emax
- Mantissa
;
2089 -- Note: for the call from Cstand to initially create the types in
2090 -- Standard, Float_Rep will never be VAX_Native. Circuitry in Sem_Vfpt
2091 -- will adjust these types appropriately VAX_Native if a pragma
2092 -- Float_Representation (VAX_Float) is used.
2094 H
:= Make_Float_Literal
(Stloc
, Radix
, Significand
, Exponent
);
2095 L
:= Make_Float_Literal
(Stloc
, Radix
, -Significand
, Exponent
);
2098 Set_Is_Static_Expression
(L
);
2101 Set_Is_Static_Expression
(H
);
2103 R
:= New_Node
(N_Range
, Stloc
);
2104 Set_Low_Bound
(R
, L
);
2105 Set_High_Bound
(R
, H
);
2106 Set_Includes_Infinities
(R
, True);
2107 Set_Scalar_Range
(Id
, R
);
2110 end Set_Float_Bounds
;
2112 ------------------------
2113 -- Set_Integer_Bounds --
2114 ------------------------
2116 procedure Set_Integer_Bounds
2124 -- Low and high bounds of literal value
2127 -- Range specification
2130 L
:= Make_Integer
(Lb
);
2131 H
:= Make_Integer
(Hb
);
2136 R
:= New_Node
(N_Range
, Stloc
);
2137 Set_Low_Bound
(R
, L
);
2138 Set_High_Bound
(R
, H
);
2139 Set_Scalar_Range
(Id
, R
);
2142 Set_Is_Unsigned_Type
(Id
, Lb
>= 0);
2143 end Set_Integer_Bounds
;