1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2010, 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 Layout
; use Layout
;
31 with Namet
; use Namet
;
32 with Nlists
; use Nlists
;
33 with Nmake
; use Nmake
;
35 with Output
; use Output
;
36 with Targparm
; use Targparm
;
37 with Tbuild
; use Tbuild
;
38 with Ttypes
; use Ttypes
;
39 with Ttypef
; use Ttypef
;
41 with Sem_Mech
; use Sem_Mech
;
42 with Sem_Util
; use Sem_Util
;
43 with Sinfo
; use Sinfo
;
44 with Snames
; use Snames
;
45 with Stand
; use Stand
;
46 with Uintp
; use Uintp
;
47 with Urealp
; use Urealp
;
49 package body CStand
is
51 Stloc
: constant Source_Ptr
:= Standard_Location
;
52 Staloc
: constant Source_Ptr
:= Standard_ASCII_Location
;
53 -- Standard abbreviations used throughout this package
55 -----------------------
56 -- Local Subprograms --
57 -----------------------
59 procedure Build_Float_Type
(E
: Entity_Id
; Siz
: Int
; Digs
: Int
);
60 -- Procedure to build standard predefined float base type. The first
61 -- parameter is the entity for the type, and the second parameter
62 -- is the size in bits. The third parameter is the digits value.
64 procedure Build_Signed_Integer_Type
(E
: Entity_Id
; Siz
: Int
);
65 -- Procedure to build standard predefined signed integer subtype. The
66 -- first parameter is the entity for the subtype. The second parameter
67 -- is the size in bits. The corresponding base type is not built by
68 -- this routine but instead must be built by the caller where needed.
70 procedure Create_Operators
;
71 -- Make entries for each of the predefined operators in Standard
73 procedure Create_Unconstrained_Base_Type
76 -- The predefined signed integer types are constrained subtypes which
77 -- must have a corresponding unconstrained base type. This type is almost
78 -- useless. The only place it has semantics is Subtypes_Statically_Match.
79 -- Consequently, we arrange for it to be identical apart from the setting
80 -- of the constrained bit. This routine takes an entity E for the Type,
81 -- copies it to estabish the base type, then resets the Ekind of the
82 -- original entity to K (the Ekind for the subtype). The Etype field of
83 -- E is set by the call (to point to the created base type entity), and
84 -- also the Is_Constrained flag of E is set.
86 -- To understand the exact requirement for this, see RM 3.5.4(11) which
87 -- makes it clear that Integer, for example, is constrained, with the
88 -- constraint bounds matching the bounds of the (unconstrained) base
89 -- type. The point is that Integer and Integer'Base have identical
90 -- bounds, but do not statically match, since a subtype with constraints
91 -- never matches a subtype with no constraints.
93 function Identifier_For
(S
: Standard_Entity_Type
) return Node_Id
;
94 -- Returns an identifier node with the same name as the defining
95 -- identifier corresponding to the given Standard_Entity_Type value
97 procedure Make_Component
101 -- Build a record component with the given type and name, and append to
102 -- the list of components of Rec.
106 Formal_Name
: String) return Entity_Id
;
107 -- Construct entity for subprogram formal with given name and type
109 function Make_Integer
(V
: Uint
) return Node_Id
;
110 -- Builds integer literal with given value
112 procedure Make_Name
(Id
: Entity_Id
; Nam
: String);
113 -- Make an entry in the names table for Nam, and set as Chars field of Id
115 function New_Operator
(Op
: Name_Id
; Typ
: Entity_Id
) return Entity_Id
;
116 -- Build entity for standard operator with given name and type
118 function New_Standard_Entity
119 (New_Node_Kind
: Node_Kind
:= N_Defining_Identifier
) return Entity_Id
;
120 -- Builds a new entity for Standard
122 procedure Print_Standard
;
123 -- Print representation of package Standard if switch set
125 procedure Set_Integer_Bounds
130 -- Procedure to set bounds for integer type or subtype. Id is the entity
131 -- whose bounds and type are to be set. The Typ parameter is the Etype
132 -- value for the entity (which will be the same as Id for all predefined
133 -- integer base types. The third and fourth parameters are the bounds.
135 ----------------------
136 -- Build_Float_Type --
137 ----------------------
139 procedure Build_Float_Type
(E
: Entity_Id
; Siz
: Int
; Digs
: Int
) is
141 Set_Type_Definition
(Parent
(E
),
142 Make_Floating_Point_Definition
(Stloc
,
143 Digits_Expression
=> Make_Integer
(UI_From_Int
(Digs
))));
144 Set_Ekind
(E
, E_Floating_Point_Type
);
147 Set_Elem_Alignment
(E
);
148 Init_Digits_Value
(E
, Digs
);
149 Set_Float_Bounds
(E
);
152 Set_Size_Known_At_Compile_Time
(E
);
153 end Build_Float_Type
;
155 -------------------------------
156 -- Build_Signed_Integer_Type --
157 -------------------------------
159 procedure Build_Signed_Integer_Type
(E
: Entity_Id
; Siz
: Int
) is
160 U2Siz1
: constant Uint
:= 2 ** (Siz
- 1);
161 Lbound
: constant Uint
:= -U2Siz1
;
162 Ubound
: constant Uint
:= U2Siz1
- 1;
165 Set_Type_Definition
(Parent
(E
),
166 Make_Signed_Integer_Type_Definition
(Stloc
,
167 Low_Bound
=> Make_Integer
(Lbound
),
168 High_Bound
=> Make_Integer
(Ubound
)));
170 Set_Ekind
(E
, E_Signed_Integer_Type
);
173 Set_Elem_Alignment
(E
);
174 Set_Integer_Bounds
(E
, E
, Lbound
, Ubound
);
177 Set_Is_Known_Valid
(E
);
178 Set_Size_Known_At_Compile_Time
(E
);
179 end Build_Signed_Integer_Type
;
181 ----------------------
182 -- Create_Operators --
183 ----------------------
185 -- Each operator has an abbreviated signature. The formals have the names
186 -- LEFT and RIGHT. Their types are not actually used for resolution.
188 procedure Create_Operators
is
191 -- The following tables define the binary and unary operators and their
192 -- corresponding result type.
194 Binary_Ops
: constant array (S_Binary_Ops
) of Name_Id
:=
196 -- There is one entry here for each binary operator, except for the
197 -- case of concatenation, where there are three entries, one for a
198 -- String result, one for Wide_String, and one for Wide_Wide_String.
220 Bin_Op_Types
: constant array (S_Binary_Ops
) of Entity_Id
:=
222 -- This table has the corresponding result types. The entries are
223 -- ordered so they correspond to the Binary_Ops array above.
225 (Universal_Integer
, -- Add
226 Standard_Boolean
, -- And
227 Standard_String
, -- Concat (String)
228 Standard_Wide_String
, -- Concat (Wide_String)
229 Standard_Wide_Wide_String
, -- Concat (Wide_Wide_String)
230 Universal_Integer
, -- Divide
231 Standard_Boolean
, -- Eq
232 Universal_Integer
, -- Expon
233 Standard_Boolean
, -- Ge
234 Standard_Boolean
, -- Gt
235 Standard_Boolean
, -- Le
236 Standard_Boolean
, -- Lt
237 Universal_Integer
, -- Mod
238 Universal_Integer
, -- Multiply
239 Standard_Boolean
, -- Ne
240 Standard_Boolean
, -- Or
241 Universal_Integer
, -- Rem
242 Universal_Integer
, -- Subtract
243 Standard_Boolean
); -- Xor
245 Unary_Ops
: constant array (S_Unary_Ops
) of Name_Id
:=
247 -- There is one entry here for each unary operator
254 Unary_Op_Types
: constant array (S_Unary_Ops
) of Entity_Id
:=
256 -- This table has the corresponding result types. The entries are
257 -- ordered so they correspond to the Unary_Ops array above.
259 (Universal_Integer
, -- Abs
260 Universal_Integer
, -- Subtract
261 Standard_Boolean
, -- Not
262 Universal_Integer
); -- Add
265 for J
in S_Binary_Ops
loop
266 Op_Node
:= New_Operator
(Binary_Ops
(J
), Bin_Op_Types
(J
));
268 Append_Entity
(Make_Formal
(Any_Type
, "LEFT"), Op_Node
);
269 Append_Entity
(Make_Formal
(Any_Type
, "RIGHT"), Op_Node
);
272 for J
in S_Unary_Ops
loop
273 Op_Node
:= New_Operator
(Unary_Ops
(J
), Unary_Op_Types
(J
));
275 Append_Entity
(Make_Formal
(Any_Type
, "RIGHT"), Op_Node
);
278 -- For concatenation, we create a separate operator for each
279 -- array type. This simplifies the resolution of the component-
280 -- component concatenation operation. In Standard, we set the types
281 -- of the formals for string, wide [wide]_string, concatenations.
283 Set_Etype
(First_Entity
(Standard_Op_Concat
), Standard_String
);
284 Set_Etype
(Last_Entity
(Standard_Op_Concat
), Standard_String
);
286 Set_Etype
(First_Entity
(Standard_Op_Concatw
), Standard_Wide_String
);
287 Set_Etype
(Last_Entity
(Standard_Op_Concatw
), Standard_Wide_String
);
289 Set_Etype
(First_Entity
(Standard_Op_Concatww
),
290 Standard_Wide_Wide_String
);
292 Set_Etype
(Last_Entity
(Standard_Op_Concatww
),
293 Standard_Wide_Wide_String
);
294 end Create_Operators
;
296 ---------------------
297 -- Create_Standard --
298 ---------------------
300 -- The tree for the package Standard is prefixed to all compilations.
301 -- Several entities required by semantic analysis are denoted by global
302 -- variables that are initialized to point to the corresponding
303 -- occurrences in STANDARD. The visible entities of STANDARD are
304 -- created here. The private entities defined in STANDARD are created
305 -- by Initialize_Standard in the semantics module.
307 procedure Create_Standard
is
308 Decl_S
: constant List_Id
:= New_List
;
309 -- List of declarations in Standard
311 Decl_A
: constant List_Id
:= New_List
;
312 -- List of declarations in ASCII
317 Ident_Node
: Node_Id
;
323 procedure Build_Exception
(S
: Standard_Entity_Type
);
324 -- Procedure to declare given entity as an exception
326 procedure Pack_String_Type
(String_Type
: Entity_Id
);
327 -- Generate proper tree for pragma Pack that applies to given type, and
328 -- mark type as having the pragma.
330 ---------------------
331 -- Build_Exception --
332 ---------------------
334 procedure Build_Exception
(S
: Standard_Entity_Type
) is
336 Set_Ekind
(Standard_Entity
(S
), E_Exception
);
337 Set_Etype
(Standard_Entity
(S
), Standard_Exception_Type
);
338 Set_Exception_Code
(Standard_Entity
(S
), Uint_0
);
339 Set_Is_Public
(Standard_Entity
(S
), True);
342 Make_Exception_Declaration
(Stloc
,
343 Defining_Identifier
=> Standard_Entity
(S
));
344 Append
(Decl
, Decl_S
);
347 ----------------------
348 -- Pack_String_Type --
349 ----------------------
351 procedure Pack_String_Type
(String_Type
: Entity_Id
) is
352 Prag
: constant Node_Id
:=
355 Pragma_Argument_Associations
=>
357 Make_Pragma_Argument_Association
(Stloc
,
359 New_Occurrence_Of
(String_Type
, Stloc
))));
361 Append
(Prag
, Decl_S
);
362 Record_Rep_Item
(String_Type
, Prag
);
363 Set_Has_Pragma_Pack
(String_Type
, True);
364 end Pack_String_Type
;
366 -- Start of processing for Create_Standard
369 -- Initialize scanner for internal scans of literals
371 Scn
.Initialize_Scanner
(No_Unit
, Internal_Source_File
);
373 -- First step is to create defining identifiers for each entity
375 for S
in Standard_Entity_Type
loop
377 S_Name
: constant String := Standard_Entity_Type
'Image (S
);
378 -- Name of entity (note we skip S_ at the start)
380 Ident_Node
: Node_Id
;
381 -- Defining identifier node
384 Ident_Node
:= New_Standard_Entity
;
385 Make_Name
(Ident_Node
, S_Name
(3 .. S_Name
'Length));
386 Standard_Entity
(S
) := Ident_Node
;
390 -- Create package declaration node for package Standard
392 Standard_Package_Node
:= New_Node
(N_Package_Declaration
, Stloc
);
394 Pspec
:= New_Node
(N_Package_Specification
, Stloc
);
395 Set_Specification
(Standard_Package_Node
, Pspec
);
397 Set_Defining_Unit_Name
(Pspec
, Standard_Standard
);
398 Set_Visible_Declarations
(Pspec
, Decl_S
);
400 Set_Ekind
(Standard_Standard
, E_Package
);
401 Set_Is_Pure
(Standard_Standard
);
402 Set_Is_Compilation_Unit
(Standard_Standard
);
404 -- Create type/subtype declaration nodes for standard types
406 for S
in S_Types
loop
408 -- Subtype declaration case
410 if S
= S_Natural
or else S
= S_Positive
then
411 Decl
:= New_Node
(N_Subtype_Declaration
, Stloc
);
412 Set_Subtype_Indication
(Decl
,
413 New_Occurrence_Of
(Standard_Integer
, Stloc
));
415 -- Full type declaration case
418 Decl
:= New_Node
(N_Full_Type_Declaration
, Stloc
);
421 Set_Is_Frozen
(Standard_Entity
(S
));
422 Set_Is_Public
(Standard_Entity
(S
));
423 Set_Defining_Identifier
(Decl
, Standard_Entity
(S
));
424 Append
(Decl
, Decl_S
);
427 -- Create type definition node for type Boolean. The Size is set to
428 -- 1 as required by Ada 95 and current ARG interpretations for Ada/83.
430 -- Note: Object_Size of Boolean is 8. This means that we do NOT in
431 -- general know that Boolean variables have valid values, so we do
432 -- not set the Is_Known_Valid flag.
434 Tdef_Node
:= New_Node
(N_Enumeration_Type_Definition
, Stloc
);
435 Set_Literals
(Tdef_Node
, New_List
);
436 Append
(Standard_False
, Literals
(Tdef_Node
));
437 Append
(Standard_True
, Literals
(Tdef_Node
));
438 Set_Type_Definition
(Parent
(Standard_Boolean
), Tdef_Node
);
440 Set_Ekind
(Standard_Boolean
, E_Enumeration_Type
);
441 Set_First_Literal
(Standard_Boolean
, Standard_False
);
442 Set_Etype
(Standard_Boolean
, Standard_Boolean
);
443 Init_Esize
(Standard_Boolean
, Standard_Character_Size
);
444 Init_RM_Size
(Standard_Boolean
, 1);
445 Set_Elem_Alignment
(Standard_Boolean
);
447 Set_Is_Unsigned_Type
(Standard_Boolean
);
448 Set_Size_Known_At_Compile_Time
(Standard_Boolean
);
450 Set_Ekind
(Standard_True
, E_Enumeration_Literal
);
451 Set_Etype
(Standard_True
, Standard_Boolean
);
452 Set_Enumeration_Pos
(Standard_True
, Uint_1
);
453 Set_Enumeration_Rep
(Standard_True
, Uint_1
);
454 Set_Is_Known_Valid
(Standard_True
, True);
456 Set_Ekind
(Standard_False
, E_Enumeration_Literal
);
457 Set_Etype
(Standard_False
, Standard_Boolean
);
458 Set_Enumeration_Pos
(Standard_False
, Uint_0
);
459 Set_Enumeration_Rep
(Standard_False
, Uint_0
);
460 Set_Is_Known_Valid
(Standard_False
, True);
462 -- For the bounds of Boolean, we create a range node corresponding to
464 -- range False .. True
466 -- where the occurrences of the literals must point to the
467 -- corresponding definition.
469 R_Node
:= New_Node
(N_Range
, Stloc
);
470 B_Node
:= New_Node
(N_Identifier
, Stloc
);
471 Set_Chars
(B_Node
, Chars
(Standard_False
));
472 Set_Entity
(B_Node
, Standard_False
);
473 Set_Etype
(B_Node
, Standard_Boolean
);
474 Set_Is_Static_Expression
(B_Node
);
475 Set_Low_Bound
(R_Node
, B_Node
);
477 B_Node
:= New_Node
(N_Identifier
, Stloc
);
478 Set_Chars
(B_Node
, Chars
(Standard_True
));
479 Set_Entity
(B_Node
, Standard_True
);
480 Set_Etype
(B_Node
, Standard_Boolean
);
481 Set_Is_Static_Expression
(B_Node
);
482 Set_High_Bound
(R_Node
, B_Node
);
484 Set_Scalar_Range
(Standard_Boolean
, R_Node
);
485 Set_Etype
(R_Node
, Standard_Boolean
);
486 Set_Parent
(R_Node
, Standard_Boolean
);
488 -- Record entity identifiers for boolean literals in the
489 -- Boolean_Literals array, for easy reference during expansion.
491 Boolean_Literals
:= (False => Standard_False
, True => Standard_True
);
493 -- Create type definition nodes for predefined integer types
495 Build_Signed_Integer_Type
496 (Standard_Short_Short_Integer
, Standard_Short_Short_Integer_Size
);
498 Build_Signed_Integer_Type
499 (Standard_Short_Integer
, Standard_Short_Integer_Size
);
501 Build_Signed_Integer_Type
502 (Standard_Integer
, Standard_Integer_Size
);
510 LIS
:= Standard_Long_Integer_Size
;
513 Build_Signed_Integer_Type
(Standard_Long_Integer
, LIS
);
516 Build_Signed_Integer_Type
517 (Standard_Long_Long_Integer
, Standard_Long_Long_Integer_Size
);
519 Create_Unconstrained_Base_Type
520 (Standard_Short_Short_Integer
, E_Signed_Integer_Subtype
);
522 Create_Unconstrained_Base_Type
523 (Standard_Short_Integer
, E_Signed_Integer_Subtype
);
525 Create_Unconstrained_Base_Type
526 (Standard_Integer
, E_Signed_Integer_Subtype
);
528 Create_Unconstrained_Base_Type
529 (Standard_Long_Integer
, E_Signed_Integer_Subtype
);
531 Create_Unconstrained_Base_Type
532 (Standard_Long_Long_Integer
, E_Signed_Integer_Subtype
);
534 -- Create type definition nodes for predefined float types
537 (Standard_Short_Float
,
538 Standard_Short_Float_Size
,
539 Standard_Short_Float_Digits
);
544 Standard_Float_Digits
);
547 (Standard_Long_Float
,
548 Standard_Long_Float_Size
,
549 Standard_Long_Float_Digits
);
552 (Standard_Long_Long_Float
,
553 Standard_Long_Long_Float_Size
,
554 Standard_Long_Long_Float_Digits
);
556 -- Create type definition node for type Character. Note that we do not
557 -- set the Literals field, since type Character is handled with special
558 -- routine that do not need a literal list.
560 Tdef_Node
:= New_Node
(N_Enumeration_Type_Definition
, Stloc
);
561 Set_Type_Definition
(Parent
(Standard_Character
), Tdef_Node
);
563 Set_Ekind
(Standard_Character
, E_Enumeration_Type
);
564 Set_Etype
(Standard_Character
, Standard_Character
);
565 Init_Esize
(Standard_Character
, Standard_Character_Size
);
566 Init_RM_Size
(Standard_Character
, 8);
567 Set_Elem_Alignment
(Standard_Character
);
569 Set_Is_Unsigned_Type
(Standard_Character
);
570 Set_Is_Character_Type
(Standard_Character
);
571 Set_Is_Known_Valid
(Standard_Character
);
572 Set_Size_Known_At_Compile_Time
(Standard_Character
);
574 -- Create the bounds for type Character
576 R_Node
:= New_Node
(N_Range
, Stloc
);
578 -- Low bound for type Character (Standard.Nul)
580 B_Node
:= New_Node
(N_Character_Literal
, Stloc
);
581 Set_Is_Static_Expression
(B_Node
);
582 Set_Chars
(B_Node
, No_Name
);
583 Set_Char_Literal_Value
(B_Node
, Uint_0
);
584 Set_Entity
(B_Node
, Empty
);
585 Set_Etype
(B_Node
, Standard_Character
);
586 Set_Low_Bound
(R_Node
, B_Node
);
588 -- High bound for type Character
590 B_Node
:= New_Node
(N_Character_Literal
, Stloc
);
591 Set_Is_Static_Expression
(B_Node
);
592 Set_Chars
(B_Node
, No_Name
);
593 Set_Char_Literal_Value
(B_Node
, UI_From_Int
(16#FF#
));
594 Set_Entity
(B_Node
, Empty
);
595 Set_Etype
(B_Node
, Standard_Character
);
596 Set_High_Bound
(R_Node
, B_Node
);
598 Set_Scalar_Range
(Standard_Character
, R_Node
);
599 Set_Etype
(R_Node
, Standard_Character
);
600 Set_Parent
(R_Node
, Standard_Character
);
602 -- Create type definition for type Wide_Character. Note that we do not
603 -- set the Literals field, since type Wide_Character is handled with
604 -- special routines that do not need a literal list.
606 Tdef_Node
:= New_Node
(N_Enumeration_Type_Definition
, Stloc
);
607 Set_Type_Definition
(Parent
(Standard_Wide_Character
), Tdef_Node
);
609 Set_Ekind
(Standard_Wide_Character
, E_Enumeration_Type
);
610 Set_Etype
(Standard_Wide_Character
, Standard_Wide_Character
);
611 Init_Size
(Standard_Wide_Character
, Standard_Wide_Character_Size
);
613 Set_Elem_Alignment
(Standard_Wide_Character
);
614 Set_Is_Unsigned_Type
(Standard_Wide_Character
);
615 Set_Is_Character_Type
(Standard_Wide_Character
);
616 Set_Is_Known_Valid
(Standard_Wide_Character
);
617 Set_Size_Known_At_Compile_Time
(Standard_Wide_Character
);
619 -- Create the bounds for type Wide_Character
621 R_Node
:= New_Node
(N_Range
, Stloc
);
623 -- Low bound for type Wide_Character
625 B_Node
:= New_Node
(N_Character_Literal
, Stloc
);
626 Set_Is_Static_Expression
(B_Node
);
627 Set_Chars
(B_Node
, No_Name
); -- ???
628 Set_Char_Literal_Value
(B_Node
, Uint_0
);
629 Set_Entity
(B_Node
, Empty
);
630 Set_Etype
(B_Node
, Standard_Wide_Character
);
631 Set_Low_Bound
(R_Node
, B_Node
);
633 -- High bound for type Wide_Character
635 B_Node
:= New_Node
(N_Character_Literal
, Stloc
);
636 Set_Is_Static_Expression
(B_Node
);
637 Set_Chars
(B_Node
, No_Name
); -- ???
638 Set_Char_Literal_Value
(B_Node
, UI_From_Int
(16#FFFF#
));
639 Set_Entity
(B_Node
, Empty
);
640 Set_Etype
(B_Node
, Standard_Wide_Character
);
641 Set_High_Bound
(R_Node
, B_Node
);
643 Set_Scalar_Range
(Standard_Wide_Character
, R_Node
);
644 Set_Etype
(R_Node
, Standard_Wide_Character
);
645 Set_Parent
(R_Node
, Standard_Wide_Character
);
647 -- Create type definition for type Wide_Wide_Character. Note that we
648 -- do not set the Literals field, since type Wide_Wide_Character is
649 -- handled with special routines that do not need a literal list.
651 Tdef_Node
:= New_Node
(N_Enumeration_Type_Definition
, Stloc
);
652 Set_Type_Definition
(Parent
(Standard_Wide_Wide_Character
), Tdef_Node
);
654 Set_Ekind
(Standard_Wide_Wide_Character
, E_Enumeration_Type
);
655 Set_Etype
(Standard_Wide_Wide_Character
,
656 Standard_Wide_Wide_Character
);
657 Init_Size
(Standard_Wide_Wide_Character
,
658 Standard_Wide_Wide_Character_Size
);
660 Set_Elem_Alignment
(Standard_Wide_Wide_Character
);
661 Set_Is_Unsigned_Type
(Standard_Wide_Wide_Character
);
662 Set_Is_Character_Type
(Standard_Wide_Wide_Character
);
663 Set_Is_Known_Valid
(Standard_Wide_Wide_Character
);
664 Set_Size_Known_At_Compile_Time
(Standard_Wide_Wide_Character
);
665 Set_Is_Ada_2005_Only
(Standard_Wide_Wide_Character
);
667 -- Create the bounds for type Wide_Wide_Character
669 R_Node
:= New_Node
(N_Range
, Stloc
);
671 -- Low bound for type Wide_Wide_Character
673 B_Node
:= New_Node
(N_Character_Literal
, Stloc
);
674 Set_Is_Static_Expression
(B_Node
);
675 Set_Chars
(B_Node
, No_Name
); -- ???
676 Set_Char_Literal_Value
(B_Node
, Uint_0
);
677 Set_Entity
(B_Node
, Empty
);
678 Set_Etype
(B_Node
, Standard_Wide_Wide_Character
);
679 Set_Low_Bound
(R_Node
, B_Node
);
681 -- High bound for type Wide_Wide_Character
683 B_Node
:= New_Node
(N_Character_Literal
, Stloc
);
684 Set_Is_Static_Expression
(B_Node
);
685 Set_Chars
(B_Node
, No_Name
); -- ???
686 Set_Char_Literal_Value
(B_Node
, UI_From_Int
(16#
7FFF_FFFF#
));
687 Set_Entity
(B_Node
, Empty
);
688 Set_Etype
(B_Node
, Standard_Wide_Wide_Character
);
689 Set_High_Bound
(R_Node
, B_Node
);
691 Set_Scalar_Range
(Standard_Wide_Wide_Character
, R_Node
);
692 Set_Etype
(R_Node
, Standard_Wide_Wide_Character
);
693 Set_Parent
(R_Node
, Standard_Wide_Wide_Character
);
695 -- Create type definition node for type String
697 Tdef_Node
:= New_Node
(N_Unconstrained_Array_Definition
, Stloc
);
700 CompDef_Node
: Node_Id
;
702 CompDef_Node
:= New_Node
(N_Component_Definition
, Stloc
);
703 Set_Aliased_Present
(CompDef_Node
, False);
704 Set_Access_Definition
(CompDef_Node
, Empty
);
705 Set_Subtype_Indication
(CompDef_Node
, Identifier_For
(S_Character
));
706 Set_Component_Definition
(Tdef_Node
, CompDef_Node
);
709 Set_Subtype_Marks
(Tdef_Node
, New_List
);
710 Append
(Identifier_For
(S_Positive
), Subtype_Marks
(Tdef_Node
));
711 Set_Type_Definition
(Parent
(Standard_String
), Tdef_Node
);
713 Set_Ekind
(Standard_String
, E_String_Type
);
714 Set_Etype
(Standard_String
, Standard_String
);
715 Set_Component_Type
(Standard_String
, Standard_Character
);
716 Set_Component_Size
(Standard_String
, Uint_8
);
717 Init_Size_Align
(Standard_String
);
718 Set_Alignment
(Standard_String
, Uint_1
);
719 Pack_String_Type
(Standard_String
);
721 -- On targets where a storage unit is larger than a byte (such as AAMP),
722 -- pragma Pack has a real effect on the representation of type String,
723 -- and the type must be marked as having a nonstandard representation.
725 if System_Storage_Unit
> Uint_8
then
726 Set_Has_Non_Standard_Rep
(Standard_String
);
727 Set_Has_Pragma_Pack
(Standard_String
);
730 -- Set index type of String
733 (Subtype_Marks
(Type_Definition
(Parent
(Standard_String
))));
734 Set_First_Index
(Standard_String
, E_Id
);
735 Set_Entity
(E_Id
, Standard_Positive
);
736 Set_Etype
(E_Id
, Standard_Positive
);
738 -- Create type definition node for type Wide_String
740 Tdef_Node
:= New_Node
(N_Unconstrained_Array_Definition
, Stloc
);
743 CompDef_Node
: Node_Id
;
745 CompDef_Node
:= New_Node
(N_Component_Definition
, Stloc
);
746 Set_Aliased_Present
(CompDef_Node
, False);
747 Set_Access_Definition
(CompDef_Node
, Empty
);
748 Set_Subtype_Indication
(CompDef_Node
,
749 Identifier_For
(S_Wide_Character
));
750 Set_Component_Definition
(Tdef_Node
, CompDef_Node
);
753 Set_Subtype_Marks
(Tdef_Node
, New_List
);
754 Append
(Identifier_For
(S_Positive
), Subtype_Marks
(Tdef_Node
));
755 Set_Type_Definition
(Parent
(Standard_Wide_String
), Tdef_Node
);
757 Set_Ekind
(Standard_Wide_String
, E_String_Type
);
758 Set_Etype
(Standard_Wide_String
, Standard_Wide_String
);
759 Set_Component_Type
(Standard_Wide_String
, Standard_Wide_Character
);
760 Set_Component_Size
(Standard_Wide_String
, Uint_16
);
761 Init_Size_Align
(Standard_Wide_String
);
762 Pack_String_Type
(Standard_Wide_String
);
764 -- Set index type of Wide_String
767 (Subtype_Marks
(Type_Definition
(Parent
(Standard_Wide_String
))));
768 Set_First_Index
(Standard_Wide_String
, E_Id
);
769 Set_Entity
(E_Id
, Standard_Positive
);
770 Set_Etype
(E_Id
, Standard_Positive
);
772 -- Create type definition node for type Wide_Wide_String
774 Tdef_Node
:= New_Node
(N_Unconstrained_Array_Definition
, Stloc
);
777 CompDef_Node
: Node_Id
;
779 CompDef_Node
:= New_Node
(N_Component_Definition
, Stloc
);
780 Set_Aliased_Present
(CompDef_Node
, False);
781 Set_Access_Definition
(CompDef_Node
, Empty
);
782 Set_Subtype_Indication
(CompDef_Node
,
783 Identifier_For
(S_Wide_Wide_Character
));
784 Set_Component_Definition
(Tdef_Node
, CompDef_Node
);
787 Set_Subtype_Marks
(Tdef_Node
, New_List
);
788 Append
(Identifier_For
(S_Positive
), Subtype_Marks
(Tdef_Node
));
789 Set_Type_Definition
(Parent
(Standard_Wide_Wide_String
), Tdef_Node
);
791 Set_Ekind
(Standard_Wide_Wide_String
, E_String_Type
);
792 Set_Etype
(Standard_Wide_Wide_String
,
793 Standard_Wide_Wide_String
);
794 Set_Component_Type
(Standard_Wide_Wide_String
,
795 Standard_Wide_Wide_Character
);
796 Set_Component_Size
(Standard_Wide_Wide_String
, Uint_32
);
797 Init_Size_Align
(Standard_Wide_Wide_String
);
798 Set_Is_Ada_2005_Only
(Standard_Wide_Wide_String
);
799 Pack_String_Type
(Standard_Wide_Wide_String
);
801 -- Set index type of Wide_Wide_String
804 (Subtype_Marks
(Type_Definition
(Parent
(Standard_Wide_Wide_String
))));
805 Set_First_Index
(Standard_Wide_Wide_String
, E_Id
);
806 Set_Entity
(E_Id
, Standard_Positive
);
807 Set_Etype
(E_Id
, Standard_Positive
);
809 -- Setup entity for Naturalend Create_Standard;
811 Set_Ekind
(Standard_Natural
, E_Signed_Integer_Subtype
);
812 Set_Etype
(Standard_Natural
, Base_Type
(Standard_Integer
));
813 Init_Esize
(Standard_Natural
, Standard_Integer_Size
);
814 Init_RM_Size
(Standard_Natural
, Standard_Integer_Size
- 1);
815 Set_Elem_Alignment
(Standard_Natural
);
816 Set_Size_Known_At_Compile_Time
818 Set_Integer_Bounds
(Standard_Natural
,
819 Typ
=> Base_Type
(Standard_Integer
),
821 Hb
=> Intval
(High_Bound
(Scalar_Range
(Standard_Integer
))));
822 Set_Is_Constrained
(Standard_Natural
);
824 -- Setup entity for Positive
826 Set_Ekind
(Standard_Positive
, E_Signed_Integer_Subtype
);
827 Set_Etype
(Standard_Positive
, Base_Type
(Standard_Integer
));
828 Init_Esize
(Standard_Positive
, Standard_Integer_Size
);
829 Init_RM_Size
(Standard_Positive
, Standard_Integer_Size
- 1);
830 Set_Elem_Alignment
(Standard_Positive
);
832 Set_Size_Known_At_Compile_Time
(Standard_Positive
);
834 Set_Integer_Bounds
(Standard_Positive
,
835 Typ
=> Base_Type
(Standard_Integer
),
837 Hb
=> Intval
(High_Bound
(Scalar_Range
(Standard_Integer
))));
838 Set_Is_Constrained
(Standard_Positive
);
840 -- Create declaration for package ASCII
842 Decl
:= New_Node
(N_Package_Declaration
, Stloc
);
843 Append
(Decl
, Decl_S
);
845 Pspec
:= New_Node
(N_Package_Specification
, Stloc
);
846 Set_Specification
(Decl
, Pspec
);
848 Set_Defining_Unit_Name
(Pspec
, Standard_Entity
(S_ASCII
));
849 Set_Ekind
(Standard_Entity
(S_ASCII
), E_Package
);
850 Set_Visible_Declarations
(Pspec
, Decl_A
);
852 -- Create control character definitions in package ASCII. Note that
853 -- the character literal entries created here correspond to literal
854 -- values that are impossible in the source, but can be represented
855 -- internally with no difficulties.
859 for S
in S_ASCII_Names
loop
860 Decl
:= New_Node
(N_Object_Declaration
, Staloc
);
861 Set_Constant_Present
(Decl
, True);
864 A_Char
: constant Entity_Id
:= Standard_Entity
(S
);
868 Set_Sloc
(A_Char
, Staloc
);
869 Set_Ekind
(A_Char
, E_Constant
);
870 Set_Never_Set_In_Source
(A_Char
, True);
871 Set_Is_True_Constant
(A_Char
, True);
872 Set_Etype
(A_Char
, Standard_Character
);
873 Set_Scope
(A_Char
, Standard_Entity
(S_ASCII
));
874 Set_Is_Immediately_Visible
(A_Char
, False);
875 Set_Is_Public
(A_Char
, True);
876 Set_Is_Known_Valid
(A_Char
, True);
878 Append_Entity
(A_Char
, Standard_Entity
(S_ASCII
));
879 Set_Defining_Identifier
(Decl
, A_Char
);
881 Set_Object_Definition
(Decl
, Identifier_For
(S_Character
));
882 Expr_Decl
:= New_Node
(N_Character_Literal
, Staloc
);
883 Set_Expression
(Decl
, Expr_Decl
);
885 Set_Is_Static_Expression
(Expr_Decl
);
886 Set_Chars
(Expr_Decl
, No_Name
);
887 Set_Etype
(Expr_Decl
, Standard_Character
);
888 Set_Char_Literal_Value
(Expr_Decl
, UI_From_Int
(Int
(Ccode
)));
891 Append
(Decl
, Decl_A
);
893 -- Increment character code, dealing with non-contiguities
897 if Ccode
= 16#
20#
then
899 elsif Ccode
= 16#
27#
then
901 elsif Ccode
= 16#
3C#
then
903 elsif Ccode
= 16#
41#
then
908 -- Create semantic phase entities
910 Standard_Void_Type
:= New_Standard_Entity
;
911 Set_Ekind
(Standard_Void_Type
, E_Void
);
912 Set_Etype
(Standard_Void_Type
, Standard_Void_Type
);
913 Set_Scope
(Standard_Void_Type
, Standard_Standard
);
914 Make_Name
(Standard_Void_Type
, "_void_type");
916 -- The type field of packages is set to void
918 Set_Etype
(Standard_Standard
, Standard_Void_Type
);
919 Set_Etype
(Standard_ASCII
, Standard_Void_Type
);
921 -- Standard_A_String is actually used in generated code, so it has a
922 -- type name that is reasonable, but does not overlap any Ada name.
924 Standard_A_String
:= New_Standard_Entity
;
925 Set_Ekind
(Standard_A_String
, E_Access_Type
);
926 Set_Scope
(Standard_A_String
, Standard_Standard
);
927 Set_Etype
(Standard_A_String
, Standard_A_String
);
930 Init_Size
(Standard_A_String
, System_Address_Size
);
932 Init_Size
(Standard_A_String
, System_Address_Size
* 2);
935 Init_Alignment
(Standard_A_String
);
937 Set_Directly_Designated_Type
938 (Standard_A_String
, Standard_String
);
939 Make_Name
(Standard_A_String
, "access_string");
941 Standard_A_Char
:= New_Standard_Entity
;
942 Set_Ekind
(Standard_A_Char
, E_Access_Type
);
943 Set_Scope
(Standard_A_Char
, Standard_Standard
);
944 Set_Etype
(Standard_A_Char
, Standard_A_String
);
945 Init_Size
(Standard_A_Char
, System_Address_Size
);
946 Set_Elem_Alignment
(Standard_A_Char
);
948 Set_Directly_Designated_Type
(Standard_A_Char
, Standard_Character
);
949 Make_Name
(Standard_A_Char
, "access_character");
951 -- Standard_Debug_Renaming_Type is used for the special objects created
952 -- to encode the names occurring in renaming declarations for use by the
953 -- debugger (see exp_dbug.adb). The type is a zero-sized subtype of
956 Standard_Debug_Renaming_Type
:= New_Standard_Entity
;
958 Set_Ekind
(Standard_Debug_Renaming_Type
, E_Signed_Integer_Subtype
);
959 Set_Scope
(Standard_Debug_Renaming_Type
, Standard_Standard
);
960 Set_Etype
(Standard_Debug_Renaming_Type
, Base_Type
(Standard_Integer
));
961 Init_Esize
(Standard_Debug_Renaming_Type
, 0);
962 Init_RM_Size
(Standard_Debug_Renaming_Type
, 0);
963 Set_Size_Known_At_Compile_Time
(Standard_Debug_Renaming_Type
);
964 Set_Integer_Bounds
(Standard_Debug_Renaming_Type
,
965 Typ
=> Base_Type
(Standard_Debug_Renaming_Type
),
968 Set_Is_Constrained
(Standard_Debug_Renaming_Type
);
969 Set_Has_Size_Clause
(Standard_Debug_Renaming_Type
);
971 Make_Name
(Standard_Debug_Renaming_Type
, "_renaming_type");
973 -- Note on type names. The type names for the following special types
974 -- are constructed so that they will look reasonable should they ever
975 -- appear in error messages etc, although in practice the use of the
976 -- special insertion character } for types results in special handling
977 -- of these type names in any case. The blanks in these names would
978 -- trouble in Gigi, but that's OK here, since none of these types
979 -- should ever get through to Gigi! Attributes of these types are
980 -- filled out to minimize problems with cascaded errors (for example,
981 -- Any_Integer is given reasonable and consistent type and size values)
983 Any_Type
:= New_Standard_Entity
;
984 Decl
:= New_Node
(N_Full_Type_Declaration
, Stloc
);
985 Set_Defining_Identifier
(Decl
, Any_Type
);
986 Set_Scope
(Any_Type
, Standard_Standard
);
987 Build_Signed_Integer_Type
(Any_Type
, Standard_Integer_Size
);
988 Make_Name
(Any_Type
, "any type");
990 Any_Id
:= New_Standard_Entity
;
991 Set_Ekind
(Any_Id
, E_Variable
);
992 Set_Scope
(Any_Id
, Standard_Standard
);
993 Set_Etype
(Any_Id
, Any_Type
);
995 Init_Alignment
(Any_Id
);
996 Make_Name
(Any_Id
, "any id");
998 Any_Access
:= New_Standard_Entity
;
999 Set_Ekind
(Any_Access
, E_Access_Type
);
1000 Set_Scope
(Any_Access
, Standard_Standard
);
1001 Set_Etype
(Any_Access
, Any_Access
);
1002 Init_Size
(Any_Access
, System_Address_Size
);
1003 Set_Elem_Alignment
(Any_Access
);
1004 Make_Name
(Any_Access
, "an access type");
1006 Any_Character
:= New_Standard_Entity
;
1007 Set_Ekind
(Any_Character
, E_Enumeration_Type
);
1008 Set_Scope
(Any_Character
, Standard_Standard
);
1009 Set_Etype
(Any_Character
, Any_Character
);
1010 Set_Is_Unsigned_Type
(Any_Character
);
1011 Set_Is_Character_Type
(Any_Character
);
1012 Init_Esize
(Any_Character
, Standard_Character_Size
);
1013 Init_RM_Size
(Any_Character
, 8);
1014 Set_Elem_Alignment
(Any_Character
);
1015 Set_Scalar_Range
(Any_Character
, Scalar_Range
(Standard_Character
));
1016 Make_Name
(Any_Character
, "a character type");
1018 Any_Array
:= New_Standard_Entity
;
1019 Set_Ekind
(Any_Array
, E_String_Type
);
1020 Set_Scope
(Any_Array
, Standard_Standard
);
1021 Set_Etype
(Any_Array
, Any_Array
);
1022 Set_Component_Type
(Any_Array
, Any_Character
);
1023 Init_Size_Align
(Any_Array
);
1024 Make_Name
(Any_Array
, "an array type");
1026 Any_Boolean
:= New_Standard_Entity
;
1027 Set_Ekind
(Any_Boolean
, E_Enumeration_Type
);
1028 Set_Scope
(Any_Boolean
, Standard_Standard
);
1029 Set_Etype
(Any_Boolean
, Standard_Boolean
);
1030 Init_Esize
(Any_Boolean
, Standard_Character_Size
);
1031 Init_RM_Size
(Any_Boolean
, 1);
1032 Set_Elem_Alignment
(Any_Boolean
);
1033 Set_Is_Unsigned_Type
(Any_Boolean
);
1034 Set_Scalar_Range
(Any_Boolean
, Scalar_Range
(Standard_Boolean
));
1035 Make_Name
(Any_Boolean
, "a boolean type");
1037 Any_Composite
:= New_Standard_Entity
;
1038 Set_Ekind
(Any_Composite
, E_Array_Type
);
1039 Set_Scope
(Any_Composite
, Standard_Standard
);
1040 Set_Etype
(Any_Composite
, Any_Composite
);
1041 Set_Component_Size
(Any_Composite
, Uint_0
);
1042 Set_Component_Type
(Any_Composite
, Standard_Integer
);
1043 Init_Size_Align
(Any_Composite
);
1044 Make_Name
(Any_Composite
, "a composite type");
1046 Any_Discrete
:= New_Standard_Entity
;
1047 Set_Ekind
(Any_Discrete
, E_Signed_Integer_Type
);
1048 Set_Scope
(Any_Discrete
, Standard_Standard
);
1049 Set_Etype
(Any_Discrete
, Any_Discrete
);
1050 Init_Size
(Any_Discrete
, Standard_Integer_Size
);
1051 Set_Elem_Alignment
(Any_Discrete
);
1052 Make_Name
(Any_Discrete
, "a discrete type");
1054 Any_Fixed
:= New_Standard_Entity
;
1055 Set_Ekind
(Any_Fixed
, E_Ordinary_Fixed_Point_Type
);
1056 Set_Scope
(Any_Fixed
, Standard_Standard
);
1057 Set_Etype
(Any_Fixed
, Any_Fixed
);
1058 Init_Size
(Any_Fixed
, Standard_Integer_Size
);
1059 Set_Elem_Alignment
(Any_Fixed
);
1060 Make_Name
(Any_Fixed
, "a fixed-point type");
1062 Any_Integer
:= New_Standard_Entity
;
1063 Set_Ekind
(Any_Integer
, E_Signed_Integer_Type
);
1064 Set_Scope
(Any_Integer
, Standard_Standard
);
1065 Set_Etype
(Any_Integer
, Standard_Long_Long_Integer
);
1066 Init_Size
(Any_Integer
, Standard_Long_Long_Integer_Size
);
1067 Set_Elem_Alignment
(Any_Integer
);
1071 Typ
=> Base_Type
(Standard_Integer
),
1073 Hb
=> Intval
(High_Bound
(Scalar_Range
(Standard_Integer
))));
1074 Make_Name
(Any_Integer
, "an integer type");
1076 Any_Modular
:= New_Standard_Entity
;
1077 Set_Ekind
(Any_Modular
, E_Modular_Integer_Type
);
1078 Set_Scope
(Any_Modular
, Standard_Standard
);
1079 Set_Etype
(Any_Modular
, Standard_Long_Long_Integer
);
1080 Init_Size
(Any_Modular
, Standard_Long_Long_Integer_Size
);
1081 Set_Elem_Alignment
(Any_Modular
);
1082 Set_Is_Unsigned_Type
(Any_Modular
);
1083 Make_Name
(Any_Modular
, "a modular type");
1085 Any_Numeric
:= New_Standard_Entity
;
1086 Set_Ekind
(Any_Numeric
, E_Signed_Integer_Type
);
1087 Set_Scope
(Any_Numeric
, Standard_Standard
);
1088 Set_Etype
(Any_Numeric
, Standard_Long_Long_Integer
);
1089 Init_Size
(Any_Numeric
, Standard_Long_Long_Integer_Size
);
1090 Set_Elem_Alignment
(Any_Numeric
);
1091 Make_Name
(Any_Numeric
, "a numeric type");
1093 Any_Real
:= New_Standard_Entity
;
1094 Set_Ekind
(Any_Real
, E_Floating_Point_Type
);
1095 Set_Scope
(Any_Real
, Standard_Standard
);
1096 Set_Etype
(Any_Real
, Standard_Long_Long_Float
);
1097 Init_Size
(Any_Real
, Standard_Long_Long_Float_Size
);
1098 Set_Elem_Alignment
(Any_Real
);
1099 Make_Name
(Any_Real
, "a real type");
1101 Any_Scalar
:= New_Standard_Entity
;
1102 Set_Ekind
(Any_Scalar
, E_Signed_Integer_Type
);
1103 Set_Scope
(Any_Scalar
, Standard_Standard
);
1104 Set_Etype
(Any_Scalar
, Any_Scalar
);
1105 Init_Size
(Any_Scalar
, Standard_Integer_Size
);
1106 Set_Elem_Alignment
(Any_Scalar
);
1107 Make_Name
(Any_Scalar
, "a scalar type");
1109 Any_String
:= New_Standard_Entity
;
1110 Set_Ekind
(Any_String
, E_String_Type
);
1111 Set_Scope
(Any_String
, Standard_Standard
);
1112 Set_Etype
(Any_String
, Any_String
);
1113 Set_Component_Type
(Any_String
, Any_Character
);
1114 Init_Size_Align
(Any_String
);
1115 Make_Name
(Any_String
, "a string type");
1123 Low_Bound
=> Make_Integer
(Uint_0
),
1124 High_Bound
=> Make_Integer
(Uint_2
** Standard_Integer_Size
));
1125 Set_Etype
(Index
, Standard_Integer
);
1126 Set_First_Index
(Any_String
, Index
);
1129 Standard_Integer_8
:= New_Standard_Entity
;
1130 Decl
:= New_Node
(N_Full_Type_Declaration
, Stloc
);
1131 Set_Defining_Identifier
(Decl
, Standard_Integer_8
);
1132 Make_Name
(Standard_Integer_8
, "integer_8");
1133 Set_Scope
(Standard_Integer_8
, Standard_Standard
);
1134 Build_Signed_Integer_Type
(Standard_Integer_8
, 8);
1136 Standard_Integer_16
:= New_Standard_Entity
;
1137 Decl
:= New_Node
(N_Full_Type_Declaration
, Stloc
);
1138 Set_Defining_Identifier
(Decl
, Standard_Integer_16
);
1139 Make_Name
(Standard_Integer_16
, "integer_16");
1140 Set_Scope
(Standard_Integer_16
, Standard_Standard
);
1141 Build_Signed_Integer_Type
(Standard_Integer_16
, 16);
1143 Standard_Integer_32
:= New_Standard_Entity
;
1144 Decl
:= New_Node
(N_Full_Type_Declaration
, Stloc
);
1145 Set_Defining_Identifier
(Decl
, Standard_Integer_32
);
1146 Make_Name
(Standard_Integer_32
, "integer_32");
1147 Set_Scope
(Standard_Integer_32
, Standard_Standard
);
1148 Build_Signed_Integer_Type
(Standard_Integer_32
, 32);
1150 Standard_Integer_64
:= New_Standard_Entity
;
1151 Decl
:= New_Node
(N_Full_Type_Declaration
, Stloc
);
1152 Set_Defining_Identifier
(Decl
, Standard_Integer_64
);
1153 Make_Name
(Standard_Integer_64
, "integer_64");
1154 Set_Scope
(Standard_Integer_64
, Standard_Standard
);
1155 Build_Signed_Integer_Type
(Standard_Integer_64
, 64);
1157 Standard_Unsigned
:= New_Standard_Entity
;
1158 Decl
:= New_Node
(N_Full_Type_Declaration
, Stloc
);
1159 Set_Defining_Identifier
(Decl
, Standard_Unsigned
);
1160 Make_Name
(Standard_Unsigned
, "unsigned");
1162 Set_Ekind
(Standard_Unsigned
, E_Modular_Integer_Type
);
1163 Set_Scope
(Standard_Unsigned
, Standard_Standard
);
1164 Set_Etype
(Standard_Unsigned
, Standard_Unsigned
);
1165 Init_Size
(Standard_Unsigned
, Standard_Integer_Size
);
1166 Set_Elem_Alignment
(Standard_Unsigned
);
1167 Set_Modulus
(Standard_Unsigned
,
1168 Uint_2
** Standard_Integer_Size
);
1169 Set_Is_Unsigned_Type
(Standard_Unsigned
);
1170 Set_Size_Known_At_Compile_Time
1171 (Standard_Unsigned
);
1172 Set_Is_Known_Valid
(Standard_Unsigned
, True);
1174 R_Node
:= New_Node
(N_Range
, Stloc
);
1175 Set_Low_Bound
(R_Node
, Make_Integer
(Uint_0
));
1176 Set_High_Bound
(R_Node
, Make_Integer
(Modulus
(Standard_Unsigned
) - 1));
1177 Set_Etype
(Low_Bound
(R_Node
), Standard_Unsigned
);
1178 Set_Etype
(High_Bound
(R_Node
), Standard_Unsigned
);
1179 Set_Scalar_Range
(Standard_Unsigned
, R_Node
);
1181 -- Note: universal integer and universal real are constructed as fully
1182 -- formed signed numeric types, with parameters corresponding to the
1183 -- longest runtime types (Long_Long_Integer and Long_Long_Float). This
1184 -- allows Gigi to properly process references to universal types that
1185 -- are not folded at compile time.
1187 Universal_Integer
:= New_Standard_Entity
;
1188 Decl
:= New_Node
(N_Full_Type_Declaration
, Stloc
);
1189 Set_Defining_Identifier
(Decl
, Universal_Integer
);
1190 Make_Name
(Universal_Integer
, "universal_integer");
1191 Set_Scope
(Universal_Integer
, Standard_Standard
);
1192 Build_Signed_Integer_Type
1193 (Universal_Integer
, Standard_Long_Long_Integer_Size
);
1195 Universal_Real
:= New_Standard_Entity
;
1196 Decl
:= New_Node
(N_Full_Type_Declaration
, Stloc
);
1197 Set_Defining_Identifier
(Decl
, Universal_Real
);
1198 Make_Name
(Universal_Real
, "universal_real");
1199 Set_Scope
(Universal_Real
, Standard_Standard
);
1202 Standard_Long_Long_Float_Size
,
1203 Standard_Long_Long_Float_Digits
);
1205 -- Note: universal fixed, unlike universal integer and universal real,
1206 -- is never used at runtime, so it does not need to have bounds set.
1208 Universal_Fixed
:= New_Standard_Entity
;
1209 Decl
:= New_Node
(N_Full_Type_Declaration
, Stloc
);
1210 Set_Defining_Identifier
(Decl
, Universal_Fixed
);
1211 Make_Name
(Universal_Fixed
, "universal_fixed");
1212 Set_Ekind
(Universal_Fixed
, E_Ordinary_Fixed_Point_Type
);
1213 Set_Etype
(Universal_Fixed
, Universal_Fixed
);
1214 Set_Scope
(Universal_Fixed
, Standard_Standard
);
1215 Init_Size
(Universal_Fixed
, Standard_Long_Long_Integer_Size
);
1216 Set_Elem_Alignment
(Universal_Fixed
);
1217 Set_Size_Known_At_Compile_Time
1220 -- Create type declaration for Duration, using a 64-bit size. The
1221 -- delta and size values depend on the mode set in system.ads.
1223 Build_Duration
: declare
1229 -- In 32 bit mode, the size is 32 bits, and the delta and
1230 -- small values are set to 20 milliseconds (20.0**(10.0**(-3)).
1232 if Duration_32_Bits_On_Target
then
1233 Dlo
:= Intval
(Type_Low_Bound
(Standard_Integer_32
));
1234 Dhi
:= Intval
(Type_High_Bound
(Standard_Integer_32
));
1235 Delta_Val
:= UR_From_Components
(UI_From_Int
(20), Uint_3
, 10);
1237 -- In standard 64-bit mode, the size is 64-bits and the delta and
1238 -- small values are set to nanoseconds (1.0**(10.0**(-9))
1241 Dlo
:= Intval
(Type_Low_Bound
(Standard_Integer_64
));
1242 Dhi
:= Intval
(Type_High_Bound
(Standard_Integer_64
));
1243 Delta_Val
:= UR_From_Components
(Uint_1
, Uint_9
, 10);
1246 Tdef_Node
:= Make_Ordinary_Fixed_Point_Definition
(Stloc
,
1247 Delta_Expression
=> Make_Real_Literal
(Stloc
, Delta_Val
),
1248 Real_Range_Specification
=>
1249 Make_Real_Range_Specification
(Stloc
,
1250 Low_Bound
=> Make_Real_Literal
(Stloc
,
1251 Realval
=> Dlo
* Delta_Val
),
1252 High_Bound
=> Make_Real_Literal
(Stloc
,
1253 Realval
=> Dhi
* Delta_Val
)));
1255 Set_Type_Definition
(Parent
(Standard_Duration
), Tdef_Node
);
1257 Set_Ekind
(Standard_Duration
, E_Ordinary_Fixed_Point_Type
);
1258 Set_Etype
(Standard_Duration
, Standard_Duration
);
1260 if Duration_32_Bits_On_Target
then
1261 Init_Size
(Standard_Duration
, 32);
1263 Init_Size
(Standard_Duration
, 64);
1266 Set_Elem_Alignment
(Standard_Duration
);
1267 Set_Delta_Value
(Standard_Duration
, Delta_Val
);
1268 Set_Small_Value
(Standard_Duration
, Delta_Val
);
1269 Set_Scalar_Range
(Standard_Duration
,
1270 Real_Range_Specification
1271 (Type_Definition
(Parent
(Standard_Duration
))));
1273 -- Normally it does not matter that nodes in package Standard are
1274 -- not marked as analyzed. The Scalar_Range of the fixed-point
1275 -- type Standard_Duration is an exception, because of the special
1276 -- test made in Freeze.Freeze_Fixed_Point_Type.
1278 Set_Analyzed
(Scalar_Range
(Standard_Duration
));
1280 Set_Etype
(Type_High_Bound
(Standard_Duration
), Standard_Duration
);
1281 Set_Etype
(Type_Low_Bound
(Standard_Duration
), Standard_Duration
);
1283 Set_Is_Static_Expression
(Type_High_Bound
(Standard_Duration
));
1284 Set_Is_Static_Expression
(Type_Low_Bound
(Standard_Duration
));
1286 Set_Corresponding_Integer_Value
1287 (Type_High_Bound
(Standard_Duration
), Dhi
);
1289 Set_Corresponding_Integer_Value
1290 (Type_Low_Bound
(Standard_Duration
), Dlo
);
1292 Set_Size_Known_At_Compile_Time
(Standard_Duration
);
1295 -- Build standard exception type. Note that the type name here is
1296 -- actually used in the generated code, so it must be set correctly
1298 -- ??? Also note that the Import_Code component is now declared
1299 -- as a System.Standard_Library.Exception_Code to enforce run-time
1300 -- library implementation consistency. It's too early here to resort
1301 -- to rtsfind to get the proper node for that type, so we use the
1302 -- closest possible available type node at hand instead. We should
1303 -- probably be fixing this up at some point.
1305 Standard_Exception_Type
:= New_Standard_Entity
;
1306 Set_Ekind
(Standard_Exception_Type
, E_Record_Type
);
1307 Set_Etype
(Standard_Exception_Type
, Standard_Exception_Type
);
1308 Set_Scope
(Standard_Exception_Type
, Standard_Standard
);
1309 Set_Stored_Constraint
1310 (Standard_Exception_Type
, No_Elist
);
1311 Init_Size_Align
(Standard_Exception_Type
);
1312 Set_Size_Known_At_Compile_Time
1313 (Standard_Exception_Type
, True);
1314 Make_Name
(Standard_Exception_Type
, "exception");
1317 (Standard_Exception_Type
, Standard_Boolean
, "Not_Handled_By_Others");
1319 (Standard_Exception_Type
, Standard_Character
, "Lang");
1321 (Standard_Exception_Type
, Standard_Natural
, "Name_Length");
1323 (Standard_Exception_Type
, Standard_A_Char
, "Full_Name");
1325 (Standard_Exception_Type
, Standard_A_Char
, "HTable_Ptr");
1327 (Standard_Exception_Type
, Standard_Unsigned
, "Import_Code");
1329 (Standard_Exception_Type
, Standard_A_Char
, "Raise_Hook");
1331 -- Build tree for record declaration, for use by the back-end
1334 Comp_List
: List_Id
;
1338 Comp
:= First_Entity
(Standard_Exception_Type
);
1339 Comp_List
:= New_List
;
1340 while Present
(Comp
) loop
1342 Make_Component_Declaration
(Stloc
,
1343 Defining_Identifier
=> Comp
,
1344 Component_Definition
=>
1345 Make_Component_Definition
(Stloc
,
1346 Aliased_Present
=> False,
1347 Subtype_Indication
=> New_Occurrence_Of
(Etype
(Comp
),
1354 Decl
:= Make_Full_Type_Declaration
(Stloc
,
1355 Defining_Identifier
=> Standard_Exception_Type
,
1357 Make_Record_Definition
(Stloc
,
1360 Make_Component_List
(Stloc
,
1361 Component_Items
=> Comp_List
)));
1364 Append
(Decl
, Decl_S
);
1366 Layout_Type
(Standard_Exception_Type
);
1368 -- Create declarations of standard exceptions
1370 Build_Exception
(S_Constraint_Error
);
1371 Build_Exception
(S_Program_Error
);
1372 Build_Exception
(S_Storage_Error
);
1373 Build_Exception
(S_Tasking_Error
);
1375 -- Numeric_Error is a normal exception in Ada 83, but in Ada 95
1376 -- it is a renaming of Constraint_Error. Is this test too early???
1378 if Ada_Version
= Ada_83
then
1379 Build_Exception
(S_Numeric_Error
);
1382 Decl
:= New_Node
(N_Exception_Renaming_Declaration
, Stloc
);
1383 E_Id
:= Standard_Entity
(S_Numeric_Error
);
1385 Set_Ekind
(E_Id
, E_Exception
);
1386 Set_Exception_Code
(E_Id
, Uint_0
);
1387 Set_Etype
(E_Id
, Standard_Exception_Type
);
1388 Set_Is_Public
(E_Id
);
1389 Set_Renamed_Entity
(E_Id
, Standard_Entity
(S_Constraint_Error
));
1391 Set_Defining_Identifier
(Decl
, E_Id
);
1392 Append
(Decl
, Decl_S
);
1394 Ident_Node
:= New_Node
(N_Identifier
, Stloc
);
1395 Set_Chars
(Ident_Node
, Chars
(Standard_Entity
(S_Constraint_Error
)));
1396 Set_Entity
(Ident_Node
, Standard_Entity
(S_Constraint_Error
));
1397 Set_Name
(Decl
, Ident_Node
);
1400 -- Abort_Signal is an entity that does not get made visible
1402 Abort_Signal
:= New_Standard_Entity
;
1403 Set_Chars
(Abort_Signal
, Name_uAbort_Signal
);
1404 Set_Ekind
(Abort_Signal
, E_Exception
);
1405 Set_Exception_Code
(Abort_Signal
, Uint_0
);
1406 Set_Etype
(Abort_Signal
, Standard_Exception_Type
);
1407 Set_Scope
(Abort_Signal
, Standard_Standard
);
1408 Set_Is_Public
(Abort_Signal
, True);
1410 Make_Exception_Declaration
(Stloc
,
1411 Defining_Identifier
=> Abort_Signal
);
1413 -- Create defining identifiers for shift operator entities. Note
1414 -- that these entities are used only for marking shift operators
1415 -- generated internally, and hence need no structure, just a name
1416 -- and a unique identity.
1418 Standard_Op_Rotate_Left
:= New_Standard_Entity
;
1419 Set_Chars
(Standard_Op_Rotate_Left
, Name_Rotate_Left
);
1420 Set_Ekind
(Standard_Op_Rotate_Left
, E_Operator
);
1422 Standard_Op_Rotate_Right
:= New_Standard_Entity
;
1423 Set_Chars
(Standard_Op_Rotate_Right
, Name_Rotate_Right
);
1424 Set_Ekind
(Standard_Op_Rotate_Right
, E_Operator
);
1426 Standard_Op_Shift_Left
:= New_Standard_Entity
;
1427 Set_Chars
(Standard_Op_Shift_Left
, Name_Shift_Left
);
1428 Set_Ekind
(Standard_Op_Shift_Left
, E_Operator
);
1430 Standard_Op_Shift_Right
:= New_Standard_Entity
;
1431 Set_Chars
(Standard_Op_Shift_Right
, Name_Shift_Right
);
1432 Set_Ekind
(Standard_Op_Shift_Right
, E_Operator
);
1434 Standard_Op_Shift_Right_Arithmetic
:= New_Standard_Entity
;
1435 Set_Chars
(Standard_Op_Shift_Right_Arithmetic
,
1436 Name_Shift_Right_Arithmetic
);
1437 Set_Ekind
(Standard_Op_Shift_Right_Arithmetic
,
1440 -- Create standard operator declarations
1444 -- Initialize visibility table with entities in Standard
1446 for E
in Standard_Entity_Type
loop
1447 if Ekind
(Standard_Entity
(E
)) /= E_Operator
then
1449 (Chars
(Standard_Entity
(E
)), Standard_Entity
(E
));
1450 Set_Homonym
(Standard_Entity
(E
), Empty
);
1453 if E
not in S_ASCII_Names
then
1454 Set_Scope
(Standard_Entity
(E
), Standard_Standard
);
1455 Set_Is_Immediately_Visible
(Standard_Entity
(E
));
1459 -- The predefined package Standard itself does not have a scope;
1460 -- it is the only entity in the system not to have one, and this
1461 -- is what identifies the package to Gigi.
1463 Set_Scope
(Standard_Standard
, Empty
);
1465 -- Set global variables indicating last Id values and version
1467 Last_Standard_Node_Id
:= Last_Node_Id
;
1468 Last_Standard_List_Id
:= Last_List_Id
;
1470 -- The Error node has an Etype of Any_Type to help error recovery
1472 Set_Etype
(Error
, Any_Type
);
1474 -- Print representation of standard if switch set
1476 if Opt
.Print_Standard
then
1479 end Create_Standard
;
1481 ------------------------------------
1482 -- Create_Unconstrained_Base_Type --
1483 ------------------------------------
1485 procedure Create_Unconstrained_Base_Type
1489 New_Ent
: constant Entity_Id
:= New_Copy
(E
);
1493 Set_Is_Constrained
(E
, True);
1494 Set_Is_First_Subtype
(E
, True);
1495 Set_Etype
(E
, New_Ent
);
1497 Append_Entity
(New_Ent
, Standard_Standard
);
1498 Set_Is_Constrained
(New_Ent
, False);
1499 Set_Etype
(New_Ent
, New_Ent
);
1500 Set_Is_Known_Valid
(New_Ent
, True);
1502 if K
= E_Signed_Integer_Subtype
then
1503 Set_Etype
(Low_Bound
(Scalar_Range
(E
)), New_Ent
);
1504 Set_Etype
(High_Bound
(Scalar_Range
(E
)), New_Ent
);
1507 end Create_Unconstrained_Base_Type
;
1509 --------------------
1510 -- Identifier_For --
1511 --------------------
1513 function Identifier_For
(S
: Standard_Entity_Type
) return Node_Id
is
1514 Ident_Node
: Node_Id
;
1516 Ident_Node
:= New_Node
(N_Identifier
, Stloc
);
1517 Set_Chars
(Ident_Node
, Chars
(Standard_Entity
(S
)));
1521 --------------------
1522 -- Make_Component --
1523 --------------------
1525 procedure Make_Component
1530 Id
: constant Entity_Id
:= New_Standard_Entity
;
1533 Set_Ekind
(Id
, E_Component
);
1534 Set_Etype
(Id
, Typ
);
1535 Set_Scope
(Id
, Rec
);
1536 Init_Component_Location
(Id
);
1538 Set_Original_Record_Component
(Id
, Id
);
1539 Make_Name
(Id
, Nam
);
1540 Append_Entity
(Id
, Rec
);
1547 function Make_Formal
1549 Formal_Name
: String) return Entity_Id
1554 Formal
:= New_Standard_Entity
;
1556 Set_Ekind
(Formal
, E_In_Parameter
);
1557 Set_Mechanism
(Formal
, Default_Mechanism
);
1558 Set_Scope
(Formal
, Standard_Standard
);
1559 Set_Etype
(Formal
, Typ
);
1560 Make_Name
(Formal
, Formal_Name
);
1569 function Make_Integer
(V
: Uint
) return Node_Id
is
1570 N
: constant Node_Id
:= Make_Integer_Literal
(Stloc
, V
);
1572 Set_Is_Static_Expression
(N
);
1580 procedure Make_Name
(Id
: Entity_Id
; Nam
: String) is
1582 for J
in 1 .. Nam
'Length loop
1583 Name_Buffer
(J
) := Fold_Lower
(Nam
(Nam
'First + (J
- 1)));
1586 Name_Len
:= Nam
'Length;
1587 Set_Chars
(Id
, Name_Find
);
1594 function New_Operator
(Op
: Name_Id
; Typ
: Entity_Id
) return Entity_Id
is
1595 Ident_Node
: Entity_Id
;
1598 Ident_Node
:= Make_Defining_Identifier
(Stloc
, Op
);
1600 Set_Is_Pure
(Ident_Node
, True);
1601 Set_Ekind
(Ident_Node
, E_Operator
);
1602 Set_Etype
(Ident_Node
, Typ
);
1603 Set_Scope
(Ident_Node
, Standard_Standard
);
1604 Set_Homonym
(Ident_Node
, Get_Name_Entity_Id
(Op
));
1605 Set_Convention
(Ident_Node
, Convention_Intrinsic
);
1607 Set_Is_Immediately_Visible
(Ident_Node
, True);
1608 Set_Is_Intrinsic_Subprogram
(Ident_Node
, True);
1610 Set_Name_Entity_Id
(Op
, Ident_Node
);
1611 Append_Entity
(Ident_Node
, Standard_Standard
);
1615 -------------------------
1616 -- New_Standard_Entity --
1617 -------------------------
1619 function New_Standard_Entity
1620 (New_Node_Kind
: Node_Kind
:= N_Defining_Identifier
) return Entity_Id
1622 E
: constant Entity_Id
:= New_Entity
(New_Node_Kind
, Stloc
);
1625 -- All standard entities are Pure and Public
1630 -- All standard entity names are analyzed manually, and are thus
1631 -- frozen as soon as they are created.
1635 -- Set debug information required for all standard types
1637 Set_Needs_Debug_Info
(E
);
1639 -- All standard entities are built with fully qualified names, so
1640 -- set the flag to prevent an abortive attempt at requalification!
1642 Set_Has_Qualified_Name
(E
);
1644 -- Return newly created entity to be completed by caller
1647 end New_Standard_Entity
;
1649 --------------------
1650 -- Print_Standard --
1651 --------------------
1653 procedure Print_Standard
is
1655 procedure P
(Item
: String) renames Output
.Write_Line
;
1656 -- Short-hand, since we do a lot of line writes here!
1658 procedure P_Int_Range
(Size
: Pos
);
1659 -- Prints the range of an integer based on its Size
1661 procedure P_Float_Range
(Id
: Entity_Id
);
1662 -- Prints the bounds range for the given float type entity
1668 procedure P_Float_Range
(Id
: Entity_Id
) is
1669 Digs
: constant Nat
:= UI_To_Int
(Digits_Value
(Id
));
1672 Write_Str
(" range ");
1674 if Vax_Float
(Id
) then
1675 if Digs
= VAXFF_Digits
then
1676 Write_Str
(VAXFF_First
'Universal_Literal_String);
1678 Write_Str
(VAXFF_Last
'Universal_Literal_String);
1680 elsif Digs
= VAXDF_Digits
then
1681 Write_Str
(VAXDF_First
'Universal_Literal_String);
1683 Write_Str
(VAXDF_Last
'Universal_Literal_String);
1686 pragma Assert
(Digs
= VAXGF_Digits
);
1688 Write_Str
(VAXGF_First
'Universal_Literal_String);
1690 Write_Str
(VAXGF_Last
'Universal_Literal_String);
1693 elsif Is_AAMP_Float
(Id
) then
1694 if Digs
= AAMPS_Digits
then
1695 Write_Str
(AAMPS_First
'Universal_Literal_String);
1697 Write_Str
(AAMPS_Last
'Universal_Literal_String);
1700 pragma Assert
(Digs
= AAMPL_Digits
);
1701 Write_Str
(AAMPL_First
'Universal_Literal_String);
1703 Write_Str
(AAMPL_Last
'Universal_Literal_String);
1706 elsif Digs
= IEEES_Digits
then
1707 Write_Str
(IEEES_First
'Universal_Literal_String);
1709 Write_Str
(IEEES_Last
'Universal_Literal_String);
1711 elsif Digs
= IEEEL_Digits
then
1712 Write_Str
(IEEEL_First
'Universal_Literal_String);
1714 Write_Str
(IEEEL_Last
'Universal_Literal_String);
1717 pragma Assert
(Digs
= IEEEX_Digits
);
1719 Write_Str
(IEEEX_First
'Universal_Literal_String);
1721 Write_Str
(IEEEX_Last
'Universal_Literal_String);
1732 procedure P_Int_Range
(Size
: Pos
) is
1734 Write_Str
(" is range -(2 **");
1735 Write_Int
(Size
- 1);
1737 Write_Str
(" .. +(2 **");
1738 Write_Int
(Size
- 1);
1739 Write_Str
(" - 1);");
1743 -- Start of processing for Print_Standard
1746 P
("-- Representation of package Standard");
1748 P
("-- This is not accurate Ada, since new base types cannot be ");
1749 P
("-- created, but the listing shows the target dependent");
1750 P
("-- characteristics of the Standard types for this compiler");
1753 P
("package Standard is");
1754 P
("pragma Pure (Standard);");
1757 P
(" type Boolean is (False, True);");
1758 P
(" for Boolean'Size use 1;");
1759 P
(" for Boolean use (False => 0, True => 1);");
1764 Write_Str
(" type Integer");
1765 P_Int_Range
(Standard_Integer_Size
);
1766 Write_Str
(" for Integer'Size use ");
1767 Write_Int
(Standard_Integer_Size
);
1771 P
(" subtype Natural is Integer range 0 .. Integer'Last;");
1772 P
(" subtype Positive is Integer range 1 .. Integer'Last;");
1775 Write_Str
(" type Short_Short_Integer");
1776 P_Int_Range
(Standard_Short_Short_Integer_Size
);
1777 Write_Str
(" for Short_Short_Integer'Size use ");
1778 Write_Int
(Standard_Short_Short_Integer_Size
);
1782 Write_Str
(" type Short_Integer");
1783 P_Int_Range
(Standard_Short_Integer_Size
);
1784 Write_Str
(" for Short_Integer'Size use ");
1785 Write_Int
(Standard_Short_Integer_Size
);
1789 Write_Str
(" type Long_Integer");
1790 P_Int_Range
(Standard_Long_Integer_Size
);
1791 Write_Str
(" for Long_Integer'Size use ");
1792 Write_Int
(Standard_Long_Integer_Size
);
1796 Write_Str
(" type Long_Long_Integer");
1797 P_Int_Range
(Standard_Long_Long_Integer_Size
);
1798 Write_Str
(" for Long_Long_Integer'Size use ");
1799 Write_Int
(Standard_Long_Long_Integer_Size
);
1803 -- Floating point types
1805 Write_Str
(" type Short_Float is digits ");
1806 Write_Int
(Standard_Short_Float_Digits
);
1808 P_Float_Range
(Standard_Short_Float
);
1809 Write_Str
(" for Short_Float'Size use ");
1810 Write_Int
(Standard_Short_Float_Size
);
1814 Write_Str
(" type Float is digits ");
1815 Write_Int
(Standard_Float_Digits
);
1817 P_Float_Range
(Standard_Float
);
1818 Write_Str
(" for Float'Size use ");
1819 Write_Int
(Standard_Float_Size
);
1823 Write_Str
(" type Long_Float is digits ");
1824 Write_Int
(Standard_Long_Float_Digits
);
1826 P_Float_Range
(Standard_Long_Float
);
1827 Write_Str
(" for Long_Float'Size use ");
1828 Write_Int
(Standard_Long_Float_Size
);
1832 Write_Str
(" type Long_Long_Float is digits ");
1833 Write_Int
(Standard_Long_Long_Float_Digits
);
1835 P_Float_Range
(Standard_Long_Long_Float
);
1836 Write_Str
(" for Long_Long_Float'Size use ");
1837 Write_Int
(Standard_Long_Long_Float_Size
);
1841 P
(" type Character is (...)");
1842 Write_Str
(" for Character'Size use ");
1843 Write_Int
(Standard_Character_Size
);
1845 P
(" -- See RM A.1(35) for details of this type");
1848 P
(" type Wide_Character is (...)");
1849 Write_Str
(" for Wide_Character'Size use ");
1850 Write_Int
(Standard_Wide_Character_Size
);
1852 P
(" -- See RM A.1(36) for details of this type");
1855 P
(" type Wide_Wide_Character is (...)");
1856 Write_Str
(" for Wide_Wide_Character'Size use ");
1857 Write_Int
(Standard_Wide_Wide_Character_Size
);
1859 P
(" -- See RM A.1(36) for details of this type");
1861 P
(" type String is array (Positive range <>) of Character;");
1862 P
(" pragma Pack (String);");
1865 P
(" type Wide_String is array (Positive range <>)" &
1866 " of Wide_Character;");
1867 P
(" pragma Pack (Wide_String);");
1870 P
(" type Wide_Wide_String is array (Positive range <>)" &
1871 " of Wide_Wide_Character;");
1872 P
(" pragma Pack (Wide_Wide_String);");
1875 -- Here it's OK to use the Duration type of the host compiler since
1876 -- the implementation of Duration in GNAT is target independent.
1878 if Duration_32_Bits_On_Target
then
1879 P
(" type Duration is delta 0.020");
1880 P
(" range -((2 ** 31 - 1) * 0.020) ..");
1881 P
(" +((2 ** 31 - 1) * 0.020);");
1882 P
(" for Duration'Small use 0.020;");
1884 P
(" type Duration is delta 0.000000001");
1885 P
(" range -((2 ** 63 - 1) * 0.000000001) ..");
1886 P
(" +((2 ** 63 - 1) * 0.000000001);");
1887 P
(" for Duration'Small use 0.000000001;");
1892 P
(" Constraint_Error : exception;");
1893 P
(" Program_Error : exception;");
1894 P
(" Storage_Error : exception;");
1895 P
(" Tasking_Error : exception;");
1896 P
(" Numeric_Error : exception renames Constraint_Error;");
1899 P
("end Standard;");
1902 ----------------------
1903 -- Set_Float_Bounds --
1904 ----------------------
1906 procedure Set_Float_Bounds
(Id
: Entity_Id
) is
1908 -- Low bound of literal value
1911 -- High bound of literal value
1914 -- Range specification
1916 Digs
: constant Nat
:= UI_To_Int
(Digits_Value
(Id
));
1917 -- Digits value, used to select bounds
1920 -- Note: for the call from Cstand to initially create the types in
1921 -- Standard, Vax_Float will always be False. Circuitry in Sem_Vfpt
1922 -- will adjust these types appropriately in the Vax_Float case if
1923 -- a pragma Float_Representation (VAX_Float) is used.
1925 if Vax_Float
(Id
) then
1926 if Digs
= VAXFF_Digits
then
1928 (VAXFF_First
'Universal_Literal_String);
1930 (VAXFF_Last
'Universal_Literal_String);
1932 elsif Digs
= VAXDF_Digits
then
1934 (VAXDF_First
'Universal_Literal_String);
1936 (VAXDF_Last
'Universal_Literal_String);
1939 pragma Assert
(Digs
= VAXGF_Digits
);
1942 (VAXGF_First
'Universal_Literal_String);
1944 (VAXGF_Last
'Universal_Literal_String);
1947 elsif Is_AAMP_Float
(Id
) then
1948 if Digs
= AAMPS_Digits
then
1950 (AAMPS_First
'Universal_Literal_String);
1952 (AAMPS_Last
'Universal_Literal_String);
1955 pragma Assert
(Digs
= AAMPL_Digits
);
1957 (AAMPL_First
'Universal_Literal_String);
1959 (AAMPL_Last
'Universal_Literal_String);
1962 elsif Digs
= IEEES_Digits
then
1964 (IEEES_First
'Universal_Literal_String);
1966 (IEEES_Last
'Universal_Literal_String);
1968 elsif Digs
= IEEEL_Digits
then
1970 (IEEEL_First
'Universal_Literal_String);
1972 (IEEEL_Last
'Universal_Literal_String);
1975 pragma Assert
(Digs
= IEEEX_Digits
);
1978 (IEEEX_First
'Universal_Literal_String);
1980 (IEEEX_Last
'Universal_Literal_String);
1984 Set_Is_Static_Expression
(L
);
1987 Set_Is_Static_Expression
(H
);
1989 R
:= New_Node
(N_Range
, Stloc
);
1990 Set_Low_Bound
(R
, L
);
1991 Set_High_Bound
(R
, H
);
1992 Set_Includes_Infinities
(R
, True);
1993 Set_Scalar_Range
(Id
, R
);
1996 end Set_Float_Bounds
;
1998 ------------------------
1999 -- Set_Integer_Bounds --
2000 ------------------------
2002 procedure Set_Integer_Bounds
2008 L
: Node_Id
; -- Low bound of literal value
2009 H
: Node_Id
; -- High bound of literal value
2010 R
: Node_Id
; -- Range specification
2013 L
:= Make_Integer
(Lb
);
2014 H
:= Make_Integer
(Hb
);
2019 R
:= New_Node
(N_Range
, Stloc
);
2020 Set_Low_Bound
(R
, L
);
2021 Set_High_Bound
(R
, H
);
2022 Set_Scalar_Range
(Id
, R
);
2025 Set_Is_Unsigned_Type
(Id
, Lb
>= 0);
2026 end Set_Integer_Bounds
;