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
);
449 Set_Has_Pragma_Ordered
(Standard_Boolean
);
451 Set_Ekind
(Standard_True
, E_Enumeration_Literal
);
452 Set_Etype
(Standard_True
, Standard_Boolean
);
453 Set_Enumeration_Pos
(Standard_True
, Uint_1
);
454 Set_Enumeration_Rep
(Standard_True
, Uint_1
);
455 Set_Is_Known_Valid
(Standard_True
, True);
457 Set_Ekind
(Standard_False
, E_Enumeration_Literal
);
458 Set_Etype
(Standard_False
, Standard_Boolean
);
459 Set_Enumeration_Pos
(Standard_False
, Uint_0
);
460 Set_Enumeration_Rep
(Standard_False
, Uint_0
);
461 Set_Is_Known_Valid
(Standard_False
, True);
463 -- For the bounds of Boolean, we create a range node corresponding to
465 -- range False .. True
467 -- where the occurrences of the literals must point to the
468 -- corresponding definition.
470 R_Node
:= New_Node
(N_Range
, Stloc
);
471 B_Node
:= New_Node
(N_Identifier
, Stloc
);
472 Set_Chars
(B_Node
, Chars
(Standard_False
));
473 Set_Entity
(B_Node
, Standard_False
);
474 Set_Etype
(B_Node
, Standard_Boolean
);
475 Set_Is_Static_Expression
(B_Node
);
476 Set_Low_Bound
(R_Node
, B_Node
);
478 B_Node
:= New_Node
(N_Identifier
, Stloc
);
479 Set_Chars
(B_Node
, Chars
(Standard_True
));
480 Set_Entity
(B_Node
, Standard_True
);
481 Set_Etype
(B_Node
, Standard_Boolean
);
482 Set_Is_Static_Expression
(B_Node
);
483 Set_High_Bound
(R_Node
, B_Node
);
485 Set_Scalar_Range
(Standard_Boolean
, R_Node
);
486 Set_Etype
(R_Node
, Standard_Boolean
);
487 Set_Parent
(R_Node
, Standard_Boolean
);
489 -- Record entity identifiers for boolean literals in the
490 -- Boolean_Literals array, for easy reference during expansion.
492 Boolean_Literals
:= (False => Standard_False
, True => Standard_True
);
494 -- Create type definition nodes for predefined integer types
496 Build_Signed_Integer_Type
497 (Standard_Short_Short_Integer
, Standard_Short_Short_Integer_Size
);
499 Build_Signed_Integer_Type
500 (Standard_Short_Integer
, Standard_Short_Integer_Size
);
502 Build_Signed_Integer_Type
503 (Standard_Integer
, Standard_Integer_Size
);
511 LIS
:= Standard_Long_Integer_Size
;
514 Build_Signed_Integer_Type
(Standard_Long_Integer
, LIS
);
517 Build_Signed_Integer_Type
518 (Standard_Long_Long_Integer
, Standard_Long_Long_Integer_Size
);
520 Create_Unconstrained_Base_Type
521 (Standard_Short_Short_Integer
, E_Signed_Integer_Subtype
);
523 Create_Unconstrained_Base_Type
524 (Standard_Short_Integer
, E_Signed_Integer_Subtype
);
526 Create_Unconstrained_Base_Type
527 (Standard_Integer
, E_Signed_Integer_Subtype
);
529 Create_Unconstrained_Base_Type
530 (Standard_Long_Integer
, E_Signed_Integer_Subtype
);
532 Create_Unconstrained_Base_Type
533 (Standard_Long_Long_Integer
, E_Signed_Integer_Subtype
);
535 -- Create type definition nodes for predefined float types
538 (Standard_Short_Float
,
539 Standard_Short_Float_Size
,
540 Standard_Short_Float_Digits
);
545 Standard_Float_Digits
);
548 (Standard_Long_Float
,
549 Standard_Long_Float_Size
,
550 Standard_Long_Float_Digits
);
553 (Standard_Long_Long_Float
,
554 Standard_Long_Long_Float_Size
,
555 Standard_Long_Long_Float_Digits
);
557 -- Create type definition node for type Character. Note that we do not
558 -- set the Literals field, since type Character is handled with special
559 -- routine that do not need a literal list.
561 Tdef_Node
:= New_Node
(N_Enumeration_Type_Definition
, Stloc
);
562 Set_Type_Definition
(Parent
(Standard_Character
), Tdef_Node
);
564 Set_Ekind
(Standard_Character
, E_Enumeration_Type
);
565 Set_Etype
(Standard_Character
, Standard_Character
);
566 Init_Esize
(Standard_Character
, Standard_Character_Size
);
567 Init_RM_Size
(Standard_Character
, 8);
568 Set_Elem_Alignment
(Standard_Character
);
570 Set_Has_Pragma_Ordered
(Standard_Character
);
571 Set_Is_Unsigned_Type
(Standard_Character
);
572 Set_Is_Character_Type
(Standard_Character
);
573 Set_Is_Known_Valid
(Standard_Character
);
574 Set_Size_Known_At_Compile_Time
(Standard_Character
);
576 -- Create the bounds for type Character
578 R_Node
:= New_Node
(N_Range
, Stloc
);
580 -- Low bound for type Character (Standard.Nul)
582 B_Node
:= New_Node
(N_Character_Literal
, Stloc
);
583 Set_Is_Static_Expression
(B_Node
);
584 Set_Chars
(B_Node
, No_Name
);
585 Set_Char_Literal_Value
(B_Node
, Uint_0
);
586 Set_Entity
(B_Node
, Empty
);
587 Set_Etype
(B_Node
, Standard_Character
);
588 Set_Low_Bound
(R_Node
, B_Node
);
590 -- High bound for type Character
592 B_Node
:= New_Node
(N_Character_Literal
, Stloc
);
593 Set_Is_Static_Expression
(B_Node
);
594 Set_Chars
(B_Node
, No_Name
);
595 Set_Char_Literal_Value
(B_Node
, UI_From_Int
(16#FF#
));
596 Set_Entity
(B_Node
, Empty
);
597 Set_Etype
(B_Node
, Standard_Character
);
598 Set_High_Bound
(R_Node
, B_Node
);
600 Set_Scalar_Range
(Standard_Character
, R_Node
);
601 Set_Etype
(R_Node
, Standard_Character
);
602 Set_Parent
(R_Node
, Standard_Character
);
604 -- Create type definition for type Wide_Character. Note that we do not
605 -- set the Literals field, since type Wide_Character is handled with
606 -- special routines that do not need a literal list.
608 Tdef_Node
:= New_Node
(N_Enumeration_Type_Definition
, Stloc
);
609 Set_Type_Definition
(Parent
(Standard_Wide_Character
), Tdef_Node
);
611 Set_Ekind
(Standard_Wide_Character
, E_Enumeration_Type
);
612 Set_Etype
(Standard_Wide_Character
, Standard_Wide_Character
);
613 Init_Size
(Standard_Wide_Character
, Standard_Wide_Character_Size
);
615 Set_Elem_Alignment
(Standard_Wide_Character
);
616 Set_Has_Pragma_Ordered
(Standard_Wide_Character
);
617 Set_Is_Unsigned_Type
(Standard_Wide_Character
);
618 Set_Is_Character_Type
(Standard_Wide_Character
);
619 Set_Is_Known_Valid
(Standard_Wide_Character
);
620 Set_Size_Known_At_Compile_Time
(Standard_Wide_Character
);
622 -- Create the bounds for type Wide_Character
624 R_Node
:= New_Node
(N_Range
, Stloc
);
626 -- Low bound for type Wide_Character
628 B_Node
:= New_Node
(N_Character_Literal
, Stloc
);
629 Set_Is_Static_Expression
(B_Node
);
630 Set_Chars
(B_Node
, No_Name
); -- ???
631 Set_Char_Literal_Value
(B_Node
, Uint_0
);
632 Set_Entity
(B_Node
, Empty
);
633 Set_Etype
(B_Node
, Standard_Wide_Character
);
634 Set_Low_Bound
(R_Node
, B_Node
);
636 -- High bound for type Wide_Character
638 B_Node
:= New_Node
(N_Character_Literal
, Stloc
);
639 Set_Is_Static_Expression
(B_Node
);
640 Set_Chars
(B_Node
, No_Name
); -- ???
641 Set_Char_Literal_Value
(B_Node
, UI_From_Int
(16#FFFF#
));
642 Set_Entity
(B_Node
, Empty
);
643 Set_Etype
(B_Node
, Standard_Wide_Character
);
644 Set_High_Bound
(R_Node
, B_Node
);
646 Set_Scalar_Range
(Standard_Wide_Character
, R_Node
);
647 Set_Etype
(R_Node
, Standard_Wide_Character
);
648 Set_Parent
(R_Node
, Standard_Wide_Character
);
650 -- Create type definition for type Wide_Wide_Character. Note that we
651 -- do not set the Literals field, since type Wide_Wide_Character is
652 -- handled with special routines that do not need a literal list.
654 Tdef_Node
:= New_Node
(N_Enumeration_Type_Definition
, Stloc
);
655 Set_Type_Definition
(Parent
(Standard_Wide_Wide_Character
), Tdef_Node
);
657 Set_Ekind
(Standard_Wide_Wide_Character
, E_Enumeration_Type
);
658 Set_Etype
(Standard_Wide_Wide_Character
,
659 Standard_Wide_Wide_Character
);
660 Init_Size
(Standard_Wide_Wide_Character
,
661 Standard_Wide_Wide_Character_Size
);
663 Set_Elem_Alignment
(Standard_Wide_Wide_Character
);
664 Set_Has_Pragma_Ordered
(Standard_Wide_Wide_Character
);
665 Set_Is_Unsigned_Type
(Standard_Wide_Wide_Character
);
666 Set_Is_Character_Type
(Standard_Wide_Wide_Character
);
667 Set_Is_Known_Valid
(Standard_Wide_Wide_Character
);
668 Set_Size_Known_At_Compile_Time
(Standard_Wide_Wide_Character
);
669 Set_Is_Ada_2005_Only
(Standard_Wide_Wide_Character
);
671 -- Create the bounds for type Wide_Wide_Character
673 R_Node
:= New_Node
(N_Range
, Stloc
);
675 -- Low bound for type Wide_Wide_Character
677 B_Node
:= New_Node
(N_Character_Literal
, Stloc
);
678 Set_Is_Static_Expression
(B_Node
);
679 Set_Chars
(B_Node
, No_Name
); -- ???
680 Set_Char_Literal_Value
(B_Node
, Uint_0
);
681 Set_Entity
(B_Node
, Empty
);
682 Set_Etype
(B_Node
, Standard_Wide_Wide_Character
);
683 Set_Low_Bound
(R_Node
, B_Node
);
685 -- High bound for type Wide_Wide_Character
687 B_Node
:= New_Node
(N_Character_Literal
, Stloc
);
688 Set_Is_Static_Expression
(B_Node
);
689 Set_Chars
(B_Node
, No_Name
); -- ???
690 Set_Char_Literal_Value
(B_Node
, UI_From_Int
(16#
7FFF_FFFF#
));
691 Set_Entity
(B_Node
, Empty
);
692 Set_Etype
(B_Node
, Standard_Wide_Wide_Character
);
693 Set_High_Bound
(R_Node
, B_Node
);
695 Set_Scalar_Range
(Standard_Wide_Wide_Character
, R_Node
);
696 Set_Etype
(R_Node
, Standard_Wide_Wide_Character
);
697 Set_Parent
(R_Node
, Standard_Wide_Wide_Character
);
699 -- Create type definition node for type String
701 Tdef_Node
:= New_Node
(N_Unconstrained_Array_Definition
, Stloc
);
704 CompDef_Node
: Node_Id
;
706 CompDef_Node
:= New_Node
(N_Component_Definition
, Stloc
);
707 Set_Aliased_Present
(CompDef_Node
, False);
708 Set_Access_Definition
(CompDef_Node
, Empty
);
709 Set_Subtype_Indication
(CompDef_Node
, Identifier_For
(S_Character
));
710 Set_Component_Definition
(Tdef_Node
, CompDef_Node
);
713 Set_Subtype_Marks
(Tdef_Node
, New_List
);
714 Append
(Identifier_For
(S_Positive
), Subtype_Marks
(Tdef_Node
));
715 Set_Type_Definition
(Parent
(Standard_String
), Tdef_Node
);
717 Set_Ekind
(Standard_String
, E_String_Type
);
718 Set_Etype
(Standard_String
, Standard_String
);
719 Set_Component_Type
(Standard_String
, Standard_Character
);
720 Set_Component_Size
(Standard_String
, Uint_8
);
721 Init_Size_Align
(Standard_String
);
722 Set_Alignment
(Standard_String
, Uint_1
);
723 Pack_String_Type
(Standard_String
);
725 -- On targets where a storage unit is larger than a byte (such as AAMP),
726 -- pragma Pack has a real effect on the representation of type String,
727 -- and the type must be marked as having a nonstandard representation.
729 if System_Storage_Unit
> Uint_8
then
730 Set_Has_Non_Standard_Rep
(Standard_String
);
731 Set_Has_Pragma_Pack
(Standard_String
);
734 -- Set index type of String
737 (Subtype_Marks
(Type_Definition
(Parent
(Standard_String
))));
738 Set_First_Index
(Standard_String
, E_Id
);
739 Set_Entity
(E_Id
, Standard_Positive
);
740 Set_Etype
(E_Id
, Standard_Positive
);
742 -- Create type definition node for type Wide_String
744 Tdef_Node
:= New_Node
(N_Unconstrained_Array_Definition
, Stloc
);
747 CompDef_Node
: Node_Id
;
749 CompDef_Node
:= New_Node
(N_Component_Definition
, Stloc
);
750 Set_Aliased_Present
(CompDef_Node
, False);
751 Set_Access_Definition
(CompDef_Node
, Empty
);
752 Set_Subtype_Indication
(CompDef_Node
,
753 Identifier_For
(S_Wide_Character
));
754 Set_Component_Definition
(Tdef_Node
, CompDef_Node
);
757 Set_Subtype_Marks
(Tdef_Node
, New_List
);
758 Append
(Identifier_For
(S_Positive
), Subtype_Marks
(Tdef_Node
));
759 Set_Type_Definition
(Parent
(Standard_Wide_String
), Tdef_Node
);
761 Set_Ekind
(Standard_Wide_String
, E_String_Type
);
762 Set_Etype
(Standard_Wide_String
, Standard_Wide_String
);
763 Set_Component_Type
(Standard_Wide_String
, Standard_Wide_Character
);
764 Set_Component_Size
(Standard_Wide_String
, Uint_16
);
765 Init_Size_Align
(Standard_Wide_String
);
766 Pack_String_Type
(Standard_Wide_String
);
768 -- Set index type of Wide_String
771 (Subtype_Marks
(Type_Definition
(Parent
(Standard_Wide_String
))));
772 Set_First_Index
(Standard_Wide_String
, E_Id
);
773 Set_Entity
(E_Id
, Standard_Positive
);
774 Set_Etype
(E_Id
, Standard_Positive
);
776 -- Create type definition node for type Wide_Wide_String
778 Tdef_Node
:= New_Node
(N_Unconstrained_Array_Definition
, Stloc
);
781 CompDef_Node
: Node_Id
;
783 CompDef_Node
:= New_Node
(N_Component_Definition
, Stloc
);
784 Set_Aliased_Present
(CompDef_Node
, False);
785 Set_Access_Definition
(CompDef_Node
, Empty
);
786 Set_Subtype_Indication
(CompDef_Node
,
787 Identifier_For
(S_Wide_Wide_Character
));
788 Set_Component_Definition
(Tdef_Node
, CompDef_Node
);
791 Set_Subtype_Marks
(Tdef_Node
, New_List
);
792 Append
(Identifier_For
(S_Positive
), Subtype_Marks
(Tdef_Node
));
793 Set_Type_Definition
(Parent
(Standard_Wide_Wide_String
), Tdef_Node
);
795 Set_Ekind
(Standard_Wide_Wide_String
, E_String_Type
);
796 Set_Etype
(Standard_Wide_Wide_String
,
797 Standard_Wide_Wide_String
);
798 Set_Component_Type
(Standard_Wide_Wide_String
,
799 Standard_Wide_Wide_Character
);
800 Set_Component_Size
(Standard_Wide_Wide_String
, Uint_32
);
801 Init_Size_Align
(Standard_Wide_Wide_String
);
802 Set_Is_Ada_2005_Only
(Standard_Wide_Wide_String
);
803 Pack_String_Type
(Standard_Wide_Wide_String
);
805 -- Set index type of Wide_Wide_String
808 (Subtype_Marks
(Type_Definition
(Parent
(Standard_Wide_Wide_String
))));
809 Set_First_Index
(Standard_Wide_Wide_String
, E_Id
);
810 Set_Entity
(E_Id
, Standard_Positive
);
811 Set_Etype
(E_Id
, Standard_Positive
);
813 -- Setup entity for Naturalend Create_Standard;
815 Set_Ekind
(Standard_Natural
, E_Signed_Integer_Subtype
);
816 Set_Etype
(Standard_Natural
, Base_Type
(Standard_Integer
));
817 Init_Esize
(Standard_Natural
, Standard_Integer_Size
);
818 Init_RM_Size
(Standard_Natural
, Standard_Integer_Size
- 1);
819 Set_Elem_Alignment
(Standard_Natural
);
820 Set_Size_Known_At_Compile_Time
822 Set_Integer_Bounds
(Standard_Natural
,
823 Typ
=> Base_Type
(Standard_Integer
),
825 Hb
=> Intval
(High_Bound
(Scalar_Range
(Standard_Integer
))));
826 Set_Is_Constrained
(Standard_Natural
);
828 -- Setup entity for Positive
830 Set_Ekind
(Standard_Positive
, E_Signed_Integer_Subtype
);
831 Set_Etype
(Standard_Positive
, Base_Type
(Standard_Integer
));
832 Init_Esize
(Standard_Positive
, Standard_Integer_Size
);
833 Init_RM_Size
(Standard_Positive
, Standard_Integer_Size
- 1);
834 Set_Elem_Alignment
(Standard_Positive
);
836 Set_Size_Known_At_Compile_Time
(Standard_Positive
);
838 Set_Integer_Bounds
(Standard_Positive
,
839 Typ
=> Base_Type
(Standard_Integer
),
841 Hb
=> Intval
(High_Bound
(Scalar_Range
(Standard_Integer
))));
842 Set_Is_Constrained
(Standard_Positive
);
844 -- Create declaration for package ASCII
846 Decl
:= New_Node
(N_Package_Declaration
, Stloc
);
847 Append
(Decl
, Decl_S
);
849 Pspec
:= New_Node
(N_Package_Specification
, Stloc
);
850 Set_Specification
(Decl
, Pspec
);
852 Set_Defining_Unit_Name
(Pspec
, Standard_Entity
(S_ASCII
));
853 Set_Ekind
(Standard_Entity
(S_ASCII
), E_Package
);
854 Set_Visible_Declarations
(Pspec
, Decl_A
);
856 -- Create control character definitions in package ASCII. Note that
857 -- the character literal entries created here correspond to literal
858 -- values that are impossible in the source, but can be represented
859 -- internally with no difficulties.
863 for S
in S_ASCII_Names
loop
864 Decl
:= New_Node
(N_Object_Declaration
, Staloc
);
865 Set_Constant_Present
(Decl
, True);
868 A_Char
: constant Entity_Id
:= Standard_Entity
(S
);
872 Set_Sloc
(A_Char
, Staloc
);
873 Set_Ekind
(A_Char
, E_Constant
);
874 Set_Never_Set_In_Source
(A_Char
, True);
875 Set_Is_True_Constant
(A_Char
, True);
876 Set_Etype
(A_Char
, Standard_Character
);
877 Set_Scope
(A_Char
, Standard_Entity
(S_ASCII
));
878 Set_Is_Immediately_Visible
(A_Char
, False);
879 Set_Is_Public
(A_Char
, True);
880 Set_Is_Known_Valid
(A_Char
, True);
882 Append_Entity
(A_Char
, Standard_Entity
(S_ASCII
));
883 Set_Defining_Identifier
(Decl
, A_Char
);
885 Set_Object_Definition
(Decl
, Identifier_For
(S_Character
));
886 Expr_Decl
:= New_Node
(N_Character_Literal
, Staloc
);
887 Set_Expression
(Decl
, Expr_Decl
);
889 Set_Is_Static_Expression
(Expr_Decl
);
890 Set_Chars
(Expr_Decl
, No_Name
);
891 Set_Etype
(Expr_Decl
, Standard_Character
);
892 Set_Char_Literal_Value
(Expr_Decl
, UI_From_Int
(Int
(Ccode
)));
895 Append
(Decl
, Decl_A
);
897 -- Increment character code, dealing with non-contiguities
901 if Ccode
= 16#
20#
then
903 elsif Ccode
= 16#
27#
then
905 elsif Ccode
= 16#
3C#
then
907 elsif Ccode
= 16#
41#
then
912 -- Create semantic phase entities
914 Standard_Void_Type
:= New_Standard_Entity
;
915 Set_Ekind
(Standard_Void_Type
, E_Void
);
916 Set_Etype
(Standard_Void_Type
, Standard_Void_Type
);
917 Set_Scope
(Standard_Void_Type
, Standard_Standard
);
918 Make_Name
(Standard_Void_Type
, "_void_type");
920 -- The type field of packages is set to void
922 Set_Etype
(Standard_Standard
, Standard_Void_Type
);
923 Set_Etype
(Standard_ASCII
, Standard_Void_Type
);
925 -- Standard_A_String is actually used in generated code, so it has a
926 -- type name that is reasonable, but does not overlap any Ada name.
928 Standard_A_String
:= New_Standard_Entity
;
929 Set_Ekind
(Standard_A_String
, E_Access_Type
);
930 Set_Scope
(Standard_A_String
, Standard_Standard
);
931 Set_Etype
(Standard_A_String
, Standard_A_String
);
934 Init_Size
(Standard_A_String
, System_Address_Size
);
936 Init_Size
(Standard_A_String
, System_Address_Size
* 2);
939 Init_Alignment
(Standard_A_String
);
941 Set_Directly_Designated_Type
942 (Standard_A_String
, Standard_String
);
943 Make_Name
(Standard_A_String
, "access_string");
945 Standard_A_Char
:= New_Standard_Entity
;
946 Set_Ekind
(Standard_A_Char
, E_Access_Type
);
947 Set_Scope
(Standard_A_Char
, Standard_Standard
);
948 Set_Etype
(Standard_A_Char
, Standard_A_String
);
949 Init_Size
(Standard_A_Char
, System_Address_Size
);
950 Set_Elem_Alignment
(Standard_A_Char
);
952 Set_Directly_Designated_Type
(Standard_A_Char
, Standard_Character
);
953 Make_Name
(Standard_A_Char
, "access_character");
955 -- Standard_Debug_Renaming_Type is used for the special objects created
956 -- to encode the names occurring in renaming declarations for use by the
957 -- debugger (see exp_dbug.adb). The type is a zero-sized subtype of
960 Standard_Debug_Renaming_Type
:= New_Standard_Entity
;
962 Set_Ekind
(Standard_Debug_Renaming_Type
, E_Signed_Integer_Subtype
);
963 Set_Scope
(Standard_Debug_Renaming_Type
, Standard_Standard
);
964 Set_Etype
(Standard_Debug_Renaming_Type
, Base_Type
(Standard_Integer
));
965 Init_Esize
(Standard_Debug_Renaming_Type
, 0);
966 Init_RM_Size
(Standard_Debug_Renaming_Type
, 0);
967 Set_Size_Known_At_Compile_Time
(Standard_Debug_Renaming_Type
);
968 Set_Integer_Bounds
(Standard_Debug_Renaming_Type
,
969 Typ
=> Base_Type
(Standard_Debug_Renaming_Type
),
972 Set_Is_Constrained
(Standard_Debug_Renaming_Type
);
973 Set_Has_Size_Clause
(Standard_Debug_Renaming_Type
);
975 Make_Name
(Standard_Debug_Renaming_Type
, "_renaming_type");
977 -- Note on type names. The type names for the following special types
978 -- are constructed so that they will look reasonable should they ever
979 -- appear in error messages etc, although in practice the use of the
980 -- special insertion character } for types results in special handling
981 -- of these type names in any case. The blanks in these names would
982 -- trouble in Gigi, but that's OK here, since none of these types
983 -- should ever get through to Gigi! Attributes of these types are
984 -- filled out to minimize problems with cascaded errors (for example,
985 -- Any_Integer is given reasonable and consistent type and size values)
987 Any_Type
:= New_Standard_Entity
;
988 Decl
:= New_Node
(N_Full_Type_Declaration
, Stloc
);
989 Set_Defining_Identifier
(Decl
, Any_Type
);
990 Set_Scope
(Any_Type
, Standard_Standard
);
991 Build_Signed_Integer_Type
(Any_Type
, Standard_Integer_Size
);
992 Make_Name
(Any_Type
, "any type");
994 Any_Id
:= New_Standard_Entity
;
995 Set_Ekind
(Any_Id
, E_Variable
);
996 Set_Scope
(Any_Id
, Standard_Standard
);
997 Set_Etype
(Any_Id
, Any_Type
);
999 Init_Alignment
(Any_Id
);
1000 Make_Name
(Any_Id
, "any id");
1002 Any_Access
:= New_Standard_Entity
;
1003 Set_Ekind
(Any_Access
, E_Access_Type
);
1004 Set_Scope
(Any_Access
, Standard_Standard
);
1005 Set_Etype
(Any_Access
, Any_Access
);
1006 Init_Size
(Any_Access
, System_Address_Size
);
1007 Set_Elem_Alignment
(Any_Access
);
1008 Make_Name
(Any_Access
, "an access type");
1010 Any_Character
:= New_Standard_Entity
;
1011 Set_Ekind
(Any_Character
, E_Enumeration_Type
);
1012 Set_Scope
(Any_Character
, Standard_Standard
);
1013 Set_Etype
(Any_Character
, Any_Character
);
1014 Set_Is_Unsigned_Type
(Any_Character
);
1015 Set_Is_Character_Type
(Any_Character
);
1016 Init_Esize
(Any_Character
, Standard_Character_Size
);
1017 Init_RM_Size
(Any_Character
, 8);
1018 Set_Elem_Alignment
(Any_Character
);
1019 Set_Scalar_Range
(Any_Character
, Scalar_Range
(Standard_Character
));
1020 Make_Name
(Any_Character
, "a character type");
1022 Any_Array
:= New_Standard_Entity
;
1023 Set_Ekind
(Any_Array
, E_String_Type
);
1024 Set_Scope
(Any_Array
, Standard_Standard
);
1025 Set_Etype
(Any_Array
, Any_Array
);
1026 Set_Component_Type
(Any_Array
, Any_Character
);
1027 Init_Size_Align
(Any_Array
);
1028 Make_Name
(Any_Array
, "an array type");
1030 Any_Boolean
:= New_Standard_Entity
;
1031 Set_Ekind
(Any_Boolean
, E_Enumeration_Type
);
1032 Set_Scope
(Any_Boolean
, Standard_Standard
);
1033 Set_Etype
(Any_Boolean
, Standard_Boolean
);
1034 Init_Esize
(Any_Boolean
, Standard_Character_Size
);
1035 Init_RM_Size
(Any_Boolean
, 1);
1036 Set_Elem_Alignment
(Any_Boolean
);
1037 Set_Is_Unsigned_Type
(Any_Boolean
);
1038 Set_Scalar_Range
(Any_Boolean
, Scalar_Range
(Standard_Boolean
));
1039 Make_Name
(Any_Boolean
, "a boolean type");
1041 Any_Composite
:= New_Standard_Entity
;
1042 Set_Ekind
(Any_Composite
, E_Array_Type
);
1043 Set_Scope
(Any_Composite
, Standard_Standard
);
1044 Set_Etype
(Any_Composite
, Any_Composite
);
1045 Set_Component_Size
(Any_Composite
, Uint_0
);
1046 Set_Component_Type
(Any_Composite
, Standard_Integer
);
1047 Init_Size_Align
(Any_Composite
);
1048 Make_Name
(Any_Composite
, "a composite type");
1050 Any_Discrete
:= New_Standard_Entity
;
1051 Set_Ekind
(Any_Discrete
, E_Signed_Integer_Type
);
1052 Set_Scope
(Any_Discrete
, Standard_Standard
);
1053 Set_Etype
(Any_Discrete
, Any_Discrete
);
1054 Init_Size
(Any_Discrete
, Standard_Integer_Size
);
1055 Set_Elem_Alignment
(Any_Discrete
);
1056 Make_Name
(Any_Discrete
, "a discrete type");
1058 Any_Fixed
:= New_Standard_Entity
;
1059 Set_Ekind
(Any_Fixed
, E_Ordinary_Fixed_Point_Type
);
1060 Set_Scope
(Any_Fixed
, Standard_Standard
);
1061 Set_Etype
(Any_Fixed
, Any_Fixed
);
1062 Init_Size
(Any_Fixed
, Standard_Integer_Size
);
1063 Set_Elem_Alignment
(Any_Fixed
);
1064 Make_Name
(Any_Fixed
, "a fixed-point type");
1066 Any_Integer
:= New_Standard_Entity
;
1067 Set_Ekind
(Any_Integer
, E_Signed_Integer_Type
);
1068 Set_Scope
(Any_Integer
, Standard_Standard
);
1069 Set_Etype
(Any_Integer
, Standard_Long_Long_Integer
);
1070 Init_Size
(Any_Integer
, Standard_Long_Long_Integer_Size
);
1071 Set_Elem_Alignment
(Any_Integer
);
1075 Typ
=> Base_Type
(Standard_Integer
),
1077 Hb
=> Intval
(High_Bound
(Scalar_Range
(Standard_Integer
))));
1078 Make_Name
(Any_Integer
, "an integer type");
1080 Any_Modular
:= New_Standard_Entity
;
1081 Set_Ekind
(Any_Modular
, E_Modular_Integer_Type
);
1082 Set_Scope
(Any_Modular
, Standard_Standard
);
1083 Set_Etype
(Any_Modular
, Standard_Long_Long_Integer
);
1084 Init_Size
(Any_Modular
, Standard_Long_Long_Integer_Size
);
1085 Set_Elem_Alignment
(Any_Modular
);
1086 Set_Is_Unsigned_Type
(Any_Modular
);
1087 Make_Name
(Any_Modular
, "a modular type");
1089 Any_Numeric
:= New_Standard_Entity
;
1090 Set_Ekind
(Any_Numeric
, E_Signed_Integer_Type
);
1091 Set_Scope
(Any_Numeric
, Standard_Standard
);
1092 Set_Etype
(Any_Numeric
, Standard_Long_Long_Integer
);
1093 Init_Size
(Any_Numeric
, Standard_Long_Long_Integer_Size
);
1094 Set_Elem_Alignment
(Any_Numeric
);
1095 Make_Name
(Any_Numeric
, "a numeric type");
1097 Any_Real
:= New_Standard_Entity
;
1098 Set_Ekind
(Any_Real
, E_Floating_Point_Type
);
1099 Set_Scope
(Any_Real
, Standard_Standard
);
1100 Set_Etype
(Any_Real
, Standard_Long_Long_Float
);
1101 Init_Size
(Any_Real
, Standard_Long_Long_Float_Size
);
1102 Set_Elem_Alignment
(Any_Real
);
1103 Make_Name
(Any_Real
, "a real type");
1105 Any_Scalar
:= New_Standard_Entity
;
1106 Set_Ekind
(Any_Scalar
, E_Signed_Integer_Type
);
1107 Set_Scope
(Any_Scalar
, Standard_Standard
);
1108 Set_Etype
(Any_Scalar
, Any_Scalar
);
1109 Init_Size
(Any_Scalar
, Standard_Integer_Size
);
1110 Set_Elem_Alignment
(Any_Scalar
);
1111 Make_Name
(Any_Scalar
, "a scalar type");
1113 Any_String
:= New_Standard_Entity
;
1114 Set_Ekind
(Any_String
, E_String_Type
);
1115 Set_Scope
(Any_String
, Standard_Standard
);
1116 Set_Etype
(Any_String
, Any_String
);
1117 Set_Component_Type
(Any_String
, Any_Character
);
1118 Init_Size_Align
(Any_String
);
1119 Make_Name
(Any_String
, "a string type");
1127 Low_Bound
=> Make_Integer
(Uint_0
),
1128 High_Bound
=> Make_Integer
(Uint_2
** Standard_Integer_Size
));
1129 Set_Etype
(Index
, Standard_Integer
);
1130 Set_First_Index
(Any_String
, Index
);
1133 Standard_Integer_8
:= New_Standard_Entity
;
1134 Decl
:= New_Node
(N_Full_Type_Declaration
, Stloc
);
1135 Set_Defining_Identifier
(Decl
, Standard_Integer_8
);
1136 Make_Name
(Standard_Integer_8
, "integer_8");
1137 Set_Scope
(Standard_Integer_8
, Standard_Standard
);
1138 Build_Signed_Integer_Type
(Standard_Integer_8
, 8);
1140 Standard_Integer_16
:= New_Standard_Entity
;
1141 Decl
:= New_Node
(N_Full_Type_Declaration
, Stloc
);
1142 Set_Defining_Identifier
(Decl
, Standard_Integer_16
);
1143 Make_Name
(Standard_Integer_16
, "integer_16");
1144 Set_Scope
(Standard_Integer_16
, Standard_Standard
);
1145 Build_Signed_Integer_Type
(Standard_Integer_16
, 16);
1147 Standard_Integer_32
:= New_Standard_Entity
;
1148 Decl
:= New_Node
(N_Full_Type_Declaration
, Stloc
);
1149 Set_Defining_Identifier
(Decl
, Standard_Integer_32
);
1150 Make_Name
(Standard_Integer_32
, "integer_32");
1151 Set_Scope
(Standard_Integer_32
, Standard_Standard
);
1152 Build_Signed_Integer_Type
(Standard_Integer_32
, 32);
1154 Standard_Integer_64
:= New_Standard_Entity
;
1155 Decl
:= New_Node
(N_Full_Type_Declaration
, Stloc
);
1156 Set_Defining_Identifier
(Decl
, Standard_Integer_64
);
1157 Make_Name
(Standard_Integer_64
, "integer_64");
1158 Set_Scope
(Standard_Integer_64
, Standard_Standard
);
1159 Build_Signed_Integer_Type
(Standard_Integer_64
, 64);
1161 Standard_Unsigned
:= New_Standard_Entity
;
1162 Decl
:= New_Node
(N_Full_Type_Declaration
, Stloc
);
1163 Set_Defining_Identifier
(Decl
, Standard_Unsigned
);
1164 Make_Name
(Standard_Unsigned
, "unsigned");
1166 Set_Ekind
(Standard_Unsigned
, E_Modular_Integer_Type
);
1167 Set_Scope
(Standard_Unsigned
, Standard_Standard
);
1168 Set_Etype
(Standard_Unsigned
, Standard_Unsigned
);
1169 Init_Size
(Standard_Unsigned
, Standard_Integer_Size
);
1170 Set_Elem_Alignment
(Standard_Unsigned
);
1171 Set_Modulus
(Standard_Unsigned
,
1172 Uint_2
** Standard_Integer_Size
);
1173 Set_Is_Unsigned_Type
(Standard_Unsigned
);
1174 Set_Size_Known_At_Compile_Time
1175 (Standard_Unsigned
);
1176 Set_Is_Known_Valid
(Standard_Unsigned
, True);
1178 R_Node
:= New_Node
(N_Range
, Stloc
);
1179 Set_Low_Bound
(R_Node
, Make_Integer
(Uint_0
));
1180 Set_High_Bound
(R_Node
, Make_Integer
(Modulus
(Standard_Unsigned
) - 1));
1181 Set_Etype
(Low_Bound
(R_Node
), Standard_Unsigned
);
1182 Set_Etype
(High_Bound
(R_Node
), Standard_Unsigned
);
1183 Set_Scalar_Range
(Standard_Unsigned
, R_Node
);
1185 -- Note: universal integer and universal real are constructed as fully
1186 -- formed signed numeric types, with parameters corresponding to the
1187 -- longest runtime types (Long_Long_Integer and Long_Long_Float). This
1188 -- allows Gigi to properly process references to universal types that
1189 -- are not folded at compile time.
1191 Universal_Integer
:= New_Standard_Entity
;
1192 Decl
:= New_Node
(N_Full_Type_Declaration
, Stloc
);
1193 Set_Defining_Identifier
(Decl
, Universal_Integer
);
1194 Make_Name
(Universal_Integer
, "universal_integer");
1195 Set_Scope
(Universal_Integer
, Standard_Standard
);
1196 Build_Signed_Integer_Type
1197 (Universal_Integer
, Standard_Long_Long_Integer_Size
);
1199 Universal_Real
:= New_Standard_Entity
;
1200 Decl
:= New_Node
(N_Full_Type_Declaration
, Stloc
);
1201 Set_Defining_Identifier
(Decl
, Universal_Real
);
1202 Make_Name
(Universal_Real
, "universal_real");
1203 Set_Scope
(Universal_Real
, Standard_Standard
);
1206 Standard_Long_Long_Float_Size
,
1207 Standard_Long_Long_Float_Digits
);
1209 -- Note: universal fixed, unlike universal integer and universal real,
1210 -- is never used at runtime, so it does not need to have bounds set.
1212 Universal_Fixed
:= New_Standard_Entity
;
1213 Decl
:= New_Node
(N_Full_Type_Declaration
, Stloc
);
1214 Set_Defining_Identifier
(Decl
, Universal_Fixed
);
1215 Make_Name
(Universal_Fixed
, "universal_fixed");
1216 Set_Ekind
(Universal_Fixed
, E_Ordinary_Fixed_Point_Type
);
1217 Set_Etype
(Universal_Fixed
, Universal_Fixed
);
1218 Set_Scope
(Universal_Fixed
, Standard_Standard
);
1219 Init_Size
(Universal_Fixed
, Standard_Long_Long_Integer_Size
);
1220 Set_Elem_Alignment
(Universal_Fixed
);
1221 Set_Size_Known_At_Compile_Time
1224 -- Create type declaration for Duration, using a 64-bit size. The
1225 -- delta and size values depend on the mode set in system.ads.
1227 Build_Duration
: declare
1233 -- In 32 bit mode, the size is 32 bits, and the delta and
1234 -- small values are set to 20 milliseconds (20.0**(10.0**(-3)).
1236 if Duration_32_Bits_On_Target
then
1237 Dlo
:= Intval
(Type_Low_Bound
(Standard_Integer_32
));
1238 Dhi
:= Intval
(Type_High_Bound
(Standard_Integer_32
));
1239 Delta_Val
:= UR_From_Components
(UI_From_Int
(20), Uint_3
, 10);
1241 -- In standard 64-bit mode, the size is 64-bits and the delta and
1242 -- small values are set to nanoseconds (1.0**(10.0**(-9))
1245 Dlo
:= Intval
(Type_Low_Bound
(Standard_Integer_64
));
1246 Dhi
:= Intval
(Type_High_Bound
(Standard_Integer_64
));
1247 Delta_Val
:= UR_From_Components
(Uint_1
, Uint_9
, 10);
1250 Tdef_Node
:= Make_Ordinary_Fixed_Point_Definition
(Stloc
,
1251 Delta_Expression
=> Make_Real_Literal
(Stloc
, Delta_Val
),
1252 Real_Range_Specification
=>
1253 Make_Real_Range_Specification
(Stloc
,
1254 Low_Bound
=> Make_Real_Literal
(Stloc
,
1255 Realval
=> Dlo
* Delta_Val
),
1256 High_Bound
=> Make_Real_Literal
(Stloc
,
1257 Realval
=> Dhi
* Delta_Val
)));
1259 Set_Type_Definition
(Parent
(Standard_Duration
), Tdef_Node
);
1261 Set_Ekind
(Standard_Duration
, E_Ordinary_Fixed_Point_Type
);
1262 Set_Etype
(Standard_Duration
, Standard_Duration
);
1264 if Duration_32_Bits_On_Target
then
1265 Init_Size
(Standard_Duration
, 32);
1267 Init_Size
(Standard_Duration
, 64);
1270 Set_Elem_Alignment
(Standard_Duration
);
1271 Set_Delta_Value
(Standard_Duration
, Delta_Val
);
1272 Set_Small_Value
(Standard_Duration
, Delta_Val
);
1273 Set_Scalar_Range
(Standard_Duration
,
1274 Real_Range_Specification
1275 (Type_Definition
(Parent
(Standard_Duration
))));
1277 -- Normally it does not matter that nodes in package Standard are
1278 -- not marked as analyzed. The Scalar_Range of the fixed-point
1279 -- type Standard_Duration is an exception, because of the special
1280 -- test made in Freeze.Freeze_Fixed_Point_Type.
1282 Set_Analyzed
(Scalar_Range
(Standard_Duration
));
1284 Set_Etype
(Type_High_Bound
(Standard_Duration
), Standard_Duration
);
1285 Set_Etype
(Type_Low_Bound
(Standard_Duration
), Standard_Duration
);
1287 Set_Is_Static_Expression
(Type_High_Bound
(Standard_Duration
));
1288 Set_Is_Static_Expression
(Type_Low_Bound
(Standard_Duration
));
1290 Set_Corresponding_Integer_Value
1291 (Type_High_Bound
(Standard_Duration
), Dhi
);
1293 Set_Corresponding_Integer_Value
1294 (Type_Low_Bound
(Standard_Duration
), Dlo
);
1296 Set_Size_Known_At_Compile_Time
(Standard_Duration
);
1299 -- Build standard exception type. Note that the type name here is
1300 -- actually used in the generated code, so it must be set correctly
1302 -- ??? Also note that the Import_Code component is now declared
1303 -- as a System.Standard_Library.Exception_Code to enforce run-time
1304 -- library implementation consistency. It's too early here to resort
1305 -- to rtsfind to get the proper node for that type, so we use the
1306 -- closest possible available type node at hand instead. We should
1307 -- probably be fixing this up at some point.
1309 Standard_Exception_Type
:= New_Standard_Entity
;
1310 Set_Ekind
(Standard_Exception_Type
, E_Record_Type
);
1311 Set_Etype
(Standard_Exception_Type
, Standard_Exception_Type
);
1312 Set_Scope
(Standard_Exception_Type
, Standard_Standard
);
1313 Set_Stored_Constraint
1314 (Standard_Exception_Type
, No_Elist
);
1315 Init_Size_Align
(Standard_Exception_Type
);
1316 Set_Size_Known_At_Compile_Time
1317 (Standard_Exception_Type
, True);
1318 Make_Name
(Standard_Exception_Type
, "exception");
1321 (Standard_Exception_Type
, Standard_Boolean
, "Not_Handled_By_Others");
1323 (Standard_Exception_Type
, Standard_Character
, "Lang");
1325 (Standard_Exception_Type
, Standard_Natural
, "Name_Length");
1327 (Standard_Exception_Type
, Standard_A_Char
, "Full_Name");
1329 (Standard_Exception_Type
, Standard_A_Char
, "HTable_Ptr");
1331 (Standard_Exception_Type
, Standard_Unsigned
, "Import_Code");
1333 (Standard_Exception_Type
, Standard_A_Char
, "Raise_Hook");
1335 -- Build tree for record declaration, for use by the back-end
1338 Comp_List
: List_Id
;
1342 Comp
:= First_Entity
(Standard_Exception_Type
);
1343 Comp_List
:= New_List
;
1344 while Present
(Comp
) loop
1346 Make_Component_Declaration
(Stloc
,
1347 Defining_Identifier
=> Comp
,
1348 Component_Definition
=>
1349 Make_Component_Definition
(Stloc
,
1350 Aliased_Present
=> False,
1351 Subtype_Indication
=> New_Occurrence_Of
(Etype
(Comp
),
1358 Decl
:= Make_Full_Type_Declaration
(Stloc
,
1359 Defining_Identifier
=> Standard_Exception_Type
,
1361 Make_Record_Definition
(Stloc
,
1364 Make_Component_List
(Stloc
,
1365 Component_Items
=> Comp_List
)));
1368 Append
(Decl
, Decl_S
);
1370 Layout_Type
(Standard_Exception_Type
);
1372 -- Create declarations of standard exceptions
1374 Build_Exception
(S_Constraint_Error
);
1375 Build_Exception
(S_Program_Error
);
1376 Build_Exception
(S_Storage_Error
);
1377 Build_Exception
(S_Tasking_Error
);
1379 -- Numeric_Error is a normal exception in Ada 83, but in Ada 95
1380 -- it is a renaming of Constraint_Error. Is this test too early???
1382 if Ada_Version
= Ada_83
then
1383 Build_Exception
(S_Numeric_Error
);
1386 Decl
:= New_Node
(N_Exception_Renaming_Declaration
, Stloc
);
1387 E_Id
:= Standard_Entity
(S_Numeric_Error
);
1389 Set_Ekind
(E_Id
, E_Exception
);
1390 Set_Exception_Code
(E_Id
, Uint_0
);
1391 Set_Etype
(E_Id
, Standard_Exception_Type
);
1392 Set_Is_Public
(E_Id
);
1393 Set_Renamed_Entity
(E_Id
, Standard_Entity
(S_Constraint_Error
));
1395 Set_Defining_Identifier
(Decl
, E_Id
);
1396 Append
(Decl
, Decl_S
);
1398 Ident_Node
:= New_Node
(N_Identifier
, Stloc
);
1399 Set_Chars
(Ident_Node
, Chars
(Standard_Entity
(S_Constraint_Error
)));
1400 Set_Entity
(Ident_Node
, Standard_Entity
(S_Constraint_Error
));
1401 Set_Name
(Decl
, Ident_Node
);
1404 -- Abort_Signal is an entity that does not get made visible
1406 Abort_Signal
:= New_Standard_Entity
;
1407 Set_Chars
(Abort_Signal
, Name_uAbort_Signal
);
1408 Set_Ekind
(Abort_Signal
, E_Exception
);
1409 Set_Exception_Code
(Abort_Signal
, Uint_0
);
1410 Set_Etype
(Abort_Signal
, Standard_Exception_Type
);
1411 Set_Scope
(Abort_Signal
, Standard_Standard
);
1412 Set_Is_Public
(Abort_Signal
, True);
1414 Make_Exception_Declaration
(Stloc
,
1415 Defining_Identifier
=> Abort_Signal
);
1417 -- Create defining identifiers for shift operator entities. Note
1418 -- that these entities are used only for marking shift operators
1419 -- generated internally, and hence need no structure, just a name
1420 -- and a unique identity.
1422 Standard_Op_Rotate_Left
:= New_Standard_Entity
;
1423 Set_Chars
(Standard_Op_Rotate_Left
, Name_Rotate_Left
);
1424 Set_Ekind
(Standard_Op_Rotate_Left
, E_Operator
);
1426 Standard_Op_Rotate_Right
:= New_Standard_Entity
;
1427 Set_Chars
(Standard_Op_Rotate_Right
, Name_Rotate_Right
);
1428 Set_Ekind
(Standard_Op_Rotate_Right
, E_Operator
);
1430 Standard_Op_Shift_Left
:= New_Standard_Entity
;
1431 Set_Chars
(Standard_Op_Shift_Left
, Name_Shift_Left
);
1432 Set_Ekind
(Standard_Op_Shift_Left
, E_Operator
);
1434 Standard_Op_Shift_Right
:= New_Standard_Entity
;
1435 Set_Chars
(Standard_Op_Shift_Right
, Name_Shift_Right
);
1436 Set_Ekind
(Standard_Op_Shift_Right
, E_Operator
);
1438 Standard_Op_Shift_Right_Arithmetic
:= New_Standard_Entity
;
1439 Set_Chars
(Standard_Op_Shift_Right_Arithmetic
,
1440 Name_Shift_Right_Arithmetic
);
1441 Set_Ekind
(Standard_Op_Shift_Right_Arithmetic
,
1444 -- Create standard operator declarations
1448 -- Initialize visibility table with entities in Standard
1450 for E
in Standard_Entity_Type
loop
1451 if Ekind
(Standard_Entity
(E
)) /= E_Operator
then
1453 (Chars
(Standard_Entity
(E
)), Standard_Entity
(E
));
1454 Set_Homonym
(Standard_Entity
(E
), Empty
);
1457 if E
not in S_ASCII_Names
then
1458 Set_Scope
(Standard_Entity
(E
), Standard_Standard
);
1459 Set_Is_Immediately_Visible
(Standard_Entity
(E
));
1463 -- The predefined package Standard itself does not have a scope;
1464 -- it is the only entity in the system not to have one, and this
1465 -- is what identifies the package to Gigi.
1467 Set_Scope
(Standard_Standard
, Empty
);
1469 -- Set global variables indicating last Id values and version
1471 Last_Standard_Node_Id
:= Last_Node_Id
;
1472 Last_Standard_List_Id
:= Last_List_Id
;
1474 -- The Error node has an Etype of Any_Type to help error recovery
1476 Set_Etype
(Error
, Any_Type
);
1478 -- Print representation of standard if switch set
1480 if Opt
.Print_Standard
then
1483 end Create_Standard
;
1485 ------------------------------------
1486 -- Create_Unconstrained_Base_Type --
1487 ------------------------------------
1489 procedure Create_Unconstrained_Base_Type
1493 New_Ent
: constant Entity_Id
:= New_Copy
(E
);
1497 Set_Is_Constrained
(E
, True);
1498 Set_Is_First_Subtype
(E
, True);
1499 Set_Etype
(E
, New_Ent
);
1501 Append_Entity
(New_Ent
, Standard_Standard
);
1502 Set_Is_Constrained
(New_Ent
, False);
1503 Set_Etype
(New_Ent
, New_Ent
);
1504 Set_Is_Known_Valid
(New_Ent
, True);
1506 if K
= E_Signed_Integer_Subtype
then
1507 Set_Etype
(Low_Bound
(Scalar_Range
(E
)), New_Ent
);
1508 Set_Etype
(High_Bound
(Scalar_Range
(E
)), New_Ent
);
1511 end Create_Unconstrained_Base_Type
;
1513 --------------------
1514 -- Identifier_For --
1515 --------------------
1517 function Identifier_For
(S
: Standard_Entity_Type
) return Node_Id
is
1518 Ident_Node
: Node_Id
;
1520 Ident_Node
:= New_Node
(N_Identifier
, Stloc
);
1521 Set_Chars
(Ident_Node
, Chars
(Standard_Entity
(S
)));
1525 --------------------
1526 -- Make_Component --
1527 --------------------
1529 procedure Make_Component
1534 Id
: constant Entity_Id
:= New_Standard_Entity
;
1537 Set_Ekind
(Id
, E_Component
);
1538 Set_Etype
(Id
, Typ
);
1539 Set_Scope
(Id
, Rec
);
1540 Init_Component_Location
(Id
);
1542 Set_Original_Record_Component
(Id
, Id
);
1543 Make_Name
(Id
, Nam
);
1544 Append_Entity
(Id
, Rec
);
1551 function Make_Formal
1553 Formal_Name
: String) return Entity_Id
1558 Formal
:= New_Standard_Entity
;
1560 Set_Ekind
(Formal
, E_In_Parameter
);
1561 Set_Mechanism
(Formal
, Default_Mechanism
);
1562 Set_Scope
(Formal
, Standard_Standard
);
1563 Set_Etype
(Formal
, Typ
);
1564 Make_Name
(Formal
, Formal_Name
);
1573 function Make_Integer
(V
: Uint
) return Node_Id
is
1574 N
: constant Node_Id
:= Make_Integer_Literal
(Stloc
, V
);
1576 Set_Is_Static_Expression
(N
);
1584 procedure Make_Name
(Id
: Entity_Id
; Nam
: String) is
1586 for J
in 1 .. Nam
'Length loop
1587 Name_Buffer
(J
) := Fold_Lower
(Nam
(Nam
'First + (J
- 1)));
1590 Name_Len
:= Nam
'Length;
1591 Set_Chars
(Id
, Name_Find
);
1598 function New_Operator
(Op
: Name_Id
; Typ
: Entity_Id
) return Entity_Id
is
1599 Ident_Node
: Entity_Id
;
1602 Ident_Node
:= Make_Defining_Identifier
(Stloc
, Op
);
1604 Set_Is_Pure
(Ident_Node
, True);
1605 Set_Ekind
(Ident_Node
, E_Operator
);
1606 Set_Etype
(Ident_Node
, Typ
);
1607 Set_Scope
(Ident_Node
, Standard_Standard
);
1608 Set_Homonym
(Ident_Node
, Get_Name_Entity_Id
(Op
));
1609 Set_Convention
(Ident_Node
, Convention_Intrinsic
);
1611 Set_Is_Immediately_Visible
(Ident_Node
, True);
1612 Set_Is_Intrinsic_Subprogram
(Ident_Node
, True);
1614 Set_Name_Entity_Id
(Op
, Ident_Node
);
1615 Append_Entity
(Ident_Node
, Standard_Standard
);
1619 -------------------------
1620 -- New_Standard_Entity --
1621 -------------------------
1623 function New_Standard_Entity
1624 (New_Node_Kind
: Node_Kind
:= N_Defining_Identifier
) return Entity_Id
1626 E
: constant Entity_Id
:= New_Entity
(New_Node_Kind
, Stloc
);
1629 -- All standard entities are Pure and Public
1634 -- All standard entity names are analyzed manually, and are thus
1635 -- frozen as soon as they are created.
1639 -- Set debug information required for all standard types
1641 Set_Needs_Debug_Info
(E
);
1643 -- All standard entities are built with fully qualified names, so
1644 -- set the flag to prevent an abortive attempt at requalification!
1646 Set_Has_Qualified_Name
(E
);
1648 -- Return newly created entity to be completed by caller
1651 end New_Standard_Entity
;
1653 --------------------
1654 -- Print_Standard --
1655 --------------------
1657 procedure Print_Standard
is
1659 procedure P
(Item
: String) renames Output
.Write_Line
;
1660 -- Short-hand, since we do a lot of line writes here!
1662 procedure P_Int_Range
(Size
: Pos
);
1663 -- Prints the range of an integer based on its Size
1665 procedure P_Float_Range
(Id
: Entity_Id
);
1666 -- Prints the bounds range for the given float type entity
1672 procedure P_Float_Range
(Id
: Entity_Id
) is
1673 Digs
: constant Nat
:= UI_To_Int
(Digits_Value
(Id
));
1676 Write_Str
(" range ");
1678 if Vax_Float
(Id
) then
1679 if Digs
= VAXFF_Digits
then
1680 Write_Str
(VAXFF_First
'Universal_Literal_String);
1682 Write_Str
(VAXFF_Last
'Universal_Literal_String);
1684 elsif Digs
= VAXDF_Digits
then
1685 Write_Str
(VAXDF_First
'Universal_Literal_String);
1687 Write_Str
(VAXDF_Last
'Universal_Literal_String);
1690 pragma Assert
(Digs
= VAXGF_Digits
);
1692 Write_Str
(VAXGF_First
'Universal_Literal_String);
1694 Write_Str
(VAXGF_Last
'Universal_Literal_String);
1697 elsif Is_AAMP_Float
(Id
) then
1698 if Digs
= AAMPS_Digits
then
1699 Write_Str
(AAMPS_First
'Universal_Literal_String);
1701 Write_Str
(AAMPS_Last
'Universal_Literal_String);
1704 pragma Assert
(Digs
= AAMPL_Digits
);
1705 Write_Str
(AAMPL_First
'Universal_Literal_String);
1707 Write_Str
(AAMPL_Last
'Universal_Literal_String);
1710 elsif Digs
= IEEES_Digits
then
1711 Write_Str
(IEEES_First
'Universal_Literal_String);
1713 Write_Str
(IEEES_Last
'Universal_Literal_String);
1715 elsif Digs
= IEEEL_Digits
then
1716 Write_Str
(IEEEL_First
'Universal_Literal_String);
1718 Write_Str
(IEEEL_Last
'Universal_Literal_String);
1721 pragma Assert
(Digs
= IEEEX_Digits
);
1723 Write_Str
(IEEEX_First
'Universal_Literal_String);
1725 Write_Str
(IEEEX_Last
'Universal_Literal_String);
1736 procedure P_Int_Range
(Size
: Pos
) is
1738 Write_Str
(" is range -(2 **");
1739 Write_Int
(Size
- 1);
1741 Write_Str
(" .. +(2 **");
1742 Write_Int
(Size
- 1);
1743 Write_Str
(" - 1);");
1747 -- Start of processing for Print_Standard
1750 P
("-- Representation of package Standard");
1752 P
("-- This is not accurate Ada, since new base types cannot be ");
1753 P
("-- created, but the listing shows the target dependent");
1754 P
("-- characteristics of the Standard types for this compiler");
1757 P
("package Standard is");
1758 P
("pragma Pure (Standard);");
1761 P
(" type Boolean is (False, True);");
1762 P
(" for Boolean'Size use 1;");
1763 P
(" for Boolean use (False => 0, True => 1);");
1768 Write_Str
(" type Integer");
1769 P_Int_Range
(Standard_Integer_Size
);
1770 Write_Str
(" for Integer'Size use ");
1771 Write_Int
(Standard_Integer_Size
);
1775 P
(" subtype Natural is Integer range 0 .. Integer'Last;");
1776 P
(" subtype Positive is Integer range 1 .. Integer'Last;");
1779 Write_Str
(" type Short_Short_Integer");
1780 P_Int_Range
(Standard_Short_Short_Integer_Size
);
1781 Write_Str
(" for Short_Short_Integer'Size use ");
1782 Write_Int
(Standard_Short_Short_Integer_Size
);
1786 Write_Str
(" type Short_Integer");
1787 P_Int_Range
(Standard_Short_Integer_Size
);
1788 Write_Str
(" for Short_Integer'Size use ");
1789 Write_Int
(Standard_Short_Integer_Size
);
1793 Write_Str
(" type Long_Integer");
1794 P_Int_Range
(Standard_Long_Integer_Size
);
1795 Write_Str
(" for Long_Integer'Size use ");
1796 Write_Int
(Standard_Long_Integer_Size
);
1800 Write_Str
(" type Long_Long_Integer");
1801 P_Int_Range
(Standard_Long_Long_Integer_Size
);
1802 Write_Str
(" for Long_Long_Integer'Size use ");
1803 Write_Int
(Standard_Long_Long_Integer_Size
);
1807 -- Floating point types
1809 Write_Str
(" type Short_Float is digits ");
1810 Write_Int
(Standard_Short_Float_Digits
);
1812 P_Float_Range
(Standard_Short_Float
);
1813 Write_Str
(" for Short_Float'Size use ");
1814 Write_Int
(Standard_Short_Float_Size
);
1818 Write_Str
(" type Float is digits ");
1819 Write_Int
(Standard_Float_Digits
);
1821 P_Float_Range
(Standard_Float
);
1822 Write_Str
(" for Float'Size use ");
1823 Write_Int
(Standard_Float_Size
);
1827 Write_Str
(" type Long_Float is digits ");
1828 Write_Int
(Standard_Long_Float_Digits
);
1830 P_Float_Range
(Standard_Long_Float
);
1831 Write_Str
(" for Long_Float'Size use ");
1832 Write_Int
(Standard_Long_Float_Size
);
1836 Write_Str
(" type Long_Long_Float is digits ");
1837 Write_Int
(Standard_Long_Long_Float_Digits
);
1839 P_Float_Range
(Standard_Long_Long_Float
);
1840 Write_Str
(" for Long_Long_Float'Size use ");
1841 Write_Int
(Standard_Long_Long_Float_Size
);
1845 P
(" type Character is (...)");
1846 Write_Str
(" for Character'Size use ");
1847 Write_Int
(Standard_Character_Size
);
1849 P
(" -- See RM A.1(35) for details of this type");
1852 P
(" type Wide_Character is (...)");
1853 Write_Str
(" for Wide_Character'Size use ");
1854 Write_Int
(Standard_Wide_Character_Size
);
1856 P
(" -- See RM A.1(36) for details of this type");
1859 P
(" type Wide_Wide_Character is (...)");
1860 Write_Str
(" for Wide_Wide_Character'Size use ");
1861 Write_Int
(Standard_Wide_Wide_Character_Size
);
1863 P
(" -- See RM A.1(36) for details of this type");
1865 P
(" type String is array (Positive range <>) of Character;");
1866 P
(" pragma Pack (String);");
1869 P
(" type Wide_String is array (Positive range <>)" &
1870 " of Wide_Character;");
1871 P
(" pragma Pack (Wide_String);");
1874 P
(" type Wide_Wide_String is array (Positive range <>)" &
1875 " of Wide_Wide_Character;");
1876 P
(" pragma Pack (Wide_Wide_String);");
1879 -- Here it's OK to use the Duration type of the host compiler since
1880 -- the implementation of Duration in GNAT is target independent.
1882 if Duration_32_Bits_On_Target
then
1883 P
(" type Duration is delta 0.020");
1884 P
(" range -((2 ** 31 - 1) * 0.020) ..");
1885 P
(" +((2 ** 31 - 1) * 0.020);");
1886 P
(" for Duration'Small use 0.020;");
1888 P
(" type Duration is delta 0.000000001");
1889 P
(" range -((2 ** 63 - 1) * 0.000000001) ..");
1890 P
(" +((2 ** 63 - 1) * 0.000000001);");
1891 P
(" for Duration'Small use 0.000000001;");
1896 P
(" Constraint_Error : exception;");
1897 P
(" Program_Error : exception;");
1898 P
(" Storage_Error : exception;");
1899 P
(" Tasking_Error : exception;");
1900 P
(" Numeric_Error : exception renames Constraint_Error;");
1903 P
("end Standard;");
1906 ----------------------
1907 -- Set_Float_Bounds --
1908 ----------------------
1910 procedure Set_Float_Bounds
(Id
: Entity_Id
) is
1912 -- Low bound of literal value
1915 -- High bound of literal value
1918 -- Range specification
1920 Digs
: constant Nat
:= UI_To_Int
(Digits_Value
(Id
));
1921 -- Digits value, used to select bounds
1924 -- Note: for the call from Cstand to initially create the types in
1925 -- Standard, Vax_Float will always be False. Circuitry in Sem_Vfpt
1926 -- will adjust these types appropriately in the Vax_Float case if
1927 -- a pragma Float_Representation (VAX_Float) is used.
1929 if Vax_Float
(Id
) then
1930 if Digs
= VAXFF_Digits
then
1932 (VAXFF_First
'Universal_Literal_String);
1934 (VAXFF_Last
'Universal_Literal_String);
1936 elsif Digs
= VAXDF_Digits
then
1938 (VAXDF_First
'Universal_Literal_String);
1940 (VAXDF_Last
'Universal_Literal_String);
1943 pragma Assert
(Digs
= VAXGF_Digits
);
1946 (VAXGF_First
'Universal_Literal_String);
1948 (VAXGF_Last
'Universal_Literal_String);
1951 elsif Is_AAMP_Float
(Id
) then
1952 if Digs
= AAMPS_Digits
then
1954 (AAMPS_First
'Universal_Literal_String);
1956 (AAMPS_Last
'Universal_Literal_String);
1959 pragma Assert
(Digs
= AAMPL_Digits
);
1961 (AAMPL_First
'Universal_Literal_String);
1963 (AAMPL_Last
'Universal_Literal_String);
1966 elsif Digs
= IEEES_Digits
then
1968 (IEEES_First
'Universal_Literal_String);
1970 (IEEES_Last
'Universal_Literal_String);
1972 elsif Digs
= IEEEL_Digits
then
1974 (IEEEL_First
'Universal_Literal_String);
1976 (IEEEL_Last
'Universal_Literal_String);
1979 pragma Assert
(Digs
= IEEEX_Digits
);
1982 (IEEEX_First
'Universal_Literal_String);
1984 (IEEEX_Last
'Universal_Literal_String);
1988 Set_Is_Static_Expression
(L
);
1991 Set_Is_Static_Expression
(H
);
1993 R
:= New_Node
(N_Range
, Stloc
);
1994 Set_Low_Bound
(R
, L
);
1995 Set_High_Bound
(R
, H
);
1996 Set_Includes_Infinities
(R
, True);
1997 Set_Scalar_Range
(Id
, R
);
2000 end Set_Float_Bounds
;
2002 ------------------------
2003 -- Set_Integer_Bounds --
2004 ------------------------
2006 procedure Set_Integer_Bounds
2012 L
: Node_Id
; -- Low bound of literal value
2013 H
: Node_Id
; -- High bound of literal value
2014 R
: Node_Id
; -- Range specification
2017 L
:= Make_Integer
(Lb
);
2018 H
:= Make_Integer
(Hb
);
2023 R
:= New_Node
(N_Range
, Stloc
);
2024 Set_Low_Bound
(R
, L
);
2025 Set_High_Bound
(R
, H
);
2026 Set_Scalar_Range
(Id
, R
);
2029 Set_Is_Unsigned_Type
(Id
, Lb
>= 0);
2030 end Set_Integer_Bounds
;