1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2011, 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 Back_End; use Back_End;
28 with Csets; use Csets;
29 with Debug; use Debug;
30 with Einfo; use Einfo;
31 with Elists; use Elists;
32 with Layout; use Layout;
33 with Namet; use Namet;
34 with Nlists; use Nlists;
35 with Nmake; use Nmake;
37 with Output; use Output;
38 with Targparm; use Targparm;
39 with Tbuild; use Tbuild;
40 with Ttypes; use Ttypes;
42 with Sem_Mech; use Sem_Mech;
43 with Sem_Util; use Sem_Util;
44 with Sinfo; use Sinfo;
45 with Snames; use Snames;
46 with Stand; use Stand;
47 with Uintp; use Uintp;
48 with Urealp; use Urealp;
50 package body CStand is
52 Stloc : constant Source_Ptr := Standard_Location;
53 Staloc : constant Source_Ptr := Standard_ASCII_Location;
54 -- Standard abbreviations used throughout this package
56 Back_End_Float_Types : Elist_Id := No_Elist;
57 -- List used for any floating point supported by the back end. This needs
58 -- to be at the library level, because the call back procedures retrieving
59 -- this information are at that level.
61 -----------------------
62 -- Local Subprograms --
63 -----------------------
65 procedure Build_Float_Type
70 -- Procedure to build standard predefined float base type. The first
71 -- parameter is the entity for the type, and the second parameter is the
72 -- size in bits. The third parameter indicates the kind of representation
73 -- to be used. The fourth parameter is the digits value. Each type
74 -- is added to the list of predefined floating point types.
76 procedure Build_Signed_Integer_Type (E : Entity_Id; Siz : Int);
77 -- Procedure to build standard predefined signed integer subtype. The
78 -- first parameter is the entity for the subtype. The second parameter
79 -- is the size in bits. The corresponding base type is not built by
80 -- this routine but instead must be built by the caller where needed.
82 procedure Copy_Float_Type (To : Entity_Id; From : Entity_Id);
83 -- Build a floating point type, copying representation details from From.
84 -- This is used to create predefined floating point types based on
85 -- available types in the back end.
87 procedure Create_Operators;
88 -- Make entries for each of the predefined operators in Standard
90 procedure Create_Unconstrained_Base_Type
93 -- The predefined signed integer types are constrained subtypes which
94 -- must have a corresponding unconstrained base type. This type is almost
95 -- useless. The only place it has semantics is Subtypes_Statically_Match.
96 -- Consequently, we arrange for it to be identical apart from the setting
97 -- of the constrained bit. This routine takes an entity E for the Type,
98 -- copies it to estabish the base type, then resets the Ekind of the
99 -- original entity to K (the Ekind for the subtype). The Etype field of
100 -- E is set by the call (to point to the created base type entity), and
101 -- also the Is_Constrained flag of E is set.
103 -- To understand the exact requirement for this, see RM 3.5.4(11) which
104 -- makes it clear that Integer, for example, is constrained, with the
105 -- constraint bounds matching the bounds of the (unconstrained) base
106 -- type. The point is that Integer and Integer'Base have identical
107 -- bounds, but do not statically match, since a subtype with constraints
108 -- never matches a subtype with no constraints.
110 function Find_Back_End_Float_Type (Name : String) return Entity_Id;
111 -- Return the first float type in Back_End_Float_Types with the given name.
112 -- Names of entities in back end types, are either type names of C
113 -- predefined types (all lower case), or mode names (upper case).
114 -- These are not generally valid identifier names.
116 function Identifier_For (S : Standard_Entity_Type) return Node_Id;
117 -- Returns an identifier node with the same name as the defining
118 -- identifier corresponding to the given Standard_Entity_Type value
120 procedure Make_Component
124 -- Build a record component with the given type and name, and append to
125 -- the list of components of Rec.
129 Formal_Name : String) return Entity_Id;
130 -- Construct entity for subprogram formal with given name and type
132 function Make_Integer (V : Uint) return Node_Id;
133 -- Builds integer literal with given value
135 procedure Make_Name (Id : Entity_Id; Nam : String);
136 -- Make an entry in the names table for Nam, and set as Chars field of Id
138 function New_Operator (Op : Name_Id; Typ : Entity_Id) return Entity_Id;
139 -- Build entity for standard operator with given name and type
141 function New_Standard_Entity
142 (New_Node_Kind : Node_Kind := N_Defining_Identifier) return Entity_Id;
143 -- Builds a new entity for Standard
145 procedure Print_Standard;
146 -- Print representation of package Standard if switch set
148 procedure Register_Float_Type
149 (Name : C_String; -- Nul-terminated string with name of type
150 Digs : Natural; -- Nr or digits for floating point, 0 otherwise
151 Complex : Boolean; -- True iff type has real and imaginary parts
152 Count : Natural; -- Number of elements in vector, 0 otherwise
153 Float_Rep : Float_Rep_Kind; -- Representation used for fpt type
154 Precision : Positive; -- Precision of representation in bits
155 Size : Positive; -- Size of representation in bits
156 Alignment : Natural); -- Required alignment in bits
157 pragma Convention (C, Register_Float_Type);
158 -- Call back to allow the back end to register available types.
159 -- This call back currently creates predefined floating point base types
160 -- for any floating point types reported by the back end, and adds them
161 -- to the list of predefined float types.
163 procedure Set_Integer_Bounds
168 -- Procedure to set bounds for integer type or subtype. Id is the entity
169 -- whose bounds and type are to be set. The Typ parameter is the Etype
170 -- value for the entity (which will be the same as Id for all predefined
171 -- integer base types. The third and fourth parameters are the bounds.
173 ----------------------
174 -- Build_Float_Type --
175 ----------------------
177 procedure Build_Float_Type
180 Rep : Float_Rep_Kind;
184 Set_Type_Definition (Parent (E),
185 Make_Floating_Point_Definition (Stloc,
186 Digits_Expression => Make_Integer (UI_From_Int (Digs))));
188 Set_Ekind (E, E_Floating_Point_Type);
190 Set_Float_Rep (E, Rep);
192 Set_Elem_Alignment (E);
193 Init_Digits_Value (E, Digs);
194 Set_Float_Bounds (E);
197 Set_Size_Known_At_Compile_Time (E);
198 end Build_Float_Type;
200 ------------------------------
201 -- Find_Back_End_Float_Type --
202 ------------------------------
204 function Find_Back_End_Float_Type (Name : String) return Entity_Id is
208 N := First_Elmt (Back_End_Float_Types);
209 while Present (N) and then Get_Name_String (Chars (Node (N))) /= Name
215 end Find_Back_End_Float_Type;
217 -------------------------------
218 -- Build_Signed_Integer_Type --
219 -------------------------------
221 procedure Build_Signed_Integer_Type (E : Entity_Id; Siz : Int) is
222 U2Siz1 : constant Uint := 2 ** (Siz - 1);
223 Lbound : constant Uint := -U2Siz1;
224 Ubound : constant Uint := U2Siz1 - 1;
227 Set_Type_Definition (Parent (E),
228 Make_Signed_Integer_Type_Definition (Stloc,
229 Low_Bound => Make_Integer (Lbound),
230 High_Bound => Make_Integer (Ubound)));
232 Set_Ekind (E, E_Signed_Integer_Type);
235 Set_Elem_Alignment (E);
236 Set_Integer_Bounds (E, E, Lbound, Ubound);
239 Set_Is_Known_Valid (E);
240 Set_Size_Known_At_Compile_Time (E);
241 end Build_Signed_Integer_Type;
243 ---------------------
244 -- Copy_Float_Type --
245 ---------------------
247 procedure Copy_Float_Type (To : Entity_Id; From : Entity_Id) is
249 Build_Float_Type (To, UI_To_Int (Esize (From)), Float_Rep (From),
250 UI_To_Int (Digits_Value (From)));
253 ----------------------
254 -- Create_Operators --
255 ----------------------
257 -- Each operator has an abbreviated signature. The formals have the names
258 -- LEFT and RIGHT. Their types are not actually used for resolution.
260 procedure Create_Operators is
263 -- The following tables define the binary and unary operators and their
264 -- corresponding result type.
266 Binary_Ops : constant array (S_Binary_Ops) of Name_Id :=
268 -- There is one entry here for each binary operator, except for the
269 -- case of concatenation, where there are three entries, one for a
270 -- String result, one for Wide_String, and one for Wide_Wide_String.
292 Bin_Op_Types : constant array (S_Binary_Ops) of Entity_Id :=
294 -- This table has the corresponding result types. The entries are
295 -- ordered so they correspond to the Binary_Ops array above.
297 (Universal_Integer, -- Add
298 Standard_Boolean, -- And
299 Standard_String, -- Concat (String)
300 Standard_Wide_String, -- Concat (Wide_String)
301 Standard_Wide_Wide_String, -- Concat (Wide_Wide_String)
302 Universal_Integer, -- Divide
303 Standard_Boolean, -- Eq
304 Universal_Integer, -- Expon
305 Standard_Boolean, -- Ge
306 Standard_Boolean, -- Gt
307 Standard_Boolean, -- Le
308 Standard_Boolean, -- Lt
309 Universal_Integer, -- Mod
310 Universal_Integer, -- Multiply
311 Standard_Boolean, -- Ne
312 Standard_Boolean, -- Or
313 Universal_Integer, -- Rem
314 Universal_Integer, -- Subtract
315 Standard_Boolean); -- Xor
317 Unary_Ops : constant array (S_Unary_Ops) of Name_Id :=
319 -- There is one entry here for each unary operator
326 Unary_Op_Types : constant array (S_Unary_Ops) of Entity_Id :=
328 -- This table has the corresponding result types. The entries are
329 -- ordered so they correspond to the Unary_Ops array above.
331 (Universal_Integer, -- Abs
332 Universal_Integer, -- Subtract
333 Standard_Boolean, -- Not
334 Universal_Integer); -- Add
337 for J in S_Binary_Ops loop
338 Op_Node := New_Operator (Binary_Ops (J), Bin_Op_Types (J));
340 Append_Entity (Make_Formal (Any_Type, "LEFT"), Op_Node);
341 Append_Entity (Make_Formal (Any_Type, "RIGHT"), Op_Node);
344 for J in S_Unary_Ops loop
345 Op_Node := New_Operator (Unary_Ops (J), Unary_Op_Types (J));
347 Append_Entity (Make_Formal (Any_Type, "RIGHT"), Op_Node);
350 -- For concatenation, we create a separate operator for each
351 -- array type. This simplifies the resolution of the component-
352 -- component concatenation operation. In Standard, we set the types
353 -- of the formals for string, wide [wide]_string, concatenations.
355 Set_Etype (First_Entity (Standard_Op_Concat), Standard_String);
356 Set_Etype (Last_Entity (Standard_Op_Concat), Standard_String);
358 Set_Etype (First_Entity (Standard_Op_Concatw), Standard_Wide_String);
359 Set_Etype (Last_Entity (Standard_Op_Concatw), Standard_Wide_String);
361 Set_Etype (First_Entity (Standard_Op_Concatww),
362 Standard_Wide_Wide_String);
364 Set_Etype (Last_Entity (Standard_Op_Concatww),
365 Standard_Wide_Wide_String);
366 end Create_Operators;
368 ---------------------
369 -- Create_Standard --
370 ---------------------
372 -- The tree for the package Standard is prefixed to all compilations.
373 -- Several entities required by semantic analysis are denoted by global
374 -- variables that are initialized to point to the corresponding occurrences
375 -- in Standard. The visible entities of Standard are created here. Special
376 -- entities maybe created here as well or may be created from the semantics
377 -- module. By not adding them to the Decls list of Standard they will not
378 -- be visible to Ada programs.
380 procedure Create_Standard is
381 Decl_S : constant List_Id := New_List;
382 -- List of declarations in Standard
384 Decl_A : constant List_Id := New_List;
385 -- List of declarations in ASCII
390 Ident_Node : Node_Id;
396 procedure Build_Exception (S : Standard_Entity_Type);
397 -- Procedure to declare given entity as an exception
399 procedure Create_Back_End_Float_Types;
400 -- Initialize the Back_End_Float_Types list by having the back end
401 -- enumerate all available types and building type entities for them.
403 procedure Create_Float_Types;
404 -- Creates entities for all predefined floating point types, and
405 -- adds these to the Predefined_Float_Types list in package Standard.
407 procedure Pack_String_Type (String_Type : Entity_Id);
408 -- Generate proper tree for pragma Pack that applies to given type, and
409 -- mark type as having the pragma.
411 ---------------------
412 -- Build_Exception --
413 ---------------------
415 procedure Build_Exception (S : Standard_Entity_Type) is
417 Set_Ekind (Standard_Entity (S), E_Exception);
418 Set_Etype (Standard_Entity (S), Standard_Exception_Type);
419 Set_Exception_Code (Standard_Entity (S), Uint_0);
420 Set_Is_Public (Standard_Entity (S), True);
423 Make_Exception_Declaration (Stloc,
424 Defining_Identifier => Standard_Entity (S));
425 Append (Decl, Decl_S);
428 ---------------------------
429 -- Create_Back_End_Float_Types --
430 ---------------------------
432 procedure Create_Back_End_Float_Types is
434 Back_End_Float_Types := No_Elist;
435 Register_Back_End_Types (Register_Float_Type'Access);
436 end Create_Back_End_Float_Types;
438 ------------------------
439 -- Create_Float_Types --
440 ------------------------
442 procedure Create_Float_Types is
444 -- Create type definition nodes for predefined float types
447 (Standard_Short_Float,
448 Find_Back_End_Float_Type ("float"));
449 Set_Is_Implementation_Defined (Standard_Short_Float);
451 Copy_Float_Type (Standard_Float, Standard_Short_Float);
453 Copy_Float_Type (Standard_Long_Float,
454 Find_Back_End_Float_Type ("double"));
456 Predefined_Float_Types := New_Elmt_List;
457 Append_Elmt (Standard_Short_Float, Predefined_Float_Types);
458 Append_Elmt (Standard_Float, Predefined_Float_Types);
459 Append_Elmt (Standard_Long_Float, Predefined_Float_Types);
461 -- ??? For now, we don't have a good way to tell the widest float
462 -- type with hardware support. Basically, GCC knows the size of that
463 -- type, but on x86-64 there often are two or three 128-bit types,
464 -- one double extended that has 18 decimal digits, a 128-bit quad
465 -- precision type with 33 digits and possibly a 128-bit decimal float
466 -- type with 34 digits. As a workaround, we define Long_Long_Float as
467 -- C's "long double" if that type exists and has at most 18 digits,
468 -- or otherwise the same as Long_Float.
471 Max_HW_Digs : constant := 18;
472 -- Maximum hardware digits supported
474 LLF : Entity_Id := Find_Back_End_Float_Type ("long double");
475 -- Entity for long double type
478 if No (LLF) or else Digits_Value (LLF) > Max_HW_Digs then
479 LLF := Standard_Long_Float;
482 Set_Is_Implementation_Defined (Standard_Long_Long_Float);
483 Copy_Float_Type (Standard_Long_Long_Float, LLF);
485 Append_Elmt (Standard_Long_Long_Float, Predefined_Float_Types);
488 -- Any other back end types are appended at the end of the list of
489 -- predefined float types, and will only be selected if the none of
490 -- the types in Standard is suitable, or if a specific named type is
491 -- requested through a pragma Import.
493 while not Is_Empty_Elmt_List (Back_End_Float_Types) loop
495 E : constant Elmt_Id := First_Elmt (Back_End_Float_Types);
497 Append_Elmt (Node (E), To => Predefined_Float_Types);
498 Remove_Elmt (Back_End_Float_Types, E);
501 end Create_Float_Types;
503 ----------------------
504 -- Pack_String_Type --
505 ----------------------
507 procedure Pack_String_Type (String_Type : Entity_Id) is
508 Prag : constant Node_Id :=
511 Pragma_Argument_Associations =>
513 Make_Pragma_Argument_Association (Stloc,
515 New_Occurrence_Of (String_Type, Stloc))));
517 Append (Prag, Decl_S);
518 Record_Rep_Item (String_Type, Prag);
519 Set_Has_Pragma_Pack (String_Type, True);
520 end Pack_String_Type;
522 -- Start of processing for Create_Standard
525 -- Initialize scanner for internal scans of literals
527 Scn.Initialize_Scanner (No_Unit, Internal_Source_File);
529 -- First step is to create defining identifiers for each entity
531 for S in Standard_Entity_Type loop
533 S_Name : constant String := Standard_Entity_Type'Image (S);
534 -- Name of entity (note we skip S_ at the start)
536 Ident_Node : Node_Id;
537 -- Defining identifier node
540 Ident_Node := New_Standard_Entity;
541 Make_Name (Ident_Node, S_Name (3 .. S_Name'Length));
542 Standard_Entity (S) := Ident_Node;
546 -- Create package declaration node for package Standard
548 Standard_Package_Node := New_Node (N_Package_Declaration, Stloc);
550 Pspec := New_Node (N_Package_Specification, Stloc);
551 Set_Specification (Standard_Package_Node, Pspec);
553 Set_Defining_Unit_Name (Pspec, Standard_Standard);
554 Set_Visible_Declarations (Pspec, Decl_S);
556 Set_Ekind (Standard_Standard, E_Package);
557 Set_Is_Pure (Standard_Standard);
558 Set_Is_Compilation_Unit (Standard_Standard);
560 -- Create type/subtype declaration nodes for standard types
562 for S in S_Types loop
564 -- Subtype declaration case
566 if S = S_Natural or else S = S_Positive then
567 Decl := New_Node (N_Subtype_Declaration, Stloc);
568 Set_Subtype_Indication (Decl,
569 New_Occurrence_Of (Standard_Integer, Stloc));
571 -- Full type declaration case
574 Decl := New_Node (N_Full_Type_Declaration, Stloc);
577 Set_Is_Frozen (Standard_Entity (S));
578 Set_Is_Public (Standard_Entity (S));
579 Set_Defining_Identifier (Decl, Standard_Entity (S));
580 Append (Decl, Decl_S);
583 Create_Back_End_Float_Types;
585 -- Create type definition node for type Boolean. The Size is set to
586 -- 1 as required by Ada 95 and current ARG interpretations for Ada/83.
588 -- Note: Object_Size of Boolean is 8. This means that we do NOT in
589 -- general know that Boolean variables have valid values, so we do
590 -- not set the Is_Known_Valid flag.
592 Tdef_Node := New_Node (N_Enumeration_Type_Definition, Stloc);
593 Set_Literals (Tdef_Node, New_List);
594 Append (Standard_False, Literals (Tdef_Node));
595 Append (Standard_True, Literals (Tdef_Node));
596 Set_Type_Definition (Parent (Standard_Boolean), Tdef_Node);
598 Set_Ekind (Standard_Boolean, E_Enumeration_Type);
599 Set_First_Literal (Standard_Boolean, Standard_False);
600 Set_Etype (Standard_Boolean, Standard_Boolean);
601 Init_Esize (Standard_Boolean, Standard_Character_Size);
602 Init_RM_Size (Standard_Boolean, 1);
603 Set_Elem_Alignment (Standard_Boolean);
605 Set_Is_Unsigned_Type (Standard_Boolean);
606 Set_Size_Known_At_Compile_Time (Standard_Boolean);
607 Set_Has_Pragma_Ordered (Standard_Boolean);
609 Set_Ekind (Standard_True, E_Enumeration_Literal);
610 Set_Etype (Standard_True, Standard_Boolean);
611 Set_Enumeration_Pos (Standard_True, Uint_1);
612 Set_Enumeration_Rep (Standard_True, Uint_1);
613 Set_Is_Known_Valid (Standard_True, True);
615 Set_Ekind (Standard_False, E_Enumeration_Literal);
616 Set_Etype (Standard_False, Standard_Boolean);
617 Set_Enumeration_Pos (Standard_False, Uint_0);
618 Set_Enumeration_Rep (Standard_False, Uint_0);
619 Set_Is_Known_Valid (Standard_False, True);
621 -- For the bounds of Boolean, we create a range node corresponding to
623 -- range False .. True
625 -- where the occurrences of the literals must point to the
626 -- corresponding definition.
628 R_Node := New_Node (N_Range, Stloc);
629 B_Node := New_Node (N_Identifier, Stloc);
630 Set_Chars (B_Node, Chars (Standard_False));
631 Set_Entity (B_Node, Standard_False);
632 Set_Etype (B_Node, Standard_Boolean);
633 Set_Is_Static_Expression (B_Node);
634 Set_Low_Bound (R_Node, B_Node);
636 B_Node := New_Node (N_Identifier, Stloc);
637 Set_Chars (B_Node, Chars (Standard_True));
638 Set_Entity (B_Node, Standard_True);
639 Set_Etype (B_Node, Standard_Boolean);
640 Set_Is_Static_Expression (B_Node);
641 Set_High_Bound (R_Node, B_Node);
643 Set_Scalar_Range (Standard_Boolean, R_Node);
644 Set_Etype (R_Node, Standard_Boolean);
645 Set_Parent (R_Node, Standard_Boolean);
647 -- Record entity identifiers for boolean literals in the
648 -- Boolean_Literals array, for easy reference during expansion.
650 Boolean_Literals := (False => Standard_False, True => Standard_True);
652 -- Create type definition nodes for predefined integer types
654 Build_Signed_Integer_Type
655 (Standard_Short_Short_Integer, Standard_Short_Short_Integer_Size);
657 Build_Signed_Integer_Type
658 (Standard_Short_Integer, Standard_Short_Integer_Size);
660 Build_Signed_Integer_Type
661 (Standard_Integer, Standard_Integer_Size);
669 LIS := Standard_Long_Integer_Size;
672 Build_Signed_Integer_Type (Standard_Long_Integer, LIS);
675 Build_Signed_Integer_Type
676 (Standard_Long_Long_Integer, Standard_Long_Long_Integer_Size);
677 Set_Is_Implementation_Defined (Standard_Long_Long_Integer);
679 Create_Unconstrained_Base_Type
680 (Standard_Short_Short_Integer, E_Signed_Integer_Subtype);
681 Set_Is_Implementation_Defined (Standard_Short_Short_Integer);
683 Create_Unconstrained_Base_Type
684 (Standard_Short_Integer, E_Signed_Integer_Subtype);
686 Create_Unconstrained_Base_Type
687 (Standard_Integer, E_Signed_Integer_Subtype);
689 Create_Unconstrained_Base_Type
690 (Standard_Long_Integer, E_Signed_Integer_Subtype);
692 Create_Unconstrained_Base_Type
693 (Standard_Long_Long_Integer, E_Signed_Integer_Subtype);
694 Set_Is_Implementation_Defined (Standard_Short_Short_Integer);
698 -- Create type definition node for type Character. Note that we do not
699 -- set the Literals field, since type Character is handled with special
700 -- routine that do not need a literal list.
702 Tdef_Node := New_Node (N_Enumeration_Type_Definition, Stloc);
703 Set_Type_Definition (Parent (Standard_Character), Tdef_Node);
705 Set_Ekind (Standard_Character, E_Enumeration_Type);
706 Set_Etype (Standard_Character, Standard_Character);
707 Init_Esize (Standard_Character, Standard_Character_Size);
708 Init_RM_Size (Standard_Character, 8);
709 Set_Elem_Alignment (Standard_Character);
711 Set_Has_Pragma_Ordered (Standard_Character);
712 Set_Is_Unsigned_Type (Standard_Character);
713 Set_Is_Character_Type (Standard_Character);
714 Set_Is_Known_Valid (Standard_Character);
715 Set_Size_Known_At_Compile_Time (Standard_Character);
717 -- Create the bounds for type Character
719 R_Node := New_Node (N_Range, Stloc);
721 -- Low bound for type Character (Standard.Nul)
723 B_Node := New_Node (N_Character_Literal, Stloc);
724 Set_Is_Static_Expression (B_Node);
725 Set_Chars (B_Node, No_Name);
726 Set_Char_Literal_Value (B_Node, Uint_0);
727 Set_Entity (B_Node, Empty);
728 Set_Etype (B_Node, Standard_Character);
729 Set_Low_Bound (R_Node, B_Node);
731 -- High bound for type Character
733 B_Node := New_Node (N_Character_Literal, Stloc);
734 Set_Is_Static_Expression (B_Node);
735 Set_Chars (B_Node, No_Name);
736 Set_Char_Literal_Value (B_Node, UI_From_Int (16#FF#));
737 Set_Entity (B_Node, Empty);
738 Set_Etype (B_Node, Standard_Character);
739 Set_High_Bound (R_Node, B_Node);
741 Set_Scalar_Range (Standard_Character, R_Node);
742 Set_Etype (R_Node, Standard_Character);
743 Set_Parent (R_Node, Standard_Character);
745 -- Create type definition for type Wide_Character. Note that we do not
746 -- set the Literals field, since type Wide_Character is handled with
747 -- special routines that do not need a literal list.
749 Tdef_Node := New_Node (N_Enumeration_Type_Definition, Stloc);
750 Set_Type_Definition (Parent (Standard_Wide_Character), Tdef_Node);
752 Set_Ekind (Standard_Wide_Character, E_Enumeration_Type);
753 Set_Etype (Standard_Wide_Character, Standard_Wide_Character);
754 Init_Size (Standard_Wide_Character, Standard_Wide_Character_Size);
756 Set_Elem_Alignment (Standard_Wide_Character);
757 Set_Has_Pragma_Ordered (Standard_Wide_Character);
758 Set_Is_Unsigned_Type (Standard_Wide_Character);
759 Set_Is_Character_Type (Standard_Wide_Character);
760 Set_Is_Known_Valid (Standard_Wide_Character);
761 Set_Size_Known_At_Compile_Time (Standard_Wide_Character);
763 -- Create the bounds for type Wide_Character
765 R_Node := New_Node (N_Range, Stloc);
767 -- Low bound for type Wide_Character
769 B_Node := New_Node (N_Character_Literal, Stloc);
770 Set_Is_Static_Expression (B_Node);
771 Set_Chars (B_Node, No_Name); -- ???
772 Set_Char_Literal_Value (B_Node, Uint_0);
773 Set_Entity (B_Node, Empty);
774 Set_Etype (B_Node, Standard_Wide_Character);
775 Set_Low_Bound (R_Node, B_Node);
777 -- High bound for type Wide_Character
779 B_Node := New_Node (N_Character_Literal, Stloc);
780 Set_Is_Static_Expression (B_Node);
781 Set_Chars (B_Node, No_Name); -- ???
782 Set_Char_Literal_Value (B_Node, UI_From_Int (16#FFFF#));
783 Set_Entity (B_Node, Empty);
784 Set_Etype (B_Node, Standard_Wide_Character);
785 Set_High_Bound (R_Node, B_Node);
787 Set_Scalar_Range (Standard_Wide_Character, R_Node);
788 Set_Etype (R_Node, Standard_Wide_Character);
789 Set_Parent (R_Node, Standard_Wide_Character);
791 -- Create type definition for type Wide_Wide_Character. Note that we
792 -- do not set the Literals field, since type Wide_Wide_Character is
793 -- handled with special routines that do not need a literal list.
795 Tdef_Node := New_Node (N_Enumeration_Type_Definition, Stloc);
796 Set_Type_Definition (Parent (Standard_Wide_Wide_Character), Tdef_Node);
798 Set_Ekind (Standard_Wide_Wide_Character, E_Enumeration_Type);
799 Set_Etype (Standard_Wide_Wide_Character,
800 Standard_Wide_Wide_Character);
801 Init_Size (Standard_Wide_Wide_Character,
802 Standard_Wide_Wide_Character_Size);
804 Set_Elem_Alignment (Standard_Wide_Wide_Character);
805 Set_Has_Pragma_Ordered (Standard_Wide_Wide_Character);
806 Set_Is_Unsigned_Type (Standard_Wide_Wide_Character);
807 Set_Is_Character_Type (Standard_Wide_Wide_Character);
808 Set_Is_Known_Valid (Standard_Wide_Wide_Character);
809 Set_Size_Known_At_Compile_Time (Standard_Wide_Wide_Character);
810 Set_Is_Ada_2005_Only (Standard_Wide_Wide_Character);
812 -- Create the bounds for type Wide_Wide_Character
814 R_Node := New_Node (N_Range, Stloc);
816 -- Low bound for type Wide_Wide_Character
818 B_Node := New_Node (N_Character_Literal, Stloc);
819 Set_Is_Static_Expression (B_Node);
820 Set_Chars (B_Node, No_Name); -- ???
821 Set_Char_Literal_Value (B_Node, Uint_0);
822 Set_Entity (B_Node, Empty);
823 Set_Etype (B_Node, Standard_Wide_Wide_Character);
824 Set_Low_Bound (R_Node, B_Node);
826 -- High bound for type Wide_Wide_Character
828 B_Node := New_Node (N_Character_Literal, Stloc);
829 Set_Is_Static_Expression (B_Node);
830 Set_Chars (B_Node, No_Name); -- ???
831 Set_Char_Literal_Value (B_Node, UI_From_Int (16#7FFF_FFFF#));
832 Set_Entity (B_Node, Empty);
833 Set_Etype (B_Node, Standard_Wide_Wide_Character);
834 Set_High_Bound (R_Node, B_Node);
836 Set_Scalar_Range (Standard_Wide_Wide_Character, R_Node);
837 Set_Etype (R_Node, Standard_Wide_Wide_Character);
838 Set_Parent (R_Node, Standard_Wide_Wide_Character);
840 -- Create type definition node for type String
842 Tdef_Node := New_Node (N_Unconstrained_Array_Definition, Stloc);
845 CompDef_Node : Node_Id;
847 CompDef_Node := New_Node (N_Component_Definition, Stloc);
848 Set_Aliased_Present (CompDef_Node, False);
849 Set_Access_Definition (CompDef_Node, Empty);
850 Set_Subtype_Indication (CompDef_Node, Identifier_For (S_Character));
851 Set_Component_Definition (Tdef_Node, CompDef_Node);
854 Set_Subtype_Marks (Tdef_Node, New_List);
855 Append (Identifier_For (S_Positive), Subtype_Marks (Tdef_Node));
856 Set_Type_Definition (Parent (Standard_String), Tdef_Node);
858 Set_Ekind (Standard_String, E_String_Type);
859 Set_Etype (Standard_String, Standard_String);
860 Set_Component_Type (Standard_String, Standard_Character);
861 Set_Component_Size (Standard_String, Uint_8);
862 Init_Size_Align (Standard_String);
863 Set_Alignment (Standard_String, Uint_1);
864 Pack_String_Type (Standard_String);
866 -- On targets where a storage unit is larger than a byte (such as AAMP),
867 -- pragma Pack has a real effect on the representation of type String,
868 -- and the type must be marked as having a nonstandard representation.
870 if System_Storage_Unit > Uint_8 then
871 Set_Has_Non_Standard_Rep (Standard_String);
872 Set_Has_Pragma_Pack (Standard_String);
875 -- Set index type of String
878 (Subtype_Marks (Type_Definition (Parent (Standard_String))));
879 Set_First_Index (Standard_String, E_Id);
880 Set_Entity (E_Id, Standard_Positive);
881 Set_Etype (E_Id, Standard_Positive);
883 -- Create type definition node for type Wide_String
885 Tdef_Node := New_Node (N_Unconstrained_Array_Definition, Stloc);
888 CompDef_Node : Node_Id;
890 CompDef_Node := New_Node (N_Component_Definition, Stloc);
891 Set_Aliased_Present (CompDef_Node, False);
892 Set_Access_Definition (CompDef_Node, Empty);
893 Set_Subtype_Indication (CompDef_Node,
894 Identifier_For (S_Wide_Character));
895 Set_Component_Definition (Tdef_Node, CompDef_Node);
898 Set_Subtype_Marks (Tdef_Node, New_List);
899 Append (Identifier_For (S_Positive), Subtype_Marks (Tdef_Node));
900 Set_Type_Definition (Parent (Standard_Wide_String), Tdef_Node);
902 Set_Ekind (Standard_Wide_String, E_String_Type);
903 Set_Etype (Standard_Wide_String, Standard_Wide_String);
904 Set_Component_Type (Standard_Wide_String, Standard_Wide_Character);
905 Set_Component_Size (Standard_Wide_String, Uint_16);
906 Init_Size_Align (Standard_Wide_String);
907 Pack_String_Type (Standard_Wide_String);
909 -- Set index type of Wide_String
912 (Subtype_Marks (Type_Definition (Parent (Standard_Wide_String))));
913 Set_First_Index (Standard_Wide_String, E_Id);
914 Set_Entity (E_Id, Standard_Positive);
915 Set_Etype (E_Id, Standard_Positive);
917 -- Create type definition node for type Wide_Wide_String
919 Tdef_Node := New_Node (N_Unconstrained_Array_Definition, Stloc);
922 CompDef_Node : Node_Id;
924 CompDef_Node := New_Node (N_Component_Definition, Stloc);
925 Set_Aliased_Present (CompDef_Node, False);
926 Set_Access_Definition (CompDef_Node, Empty);
927 Set_Subtype_Indication (CompDef_Node,
928 Identifier_For (S_Wide_Wide_Character));
929 Set_Component_Definition (Tdef_Node, CompDef_Node);
932 Set_Subtype_Marks (Tdef_Node, New_List);
933 Append (Identifier_For (S_Positive), Subtype_Marks (Tdef_Node));
934 Set_Type_Definition (Parent (Standard_Wide_Wide_String), Tdef_Node);
936 Set_Ekind (Standard_Wide_Wide_String, E_String_Type);
937 Set_Etype (Standard_Wide_Wide_String,
938 Standard_Wide_Wide_String);
939 Set_Component_Type (Standard_Wide_Wide_String,
940 Standard_Wide_Wide_Character);
941 Set_Component_Size (Standard_Wide_Wide_String, Uint_32);
942 Init_Size_Align (Standard_Wide_Wide_String);
943 Set_Is_Ada_2005_Only (Standard_Wide_Wide_String);
944 Pack_String_Type (Standard_Wide_Wide_String);
946 -- Set index type of Wide_Wide_String
949 (Subtype_Marks (Type_Definition (Parent (Standard_Wide_Wide_String))));
950 Set_First_Index (Standard_Wide_Wide_String, E_Id);
951 Set_Entity (E_Id, Standard_Positive);
952 Set_Etype (E_Id, Standard_Positive);
954 -- Setup entity for Natural
956 Set_Ekind (Standard_Natural, E_Signed_Integer_Subtype);
957 Set_Etype (Standard_Natural, Base_Type (Standard_Integer));
958 Init_Esize (Standard_Natural, Standard_Integer_Size);
959 Init_RM_Size (Standard_Natural, Standard_Integer_Size - 1);
960 Set_Elem_Alignment (Standard_Natural);
961 Set_Size_Known_At_Compile_Time
963 Set_Integer_Bounds (Standard_Natural,
964 Typ => Base_Type (Standard_Integer),
966 Hb => Intval (High_Bound (Scalar_Range (Standard_Integer))));
967 Set_Is_Constrained (Standard_Natural);
969 -- Setup entity for Positive
971 Set_Ekind (Standard_Positive, E_Signed_Integer_Subtype);
972 Set_Etype (Standard_Positive, Base_Type (Standard_Integer));
973 Init_Esize (Standard_Positive, Standard_Integer_Size);
974 Init_RM_Size (Standard_Positive, Standard_Integer_Size - 1);
975 Set_Elem_Alignment (Standard_Positive);
977 Set_Size_Known_At_Compile_Time (Standard_Positive);
979 Set_Integer_Bounds (Standard_Positive,
980 Typ => Base_Type (Standard_Integer),
982 Hb => Intval (High_Bound (Scalar_Range (Standard_Integer))));
983 Set_Is_Constrained (Standard_Positive);
985 -- Create declaration for package ASCII
987 Decl := New_Node (N_Package_Declaration, Stloc);
988 Append (Decl, Decl_S);
990 Pspec := New_Node (N_Package_Specification, Stloc);
991 Set_Specification (Decl, Pspec);
993 Set_Defining_Unit_Name (Pspec, Standard_Entity (S_ASCII));
994 Set_Ekind (Standard_Entity (S_ASCII), E_Package);
995 Set_Visible_Declarations (Pspec, Decl_A);
997 -- Create control character definitions in package ASCII. Note that
998 -- the character literal entries created here correspond to literal
999 -- values that are impossible in the source, but can be represented
1000 -- internally with no difficulties.
1004 for S in S_ASCII_Names loop
1005 Decl := New_Node (N_Object_Declaration, Staloc);
1006 Set_Constant_Present (Decl, True);
1009 A_Char : constant Entity_Id := Standard_Entity (S);
1010 Expr_Decl : Node_Id;
1013 Set_Sloc (A_Char, Staloc);
1014 Set_Ekind (A_Char, E_Constant);
1015 Set_Never_Set_In_Source (A_Char, True);
1016 Set_Is_True_Constant (A_Char, True);
1017 Set_Etype (A_Char, Standard_Character);
1018 Set_Scope (A_Char, Standard_Entity (S_ASCII));
1019 Set_Is_Immediately_Visible (A_Char, False);
1020 Set_Is_Public (A_Char, True);
1021 Set_Is_Known_Valid (A_Char, True);
1023 Append_Entity (A_Char, Standard_Entity (S_ASCII));
1024 Set_Defining_Identifier (Decl, A_Char);
1026 Set_Object_Definition (Decl, Identifier_For (S_Character));
1027 Expr_Decl := New_Node (N_Character_Literal, Staloc);
1028 Set_Expression (Decl, Expr_Decl);
1030 Set_Is_Static_Expression (Expr_Decl);
1031 Set_Chars (Expr_Decl, No_Name);
1032 Set_Etype (Expr_Decl, Standard_Character);
1033 Set_Char_Literal_Value (Expr_Decl, UI_From_Int (Int (Ccode)));
1036 Append (Decl, Decl_A);
1038 -- Increment character code, dealing with non-contiguities
1042 if Ccode = 16#20# then
1044 elsif Ccode = 16#27# then
1046 elsif Ccode = 16#3C# then
1048 elsif Ccode = 16#41# then
1053 -- Create semantic phase entities
1055 Standard_Void_Type := New_Standard_Entity;
1056 Set_Ekind (Standard_Void_Type, E_Void);
1057 Set_Etype (Standard_Void_Type, Standard_Void_Type);
1058 Set_Scope (Standard_Void_Type, Standard_Standard);
1059 Make_Name (Standard_Void_Type, "_void_type");
1061 -- The type field of packages is set to void
1063 Set_Etype (Standard_Standard, Standard_Void_Type);
1064 Set_Etype (Standard_ASCII, Standard_Void_Type);
1066 -- Standard_A_String is actually used in generated code, so it has a
1067 -- type name that is reasonable, but does not overlap any Ada name.
1069 Standard_A_String := New_Standard_Entity;
1070 Set_Ekind (Standard_A_String, E_Access_Type);
1071 Set_Scope (Standard_A_String, Standard_Standard);
1072 Set_Etype (Standard_A_String, Standard_A_String);
1074 if Debug_Flag_6 then
1075 Init_Size (Standard_A_String, System_Address_Size);
1077 Init_Size (Standard_A_String, System_Address_Size * 2);
1080 Init_Alignment (Standard_A_String);
1082 Set_Directly_Designated_Type
1083 (Standard_A_String, Standard_String);
1084 Make_Name (Standard_A_String, "access_string");
1086 Standard_A_Char := New_Standard_Entity;
1087 Set_Ekind (Standard_A_Char, E_Access_Type);
1088 Set_Scope (Standard_A_Char, Standard_Standard);
1089 Set_Etype (Standard_A_Char, Standard_A_String);
1090 Init_Size (Standard_A_Char, System_Address_Size);
1091 Set_Elem_Alignment (Standard_A_Char);
1093 Set_Directly_Designated_Type (Standard_A_Char, Standard_Character);
1094 Make_Name (Standard_A_Char, "access_character");
1096 -- Standard_Debug_Renaming_Type is used for the special objects created
1097 -- to encode the names occurring in renaming declarations for use by the
1098 -- debugger (see exp_dbug.adb). The type is a zero-sized subtype of
1099 -- Standard.Integer.
1101 Standard_Debug_Renaming_Type := New_Standard_Entity;
1103 Set_Ekind (Standard_Debug_Renaming_Type, E_Signed_Integer_Subtype);
1104 Set_Scope (Standard_Debug_Renaming_Type, Standard_Standard);
1105 Set_Etype (Standard_Debug_Renaming_Type, Base_Type (Standard_Integer));
1106 Init_Esize (Standard_Debug_Renaming_Type, 0);
1107 Init_RM_Size (Standard_Debug_Renaming_Type, 0);
1108 Set_Size_Known_At_Compile_Time (Standard_Debug_Renaming_Type);
1109 Set_Integer_Bounds (Standard_Debug_Renaming_Type,
1110 Typ => Base_Type (Standard_Debug_Renaming_Type),
1113 Set_Is_Constrained (Standard_Debug_Renaming_Type);
1114 Set_Has_Size_Clause (Standard_Debug_Renaming_Type);
1116 Make_Name (Standard_Debug_Renaming_Type, "_renaming_type");
1118 -- Note on type names. The type names for the following special types
1119 -- are constructed so that they will look reasonable should they ever
1120 -- appear in error messages etc, although in practice the use of the
1121 -- special insertion character } for types results in special handling
1122 -- of these type names in any case. The blanks in these names would
1123 -- trouble in Gigi, but that's OK here, since none of these types
1124 -- should ever get through to Gigi! Attributes of these types are
1125 -- filled out to minimize problems with cascaded errors (for example,
1126 -- Any_Integer is given reasonable and consistent type and size values)
1128 Any_Type := New_Standard_Entity;
1129 Decl := New_Node (N_Full_Type_Declaration, Stloc);
1130 Set_Defining_Identifier (Decl, Any_Type);
1131 Set_Scope (Any_Type, Standard_Standard);
1132 Build_Signed_Integer_Type (Any_Type, Standard_Integer_Size);
1133 Make_Name (Any_Type, "any type");
1135 Any_Id := New_Standard_Entity;
1136 Set_Ekind (Any_Id, E_Variable);
1137 Set_Scope (Any_Id, Standard_Standard);
1138 Set_Etype (Any_Id, Any_Type);
1139 Init_Esize (Any_Id);
1140 Init_Alignment (Any_Id);
1141 Make_Name (Any_Id, "any id");
1143 Any_Access := New_Standard_Entity;
1144 Set_Ekind (Any_Access, E_Access_Type);
1145 Set_Scope (Any_Access, Standard_Standard);
1146 Set_Etype (Any_Access, Any_Access);
1147 Init_Size (Any_Access, System_Address_Size);
1148 Set_Elem_Alignment (Any_Access);
1149 Make_Name (Any_Access, "an access type");
1151 Any_Character := New_Standard_Entity;
1152 Set_Ekind (Any_Character, E_Enumeration_Type);
1153 Set_Scope (Any_Character, Standard_Standard);
1154 Set_Etype (Any_Character, Any_Character);
1155 Set_Is_Unsigned_Type (Any_Character);
1156 Set_Is_Character_Type (Any_Character);
1157 Init_Esize (Any_Character, Standard_Character_Size);
1158 Init_RM_Size (Any_Character, 8);
1159 Set_Elem_Alignment (Any_Character);
1160 Set_Scalar_Range (Any_Character, Scalar_Range (Standard_Character));
1161 Make_Name (Any_Character, "a character type");
1163 Any_Array := New_Standard_Entity;
1164 Set_Ekind (Any_Array, E_String_Type);
1165 Set_Scope (Any_Array, Standard_Standard);
1166 Set_Etype (Any_Array, Any_Array);
1167 Set_Component_Type (Any_Array, Any_Character);
1168 Init_Size_Align (Any_Array);
1169 Make_Name (Any_Array, "an array type");
1171 Any_Boolean := New_Standard_Entity;
1172 Set_Ekind (Any_Boolean, E_Enumeration_Type);
1173 Set_Scope (Any_Boolean, Standard_Standard);
1174 Set_Etype (Any_Boolean, Standard_Boolean);
1175 Init_Esize (Any_Boolean, Standard_Character_Size);
1176 Init_RM_Size (Any_Boolean, 1);
1177 Set_Elem_Alignment (Any_Boolean);
1178 Set_Is_Unsigned_Type (Any_Boolean);
1179 Set_Scalar_Range (Any_Boolean, Scalar_Range (Standard_Boolean));
1180 Make_Name (Any_Boolean, "a boolean type");
1182 Any_Composite := New_Standard_Entity;
1183 Set_Ekind (Any_Composite, E_Array_Type);
1184 Set_Scope (Any_Composite, Standard_Standard);
1185 Set_Etype (Any_Composite, Any_Composite);
1186 Set_Component_Size (Any_Composite, Uint_0);
1187 Set_Component_Type (Any_Composite, Standard_Integer);
1188 Init_Size_Align (Any_Composite);
1189 Make_Name (Any_Composite, "a composite type");
1191 Any_Discrete := New_Standard_Entity;
1192 Set_Ekind (Any_Discrete, E_Signed_Integer_Type);
1193 Set_Scope (Any_Discrete, Standard_Standard);
1194 Set_Etype (Any_Discrete, Any_Discrete);
1195 Init_Size (Any_Discrete, Standard_Integer_Size);
1196 Set_Elem_Alignment (Any_Discrete);
1197 Make_Name (Any_Discrete, "a discrete type");
1199 Any_Fixed := New_Standard_Entity;
1200 Set_Ekind (Any_Fixed, E_Ordinary_Fixed_Point_Type);
1201 Set_Scope (Any_Fixed, Standard_Standard);
1202 Set_Etype (Any_Fixed, Any_Fixed);
1203 Init_Size (Any_Fixed, Standard_Integer_Size);
1204 Set_Elem_Alignment (Any_Fixed);
1205 Make_Name (Any_Fixed, "a fixed-point type");
1207 Any_Integer := New_Standard_Entity;
1208 Set_Ekind (Any_Integer, E_Signed_Integer_Type);
1209 Set_Scope (Any_Integer, Standard_Standard);
1210 Set_Etype (Any_Integer, Standard_Long_Long_Integer);
1211 Init_Size (Any_Integer, Standard_Long_Long_Integer_Size);
1212 Set_Elem_Alignment (Any_Integer);
1216 Typ => Base_Type (Standard_Integer),
1218 Hb => Intval (High_Bound (Scalar_Range (Standard_Integer))));
1219 Make_Name (Any_Integer, "an integer type");
1221 Any_Modular := New_Standard_Entity;
1222 Set_Ekind (Any_Modular, E_Modular_Integer_Type);
1223 Set_Scope (Any_Modular, Standard_Standard);
1224 Set_Etype (Any_Modular, Standard_Long_Long_Integer);
1225 Init_Size (Any_Modular, Standard_Long_Long_Integer_Size);
1226 Set_Elem_Alignment (Any_Modular);
1227 Set_Is_Unsigned_Type (Any_Modular);
1228 Make_Name (Any_Modular, "a modular type");
1230 Any_Numeric := New_Standard_Entity;
1231 Set_Ekind (Any_Numeric, E_Signed_Integer_Type);
1232 Set_Scope (Any_Numeric, Standard_Standard);
1233 Set_Etype (Any_Numeric, Standard_Long_Long_Integer);
1234 Init_Size (Any_Numeric, Standard_Long_Long_Integer_Size);
1235 Set_Elem_Alignment (Any_Numeric);
1236 Make_Name (Any_Numeric, "a numeric type");
1238 Any_Real := New_Standard_Entity;
1239 Set_Ekind (Any_Real, E_Floating_Point_Type);
1240 Set_Scope (Any_Real, Standard_Standard);
1241 Set_Etype (Any_Real, Standard_Long_Long_Float);
1242 Init_Size (Any_Real,
1243 UI_To_Int (Esize (Standard_Long_Long_Float)));
1244 Set_Elem_Alignment (Any_Real);
1245 Make_Name (Any_Real, "a real type");
1247 Any_Scalar := New_Standard_Entity;
1248 Set_Ekind (Any_Scalar, E_Signed_Integer_Type);
1249 Set_Scope (Any_Scalar, Standard_Standard);
1250 Set_Etype (Any_Scalar, Any_Scalar);
1251 Init_Size (Any_Scalar, Standard_Integer_Size);
1252 Set_Elem_Alignment (Any_Scalar);
1253 Make_Name (Any_Scalar, "a scalar type");
1255 Any_String := New_Standard_Entity;
1256 Set_Ekind (Any_String, E_String_Type);
1257 Set_Scope (Any_String, Standard_Standard);
1258 Set_Etype (Any_String, Any_String);
1259 Set_Component_Type (Any_String, Any_Character);
1260 Init_Size_Align (Any_String);
1261 Make_Name (Any_String, "a string type");
1269 Low_Bound => Make_Integer (Uint_0),
1270 High_Bound => Make_Integer (Uint_2 ** Standard_Integer_Size));
1271 Set_Etype (Index, Standard_Integer);
1272 Set_First_Index (Any_String, Index);
1275 Standard_Integer_8 := New_Standard_Entity;
1276 Decl := New_Node (N_Full_Type_Declaration, Stloc);
1277 Set_Defining_Identifier (Decl, Standard_Integer_8);
1278 Make_Name (Standard_Integer_8, "integer_8");
1279 Set_Scope (Standard_Integer_8, Standard_Standard);
1280 Build_Signed_Integer_Type (Standard_Integer_8, 8);
1282 Standard_Integer_16 := New_Standard_Entity;
1283 Decl := New_Node (N_Full_Type_Declaration, Stloc);
1284 Set_Defining_Identifier (Decl, Standard_Integer_16);
1285 Make_Name (Standard_Integer_16, "integer_16");
1286 Set_Scope (Standard_Integer_16, Standard_Standard);
1287 Build_Signed_Integer_Type (Standard_Integer_16, 16);
1289 Standard_Integer_32 := New_Standard_Entity;
1290 Decl := New_Node (N_Full_Type_Declaration, Stloc);
1291 Set_Defining_Identifier (Decl, Standard_Integer_32);
1292 Make_Name (Standard_Integer_32, "integer_32");
1293 Set_Scope (Standard_Integer_32, Standard_Standard);
1294 Build_Signed_Integer_Type (Standard_Integer_32, 32);
1296 Standard_Integer_64 := New_Standard_Entity;
1297 Decl := New_Node (N_Full_Type_Declaration, Stloc);
1298 Set_Defining_Identifier (Decl, Standard_Integer_64);
1299 Make_Name (Standard_Integer_64, "integer_64");
1300 Set_Scope (Standard_Integer_64, Standard_Standard);
1301 Build_Signed_Integer_Type (Standard_Integer_64, 64);
1303 Standard_Unsigned := New_Standard_Entity;
1304 Decl := New_Node (N_Full_Type_Declaration, Stloc);
1305 Set_Defining_Identifier (Decl, Standard_Unsigned);
1306 Make_Name (Standard_Unsigned, "unsigned");
1308 Set_Ekind (Standard_Unsigned, E_Modular_Integer_Type);
1309 Set_Scope (Standard_Unsigned, Standard_Standard);
1310 Set_Etype (Standard_Unsigned, Standard_Unsigned);
1311 Init_Size (Standard_Unsigned, Standard_Integer_Size);
1312 Set_Elem_Alignment (Standard_Unsigned);
1313 Set_Modulus (Standard_Unsigned,
1314 Uint_2 ** Standard_Integer_Size);
1315 Set_Is_Unsigned_Type (Standard_Unsigned);
1316 Set_Size_Known_At_Compile_Time
1317 (Standard_Unsigned);
1318 Set_Is_Known_Valid (Standard_Unsigned, True);
1320 R_Node := New_Node (N_Range, Stloc);
1321 Set_Low_Bound (R_Node, Make_Integer (Uint_0));
1322 Set_High_Bound (R_Node, Make_Integer (Modulus (Standard_Unsigned) - 1));
1323 Set_Etype (Low_Bound (R_Node), Standard_Unsigned);
1324 Set_Etype (High_Bound (R_Node), Standard_Unsigned);
1325 Set_Scalar_Range (Standard_Unsigned, R_Node);
1327 -- Note: universal integer and universal real are constructed as fully
1328 -- formed signed numeric types, with parameters corresponding to the
1329 -- longest runtime types (Long_Long_Integer and Long_Long_Float). This
1330 -- allows Gigi to properly process references to universal types that
1331 -- are not folded at compile time.
1333 Universal_Integer := New_Standard_Entity;
1334 Decl := New_Node (N_Full_Type_Declaration, Stloc);
1335 Set_Defining_Identifier (Decl, Universal_Integer);
1336 Make_Name (Universal_Integer, "universal_integer");
1337 Set_Scope (Universal_Integer, Standard_Standard);
1338 Build_Signed_Integer_Type
1339 (Universal_Integer, Standard_Long_Long_Integer_Size);
1341 Universal_Real := New_Standard_Entity;
1342 Decl := New_Node (N_Full_Type_Declaration, Stloc);
1343 Set_Defining_Identifier (Decl, Universal_Real);
1344 Make_Name (Universal_Real, "universal_real");
1345 Set_Scope (Universal_Real, Standard_Standard);
1346 Copy_Float_Type (Universal_Real, Standard_Long_Long_Float);
1348 -- Note: universal fixed, unlike universal integer and universal real,
1349 -- is never used at runtime, so it does not need to have bounds set.
1351 Universal_Fixed := New_Standard_Entity;
1352 Decl := New_Node (N_Full_Type_Declaration, Stloc);
1353 Set_Defining_Identifier (Decl, Universal_Fixed);
1354 Make_Name (Universal_Fixed, "universal_fixed");
1355 Set_Ekind (Universal_Fixed, E_Ordinary_Fixed_Point_Type);
1356 Set_Etype (Universal_Fixed, Universal_Fixed);
1357 Set_Scope (Universal_Fixed, Standard_Standard);
1358 Init_Size (Universal_Fixed, Standard_Long_Long_Integer_Size);
1359 Set_Elem_Alignment (Universal_Fixed);
1360 Set_Size_Known_At_Compile_Time
1363 -- Create type declaration for Duration, using a 64-bit size. The
1364 -- delta and size values depend on the mode set in system.ads.
1366 Build_Duration : declare
1372 -- In 32 bit mode, the size is 32 bits, and the delta and
1373 -- small values are set to 20 milliseconds (20.0*(10.0**(-3)).
1375 if Duration_32_Bits_On_Target then
1376 Dlo := Intval (Type_Low_Bound (Standard_Integer_32));
1377 Dhi := Intval (Type_High_Bound (Standard_Integer_32));
1378 Delta_Val := UR_From_Components (UI_From_Int (20), Uint_3, 10);
1380 -- In standard 64-bit mode, the size is 64-bits and the delta and
1381 -- small values are set to nanoseconds (1.0*(10.0**(-9))
1384 Dlo := Intval (Type_Low_Bound (Standard_Integer_64));
1385 Dhi := Intval (Type_High_Bound (Standard_Integer_64));
1386 Delta_Val := UR_From_Components (Uint_1, Uint_9, 10);
1389 Tdef_Node := Make_Ordinary_Fixed_Point_Definition (Stloc,
1390 Delta_Expression => Make_Real_Literal (Stloc, Delta_Val),
1391 Real_Range_Specification =>
1392 Make_Real_Range_Specification (Stloc,
1393 Low_Bound => Make_Real_Literal (Stloc,
1394 Realval => Dlo * Delta_Val),
1395 High_Bound => Make_Real_Literal (Stloc,
1396 Realval => Dhi * Delta_Val)));
1398 Set_Type_Definition (Parent (Standard_Duration), Tdef_Node);
1400 Set_Ekind (Standard_Duration, E_Ordinary_Fixed_Point_Type);
1401 Set_Etype (Standard_Duration, Standard_Duration);
1403 if Duration_32_Bits_On_Target then
1404 Init_Size (Standard_Duration, 32);
1406 Init_Size (Standard_Duration, 64);
1409 Set_Elem_Alignment (Standard_Duration);
1410 Set_Delta_Value (Standard_Duration, Delta_Val);
1411 Set_Small_Value (Standard_Duration, Delta_Val);
1412 Set_Scalar_Range (Standard_Duration,
1413 Real_Range_Specification
1414 (Type_Definition (Parent (Standard_Duration))));
1416 -- Normally it does not matter that nodes in package Standard are
1417 -- not marked as analyzed. The Scalar_Range of the fixed-point
1418 -- type Standard_Duration is an exception, because of the special
1419 -- test made in Freeze.Freeze_Fixed_Point_Type.
1421 Set_Analyzed (Scalar_Range (Standard_Duration));
1423 Set_Etype (Type_High_Bound (Standard_Duration), Standard_Duration);
1424 Set_Etype (Type_Low_Bound (Standard_Duration), Standard_Duration);
1426 Set_Is_Static_Expression (Type_High_Bound (Standard_Duration));
1427 Set_Is_Static_Expression (Type_Low_Bound (Standard_Duration));
1429 Set_Corresponding_Integer_Value
1430 (Type_High_Bound (Standard_Duration), Dhi);
1432 Set_Corresponding_Integer_Value
1433 (Type_Low_Bound (Standard_Duration), Dlo);
1435 Set_Size_Known_At_Compile_Time (Standard_Duration);
1438 -- Build standard exception type. Note that the type name here is
1439 -- actually used in the generated code, so it must be set correctly
1441 -- ??? Also note that the Import_Code component is now declared
1442 -- as a System.Standard_Library.Exception_Code to enforce run-time
1443 -- library implementation consistency. It's too early here to resort
1444 -- to rtsfind to get the proper node for that type, so we use the
1445 -- closest possible available type node at hand instead. We should
1446 -- probably be fixing this up at some point.
1448 Standard_Exception_Type := New_Standard_Entity;
1449 Set_Ekind (Standard_Exception_Type, E_Record_Type);
1450 Set_Etype (Standard_Exception_Type, Standard_Exception_Type);
1451 Set_Scope (Standard_Exception_Type, Standard_Standard);
1452 Set_Stored_Constraint
1453 (Standard_Exception_Type, No_Elist);
1454 Init_Size_Align (Standard_Exception_Type);
1455 Set_Size_Known_At_Compile_Time
1456 (Standard_Exception_Type, True);
1457 Make_Name (Standard_Exception_Type, "exception");
1460 (Standard_Exception_Type, Standard_Boolean, "Not_Handled_By_Others");
1462 (Standard_Exception_Type, Standard_Character, "Lang");
1464 (Standard_Exception_Type, Standard_Natural, "Name_Length");
1466 (Standard_Exception_Type, Standard_A_Char, "Full_Name");
1468 (Standard_Exception_Type, Standard_A_Char, "HTable_Ptr");
1470 (Standard_Exception_Type, Standard_Unsigned, "Import_Code");
1472 (Standard_Exception_Type, Standard_A_Char, "Raise_Hook");
1474 -- Build tree for record declaration, for use by the back-end
1477 Comp_List : List_Id;
1481 Comp := First_Entity (Standard_Exception_Type);
1482 Comp_List := New_List;
1483 while Present (Comp) loop
1485 Make_Component_Declaration (Stloc,
1486 Defining_Identifier => Comp,
1487 Component_Definition =>
1488 Make_Component_Definition (Stloc,
1489 Aliased_Present => False,
1490 Subtype_Indication => New_Occurrence_Of (Etype (Comp),
1497 Decl := Make_Full_Type_Declaration (Stloc,
1498 Defining_Identifier => Standard_Exception_Type,
1500 Make_Record_Definition (Stloc,
1503 Make_Component_List (Stloc,
1504 Component_Items => Comp_List)));
1507 Append (Decl, Decl_S);
1509 Layout_Type (Standard_Exception_Type);
1511 -- Create declarations of standard exceptions
1513 Build_Exception (S_Constraint_Error);
1514 Build_Exception (S_Program_Error);
1515 Build_Exception (S_Storage_Error);
1516 Build_Exception (S_Tasking_Error);
1518 -- Numeric_Error is a normal exception in Ada 83, but in Ada 95
1519 -- it is a renaming of Constraint_Error. Is this test too early???
1521 if Ada_Version = Ada_83 then
1522 Build_Exception (S_Numeric_Error);
1525 Decl := New_Node (N_Exception_Renaming_Declaration, Stloc);
1526 E_Id := Standard_Entity (S_Numeric_Error);
1528 Set_Ekind (E_Id, E_Exception);
1529 Set_Exception_Code (E_Id, Uint_0);
1530 Set_Etype (E_Id, Standard_Exception_Type);
1531 Set_Is_Public (E_Id);
1532 Set_Renamed_Entity (E_Id, Standard_Entity (S_Constraint_Error));
1534 Set_Defining_Identifier (Decl, E_Id);
1535 Append (Decl, Decl_S);
1537 Ident_Node := New_Node (N_Identifier, Stloc);
1538 Set_Chars (Ident_Node, Chars (Standard_Entity (S_Constraint_Error)));
1539 Set_Entity (Ident_Node, Standard_Entity (S_Constraint_Error));
1540 Set_Name (Decl, Ident_Node);
1543 -- Abort_Signal is an entity that does not get made visible
1545 Abort_Signal := New_Standard_Entity;
1546 Set_Chars (Abort_Signal, Name_uAbort_Signal);
1547 Set_Ekind (Abort_Signal, E_Exception);
1548 Set_Exception_Code (Abort_Signal, Uint_0);
1549 Set_Etype (Abort_Signal, Standard_Exception_Type);
1550 Set_Scope (Abort_Signal, Standard_Standard);
1551 Set_Is_Public (Abort_Signal, True);
1553 Make_Exception_Declaration (Stloc,
1554 Defining_Identifier => Abort_Signal);
1556 -- Create defining identifiers for shift operator entities. Note
1557 -- that these entities are used only for marking shift operators
1558 -- generated internally, and hence need no structure, just a name
1559 -- and a unique identity.
1561 Standard_Op_Rotate_Left := New_Standard_Entity;
1562 Set_Chars (Standard_Op_Rotate_Left, Name_Rotate_Left);
1563 Set_Ekind (Standard_Op_Rotate_Left, E_Operator);
1565 Standard_Op_Rotate_Right := New_Standard_Entity;
1566 Set_Chars (Standard_Op_Rotate_Right, Name_Rotate_Right);
1567 Set_Ekind (Standard_Op_Rotate_Right, E_Operator);
1569 Standard_Op_Shift_Left := New_Standard_Entity;
1570 Set_Chars (Standard_Op_Shift_Left, Name_Shift_Left);
1571 Set_Ekind (Standard_Op_Shift_Left, E_Operator);
1573 Standard_Op_Shift_Right := New_Standard_Entity;
1574 Set_Chars (Standard_Op_Shift_Right, Name_Shift_Right);
1575 Set_Ekind (Standard_Op_Shift_Right, E_Operator);
1577 Standard_Op_Shift_Right_Arithmetic := New_Standard_Entity;
1578 Set_Chars (Standard_Op_Shift_Right_Arithmetic,
1579 Name_Shift_Right_Arithmetic);
1580 Set_Ekind (Standard_Op_Shift_Right_Arithmetic,
1583 -- Create standard operator declarations
1587 -- Initialize visibility table with entities in Standard
1589 for E in Standard_Entity_Type loop
1590 if Ekind (Standard_Entity (E)) /= E_Operator then
1592 (Chars (Standard_Entity (E)), Standard_Entity (E));
1593 Set_Homonym (Standard_Entity (E), Empty);
1596 if E not in S_ASCII_Names then
1597 Set_Scope (Standard_Entity (E), Standard_Standard);
1598 Set_Is_Immediately_Visible (Standard_Entity (E));
1602 -- The predefined package Standard itself does not have a scope;
1603 -- it is the only entity in the system not to have one, and this
1604 -- is what identifies the package to Gigi.
1606 Set_Scope (Standard_Standard, Empty);
1608 -- Set global variables indicating last Id values and version
1610 Last_Standard_Node_Id := Last_Node_Id;
1611 Last_Standard_List_Id := Last_List_Id;
1613 -- The Error node has an Etype of Any_Type to help error recovery
1615 Set_Etype (Error, Any_Type);
1617 -- Print representation of standard if switch set
1619 if Opt.Print_Standard then
1622 end Create_Standard;
1624 ------------------------------------
1625 -- Create_Unconstrained_Base_Type --
1626 ------------------------------------
1628 procedure Create_Unconstrained_Base_Type
1632 New_Ent : constant Entity_Id := New_Copy (E);
1636 Set_Is_Constrained (E, True);
1637 Set_Is_First_Subtype (E, True);
1638 Set_Etype (E, New_Ent);
1640 Append_Entity (New_Ent, Standard_Standard);
1641 Set_Is_Constrained (New_Ent, False);
1642 Set_Etype (New_Ent, New_Ent);
1643 Set_Is_Known_Valid (New_Ent, True);
1645 if K = E_Signed_Integer_Subtype then
1646 Set_Etype (Low_Bound (Scalar_Range (E)), New_Ent);
1647 Set_Etype (High_Bound (Scalar_Range (E)), New_Ent);
1650 end Create_Unconstrained_Base_Type;
1652 --------------------
1653 -- Identifier_For --
1654 --------------------
1656 function Identifier_For (S : Standard_Entity_Type) return Node_Id is
1657 Ident_Node : Node_Id;
1659 Ident_Node := New_Node (N_Identifier, Stloc);
1660 Set_Chars (Ident_Node, Chars (Standard_Entity (S)));
1661 Set_Entity (Ident_Node, Standard_Entity (S));
1665 --------------------
1666 -- Make_Component --
1667 --------------------
1669 procedure Make_Component
1674 Id : constant Entity_Id := New_Standard_Entity;
1677 Set_Ekind (Id, E_Component);
1678 Set_Etype (Id, Typ);
1679 Set_Scope (Id, Rec);
1680 Init_Component_Location (Id);
1682 Set_Original_Record_Component (Id, Id);
1683 Make_Name (Id, Nam);
1684 Append_Entity (Id, Rec);
1691 function Make_Formal
1693 Formal_Name : String) return Entity_Id
1698 Formal := New_Standard_Entity;
1700 Set_Ekind (Formal, E_In_Parameter);
1701 Set_Mechanism (Formal, Default_Mechanism);
1702 Set_Scope (Formal, Standard_Standard);
1703 Set_Etype (Formal, Typ);
1704 Make_Name (Formal, Formal_Name);
1713 function Make_Integer (V : Uint) return Node_Id is
1714 N : constant Node_Id := Make_Integer_Literal (Stloc, V);
1716 Set_Is_Static_Expression (N);
1724 procedure Make_Name (Id : Entity_Id; Nam : String) is
1726 for J in 1 .. Nam'Length loop
1727 Name_Buffer (J) := Fold_Lower (Nam (Nam'First + (J - 1)));
1730 Name_Len := Nam'Length;
1731 Set_Chars (Id, Name_Find);
1738 function New_Operator (Op : Name_Id; Typ : Entity_Id) return Entity_Id is
1739 Ident_Node : Entity_Id;
1742 Ident_Node := Make_Defining_Identifier (Stloc, Op);
1744 Set_Is_Pure (Ident_Node, True);
1745 Set_Ekind (Ident_Node, E_Operator);
1746 Set_Etype (Ident_Node, Typ);
1747 Set_Scope (Ident_Node, Standard_Standard);
1748 Set_Homonym (Ident_Node, Get_Name_Entity_Id (Op));
1749 Set_Convention (Ident_Node, Convention_Intrinsic);
1751 Set_Is_Immediately_Visible (Ident_Node, True);
1752 Set_Is_Intrinsic_Subprogram (Ident_Node, True);
1754 Set_Name_Entity_Id (Op, Ident_Node);
1755 Append_Entity (Ident_Node, Standard_Standard);
1759 -------------------------
1760 -- New_Standard_Entity --
1761 -------------------------
1763 function New_Standard_Entity
1764 (New_Node_Kind : Node_Kind := N_Defining_Identifier) return Entity_Id
1766 E : constant Entity_Id := New_Entity (New_Node_Kind, Stloc);
1769 -- All standard entities are Pure and Public
1774 -- All standard entity names are analyzed manually, and are thus
1775 -- frozen as soon as they are created.
1779 -- Set debug information required for all standard types
1781 Set_Needs_Debug_Info (E);
1783 -- All standard entities are built with fully qualified names, so
1784 -- set the flag to prevent an abortive attempt at requalification!
1786 Set_Has_Qualified_Name (E);
1788 -- Return newly created entity to be completed by caller
1791 end New_Standard_Entity;
1793 --------------------
1794 -- Print_Standard --
1795 --------------------
1797 procedure Print_Standard is
1799 procedure P (Item : String) renames Output.Write_Line;
1800 -- Short-hand, since we do a lot of line writes here!
1802 procedure P_Int_Range (Size : Pos);
1803 -- Prints the range of an integer based on its Size
1805 procedure P_Float_Range (Id : Entity_Id);
1806 -- Prints the bounds range for the given float type entity
1808 procedure P_Float_Type (Id : Entity_Id);
1809 -- Prints the type declaration of the given float type entity
1811 procedure P_Mixed_Name (Id : Name_Id);
1812 -- Prints Id in mixed case
1818 procedure P_Float_Range (Id : Entity_Id) is
1820 Write_Str (" range ");
1821 UR_Write (Realval (Type_Low_Bound (Id)));
1823 UR_Write (Realval (Type_High_Bound (Id)));
1832 procedure P_Float_Type (Id : Entity_Id) is
1834 Write_Str (" type ");
1835 P_Mixed_Name (Chars (Id));
1836 Write_Str (" is digits ");
1837 Write_Int (UI_To_Int (Digits_Value (Id)));
1840 Write_Str (" for ");
1841 P_Mixed_Name (Chars (Id));
1842 Write_Str ("'Size use ");
1843 Write_Int (UI_To_Int (RM_Size (Id)));
1852 procedure P_Int_Range (Size : Pos) is
1854 Write_Str (" is range -(2 **");
1855 Write_Int (Size - 1);
1857 Write_Str (" .. +(2 **");
1858 Write_Int (Size - 1);
1859 Write_Str (" - 1);");
1867 procedure P_Mixed_Name (Id : Name_Id) is
1869 Get_Name_String (Id);
1871 for J in 1 .. Name_Len loop
1872 if J = 1 or else Name_Buffer (J - 1) = '_' then
1873 Name_Buffer (J) := Fold_Upper (Name_Buffer (J));
1877 Write_Str (Name_Buffer (1 .. Name_Len));
1880 -- Start of processing for Print_Standard
1883 P ("-- Representation of package Standard");
1885 P ("-- This is not accurate Ada, since new base types cannot be ");
1886 P ("-- created, but the listing shows the target dependent");
1887 P ("-- characteristics of the Standard types for this compiler");
1890 P ("package Standard is");
1891 P ("pragma Pure (Standard);");
1894 P (" type Boolean is (False, True);");
1895 P (" for Boolean'Size use 1;");
1896 P (" for Boolean use (False => 0, True => 1);");
1901 Write_Str (" type Integer");
1902 P_Int_Range (Standard_Integer_Size);
1903 Write_Str (" for Integer'Size use ");
1904 Write_Int (Standard_Integer_Size);
1908 P (" subtype Natural is Integer range 0 .. Integer'Last;");
1909 P (" subtype Positive is Integer range 1 .. Integer'Last;");
1912 Write_Str (" type Short_Short_Integer");
1913 P_Int_Range (Standard_Short_Short_Integer_Size);
1914 Write_Str (" for Short_Short_Integer'Size use ");
1915 Write_Int (Standard_Short_Short_Integer_Size);
1919 Write_Str (" type Short_Integer");
1920 P_Int_Range (Standard_Short_Integer_Size);
1921 Write_Str (" for Short_Integer'Size use ");
1922 Write_Int (Standard_Short_Integer_Size);
1926 Write_Str (" type Long_Integer");
1927 P_Int_Range (Standard_Long_Integer_Size);
1928 Write_Str (" for Long_Integer'Size use ");
1929 Write_Int (Standard_Long_Integer_Size);
1933 Write_Str (" type Long_Long_Integer");
1934 P_Int_Range (Standard_Long_Long_Integer_Size);
1935 Write_Str (" for Long_Long_Integer'Size use ");
1936 Write_Int (Standard_Long_Long_Integer_Size);
1940 -- Floating point types
1942 P_Float_Type (Standard_Short_Float);
1943 P_Float_Type (Standard_Float);
1944 P_Float_Type (Standard_Long_Float);
1945 P_Float_Type (Standard_Long_Long_Float);
1947 P (" type Character is (...)");
1948 Write_Str (" for Character'Size use ");
1949 Write_Int (Standard_Character_Size);
1951 P (" -- See RM A.1(35) for details of this type");
1954 P (" type Wide_Character is (...)");
1955 Write_Str (" for Wide_Character'Size use ");
1956 Write_Int (Standard_Wide_Character_Size);
1958 P (" -- See RM A.1(36) for details of this type");
1961 P (" type Wide_Wide_Character is (...)");
1962 Write_Str (" for Wide_Wide_Character'Size use ");
1963 Write_Int (Standard_Wide_Wide_Character_Size);
1965 P (" -- See RM A.1(36) for details of this type");
1967 P (" type String is array (Positive range <>) of Character;");
1968 P (" pragma Pack (String);");
1971 P (" type Wide_String is array (Positive range <>)" &
1972 " of Wide_Character;");
1973 P (" pragma Pack (Wide_String);");
1976 P (" type Wide_Wide_String is array (Positive range <>)" &
1977 " of Wide_Wide_Character;");
1978 P (" pragma Pack (Wide_Wide_String);");
1981 -- We only have one representation each for 32-bit and 64-bit sizes,
1982 -- so select the right one based on Duration_32_Bits_On_Target.
1984 if Duration_32_Bits_On_Target then
1985 P (" type Duration is delta 0.020");
1986 P (" range -((2 ** 31 - 1) * 0.020) ..");
1987 P (" +((2 ** 31 - 1) * 0.020);");
1988 P (" for Duration'Small use 0.020;");
1991 P (" type Duration is delta 0.000000001");
1992 P (" range -((2 ** 63 - 1) * 0.000000001) ..");
1993 P (" +((2 ** 63 - 1) * 0.000000001);");
1994 P (" for Duration'Small use 0.000000001;");
1999 P (" Constraint_Error : exception;");
2000 P (" Program_Error : exception;");
2001 P (" Storage_Error : exception;");
2002 P (" Tasking_Error : exception;");
2003 P (" Numeric_Error : exception renames Constraint_Error;");
2006 P ("end Standard;");
2009 -------------------------
2010 -- Register_Float_Type --
2011 -------------------------
2013 procedure Register_Float_Type
2018 Float_Rep : Float_Rep_Kind;
2019 Precision : Positive;
2021 Alignment : Natural)
2023 T : String (1 .. Name'Length);
2024 Last : Natural := 0;
2027 -- Dump information given by the back end for the type to register
2031 Write_Str ("type " & T (1 .. Last) & " is ");
2034 Write_Str ("array (1 .. ");
2035 Write_Int (Int (Count));
2038 Write_Str (", 1 .. 2");
2041 Write_Str (") of ");
2044 Write_Str ("array (1 .. 2) of ");
2048 Write_Str ("digits ");
2049 Write_Int (Int (Digs));
2052 Write_Str ("pragma Float_Representation (");
2055 when IEEE_Binary => Write_Str ("IEEE");
2058 when 6 => Write_Str ("VAXF");
2059 when 9 => Write_Str ("VAXD");
2060 when 15 => Write_Str ("VAXG");
2061 when others => Write_Str ("VAX_"); Write_Int (Int (Digs));
2063 when AAMP => Write_Str ("AAMP");
2065 Write_Line (", " & T & ");");
2068 Write_Str ("mod 2**");
2069 Write_Int (Int (Precision / Positive'Max (1, Count)));
2073 if Precision = Size then
2074 Write_Str ("for " & T (1 .. Last) & "'Size use ");
2075 Write_Int (Int (Size));
2079 Write_Str ("for " & T (1 .. Last) & "'Value_Size use ");
2080 Write_Int (Int (Precision));
2083 Write_Str ("for " & T (1 .. Last) & "'Object_Size use ");
2084 Write_Int (Int (Size));
2088 Write_Str ("for " & T & "'Alignment use ");
2089 Write_Int (Int (Alignment / 8));
2094 for J in T'Range loop
2095 T (J) := Name (Name'First + J - 1);
2096 if T (J) = ASCII.NUL then
2102 if Debug_Flag_Dot_B then
2106 if Digs > 0 and then not Complex and then Count = 0 then
2108 Ent : constant Entity_Id := New_Standard_Entity;
2110 Set_Defining_Identifier
2111 (New_Node (N_Full_Type_Declaration, Stloc), Ent);
2112 Make_Name (Ent, T (1 .. Last));
2113 Set_Scope (Ent, Standard_Standard);
2114 Build_Float_Type (Ent, Int (Size), Float_Rep, Pos (Digs));
2115 Set_RM_Size (Ent, UI_From_Int (Int (Precision)));
2116 Set_Alignment (Ent, UI_From_Int (Int (Alignment / 8)));
2118 if No (Back_End_Float_Types) then
2119 Back_End_Float_Types := New_Elmt_List;
2122 Append_Elmt (Ent, Back_End_Float_Types);
2125 end Register_Float_Type;
2127 ----------------------
2128 -- Set_Float_Bounds --
2129 ----------------------
2131 procedure Set_Float_Bounds (Id : Entity_Id) is
2133 -- Low bound of literal value
2136 -- High bound of literal value
2139 -- Range specification
2141 Radix : constant Uint := Machine_Radix_Value (Id);
2142 Mantissa : constant Uint := Machine_Mantissa_Value (Id);
2143 Emax : constant Uint := Machine_Emax_Value (Id);
2144 Significand : constant Uint := Radix ** Mantissa - 1;
2145 Exponent : constant Uint := Emax - Mantissa;
2148 -- Note: for the call from Cstand to initially create the types in
2149 -- Standard, Float_Rep will never be VAX_Native. Circuitry in Sem_Vfpt
2150 -- will adjust these types appropriately VAX_Native if a pragma
2151 -- Float_Representation (VAX_Float) is used.
2153 H := Make_Float_Literal (Stloc, Radix, Significand, Exponent);
2154 L := Make_Float_Literal (Stloc, Radix, -Significand, Exponent);
2157 Set_Is_Static_Expression (L);
2160 Set_Is_Static_Expression (H);
2162 R := New_Node (N_Range, Stloc);
2163 Set_Low_Bound (R, L);
2164 Set_High_Bound (R, H);
2165 Set_Includes_Infinities (R, True);
2166 Set_Scalar_Range (Id, R);
2169 end Set_Float_Bounds;
2171 ------------------------
2172 -- Set_Integer_Bounds --
2173 ------------------------
2175 procedure Set_Integer_Bounds
2181 L : Node_Id; -- Low bound of literal value
2182 H : Node_Id; -- High bound of literal value
2183 R : Node_Id; -- Range specification
2186 L := Make_Integer (Lb);
2187 H := Make_Integer (Hb);
2192 R := New_Node (N_Range, Stloc);
2193 Set_Low_Bound (R, L);
2194 Set_High_Bound (R, H);
2195 Set_Scalar_Range (Id, R);
2198 Set_Is_Unsigned_Type (Id, Lb >= 0);
2199 end Set_Integer_Bounds;