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
:= New_Standard_Entity
;
1309 Decl
:= New_Node
(N_Full_Type_Declaration
, Stloc
);
1310 Set_Defining_Identifier
(Decl
, Standard_Unsigned
);
1311 Make_Name
(Standard_Unsigned
, "unsigned");
1313 Set_Ekind
(Standard_Unsigned
, E_Modular_Integer_Type
);
1314 Set_Scope
(Standard_Unsigned
, Standard_Standard
);
1315 Set_Etype
(Standard_Unsigned
, Standard_Unsigned
);
1316 Init_Size
(Standard_Unsigned
, Standard_Integer_Size
);
1317 Set_Elem_Alignment
(Standard_Unsigned
);
1318 Set_Modulus
(Standard_Unsigned
,
1319 Uint_2
** Standard_Integer_Size
);
1320 Set_Is_Unsigned_Type
(Standard_Unsigned
);
1321 Set_Size_Known_At_Compile_Time
1322 (Standard_Unsigned
);
1323 Set_Is_Known_Valid
(Standard_Unsigned
, True);
1325 R_Node
:= New_Node
(N_Range
, Stloc
);
1326 Set_Low_Bound
(R_Node
, Make_Integer
(Uint_0
));
1327 Set_High_Bound
(R_Node
, Make_Integer
(Modulus
(Standard_Unsigned
) - 1));
1328 Set_Etype
(Low_Bound
(R_Node
), Standard_Unsigned
);
1329 Set_Etype
(High_Bound
(R_Node
), Standard_Unsigned
);
1330 Set_Scalar_Range
(Standard_Unsigned
, R_Node
);
1332 -- Note: universal integer and universal real are constructed as fully
1333 -- formed signed numeric types, with parameters corresponding to the
1334 -- longest runtime types (Long_Long_Integer and Long_Long_Float). This
1335 -- allows Gigi to properly process references to universal types that
1336 -- are not folded at compile time.
1338 Universal_Integer
:= New_Standard_Entity
;
1339 Decl
:= New_Node
(N_Full_Type_Declaration
, Stloc
);
1340 Set_Defining_Identifier
(Decl
, Universal_Integer
);
1341 Make_Name
(Universal_Integer
, "universal_integer");
1342 Set_Scope
(Universal_Integer
, Standard_Standard
);
1343 Build_Signed_Integer_Type
1344 (Universal_Integer
, Standard_Long_Long_Integer_Size
);
1346 Universal_Real
:= New_Standard_Entity
;
1347 Decl
:= New_Node
(N_Full_Type_Declaration
, Stloc
);
1348 Set_Defining_Identifier
(Decl
, Universal_Real
);
1349 Make_Name
(Universal_Real
, "universal_real");
1350 Set_Scope
(Universal_Real
, Standard_Standard
);
1351 Copy_Float_Type
(Universal_Real
, Standard_Long_Long_Float
);
1353 -- Note: universal fixed, unlike universal integer and universal real,
1354 -- is never used at runtime, so it does not need to have bounds set.
1356 Universal_Fixed
:= New_Standard_Entity
;
1357 Decl
:= New_Node
(N_Full_Type_Declaration
, Stloc
);
1358 Set_Defining_Identifier
(Decl
, Universal_Fixed
);
1359 Make_Name
(Universal_Fixed
, "universal_fixed");
1360 Set_Ekind
(Universal_Fixed
, E_Ordinary_Fixed_Point_Type
);
1361 Set_Etype
(Universal_Fixed
, Universal_Fixed
);
1362 Set_Scope
(Universal_Fixed
, Standard_Standard
);
1363 Init_Size
(Universal_Fixed
, Standard_Long_Long_Integer_Size
);
1364 Set_Elem_Alignment
(Universal_Fixed
);
1365 Set_Size_Known_At_Compile_Time
1368 -- Create type declaration for Duration, using a 64-bit size. The
1369 -- delta and size values depend on the mode set in system.ads.
1371 Build_Duration
: declare
1377 -- In 32 bit mode, the size is 32 bits, and the delta and
1378 -- small values are set to 20 milliseconds (20.0*(10.0**(-3)).
1380 if Duration_32_Bits_On_Target
then
1381 Dlo
:= Intval
(Type_Low_Bound
(Standard_Integer_32
));
1382 Dhi
:= Intval
(Type_High_Bound
(Standard_Integer_32
));
1383 Delta_Val
:= UR_From_Components
(UI_From_Int
(20), Uint_3
, 10);
1385 -- In standard 64-bit mode, the size is 64-bits and the delta and
1386 -- small values are set to nanoseconds (1.0*(10.0**(-9))
1389 Dlo
:= Intval
(Type_Low_Bound
(Standard_Integer_64
));
1390 Dhi
:= Intval
(Type_High_Bound
(Standard_Integer_64
));
1391 Delta_Val
:= UR_From_Components
(Uint_1
, Uint_9
, 10);
1394 Tdef_Node
:= Make_Ordinary_Fixed_Point_Definition
(Stloc
,
1395 Delta_Expression
=> Make_Real_Literal
(Stloc
, Delta_Val
),
1396 Real_Range_Specification
=>
1397 Make_Real_Range_Specification
(Stloc
,
1398 Low_Bound
=> Make_Real_Literal
(Stloc
,
1399 Realval
=> Dlo
* Delta_Val
),
1400 High_Bound
=> Make_Real_Literal
(Stloc
,
1401 Realval
=> Dhi
* Delta_Val
)));
1403 Set_Type_Definition
(Parent
(Standard_Duration
), Tdef_Node
);
1405 Set_Ekind
(Standard_Duration
, E_Ordinary_Fixed_Point_Type
);
1406 Set_Etype
(Standard_Duration
, Standard_Duration
);
1408 if Duration_32_Bits_On_Target
then
1409 Init_Size
(Standard_Duration
, 32);
1411 Init_Size
(Standard_Duration
, 64);
1414 Set_Elem_Alignment
(Standard_Duration
);
1415 Set_Delta_Value
(Standard_Duration
, Delta_Val
);
1416 Set_Small_Value
(Standard_Duration
, Delta_Val
);
1417 Set_Scalar_Range
(Standard_Duration
,
1418 Real_Range_Specification
1419 (Type_Definition
(Parent
(Standard_Duration
))));
1421 -- Normally it does not matter that nodes in package Standard are
1422 -- not marked as analyzed. The Scalar_Range of the fixed-point
1423 -- type Standard_Duration is an exception, because of the special
1424 -- test made in Freeze.Freeze_Fixed_Point_Type.
1426 Set_Analyzed
(Scalar_Range
(Standard_Duration
));
1428 Set_Etype
(Type_High_Bound
(Standard_Duration
), Standard_Duration
);
1429 Set_Etype
(Type_Low_Bound
(Standard_Duration
), Standard_Duration
);
1431 Set_Is_Static_Expression
(Type_High_Bound
(Standard_Duration
));
1432 Set_Is_Static_Expression
(Type_Low_Bound
(Standard_Duration
));
1434 Set_Corresponding_Integer_Value
1435 (Type_High_Bound
(Standard_Duration
), Dhi
);
1437 Set_Corresponding_Integer_Value
1438 (Type_Low_Bound
(Standard_Duration
), Dlo
);
1440 Set_Size_Known_At_Compile_Time
(Standard_Duration
);
1443 -- Build standard exception type. Note that the type name here is
1444 -- actually used in the generated code, so it must be set correctly
1446 -- ??? Also note that the Import_Code component is now declared
1447 -- as a System.Standard_Library.Exception_Code to enforce run-time
1448 -- library implementation consistency. It's too early here to resort
1449 -- to rtsfind to get the proper node for that type, so we use the
1450 -- closest possible available type node at hand instead. We should
1451 -- probably be fixing this up at some point.
1453 Standard_Exception_Type
:= New_Standard_Entity
;
1454 Set_Ekind
(Standard_Exception_Type
, E_Record_Type
);
1455 Set_Etype
(Standard_Exception_Type
, Standard_Exception_Type
);
1456 Set_Scope
(Standard_Exception_Type
, Standard_Standard
);
1457 Set_Stored_Constraint
1458 (Standard_Exception_Type
, No_Elist
);
1459 Init_Size_Align
(Standard_Exception_Type
);
1460 Set_Size_Known_At_Compile_Time
1461 (Standard_Exception_Type
, True);
1462 Make_Name
(Standard_Exception_Type
, "exception");
1465 (Standard_Exception_Type
, Standard_Boolean
, "Not_Handled_By_Others");
1467 (Standard_Exception_Type
, Standard_Character
, "Lang");
1469 (Standard_Exception_Type
, Standard_Natural
, "Name_Length");
1471 (Standard_Exception_Type
, Standard_A_Char
, "Full_Name");
1473 (Standard_Exception_Type
, Standard_A_Char
, "HTable_Ptr");
1475 (Standard_Exception_Type
, Standard_Unsigned
, "Import_Code");
1477 (Standard_Exception_Type
, Standard_A_Char
, "Raise_Hook");
1479 -- Build tree for record declaration, for use by the back-end
1482 Comp_List
: List_Id
;
1486 Comp
:= First_Entity
(Standard_Exception_Type
);
1487 Comp_List
:= New_List
;
1488 while Present
(Comp
) loop
1490 Make_Component_Declaration
(Stloc
,
1491 Defining_Identifier
=> Comp
,
1492 Component_Definition
=>
1493 Make_Component_Definition
(Stloc
,
1494 Aliased_Present
=> False,
1495 Subtype_Indication
=> New_Occurrence_Of
(Etype
(Comp
),
1502 Decl
:= Make_Full_Type_Declaration
(Stloc
,
1503 Defining_Identifier
=> Standard_Exception_Type
,
1505 Make_Record_Definition
(Stloc
,
1508 Make_Component_List
(Stloc
,
1509 Component_Items
=> Comp_List
)));
1512 Append
(Decl
, Decl_S
);
1514 Layout_Type
(Standard_Exception_Type
);
1516 -- Create declarations of standard exceptions
1518 Build_Exception
(S_Constraint_Error
);
1519 Build_Exception
(S_Program_Error
);
1520 Build_Exception
(S_Storage_Error
);
1521 Build_Exception
(S_Tasking_Error
);
1523 -- Numeric_Error is a normal exception in Ada 83, but in Ada 95
1524 -- it is a renaming of Constraint_Error. Is this test too early???
1526 if Ada_Version
= Ada_83
then
1527 Build_Exception
(S_Numeric_Error
);
1530 Decl
:= New_Node
(N_Exception_Renaming_Declaration
, Stloc
);
1531 E_Id
:= Standard_Entity
(S_Numeric_Error
);
1533 Set_Ekind
(E_Id
, E_Exception
);
1534 Set_Exception_Code
(E_Id
, Uint_0
);
1535 Set_Etype
(E_Id
, Standard_Exception_Type
);
1536 Set_Is_Public
(E_Id
);
1537 Set_Renamed_Entity
(E_Id
, Standard_Entity
(S_Constraint_Error
));
1539 Set_Defining_Identifier
(Decl
, E_Id
);
1540 Append
(Decl
, Decl_S
);
1542 Ident_Node
:= New_Node
(N_Identifier
, Stloc
);
1543 Set_Chars
(Ident_Node
, Chars
(Standard_Entity
(S_Constraint_Error
)));
1544 Set_Entity
(Ident_Node
, Standard_Entity
(S_Constraint_Error
));
1545 Set_Name
(Decl
, Ident_Node
);
1548 -- Abort_Signal is an entity that does not get made visible
1550 Abort_Signal
:= New_Standard_Entity
;
1551 Set_Chars
(Abort_Signal
, Name_uAbort_Signal
);
1552 Set_Ekind
(Abort_Signal
, E_Exception
);
1553 Set_Exception_Code
(Abort_Signal
, Uint_0
);
1554 Set_Etype
(Abort_Signal
, Standard_Exception_Type
);
1555 Set_Scope
(Abort_Signal
, Standard_Standard
);
1556 Set_Is_Public
(Abort_Signal
, True);
1558 Make_Exception_Declaration
(Stloc
,
1559 Defining_Identifier
=> Abort_Signal
);
1561 -- Create defining identifiers for shift operator entities. Note
1562 -- that these entities are used only for marking shift operators
1563 -- generated internally, and hence need no structure, just a name
1564 -- and a unique identity.
1566 Standard_Op_Rotate_Left
:= New_Standard_Entity
;
1567 Set_Chars
(Standard_Op_Rotate_Left
, Name_Rotate_Left
);
1568 Set_Ekind
(Standard_Op_Rotate_Left
, E_Operator
);
1570 Standard_Op_Rotate_Right
:= New_Standard_Entity
;
1571 Set_Chars
(Standard_Op_Rotate_Right
, Name_Rotate_Right
);
1572 Set_Ekind
(Standard_Op_Rotate_Right
, E_Operator
);
1574 Standard_Op_Shift_Left
:= New_Standard_Entity
;
1575 Set_Chars
(Standard_Op_Shift_Left
, Name_Shift_Left
);
1576 Set_Ekind
(Standard_Op_Shift_Left
, E_Operator
);
1578 Standard_Op_Shift_Right
:= New_Standard_Entity
;
1579 Set_Chars
(Standard_Op_Shift_Right
, Name_Shift_Right
);
1580 Set_Ekind
(Standard_Op_Shift_Right
, E_Operator
);
1582 Standard_Op_Shift_Right_Arithmetic
:= New_Standard_Entity
;
1583 Set_Chars
(Standard_Op_Shift_Right_Arithmetic
,
1584 Name_Shift_Right_Arithmetic
);
1585 Set_Ekind
(Standard_Op_Shift_Right_Arithmetic
,
1588 -- Create standard operator declarations
1592 -- Initialize visibility table with entities in Standard
1594 for E
in Standard_Entity_Type
loop
1595 if Ekind
(Standard_Entity
(E
)) /= E_Operator
then
1597 (Chars
(Standard_Entity
(E
)), Standard_Entity
(E
));
1598 Set_Homonym
(Standard_Entity
(E
), Empty
);
1601 if E
not in S_ASCII_Names
then
1602 Set_Scope
(Standard_Entity
(E
), Standard_Standard
);
1603 Set_Is_Immediately_Visible
(Standard_Entity
(E
));
1607 -- The predefined package Standard itself does not have a scope;
1608 -- it is the only entity in the system not to have one, and this
1609 -- is what identifies the package to Gigi.
1611 Set_Scope
(Standard_Standard
, Empty
);
1613 -- Set global variables indicating last Id values and version
1615 Last_Standard_Node_Id
:= Last_Node_Id
;
1616 Last_Standard_List_Id
:= Last_List_Id
;
1618 -- The Error node has an Etype of Any_Type to help error recovery
1620 Set_Etype
(Error
, Any_Type
);
1622 -- Print representation of standard if switch set
1624 if Opt
.Print_Standard
then
1627 end Create_Standard
;
1629 ------------------------------------
1630 -- Create_Unconstrained_Base_Type --
1631 ------------------------------------
1633 procedure Create_Unconstrained_Base_Type
1637 New_Ent
: constant Entity_Id
:= New_Copy
(E
);
1641 Set_Is_Constrained
(E
, True);
1642 Set_Is_First_Subtype
(E
, True);
1643 Set_Etype
(E
, New_Ent
);
1645 Append_Entity
(New_Ent
, Standard_Standard
);
1646 Set_Is_Constrained
(New_Ent
, False);
1647 Set_Etype
(New_Ent
, New_Ent
);
1648 Set_Is_Known_Valid
(New_Ent
, True);
1650 if K
= E_Signed_Integer_Subtype
then
1651 Set_Etype
(Low_Bound
(Scalar_Range
(E
)), New_Ent
);
1652 Set_Etype
(High_Bound
(Scalar_Range
(E
)), New_Ent
);
1655 end Create_Unconstrained_Base_Type
;
1657 --------------------
1658 -- Identifier_For --
1659 --------------------
1661 function Identifier_For
(S
: Standard_Entity_Type
) return Node_Id
is
1662 Ident_Node
: Node_Id
;
1664 Ident_Node
:= New_Node
(N_Identifier
, Stloc
);
1665 Set_Chars
(Ident_Node
, Chars
(Standard_Entity
(S
)));
1666 Set_Entity
(Ident_Node
, Standard_Entity
(S
));
1670 --------------------
1671 -- Make_Component --
1672 --------------------
1674 procedure Make_Component
1679 Id
: constant Entity_Id
:= New_Standard_Entity
;
1682 Set_Ekind
(Id
, E_Component
);
1683 Set_Etype
(Id
, Typ
);
1684 Set_Scope
(Id
, Rec
);
1685 Init_Component_Location
(Id
);
1687 Set_Original_Record_Component
(Id
, Id
);
1688 Make_Name
(Id
, Nam
);
1689 Append_Entity
(Id
, Rec
);
1696 function Make_Formal
1698 Formal_Name
: String) return Entity_Id
1703 Formal
:= New_Standard_Entity
;
1705 Set_Ekind
(Formal
, E_In_Parameter
);
1706 Set_Mechanism
(Formal
, Default_Mechanism
);
1707 Set_Scope
(Formal
, Standard_Standard
);
1708 Set_Etype
(Formal
, Typ
);
1709 Make_Name
(Formal
, Formal_Name
);
1718 function Make_Integer
(V
: Uint
) return Node_Id
is
1719 N
: constant Node_Id
:= Make_Integer_Literal
(Stloc
, V
);
1721 Set_Is_Static_Expression
(N
);
1729 procedure Make_Name
(Id
: Entity_Id
; Nam
: String) is
1731 for J
in 1 .. Nam
'Length loop
1732 Name_Buffer
(J
) := Fold_Lower
(Nam
(Nam
'First + (J
- 1)));
1735 Name_Len
:= Nam
'Length;
1736 Set_Chars
(Id
, Name_Find
);
1743 function New_Operator
(Op
: Name_Id
; Typ
: Entity_Id
) return Entity_Id
is
1744 Ident_Node
: Entity_Id
;
1747 Ident_Node
:= Make_Defining_Identifier
(Stloc
, Op
);
1749 Set_Is_Pure
(Ident_Node
, True);
1750 Set_Ekind
(Ident_Node
, E_Operator
);
1751 Set_Etype
(Ident_Node
, Typ
);
1752 Set_Scope
(Ident_Node
, Standard_Standard
);
1753 Set_Homonym
(Ident_Node
, Get_Name_Entity_Id
(Op
));
1754 Set_Convention
(Ident_Node
, Convention_Intrinsic
);
1756 Set_Is_Immediately_Visible
(Ident_Node
, True);
1757 Set_Is_Intrinsic_Subprogram
(Ident_Node
, True);
1759 Set_Name_Entity_Id
(Op
, Ident_Node
);
1760 Append_Entity
(Ident_Node
, Standard_Standard
);
1764 -------------------------
1765 -- New_Standard_Entity --
1766 -------------------------
1768 function New_Standard_Entity
1769 (New_Node_Kind
: Node_Kind
:= N_Defining_Identifier
) return Entity_Id
1771 E
: constant Entity_Id
:= New_Entity
(New_Node_Kind
, Stloc
);
1774 -- All standard entities are Pure and Public
1779 -- All standard entity names are analyzed manually, and are thus
1780 -- frozen as soon as they are created.
1784 -- Set debug information required for all standard types
1786 Set_Needs_Debug_Info
(E
);
1788 -- All standard entities are built with fully qualified names, so
1789 -- set the flag to prevent an abortive attempt at requalification!
1791 Set_Has_Qualified_Name
(E
);
1793 -- Return newly created entity to be completed by caller
1796 end New_Standard_Entity
;
1798 --------------------
1799 -- Print_Standard --
1800 --------------------
1802 procedure Print_Standard
is
1804 procedure P
(Item
: String) renames Output
.Write_Line
;
1805 -- Short-hand, since we do a lot of line writes here!
1807 procedure P_Int_Range
(Size
: Pos
);
1808 -- Prints the range of an integer based on its Size
1810 procedure P_Float_Range
(Id
: Entity_Id
);
1811 -- Prints the bounds range for the given float type entity
1813 procedure P_Float_Type
(Id
: Entity_Id
);
1814 -- Prints the type declaration of the given float type entity
1816 procedure P_Mixed_Name
(Id
: Name_Id
);
1817 -- Prints Id in mixed case
1823 procedure P_Float_Range
(Id
: Entity_Id
) is
1825 Write_Str
(" range ");
1826 UR_Write
(Realval
(Type_Low_Bound
(Id
)));
1828 UR_Write
(Realval
(Type_High_Bound
(Id
)));
1837 procedure P_Float_Type
(Id
: Entity_Id
) is
1839 Write_Str
(" type ");
1840 P_Mixed_Name
(Chars
(Id
));
1841 Write_Str
(" is digits ");
1842 Write_Int
(UI_To_Int
(Digits_Value
(Id
)));
1845 Write_Str
(" for ");
1846 P_Mixed_Name
(Chars
(Id
));
1847 Write_Str
("'Size use ");
1848 Write_Int
(UI_To_Int
(RM_Size
(Id
)));
1857 procedure P_Int_Range
(Size
: Pos
) is
1859 Write_Str
(" is range -(2 **");
1860 Write_Int
(Size
- 1);
1862 Write_Str
(" .. +(2 **");
1863 Write_Int
(Size
- 1);
1864 Write_Str
(" - 1);");
1872 procedure P_Mixed_Name
(Id
: Name_Id
) is
1874 Get_Name_String
(Id
);
1876 for J
in 1 .. Name_Len
loop
1877 if J
= 1 or else Name_Buffer
(J
- 1) = '_' then
1878 Name_Buffer
(J
) := Fold_Upper
(Name_Buffer
(J
));
1882 Write_Str
(Name_Buffer
(1 .. Name_Len
));
1885 -- Start of processing for Print_Standard
1888 P
("-- Representation of package Standard");
1890 P
("-- This is not accurate Ada, since new base types cannot be ");
1891 P
("-- created, but the listing shows the target dependent");
1892 P
("-- characteristics of the Standard types for this compiler");
1895 P
("package Standard is");
1896 P
("pragma Pure (Standard);");
1899 P
(" type Boolean is (False, True);");
1900 P
(" for Boolean'Size use 1;");
1901 P
(" for Boolean use (False => 0, True => 1);");
1906 Write_Str
(" type Integer");
1907 P_Int_Range
(Standard_Integer_Size
);
1908 Write_Str
(" for Integer'Size use ");
1909 Write_Int
(Standard_Integer_Size
);
1913 P
(" subtype Natural is Integer range 0 .. Integer'Last;");
1914 P
(" subtype Positive is Integer range 1 .. Integer'Last;");
1917 Write_Str
(" type Short_Short_Integer");
1918 P_Int_Range
(Standard_Short_Short_Integer_Size
);
1919 Write_Str
(" for Short_Short_Integer'Size use ");
1920 Write_Int
(Standard_Short_Short_Integer_Size
);
1924 Write_Str
(" type Short_Integer");
1925 P_Int_Range
(Standard_Short_Integer_Size
);
1926 Write_Str
(" for Short_Integer'Size use ");
1927 Write_Int
(Standard_Short_Integer_Size
);
1931 Write_Str
(" type Long_Integer");
1932 P_Int_Range
(Standard_Long_Integer_Size
);
1933 Write_Str
(" for Long_Integer'Size use ");
1934 Write_Int
(Standard_Long_Integer_Size
);
1938 Write_Str
(" type Long_Long_Integer");
1939 P_Int_Range
(Standard_Long_Long_Integer_Size
);
1940 Write_Str
(" for Long_Long_Integer'Size use ");
1941 Write_Int
(Standard_Long_Long_Integer_Size
);
1945 -- Floating point types
1947 P_Float_Type
(Standard_Short_Float
);
1948 P_Float_Type
(Standard_Float
);
1949 P_Float_Type
(Standard_Long_Float
);
1950 P_Float_Type
(Standard_Long_Long_Float
);
1952 P
(" type Character is (...)");
1953 Write_Str
(" for Character'Size use ");
1954 Write_Int
(Standard_Character_Size
);
1956 P
(" -- See RM A.1(35) for details of this type");
1959 P
(" type Wide_Character is (...)");
1960 Write_Str
(" for Wide_Character'Size use ");
1961 Write_Int
(Standard_Wide_Character_Size
);
1963 P
(" -- See RM A.1(36) for details of this type");
1966 P
(" type Wide_Wide_Character is (...)");
1967 Write_Str
(" for Wide_Wide_Character'Size use ");
1968 Write_Int
(Standard_Wide_Wide_Character_Size
);
1970 P
(" -- See RM A.1(36) for details of this type");
1972 P
(" type String is array (Positive range <>) of Character;");
1973 P
(" pragma Pack (String);");
1976 P
(" type Wide_String is array (Positive range <>)" &
1977 " of Wide_Character;");
1978 P
(" pragma Pack (Wide_String);");
1981 P
(" type Wide_Wide_String is array (Positive range <>)" &
1982 " of Wide_Wide_Character;");
1983 P
(" pragma Pack (Wide_Wide_String);");
1986 -- We only have one representation each for 32-bit and 64-bit sizes,
1987 -- so select the right one based on Duration_32_Bits_On_Target.
1989 if Duration_32_Bits_On_Target
then
1990 P
(" type Duration is delta 0.020");
1991 P
(" range -((2 ** 31 - 1) * 0.020) ..");
1992 P
(" +((2 ** 31 - 1) * 0.020);");
1993 P
(" for Duration'Small use 0.020;");
1996 P
(" type Duration is delta 0.000000001");
1997 P
(" range -((2 ** 63 - 1) * 0.000000001) ..");
1998 P
(" +((2 ** 63 - 1) * 0.000000001);");
1999 P
(" for Duration'Small use 0.000000001;");
2004 P
(" Constraint_Error : exception;");
2005 P
(" Program_Error : exception;");
2006 P
(" Storage_Error : exception;");
2007 P
(" Tasking_Error : exception;");
2008 P
(" Numeric_Error : exception renames Constraint_Error;");
2011 P
("end Standard;");
2014 -------------------------
2015 -- Register_Float_Type --
2016 -------------------------
2018 procedure Register_Float_Type
2021 Float_Rep
: Float_Rep_Kind
;
2023 Alignment
: Natural)
2025 Ent
: constant Entity_Id
:= New_Standard_Entity
;
2026 Esize
: constant Pos
:=
2027 Pos
((Size
+ Alignment
- 1) / Alignment
* Alignment
);
2030 Set_Defining_Identifier
(New_Node
(N_Full_Type_Declaration
, Stloc
), Ent
);
2031 Make_Name
(Ent
, Name
);
2032 Set_Scope
(Ent
, Standard_Standard
);
2033 Build_Float_Type
(Ent
, Esize
, Float_Rep
, Pos
(Digs
));
2034 Set_RM_Size
(Ent
, UI_From_Int
(Int
(Size
)));
2035 Set_Alignment
(Ent
, UI_From_Int
(Int
(Alignment
/ 8)));
2037 if No
(Back_End_Float_Types
) then
2038 Back_End_Float_Types
:= New_Elmt_List
;
2041 Append_Elmt
(Ent
, Back_End_Float_Types
);
2042 end Register_Float_Type
;
2044 ----------------------
2045 -- Set_Float_Bounds --
2046 ----------------------
2048 procedure Set_Float_Bounds
(Id
: Entity_Id
) is
2051 -- Low and high bounds of literal value
2054 -- Range specification
2056 Radix
: constant Uint
:= Machine_Radix_Value
(Id
);
2057 Mantissa
: constant Uint
:= Machine_Mantissa_Value
(Id
);
2058 Emax
: constant Uint
:= Machine_Emax_Value
(Id
);
2059 Significand
: constant Uint
:= Radix
** Mantissa
- 1;
2060 Exponent
: constant Uint
:= Emax
- Mantissa
;
2063 -- Note: for the call from Cstand to initially create the types in
2064 -- Standard, Float_Rep will never be VAX_Native. Circuitry in Sem_Vfpt
2065 -- will adjust these types appropriately VAX_Native if a pragma
2066 -- Float_Representation (VAX_Float) is used.
2068 H
:= Make_Float_Literal
(Stloc
, Radix
, Significand
, Exponent
);
2069 L
:= Make_Float_Literal
(Stloc
, Radix
, -Significand
, Exponent
);
2072 Set_Is_Static_Expression
(L
);
2075 Set_Is_Static_Expression
(H
);
2077 R
:= New_Node
(N_Range
, Stloc
);
2078 Set_Low_Bound
(R
, L
);
2079 Set_High_Bound
(R
, H
);
2080 Set_Includes_Infinities
(R
, True);
2081 Set_Scalar_Range
(Id
, R
);
2084 end Set_Float_Bounds
;
2086 ------------------------
2087 -- Set_Integer_Bounds --
2088 ------------------------
2090 procedure Set_Integer_Bounds
2098 -- Low and high bounds of literal value
2101 -- Range specification
2104 L
:= Make_Integer
(Lb
);
2105 H
:= Make_Integer
(Hb
);
2110 R
:= New_Node
(N_Range
, Stloc
);
2111 Set_Low_Bound
(R
, L
);
2112 Set_High_Bound
(R
, H
);
2113 Set_Scalar_Range
(Id
, R
);
2116 Set_Is_Unsigned_Type
(Id
, Lb
>= 0);
2117 end Set_Integer_Bounds
;