Update concepts branch to revision 131834
[official-gcc.git] / gcc / ada / cstand.adb
blob56f87916c45f41978517fe1f578bca50a0407d72
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- C S T A N D --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 1992-2008, Free Software Foundation, Inc. --
10 -- --
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. --
20 -- --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
23 -- --
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;
34 with Opt; use Opt;
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;
40 with Scn;
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
74 (E : Entity_Id;
75 K : Entity_Kind);
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
98 (Rec : Entity_Id;
99 Typ : Entity_Id;
100 Nam : String);
101 -- Build a record component with the given type and name, and append to
102 -- the list of components of Rec.
104 function Make_Formal
105 (Typ : Entity_Id;
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
126 (Id : Entity_Id;
127 Typ : Entity_Id;
128 Lb : Uint;
129 Hb : Uint);
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
140 begin
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);
145 Set_Etype (E, E);
146 Init_Size (E, Siz);
147 Set_Elem_Alignment (E);
148 Init_Digits_Value (E, Digs);
149 Set_Float_Bounds (E);
150 Set_Is_Frozen (E);
151 Set_Is_Public (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;
164 begin
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);
171 Set_Etype (E, E);
172 Init_Size (E, Siz);
173 Set_Elem_Alignment (E);
174 Set_Integer_Bounds (E, E, Lbound, Ubound);
175 Set_Is_Frozen (E);
176 Set_Is_Public (E);
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
189 Op_Node : Entity_Id;
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.
200 (Name_Op_Add,
201 Name_Op_And,
202 Name_Op_Concat,
203 Name_Op_Concat,
204 Name_Op_Concat,
205 Name_Op_Divide,
206 Name_Op_Eq,
207 Name_Op_Expon,
208 Name_Op_Ge,
209 Name_Op_Gt,
210 Name_Op_Le,
211 Name_Op_Lt,
212 Name_Op_Mod,
213 Name_Op_Multiply,
214 Name_Op_Ne,
215 Name_Op_Or,
216 Name_Op_Rem,
217 Name_Op_Subtract,
218 Name_Op_Xor);
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
249 (Name_Op_Abs,
250 Name_Op_Subtract,
251 Name_Op_Not,
252 Name_Op_Add);
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
264 begin
265 for J in S_Binary_Ops loop
266 Op_Node := New_Operator (Binary_Ops (J), Bin_Op_Types (J));
267 SE (J) := Op_Node;
268 Append_Entity (Make_Formal (Any_Type, "LEFT"), Op_Node);
269 Append_Entity (Make_Formal (Any_Type, "RIGHT"), Op_Node);
270 end loop;
272 for J in S_Unary_Ops loop
273 Op_Node := New_Operator (Unary_Ops (J), Unary_Op_Types (J));
274 SE (J) := Op_Node;
275 Append_Entity (Make_Formal (Any_Type, "RIGHT"), Op_Node);
276 end loop;
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);
295 end Create_Operators;
297 ---------------------
298 -- Create_Standard --
299 ---------------------
301 -- The tree for the package Standard is prefixed to all compilations.
302 -- Several entities required by semantic analysis are denoted by global
303 -- variables that are initialized to point to the corresponding
304 -- occurrences in STANDARD. The visible entities of STANDARD are
305 -- created here. The private entities defined in STANDARD are created
306 -- by Initialize_Standard in the semantics module.
308 procedure Create_Standard is
309 Decl_S : constant List_Id := New_List;
310 -- List of declarations in Standard
312 Decl_A : constant List_Id := New_List;
313 -- List of declarations in ASCII
315 Decl : Node_Id;
316 Pspec : Node_Id;
317 Tdef_Node : Node_Id;
318 Ident_Node : Node_Id;
319 Ccode : Char_Code;
320 E_Id : Entity_Id;
321 R_Node : Node_Id;
322 B_Node : Node_Id;
324 procedure Build_Exception (S : Standard_Entity_Type);
325 -- Procedure to declare given entity as an exception
327 ---------------------
328 -- Build_Exception --
329 ---------------------
331 procedure Build_Exception (S : Standard_Entity_Type) is
332 begin
333 Set_Ekind (Standard_Entity (S), E_Exception);
334 Set_Etype (Standard_Entity (S), Standard_Exception_Type);
335 Set_Exception_Code (Standard_Entity (S), Uint_0);
336 Set_Is_Public (Standard_Entity (S), True);
338 Decl :=
339 Make_Exception_Declaration (Stloc,
340 Defining_Identifier => Standard_Entity (S));
341 Append (Decl, Decl_S);
342 end Build_Exception;
344 -- Start of processing for Create_Standard
346 begin
347 -- Initialize scanner for internal scans of literals
349 Scn.Initialize_Scanner (No_Unit, Internal_Source_File);
351 -- First step is to create defining identifiers for each entity
353 for S in Standard_Entity_Type loop
354 declare
355 S_Name : constant String := Standard_Entity_Type'Image (S);
356 -- Name of entity (note we skip S_ at the start)
358 Ident_Node : Node_Id;
359 -- Defining identifier node
361 begin
362 Ident_Node := New_Standard_Entity;
363 Make_Name (Ident_Node, S_Name (3 .. S_Name'Length));
364 Standard_Entity (S) := Ident_Node;
365 end;
366 end loop;
368 -- Create package declaration node for package Standard
370 Standard_Package_Node := New_Node (N_Package_Declaration, Stloc);
372 Pspec := New_Node (N_Package_Specification, Stloc);
373 Set_Specification (Standard_Package_Node, Pspec);
375 Set_Defining_Unit_Name (Pspec, Standard_Standard);
376 Set_Visible_Declarations (Pspec, Decl_S);
378 Set_Ekind (Standard_Standard, E_Package);
379 Set_Is_Pure (Standard_Standard);
380 Set_Is_Compilation_Unit (Standard_Standard);
382 -- Create type/subtype declaration nodes for standard types
384 for S in S_Types loop
386 -- Subtype declaration case
388 if S = S_Natural or else S = S_Positive then
389 Decl := New_Node (N_Subtype_Declaration, Stloc);
390 Set_Subtype_Indication (Decl,
391 New_Occurrence_Of (Standard_Integer, Stloc));
393 -- Full type declaration case
395 else
396 Decl := New_Node (N_Full_Type_Declaration, Stloc);
397 end if;
399 Set_Is_Frozen (Standard_Entity (S));
400 Set_Is_Public (Standard_Entity (S));
401 Set_Defining_Identifier (Decl, Standard_Entity (S));
402 Append (Decl, Decl_S);
403 end loop;
405 -- Create type definition node for type Boolean. The Size is set to
406 -- 1 as required by Ada 95 and current ARG interpretations for Ada/83.
408 -- Note: Object_Size of Boolean is 8. This means that we do NOT in
409 -- general know that Boolean variables have valid values, so we do
410 -- not set the Is_Known_Valid flag.
412 Tdef_Node := New_Node (N_Enumeration_Type_Definition, Stloc);
413 Set_Literals (Tdef_Node, New_List);
414 Append (Standard_False, Literals (Tdef_Node));
415 Append (Standard_True, Literals (Tdef_Node));
416 Set_Type_Definition (Parent (Standard_Boolean), Tdef_Node);
418 Set_Ekind (Standard_Boolean, E_Enumeration_Type);
419 Set_First_Literal (Standard_Boolean, Standard_False);
420 Set_Etype (Standard_Boolean, Standard_Boolean);
421 Init_Esize (Standard_Boolean, Standard_Character_Size);
422 Init_RM_Size (Standard_Boolean, 1);
423 Set_Elem_Alignment (Standard_Boolean);
425 Set_Is_Unsigned_Type (Standard_Boolean);
426 Set_Size_Known_At_Compile_Time (Standard_Boolean);
428 Set_Ekind (Standard_True, E_Enumeration_Literal);
429 Set_Etype (Standard_True, Standard_Boolean);
430 Set_Enumeration_Pos (Standard_True, Uint_1);
431 Set_Enumeration_Rep (Standard_True, Uint_1);
432 Set_Is_Known_Valid (Standard_True, True);
434 Set_Ekind (Standard_False, E_Enumeration_Literal);
435 Set_Etype (Standard_False, Standard_Boolean);
436 Set_Enumeration_Pos (Standard_False, Uint_0);
437 Set_Enumeration_Rep (Standard_False, Uint_0);
438 Set_Is_Known_Valid (Standard_False, True);
440 -- For the bounds of Boolean, we create a range node corresponding to
442 -- range False .. True
444 -- where the occurrences of the literals must point to the
445 -- corresponding definition.
447 R_Node := New_Node (N_Range, Stloc);
448 B_Node := New_Node (N_Identifier, Stloc);
449 Set_Chars (B_Node, Chars (Standard_False));
450 Set_Entity (B_Node, Standard_False);
451 Set_Etype (B_Node, Standard_Boolean);
452 Set_Is_Static_Expression (B_Node);
453 Set_Low_Bound (R_Node, B_Node);
455 B_Node := New_Node (N_Identifier, Stloc);
456 Set_Chars (B_Node, Chars (Standard_True));
457 Set_Entity (B_Node, Standard_True);
458 Set_Etype (B_Node, Standard_Boolean);
459 Set_Is_Static_Expression (B_Node);
460 Set_High_Bound (R_Node, B_Node);
462 Set_Scalar_Range (Standard_Boolean, R_Node);
463 Set_Etype (R_Node, Standard_Boolean);
464 Set_Parent (R_Node, Standard_Boolean);
466 -- Record entity identifiers for boolean literals in the
467 -- Boolean_Literals array, for easy reference during expansion.
469 Boolean_Literals := (False => Standard_False, True => Standard_True);
471 -- Create type definition nodes for predefined integer types
473 Build_Signed_Integer_Type
474 (Standard_Short_Short_Integer, Standard_Short_Short_Integer_Size);
476 Build_Signed_Integer_Type
477 (Standard_Short_Integer, Standard_Short_Integer_Size);
479 Build_Signed_Integer_Type
480 (Standard_Integer, Standard_Integer_Size);
482 declare
483 LIS : Nat;
484 begin
485 if Debug_Flag_M then
486 LIS := 64;
487 else
488 LIS := Standard_Long_Integer_Size;
489 end if;
491 Build_Signed_Integer_Type (Standard_Long_Integer, LIS);
492 end;
494 Build_Signed_Integer_Type
495 (Standard_Long_Long_Integer, Standard_Long_Long_Integer_Size);
497 Create_Unconstrained_Base_Type
498 (Standard_Short_Short_Integer, E_Signed_Integer_Subtype);
500 Create_Unconstrained_Base_Type
501 (Standard_Short_Integer, E_Signed_Integer_Subtype);
503 Create_Unconstrained_Base_Type
504 (Standard_Integer, E_Signed_Integer_Subtype);
506 Create_Unconstrained_Base_Type
507 (Standard_Long_Integer, E_Signed_Integer_Subtype);
509 Create_Unconstrained_Base_Type
510 (Standard_Long_Long_Integer, E_Signed_Integer_Subtype);
512 -- Create type definition nodes for predefined float types
514 Build_Float_Type
515 (Standard_Short_Float,
516 Standard_Short_Float_Size,
517 Standard_Short_Float_Digits);
519 Build_Float_Type
520 (Standard_Float,
521 Standard_Float_Size,
522 Standard_Float_Digits);
524 Build_Float_Type
525 (Standard_Long_Float,
526 Standard_Long_Float_Size,
527 Standard_Long_Float_Digits);
529 Build_Float_Type
530 (Standard_Long_Long_Float,
531 Standard_Long_Long_Float_Size,
532 Standard_Long_Long_Float_Digits);
534 -- Create type definition node for type Character. Note that we do not
535 -- set the Literals field, since type Character is handled with special
536 -- routine that do not need a literal list.
538 Tdef_Node := New_Node (N_Enumeration_Type_Definition, Stloc);
539 Set_Type_Definition (Parent (Standard_Character), Tdef_Node);
541 Set_Ekind (Standard_Character, E_Enumeration_Type);
542 Set_Etype (Standard_Character, Standard_Character);
543 Init_Esize (Standard_Character, Standard_Character_Size);
544 Init_RM_Size (Standard_Character, 8);
545 Set_Elem_Alignment (Standard_Character);
547 Set_Is_Unsigned_Type (Standard_Character);
548 Set_Is_Character_Type (Standard_Character);
549 Set_Is_Known_Valid (Standard_Character);
550 Set_Size_Known_At_Compile_Time (Standard_Character);
552 -- Create the bounds for type Character
554 R_Node := New_Node (N_Range, Stloc);
556 -- Low bound for type Character (Standard.Nul)
558 B_Node := New_Node (N_Character_Literal, Stloc);
559 Set_Is_Static_Expression (B_Node);
560 Set_Chars (B_Node, No_Name);
561 Set_Char_Literal_Value (B_Node, Uint_0);
562 Set_Entity (B_Node, Empty);
563 Set_Etype (B_Node, Standard_Character);
564 Set_Low_Bound (R_Node, B_Node);
566 -- High bound for type Character
568 B_Node := New_Node (N_Character_Literal, Stloc);
569 Set_Is_Static_Expression (B_Node);
570 Set_Chars (B_Node, No_Name);
571 Set_Char_Literal_Value (B_Node, UI_From_Int (16#FF#));
572 Set_Entity (B_Node, Empty);
573 Set_Etype (B_Node, Standard_Character);
574 Set_High_Bound (R_Node, B_Node);
576 Set_Scalar_Range (Standard_Character, R_Node);
577 Set_Etype (R_Node, Standard_Character);
578 Set_Parent (R_Node, Standard_Character);
580 -- Create type definition for type Wide_Character. Note that we do not
581 -- set the Literals field, since type Wide_Character is handled with
582 -- special routines that do not need a literal list.
584 Tdef_Node := New_Node (N_Enumeration_Type_Definition, Stloc);
585 Set_Type_Definition (Parent (Standard_Wide_Character), Tdef_Node);
587 Set_Ekind (Standard_Wide_Character, E_Enumeration_Type);
588 Set_Etype (Standard_Wide_Character, Standard_Wide_Character);
589 Init_Size (Standard_Wide_Character, Standard_Wide_Character_Size);
591 Set_Elem_Alignment (Standard_Wide_Character);
592 Set_Is_Unsigned_Type (Standard_Wide_Character);
593 Set_Is_Character_Type (Standard_Wide_Character);
594 Set_Is_Known_Valid (Standard_Wide_Character);
595 Set_Size_Known_At_Compile_Time (Standard_Wide_Character);
597 -- Create the bounds for type Wide_Character
599 R_Node := New_Node (N_Range, Stloc);
601 -- Low bound for type Wide_Character
603 B_Node := New_Node (N_Character_Literal, Stloc);
604 Set_Is_Static_Expression (B_Node);
605 Set_Chars (B_Node, No_Name); -- ???
606 Set_Char_Literal_Value (B_Node, Uint_0);
607 Set_Entity (B_Node, Empty);
608 Set_Etype (B_Node, Standard_Wide_Character);
609 Set_Low_Bound (R_Node, B_Node);
611 -- High bound for type Wide_Character
613 B_Node := New_Node (N_Character_Literal, Stloc);
614 Set_Is_Static_Expression (B_Node);
615 Set_Chars (B_Node, No_Name); -- ???
616 Set_Char_Literal_Value (B_Node, UI_From_Int (16#FFFF#));
617 Set_Entity (B_Node, Empty);
618 Set_Etype (B_Node, Standard_Wide_Character);
619 Set_High_Bound (R_Node, B_Node);
621 Set_Scalar_Range (Standard_Wide_Character, R_Node);
622 Set_Etype (R_Node, Standard_Wide_Character);
623 Set_Parent (R_Node, Standard_Wide_Character);
625 -- Create type definition for type Wide_Wide_Character. Note that we
626 -- do not set the Literals field, since type Wide_Wide_Character is
627 -- handled with special routines that do not need a literal list.
629 Tdef_Node := New_Node (N_Enumeration_Type_Definition, Stloc);
630 Set_Type_Definition (Parent (Standard_Wide_Wide_Character), Tdef_Node);
632 Set_Ekind (Standard_Wide_Wide_Character, E_Enumeration_Type);
633 Set_Etype (Standard_Wide_Wide_Character,
634 Standard_Wide_Wide_Character);
635 Init_Size (Standard_Wide_Wide_Character,
636 Standard_Wide_Wide_Character_Size);
638 Set_Elem_Alignment (Standard_Wide_Wide_Character);
639 Set_Is_Unsigned_Type (Standard_Wide_Wide_Character);
640 Set_Is_Character_Type (Standard_Wide_Wide_Character);
641 Set_Is_Known_Valid (Standard_Wide_Wide_Character);
642 Set_Size_Known_At_Compile_Time (Standard_Wide_Wide_Character);
643 Set_Is_Ada_2005_Only (Standard_Wide_Wide_Character);
645 -- Create the bounds for type Wide_Wide_Character
647 R_Node := New_Node (N_Range, Stloc);
649 -- Low bound for type Wide_Wide_Character
651 B_Node := New_Node (N_Character_Literal, Stloc);
652 Set_Is_Static_Expression (B_Node);
653 Set_Chars (B_Node, No_Name); -- ???
654 Set_Char_Literal_Value (B_Node, Uint_0);
655 Set_Entity (B_Node, Empty);
656 Set_Etype (B_Node, Standard_Wide_Wide_Character);
657 Set_Low_Bound (R_Node, B_Node);
659 -- High bound for type Wide_Wide_Character
661 B_Node := New_Node (N_Character_Literal, Stloc);
662 Set_Is_Static_Expression (B_Node);
663 Set_Chars (B_Node, No_Name); -- ???
664 Set_Char_Literal_Value (B_Node, UI_From_Int (16#7FFF_FFFF#));
665 Set_Entity (B_Node, Empty);
666 Set_Etype (B_Node, Standard_Wide_Wide_Character);
667 Set_High_Bound (R_Node, B_Node);
669 Set_Scalar_Range (Standard_Wide_Wide_Character, R_Node);
670 Set_Etype (R_Node, Standard_Wide_Wide_Character);
671 Set_Parent (R_Node, Standard_Wide_Wide_Character);
673 -- Create type definition node for type String
675 Tdef_Node := New_Node (N_Unconstrained_Array_Definition, Stloc);
677 declare
678 CompDef_Node : Node_Id;
679 begin
680 CompDef_Node := New_Node (N_Component_Definition, Stloc);
681 Set_Aliased_Present (CompDef_Node, False);
682 Set_Access_Definition (CompDef_Node, Empty);
683 Set_Subtype_Indication (CompDef_Node, Identifier_For (S_Character));
684 Set_Component_Definition (Tdef_Node, CompDef_Node);
685 end;
687 Set_Subtype_Marks (Tdef_Node, New_List);
688 Append (Identifier_For (S_Positive), Subtype_Marks (Tdef_Node));
689 Set_Type_Definition (Parent (Standard_String), Tdef_Node);
691 Set_Ekind (Standard_String, E_String_Type);
692 Set_Etype (Standard_String, Standard_String);
693 Set_Component_Type (Standard_String, Standard_Character);
694 Set_Component_Size (Standard_String, Uint_8);
695 Init_Size_Align (Standard_String);
696 Set_Alignment (Standard_String, Uint_1);
698 -- On targets where a storage unit is larger than a byte (such as AAMP),
699 -- pragma Pack has a real effect on the representation of type String,
700 -- and the type must be marked as having a nonstandard representation.
702 if System_Storage_Unit > Uint_8 then
703 Set_Has_Non_Standard_Rep (Standard_String);
704 Set_Has_Pragma_Pack (Standard_String);
705 end if;
707 -- Set index type of String
709 E_Id := First
710 (Subtype_Marks (Type_Definition (Parent (Standard_String))));
711 Set_First_Index (Standard_String, E_Id);
712 Set_Entity (E_Id, Standard_Positive);
713 Set_Etype (E_Id, Standard_Positive);
715 -- Create type definition node for type Wide_String
717 Tdef_Node := New_Node (N_Unconstrained_Array_Definition, Stloc);
719 declare
720 CompDef_Node : Node_Id;
721 begin
722 CompDef_Node := New_Node (N_Component_Definition, Stloc);
723 Set_Aliased_Present (CompDef_Node, False);
724 Set_Access_Definition (CompDef_Node, Empty);
725 Set_Subtype_Indication (CompDef_Node,
726 Identifier_For (S_Wide_Character));
727 Set_Component_Definition (Tdef_Node, CompDef_Node);
728 end;
730 Set_Subtype_Marks (Tdef_Node, New_List);
731 Append (Identifier_For (S_Positive), Subtype_Marks (Tdef_Node));
732 Set_Type_Definition (Parent (Standard_Wide_String), Tdef_Node);
734 Set_Ekind (Standard_Wide_String, E_String_Type);
735 Set_Etype (Standard_Wide_String, Standard_Wide_String);
736 Set_Component_Type (Standard_Wide_String, Standard_Wide_Character);
737 Set_Component_Size (Standard_Wide_String, Uint_16);
738 Init_Size_Align (Standard_Wide_String);
740 -- Set index type of Wide_String
742 E_Id := First
743 (Subtype_Marks (Type_Definition (Parent (Standard_Wide_String))));
744 Set_First_Index (Standard_Wide_String, E_Id);
745 Set_Entity (E_Id, Standard_Positive);
746 Set_Etype (E_Id, Standard_Positive);
748 -- Create type definition node for type Wide_Wide_String
750 Tdef_Node := New_Node (N_Unconstrained_Array_Definition, Stloc);
752 declare
753 CompDef_Node : Node_Id;
754 begin
755 CompDef_Node := New_Node (N_Component_Definition, Stloc);
756 Set_Aliased_Present (CompDef_Node, False);
757 Set_Access_Definition (CompDef_Node, Empty);
758 Set_Subtype_Indication (CompDef_Node,
759 Identifier_For (S_Wide_Wide_Character));
760 Set_Component_Definition (Tdef_Node, CompDef_Node);
761 end;
763 Set_Subtype_Marks (Tdef_Node, New_List);
764 Append (Identifier_For (S_Positive), Subtype_Marks (Tdef_Node));
765 Set_Type_Definition (Parent (Standard_Wide_Wide_String), Tdef_Node);
767 Set_Ekind (Standard_Wide_Wide_String, E_String_Type);
768 Set_Etype (Standard_Wide_Wide_String,
769 Standard_Wide_Wide_String);
770 Set_Component_Type (Standard_Wide_Wide_String,
771 Standard_Wide_Wide_Character);
772 Set_Component_Size (Standard_Wide_Wide_String, Uint_32);
773 Init_Size_Align (Standard_Wide_Wide_String);
774 Set_Is_Ada_2005_Only (Standard_Wide_Wide_String);
776 -- Set index type of Wide_Wide_String
778 E_Id := First
779 (Subtype_Marks (Type_Definition (Parent (Standard_Wide_Wide_String))));
780 Set_First_Index (Standard_Wide_Wide_String, E_Id);
781 Set_Entity (E_Id, Standard_Positive);
782 Set_Etype (E_Id, Standard_Positive);
784 -- Setup entity for Naturalend Create_Standard;
786 Set_Ekind (Standard_Natural, E_Signed_Integer_Subtype);
787 Set_Etype (Standard_Natural, Base_Type (Standard_Integer));
788 Init_Esize (Standard_Natural, Standard_Integer_Size);
789 Init_RM_Size (Standard_Natural, Standard_Integer_Size - 1);
790 Set_Elem_Alignment (Standard_Natural);
791 Set_Size_Known_At_Compile_Time
792 (Standard_Natural);
793 Set_Integer_Bounds (Standard_Natural,
794 Typ => Base_Type (Standard_Integer),
795 Lb => Uint_0,
796 Hb => Intval (High_Bound (Scalar_Range (Standard_Integer))));
797 Set_Is_Constrained (Standard_Natural);
799 -- Setup entity for Positive
801 Set_Ekind (Standard_Positive, E_Signed_Integer_Subtype);
802 Set_Etype (Standard_Positive, Base_Type (Standard_Integer));
803 Init_Esize (Standard_Positive, Standard_Integer_Size);
804 Init_RM_Size (Standard_Positive, Standard_Integer_Size - 1);
805 Set_Elem_Alignment (Standard_Positive);
807 Set_Size_Known_At_Compile_Time (Standard_Positive);
809 Set_Integer_Bounds (Standard_Positive,
810 Typ => Base_Type (Standard_Integer),
811 Lb => Uint_1,
812 Hb => Intval (High_Bound (Scalar_Range (Standard_Integer))));
813 Set_Is_Constrained (Standard_Positive);
815 -- Create declaration for package ASCII
817 Decl := New_Node (N_Package_Declaration, Stloc);
818 Append (Decl, Decl_S);
820 Pspec := New_Node (N_Package_Specification, Stloc);
821 Set_Specification (Decl, Pspec);
823 Set_Defining_Unit_Name (Pspec, Standard_Entity (S_ASCII));
824 Set_Ekind (Standard_Entity (S_ASCII), E_Package);
825 Set_Visible_Declarations (Pspec, Decl_A);
827 -- Create control character definitions in package ASCII. Note that
828 -- the character literal entries created here correspond to literal
829 -- values that are impossible in the source, but can be represented
830 -- internally with no difficulties.
832 Ccode := 16#00#;
834 for S in S_ASCII_Names loop
835 Decl := New_Node (N_Object_Declaration, Staloc);
836 Set_Constant_Present (Decl, True);
838 declare
839 A_Char : constant Entity_Id := Standard_Entity (S);
840 Expr_Decl : Node_Id;
842 begin
843 Set_Sloc (A_Char, Staloc);
844 Set_Ekind (A_Char, E_Constant);
845 Set_Never_Set_In_Source (A_Char, True);
846 Set_Is_True_Constant (A_Char, True);
847 Set_Etype (A_Char, Standard_Character);
848 Set_Scope (A_Char, Standard_Entity (S_ASCII));
849 Set_Is_Immediately_Visible (A_Char, False);
850 Set_Is_Public (A_Char, True);
851 Set_Is_Known_Valid (A_Char, True);
853 Append_Entity (A_Char, Standard_Entity (S_ASCII));
854 Set_Defining_Identifier (Decl, A_Char);
856 Set_Object_Definition (Decl, Identifier_For (S_Character));
857 Expr_Decl := New_Node (N_Character_Literal, Staloc);
858 Set_Expression (Decl, Expr_Decl);
860 Set_Is_Static_Expression (Expr_Decl);
861 Set_Chars (Expr_Decl, No_Name);
862 Set_Etype (Expr_Decl, Standard_Character);
863 Set_Char_Literal_Value (Expr_Decl, UI_From_Int (Int (Ccode)));
864 end;
866 Append (Decl, Decl_A);
868 -- Increment character code, dealing with non-contiguities
870 Ccode := Ccode + 1;
872 if Ccode = 16#20# then
873 Ccode := 16#21#;
874 elsif Ccode = 16#27# then
875 Ccode := 16#3A#;
876 elsif Ccode = 16#3C# then
877 Ccode := 16#3F#;
878 elsif Ccode = 16#41# then
879 Ccode := 16#5B#;
880 end if;
881 end loop;
883 -- Create semantic phase entities
885 Standard_Void_Type := New_Standard_Entity;
886 Set_Ekind (Standard_Void_Type, E_Void);
887 Set_Etype (Standard_Void_Type, Standard_Void_Type);
888 Set_Scope (Standard_Void_Type, Standard_Standard);
889 Make_Name (Standard_Void_Type, "_void_type");
891 -- The type field of packages is set to void
893 Set_Etype (Standard_Standard, Standard_Void_Type);
894 Set_Etype (Standard_ASCII, Standard_Void_Type);
896 -- Standard_A_String is actually used in generated code, so it has a
897 -- type name that is reasonable, but does not overlap any Ada name.
899 Standard_A_String := New_Standard_Entity;
900 Set_Ekind (Standard_A_String, E_Access_Type);
901 Set_Scope (Standard_A_String, Standard_Standard);
902 Set_Etype (Standard_A_String, Standard_A_String);
904 if Debug_Flag_6 then
905 Init_Size (Standard_A_String, System_Address_Size);
906 else
907 Init_Size (Standard_A_String, System_Address_Size * 2);
908 end if;
910 Init_Alignment (Standard_A_String);
912 Set_Directly_Designated_Type
913 (Standard_A_String, Standard_String);
914 Make_Name (Standard_A_String, "access_string");
916 Standard_A_Char := New_Standard_Entity;
917 Set_Ekind (Standard_A_Char, E_Access_Type);
918 Set_Scope (Standard_A_Char, Standard_Standard);
919 Set_Etype (Standard_A_Char, Standard_A_String);
920 Init_Size (Standard_A_Char, System_Address_Size);
921 Set_Elem_Alignment (Standard_A_Char);
923 Set_Directly_Designated_Type (Standard_A_Char, Standard_Character);
924 Make_Name (Standard_A_Char, "access_character");
926 -- Standard_Debug_Renaming_Type is used for the special objects created
927 -- to encode the names occurring in renaming declarations for use by the
928 -- debugger (see exp_dbug.adb). The type is a zero-sized subtype of
929 -- Standard.Integer.
931 Standard_Debug_Renaming_Type := New_Standard_Entity;
933 Set_Ekind (Standard_Debug_Renaming_Type, E_Signed_Integer_Subtype);
934 Set_Scope (Standard_Debug_Renaming_Type, Standard_Standard);
935 Set_Etype (Standard_Debug_Renaming_Type, Base_Type (Standard_Integer));
936 Init_Esize (Standard_Debug_Renaming_Type, 0);
937 Init_RM_Size (Standard_Debug_Renaming_Type, 0);
938 Set_Size_Known_At_Compile_Time (Standard_Debug_Renaming_Type);
939 Set_Integer_Bounds (Standard_Debug_Renaming_Type,
940 Typ => Base_Type (Standard_Debug_Renaming_Type),
941 Lb => Uint_1,
942 Hb => Uint_0);
943 Set_Is_Constrained (Standard_Debug_Renaming_Type);
944 Set_Has_Size_Clause (Standard_Debug_Renaming_Type);
946 Make_Name (Standard_Debug_Renaming_Type, "_renaming_type");
948 -- Note on type names. The type names for the following special types
949 -- are constructed so that they will look reasonable should they ever
950 -- appear in error messages etc, although in practice the use of the
951 -- special insertion character } for types results in special handling
952 -- of these type names in any case. The blanks in these names would
953 -- trouble in Gigi, but that's OK here, since none of these types
954 -- should ever get through to Gigi! Attributes of these types are
955 -- filled out to minimize problems with cascaded errors (for example,
956 -- Any_Integer is given reasonable and consistent type and size values)
958 Any_Type := New_Standard_Entity;
959 Decl := New_Node (N_Full_Type_Declaration, Stloc);
960 Set_Defining_Identifier (Decl, Any_Type);
961 Set_Scope (Any_Type, Standard_Standard);
962 Build_Signed_Integer_Type (Any_Type, Standard_Integer_Size);
963 Make_Name (Any_Type, "any type");
965 Any_Id := New_Standard_Entity;
966 Set_Ekind (Any_Id, E_Variable);
967 Set_Scope (Any_Id, Standard_Standard);
968 Set_Etype (Any_Id, Any_Type);
969 Init_Esize (Any_Id);
970 Init_Alignment (Any_Id);
971 Make_Name (Any_Id, "any id");
973 Any_Access := New_Standard_Entity;
974 Set_Ekind (Any_Access, E_Access_Type);
975 Set_Scope (Any_Access, Standard_Standard);
976 Set_Etype (Any_Access, Any_Access);
977 Init_Size (Any_Access, System_Address_Size);
978 Set_Elem_Alignment (Any_Access);
979 Make_Name (Any_Access, "an access type");
981 Any_Character := New_Standard_Entity;
982 Set_Ekind (Any_Character, E_Enumeration_Type);
983 Set_Scope (Any_Character, Standard_Standard);
984 Set_Etype (Any_Character, Any_Character);
985 Set_Is_Unsigned_Type (Any_Character);
986 Set_Is_Character_Type (Any_Character);
987 Init_Esize (Any_Character, Standard_Character_Size);
988 Init_RM_Size (Any_Character, 8);
989 Set_Elem_Alignment (Any_Character);
990 Set_Scalar_Range (Any_Character, Scalar_Range (Standard_Character));
991 Make_Name (Any_Character, "a character type");
993 Any_Array := New_Standard_Entity;
994 Set_Ekind (Any_Array, E_String_Type);
995 Set_Scope (Any_Array, Standard_Standard);
996 Set_Etype (Any_Array, Any_Array);
997 Set_Component_Type (Any_Array, Any_Character);
998 Init_Size_Align (Any_Array);
999 Make_Name (Any_Array, "an array type");
1001 Any_Boolean := New_Standard_Entity;
1002 Set_Ekind (Any_Boolean, E_Enumeration_Type);
1003 Set_Scope (Any_Boolean, Standard_Standard);
1004 Set_Etype (Any_Boolean, Standard_Boolean);
1005 Init_Esize (Any_Boolean, Standard_Character_Size);
1006 Init_RM_Size (Any_Boolean, 1);
1007 Set_Elem_Alignment (Any_Boolean);
1008 Set_Is_Unsigned_Type (Any_Boolean);
1009 Set_Scalar_Range (Any_Boolean, Scalar_Range (Standard_Boolean));
1010 Make_Name (Any_Boolean, "a boolean type");
1012 Any_Composite := New_Standard_Entity;
1013 Set_Ekind (Any_Composite, E_Array_Type);
1014 Set_Scope (Any_Composite, Standard_Standard);
1015 Set_Etype (Any_Composite, Any_Composite);
1016 Set_Component_Size (Any_Composite, Uint_0);
1017 Set_Component_Type (Any_Composite, Standard_Integer);
1018 Init_Size_Align (Any_Composite);
1019 Make_Name (Any_Composite, "a composite type");
1021 Any_Discrete := New_Standard_Entity;
1022 Set_Ekind (Any_Discrete, E_Signed_Integer_Type);
1023 Set_Scope (Any_Discrete, Standard_Standard);
1024 Set_Etype (Any_Discrete, Any_Discrete);
1025 Init_Size (Any_Discrete, Standard_Integer_Size);
1026 Set_Elem_Alignment (Any_Discrete);
1027 Make_Name (Any_Discrete, "a discrete type");
1029 Any_Fixed := New_Standard_Entity;
1030 Set_Ekind (Any_Fixed, E_Ordinary_Fixed_Point_Type);
1031 Set_Scope (Any_Fixed, Standard_Standard);
1032 Set_Etype (Any_Fixed, Any_Fixed);
1033 Init_Size (Any_Fixed, Standard_Integer_Size);
1034 Set_Elem_Alignment (Any_Fixed);
1035 Make_Name (Any_Fixed, "a fixed-point type");
1037 Any_Integer := New_Standard_Entity;
1038 Set_Ekind (Any_Integer, E_Signed_Integer_Type);
1039 Set_Scope (Any_Integer, Standard_Standard);
1040 Set_Etype (Any_Integer, Standard_Long_Long_Integer);
1041 Init_Size (Any_Integer, Standard_Long_Long_Integer_Size);
1042 Set_Elem_Alignment (Any_Integer);
1044 Set_Integer_Bounds
1045 (Any_Integer,
1046 Typ => Base_Type (Standard_Integer),
1047 Lb => Uint_0,
1048 Hb => Intval (High_Bound (Scalar_Range (Standard_Integer))));
1049 Make_Name (Any_Integer, "an integer type");
1051 Any_Modular := New_Standard_Entity;
1052 Set_Ekind (Any_Modular, E_Modular_Integer_Type);
1053 Set_Scope (Any_Modular, Standard_Standard);
1054 Set_Etype (Any_Modular, Standard_Long_Long_Integer);
1055 Init_Size (Any_Modular, Standard_Long_Long_Integer_Size);
1056 Set_Elem_Alignment (Any_Modular);
1057 Set_Is_Unsigned_Type (Any_Modular);
1058 Make_Name (Any_Modular, "a modular type");
1060 Any_Numeric := New_Standard_Entity;
1061 Set_Ekind (Any_Numeric, E_Signed_Integer_Type);
1062 Set_Scope (Any_Numeric, Standard_Standard);
1063 Set_Etype (Any_Numeric, Standard_Long_Long_Integer);
1064 Init_Size (Any_Numeric, Standard_Long_Long_Integer_Size);
1065 Set_Elem_Alignment (Any_Numeric);
1066 Make_Name (Any_Numeric, "a numeric type");
1068 Any_Real := New_Standard_Entity;
1069 Set_Ekind (Any_Real, E_Floating_Point_Type);
1070 Set_Scope (Any_Real, Standard_Standard);
1071 Set_Etype (Any_Real, Standard_Long_Long_Float);
1072 Init_Size (Any_Real, Standard_Long_Long_Float_Size);
1073 Set_Elem_Alignment (Any_Real);
1074 Make_Name (Any_Real, "a real type");
1076 Any_Scalar := New_Standard_Entity;
1077 Set_Ekind (Any_Scalar, E_Signed_Integer_Type);
1078 Set_Scope (Any_Scalar, Standard_Standard);
1079 Set_Etype (Any_Scalar, Any_Scalar);
1080 Init_Size (Any_Scalar, Standard_Integer_Size);
1081 Set_Elem_Alignment (Any_Scalar);
1082 Make_Name (Any_Scalar, "a scalar type");
1084 Any_String := New_Standard_Entity;
1085 Set_Ekind (Any_String, E_String_Type);
1086 Set_Scope (Any_String, Standard_Standard);
1087 Set_Etype (Any_String, Any_String);
1088 Set_Component_Type (Any_String, Any_Character);
1089 Init_Size_Align (Any_String);
1090 Make_Name (Any_String, "a string type");
1092 declare
1093 Index : Node_Id;
1095 begin
1096 Index :=
1097 Make_Range (Stloc,
1098 Low_Bound => Make_Integer (Uint_0),
1099 High_Bound => Make_Integer (Uint_2 ** Standard_Integer_Size));
1100 Set_Etype (Index, Standard_Integer);
1101 Set_First_Index (Any_String, Index);
1102 end;
1104 Standard_Integer_8 := New_Standard_Entity;
1105 Decl := New_Node (N_Full_Type_Declaration, Stloc);
1106 Set_Defining_Identifier (Decl, Standard_Integer_8);
1107 Make_Name (Standard_Integer_8, "integer_8");
1108 Set_Scope (Standard_Integer_8, Standard_Standard);
1109 Build_Signed_Integer_Type (Standard_Integer_8, 8);
1111 Standard_Integer_16 := New_Standard_Entity;
1112 Decl := New_Node (N_Full_Type_Declaration, Stloc);
1113 Set_Defining_Identifier (Decl, Standard_Integer_16);
1114 Make_Name (Standard_Integer_16, "integer_16");
1115 Set_Scope (Standard_Integer_16, Standard_Standard);
1116 Build_Signed_Integer_Type (Standard_Integer_16, 16);
1118 Standard_Integer_32 := New_Standard_Entity;
1119 Decl := New_Node (N_Full_Type_Declaration, Stloc);
1120 Set_Defining_Identifier (Decl, Standard_Integer_32);
1121 Make_Name (Standard_Integer_32, "integer_32");
1122 Set_Scope (Standard_Integer_32, Standard_Standard);
1123 Build_Signed_Integer_Type (Standard_Integer_32, 32);
1125 Standard_Integer_64 := New_Standard_Entity;
1126 Decl := New_Node (N_Full_Type_Declaration, Stloc);
1127 Set_Defining_Identifier (Decl, Standard_Integer_64);
1128 Make_Name (Standard_Integer_64, "integer_64");
1129 Set_Scope (Standard_Integer_64, Standard_Standard);
1130 Build_Signed_Integer_Type (Standard_Integer_64, 64);
1132 Standard_Unsigned := New_Standard_Entity;
1133 Decl := New_Node (N_Full_Type_Declaration, Stloc);
1134 Set_Defining_Identifier (Decl, Standard_Unsigned);
1135 Make_Name (Standard_Unsigned, "unsigned");
1137 Set_Ekind (Standard_Unsigned, E_Modular_Integer_Type);
1138 Set_Scope (Standard_Unsigned, Standard_Standard);
1139 Set_Etype (Standard_Unsigned, Standard_Unsigned);
1140 Init_Size (Standard_Unsigned, Standard_Integer_Size);
1141 Set_Elem_Alignment (Standard_Unsigned);
1142 Set_Modulus (Standard_Unsigned,
1143 Uint_2 ** Standard_Integer_Size);
1144 Set_Is_Unsigned_Type (Standard_Unsigned);
1145 Set_Size_Known_At_Compile_Time
1146 (Standard_Unsigned);
1148 R_Node := New_Node (N_Range, Stloc);
1149 Set_Low_Bound (R_Node, Make_Integer (Uint_0));
1150 Set_High_Bound (R_Node, Make_Integer (Modulus (Standard_Unsigned) - 1));
1151 Set_Etype (Low_Bound (R_Node), Standard_Unsigned);
1152 Set_Etype (High_Bound (R_Node), Standard_Unsigned);
1153 Set_Scalar_Range (Standard_Unsigned, R_Node);
1155 -- Note: universal integer and universal real are constructed as fully
1156 -- formed signed numeric types, with parameters corresponding to the
1157 -- longest runtime types (Long_Long_Integer and Long_Long_Float). This
1158 -- allows Gigi to properly process references to universal types that
1159 -- are not folded at compile time.
1161 Universal_Integer := New_Standard_Entity;
1162 Decl := New_Node (N_Full_Type_Declaration, Stloc);
1163 Set_Defining_Identifier (Decl, Universal_Integer);
1164 Make_Name (Universal_Integer, "universal_integer");
1165 Set_Scope (Universal_Integer, Standard_Standard);
1166 Build_Signed_Integer_Type
1167 (Universal_Integer, Standard_Long_Long_Integer_Size);
1169 Universal_Real := New_Standard_Entity;
1170 Decl := New_Node (N_Full_Type_Declaration, Stloc);
1171 Set_Defining_Identifier (Decl, Universal_Real);
1172 Make_Name (Universal_Real, "universal_real");
1173 Set_Scope (Universal_Real, Standard_Standard);
1174 Build_Float_Type
1175 (Universal_Real,
1176 Standard_Long_Long_Float_Size,
1177 Standard_Long_Long_Float_Digits);
1179 -- Note: universal fixed, unlike universal integer and universal real,
1180 -- is never used at runtime, so it does not need to have bounds set.
1182 Universal_Fixed := New_Standard_Entity;
1183 Decl := New_Node (N_Full_Type_Declaration, Stloc);
1184 Set_Defining_Identifier (Decl, Universal_Fixed);
1185 Make_Name (Universal_Fixed, "universal_fixed");
1186 Set_Ekind (Universal_Fixed, E_Ordinary_Fixed_Point_Type);
1187 Set_Etype (Universal_Fixed, Universal_Fixed);
1188 Set_Scope (Universal_Fixed, Standard_Standard);
1189 Init_Size (Universal_Fixed, Standard_Long_Long_Integer_Size);
1190 Set_Elem_Alignment (Universal_Fixed);
1191 Set_Size_Known_At_Compile_Time
1192 (Universal_Fixed);
1194 -- Create type declaration for Duration, using a 64-bit size. The
1195 -- delta and size values depend on the mode set in system.ads.
1197 Build_Duration : declare
1198 Dlo : Uint;
1199 Dhi : Uint;
1200 Delta_Val : Ureal;
1202 begin
1203 -- In 32 bit mode, the size is 32 bits, and the delta and
1204 -- small values are set to 20 milliseconds (20.0**(10.0**(-3)).
1206 if Duration_32_Bits_On_Target then
1207 Dlo := Intval (Type_Low_Bound (Standard_Integer_32));
1208 Dhi := Intval (Type_High_Bound (Standard_Integer_32));
1209 Delta_Val := UR_From_Components (UI_From_Int (20), Uint_3, 10);
1211 -- In standard 64-bit mode, the size is 64-bits and the delta and
1212 -- small values are set to nanoseconds (1.0**(10.0**(-9))
1214 else
1215 Dlo := Intval (Type_Low_Bound (Standard_Integer_64));
1216 Dhi := Intval (Type_High_Bound (Standard_Integer_64));
1217 Delta_Val := UR_From_Components (Uint_1, Uint_9, 10);
1218 end if;
1220 Tdef_Node := Make_Ordinary_Fixed_Point_Definition (Stloc,
1221 Delta_Expression => Make_Real_Literal (Stloc, Delta_Val),
1222 Real_Range_Specification =>
1223 Make_Real_Range_Specification (Stloc,
1224 Low_Bound => Make_Real_Literal (Stloc,
1225 Realval => Dlo * Delta_Val),
1226 High_Bound => Make_Real_Literal (Stloc,
1227 Realval => Dhi * Delta_Val)));
1229 Set_Type_Definition (Parent (Standard_Duration), Tdef_Node);
1231 Set_Ekind (Standard_Duration, E_Ordinary_Fixed_Point_Type);
1232 Set_Etype (Standard_Duration, Standard_Duration);
1234 if Duration_32_Bits_On_Target then
1235 Init_Size (Standard_Duration, 32);
1236 else
1237 Init_Size (Standard_Duration, 64);
1238 end if;
1240 Set_Elem_Alignment (Standard_Duration);
1241 Set_Delta_Value (Standard_Duration, Delta_Val);
1242 Set_Small_Value (Standard_Duration, Delta_Val);
1243 Set_Scalar_Range (Standard_Duration,
1244 Real_Range_Specification
1245 (Type_Definition (Parent (Standard_Duration))));
1247 -- Normally it does not matter that nodes in package Standard are
1248 -- not marked as analyzed. The Scalar_Range of the fixed-point
1249 -- type Standard_Duration is an exception, because of the special
1250 -- test made in Freeze.Freeze_Fixed_Point_Type.
1252 Set_Analyzed (Scalar_Range (Standard_Duration));
1254 Set_Etype (Type_High_Bound (Standard_Duration), Standard_Duration);
1255 Set_Etype (Type_Low_Bound (Standard_Duration), Standard_Duration);
1257 Set_Is_Static_Expression (Type_High_Bound (Standard_Duration));
1258 Set_Is_Static_Expression (Type_Low_Bound (Standard_Duration));
1260 Set_Corresponding_Integer_Value
1261 (Type_High_Bound (Standard_Duration), Dhi);
1263 Set_Corresponding_Integer_Value
1264 (Type_Low_Bound (Standard_Duration), Dlo);
1266 Set_Size_Known_At_Compile_Time (Standard_Duration);
1267 end Build_Duration;
1269 -- Build standard exception type. Note that the type name here is
1270 -- actually used in the generated code, so it must be set correctly
1272 -- ??? Also note that the Import_Code component is now declared
1273 -- as a System.Standard_Library.Exception_Code to enforce run-time
1274 -- library implementation consistency. It's too early here to resort
1275 -- to rtsfind to get the proper node for that type, so we use the
1276 -- closest possible available type node at hand instead. We should
1277 -- probably be fixing this up at some point.
1279 Standard_Exception_Type := New_Standard_Entity;
1280 Set_Ekind (Standard_Exception_Type, E_Record_Type);
1281 Set_Etype (Standard_Exception_Type, Standard_Exception_Type);
1282 Set_Scope (Standard_Exception_Type, Standard_Standard);
1283 Set_Stored_Constraint
1284 (Standard_Exception_Type, No_Elist);
1285 Init_Size_Align (Standard_Exception_Type);
1286 Set_Size_Known_At_Compile_Time
1287 (Standard_Exception_Type, True);
1288 Make_Name (Standard_Exception_Type, "exception");
1290 Make_Component
1291 (Standard_Exception_Type, Standard_Boolean, "Not_Handled_By_Others");
1292 Make_Component
1293 (Standard_Exception_Type, Standard_Character, "Lang");
1294 Make_Component
1295 (Standard_Exception_Type, Standard_Natural, "Name_Length");
1296 Make_Component
1297 (Standard_Exception_Type, Standard_A_Char, "Full_Name");
1298 Make_Component
1299 (Standard_Exception_Type, Standard_A_Char, "HTable_Ptr");
1300 Make_Component
1301 (Standard_Exception_Type, Standard_Unsigned, "Import_Code");
1302 Make_Component
1303 (Standard_Exception_Type, Standard_A_Char, "Raise_Hook");
1305 -- Build tree for record declaration, for use by the back-end
1307 declare
1308 Comp_List : List_Id;
1309 Comp : Entity_Id;
1311 begin
1312 Comp := First_Entity (Standard_Exception_Type);
1313 Comp_List := New_List;
1315 while Present (Comp) loop
1316 Append (
1317 Make_Component_Declaration (Stloc,
1318 Defining_Identifier => Comp,
1319 Component_Definition =>
1320 Make_Component_Definition (Stloc,
1321 Aliased_Present => False,
1322 Subtype_Indication => New_Occurrence_Of (Etype (Comp),
1323 Stloc))),
1324 Comp_List);
1326 Next_Entity (Comp);
1327 end loop;
1329 Decl := Make_Full_Type_Declaration (Stloc,
1330 Defining_Identifier => Standard_Exception_Type,
1331 Type_Definition =>
1332 Make_Record_Definition (Stloc,
1333 End_Label => Empty,
1334 Component_List =>
1335 Make_Component_List (Stloc,
1336 Component_Items => Comp_List)));
1337 end;
1339 Append (Decl, Decl_S);
1341 Layout_Type (Standard_Exception_Type);
1343 -- Create declarations of standard exceptions
1345 Build_Exception (S_Constraint_Error);
1346 Build_Exception (S_Program_Error);
1347 Build_Exception (S_Storage_Error);
1348 Build_Exception (S_Tasking_Error);
1350 -- Numeric_Error is a normal exception in Ada 83, but in Ada 95
1351 -- it is a renaming of Constraint_Error. Is this test too early???
1353 if Ada_Version = Ada_83 then
1354 Build_Exception (S_Numeric_Error);
1356 else
1357 Decl := New_Node (N_Exception_Renaming_Declaration, Stloc);
1358 E_Id := Standard_Entity (S_Numeric_Error);
1360 Set_Ekind (E_Id, E_Exception);
1361 Set_Exception_Code (E_Id, Uint_0);
1362 Set_Etype (E_Id, Standard_Exception_Type);
1363 Set_Is_Public (E_Id);
1364 Set_Renamed_Entity (E_Id, Standard_Entity (S_Constraint_Error));
1366 Set_Defining_Identifier (Decl, E_Id);
1367 Append (Decl, Decl_S);
1369 Ident_Node := New_Node (N_Identifier, Stloc);
1370 Set_Chars (Ident_Node, Chars (Standard_Entity (S_Constraint_Error)));
1371 Set_Entity (Ident_Node, Standard_Entity (S_Constraint_Error));
1372 Set_Name (Decl, Ident_Node);
1373 end if;
1375 -- Abort_Signal is an entity that does not get made visible
1377 Abort_Signal := New_Standard_Entity;
1378 Set_Chars (Abort_Signal, Name_uAbort_Signal);
1379 Set_Ekind (Abort_Signal, E_Exception);
1380 Set_Exception_Code (Abort_Signal, Uint_0);
1381 Set_Etype (Abort_Signal, Standard_Exception_Type);
1382 Set_Scope (Abort_Signal, Standard_Standard);
1383 Set_Is_Public (Abort_Signal, True);
1384 Decl :=
1385 Make_Exception_Declaration (Stloc,
1386 Defining_Identifier => Abort_Signal);
1388 -- Create defining identifiers for shift operator entities. Note
1389 -- that these entities are used only for marking shift operators
1390 -- generated internally, and hence need no structure, just a name
1391 -- and a unique identity.
1393 Standard_Op_Rotate_Left := New_Standard_Entity;
1394 Set_Chars (Standard_Op_Rotate_Left, Name_Rotate_Left);
1395 Set_Ekind (Standard_Op_Rotate_Left, E_Operator);
1397 Standard_Op_Rotate_Right := New_Standard_Entity;
1398 Set_Chars (Standard_Op_Rotate_Right, Name_Rotate_Right);
1399 Set_Ekind (Standard_Op_Rotate_Right, E_Operator);
1401 Standard_Op_Shift_Left := New_Standard_Entity;
1402 Set_Chars (Standard_Op_Shift_Left, Name_Shift_Left);
1403 Set_Ekind (Standard_Op_Shift_Left, E_Operator);
1405 Standard_Op_Shift_Right := New_Standard_Entity;
1406 Set_Chars (Standard_Op_Shift_Right, Name_Shift_Right);
1407 Set_Ekind (Standard_Op_Shift_Right, E_Operator);
1409 Standard_Op_Shift_Right_Arithmetic := New_Standard_Entity;
1410 Set_Chars (Standard_Op_Shift_Right_Arithmetic,
1411 Name_Shift_Right_Arithmetic);
1412 Set_Ekind (Standard_Op_Shift_Right_Arithmetic,
1413 E_Operator);
1415 -- Create standard operator declarations
1417 Create_Operators;
1419 -- Initialize visibility table with entities in Standard
1421 for E in Standard_Entity_Type loop
1422 if Ekind (Standard_Entity (E)) /= E_Operator then
1423 Set_Name_Entity_Id
1424 (Chars (Standard_Entity (E)), Standard_Entity (E));
1425 Set_Homonym (Standard_Entity (E), Empty);
1426 end if;
1428 if E not in S_ASCII_Names then
1429 Set_Scope (Standard_Entity (E), Standard_Standard);
1430 Set_Is_Immediately_Visible (Standard_Entity (E));
1431 end if;
1432 end loop;
1434 -- The predefined package Standard itself does not have a scope;
1435 -- it is the only entity in the system not to have one, and this
1436 -- is what identifies the package to Gigi.
1438 Set_Scope (Standard_Standard, Empty);
1440 -- Set global variables indicating last Id values and version
1442 Last_Standard_Node_Id := Last_Node_Id;
1443 Last_Standard_List_Id := Last_List_Id;
1445 -- The Error node has an Etype of Any_Type to help error recovery
1447 Set_Etype (Error, Any_Type);
1449 -- Print representation of standard if switch set
1451 if Opt.Print_Standard then
1452 Print_Standard;
1453 end if;
1454 end Create_Standard;
1456 ------------------------------------
1457 -- Create_Unconstrained_Base_Type --
1458 ------------------------------------
1460 procedure Create_Unconstrained_Base_Type
1461 (E : Entity_Id;
1462 K : Entity_Kind)
1464 New_Ent : constant Entity_Id := New_Copy (E);
1466 begin
1467 Set_Ekind (E, K);
1468 Set_Is_Constrained (E, True);
1469 Set_Is_First_Subtype (E, True);
1470 Set_Etype (E, New_Ent);
1472 Append_Entity (New_Ent, Standard_Standard);
1473 Set_Is_Constrained (New_Ent, False);
1474 Set_Etype (New_Ent, New_Ent);
1475 Set_Is_Known_Valid (New_Ent, True);
1477 if K = E_Signed_Integer_Subtype then
1478 Set_Etype (Low_Bound (Scalar_Range (E)), New_Ent);
1479 Set_Etype (High_Bound (Scalar_Range (E)), New_Ent);
1480 end if;
1482 end Create_Unconstrained_Base_Type;
1484 --------------------
1485 -- Identifier_For --
1486 --------------------
1488 function Identifier_For (S : Standard_Entity_Type) return Node_Id is
1489 Ident_Node : Node_Id;
1491 begin
1492 Ident_Node := New_Node (N_Identifier, Stloc);
1493 Set_Chars (Ident_Node, Chars (Standard_Entity (S)));
1494 return Ident_Node;
1495 end Identifier_For;
1497 --------------------
1498 -- Make_Component --
1499 --------------------
1501 procedure Make_Component
1502 (Rec : Entity_Id;
1503 Typ : Entity_Id;
1504 Nam : String)
1506 Id : constant Entity_Id := New_Standard_Entity;
1508 begin
1509 Set_Ekind (Id, E_Component);
1510 Set_Etype (Id, Typ);
1511 Set_Scope (Id, Rec);
1512 Init_Component_Location (Id);
1514 Set_Original_Record_Component (Id, Id);
1515 Make_Name (Id, Nam);
1516 Append_Entity (Id, Rec);
1517 end Make_Component;
1519 -----------------
1520 -- Make_Formal --
1521 -----------------
1523 function Make_Formal
1524 (Typ : Entity_Id;
1525 Formal_Name : String) return Entity_Id
1527 Formal : Entity_Id;
1529 begin
1530 Formal := New_Standard_Entity;
1532 Set_Ekind (Formal, E_In_Parameter);
1533 Set_Mechanism (Formal, Default_Mechanism);
1534 Set_Scope (Formal, Standard_Standard);
1535 Set_Etype (Formal, Typ);
1536 Make_Name (Formal, Formal_Name);
1538 return Formal;
1539 end Make_Formal;
1541 ------------------
1542 -- Make_Integer --
1543 ------------------
1545 function Make_Integer (V : Uint) return Node_Id is
1546 N : constant Node_Id := Make_Integer_Literal (Stloc, V);
1547 begin
1548 Set_Is_Static_Expression (N);
1549 return N;
1550 end Make_Integer;
1552 ---------------
1553 -- Make_Name --
1554 ---------------
1556 procedure Make_Name (Id : Entity_Id; Nam : String) is
1557 begin
1558 for J in 1 .. Nam'Length loop
1559 Name_Buffer (J) := Fold_Lower (Nam (Nam'First + (J - 1)));
1560 end loop;
1562 Name_Len := Nam'Length;
1563 Set_Chars (Id, Name_Find);
1564 end Make_Name;
1566 ------------------
1567 -- New_Operator --
1568 ------------------
1570 function New_Operator (Op : Name_Id; Typ : Entity_Id) return Entity_Id is
1571 Ident_Node : Entity_Id;
1573 begin
1574 Ident_Node := Make_Defining_Identifier (Stloc, Op);
1576 Set_Is_Pure (Ident_Node, True);
1577 Set_Ekind (Ident_Node, E_Operator);
1578 Set_Etype (Ident_Node, Typ);
1579 Set_Scope (Ident_Node, Standard_Standard);
1580 Set_Homonym (Ident_Node, Get_Name_Entity_Id (Op));
1581 Set_Convention (Ident_Node, Convention_Intrinsic);
1583 Set_Is_Immediately_Visible (Ident_Node, True);
1584 Set_Is_Intrinsic_Subprogram (Ident_Node, True);
1586 Set_Name_Entity_Id (Op, Ident_Node);
1587 Append_Entity (Ident_Node, Standard_Standard);
1588 return Ident_Node;
1589 end New_Operator;
1591 -------------------------
1592 -- New_Standard_Entity --
1593 -------------------------
1595 function New_Standard_Entity
1596 (New_Node_Kind : Node_Kind := N_Defining_Identifier) return Entity_Id
1598 E : constant Entity_Id := New_Entity (New_Node_Kind, Stloc);
1600 begin
1601 -- All standard entities are Pure and Public
1603 Set_Is_Pure (E);
1604 Set_Is_Public (E);
1606 -- All standard entity names are analyzed manually, and are thus
1607 -- frozen as soon as they are created.
1609 Set_Is_Frozen (E);
1611 -- Set debug information required for all standard types
1613 Set_Needs_Debug_Info (E);
1615 -- All standard entities are built with fully qualified names, so
1616 -- set the flag to prevent an abortive attempt at requalification!
1618 Set_Has_Qualified_Name (E);
1620 -- Return newly created entity to be completed by caller
1622 return E;
1623 end New_Standard_Entity;
1625 --------------------
1626 -- Print_Standard --
1627 --------------------
1629 procedure Print_Standard is
1631 procedure P (Item : String) renames Output.Write_Line;
1632 -- Short-hand, since we do a lot of line writes here!
1634 procedure P_Int_Range (Size : Pos);
1635 -- Prints the range of an integer based on its Size
1637 procedure P_Float_Range (Id : Entity_Id);
1638 -- Prints the bounds range for the given float type entity
1640 -------------------
1641 -- P_Float_Range --
1642 -------------------
1644 procedure P_Float_Range (Id : Entity_Id) is
1645 Digs : constant Nat := UI_To_Int (Digits_Value (Id));
1647 begin
1648 Write_Str (" range ");
1650 if Vax_Float (Id) then
1651 if Digs = VAXFF_Digits then
1652 Write_Str (VAXFF_First'Universal_Literal_String);
1653 Write_Str (" .. ");
1654 Write_Str (VAXFF_Last'Universal_Literal_String);
1656 elsif Digs = VAXDF_Digits then
1657 Write_Str (VAXDF_First'Universal_Literal_String);
1658 Write_Str (" .. ");
1659 Write_Str (VAXDF_Last'Universal_Literal_String);
1661 else
1662 pragma Assert (Digs = VAXGF_Digits);
1664 Write_Str (VAXGF_First'Universal_Literal_String);
1665 Write_Str (" .. ");
1666 Write_Str (VAXGF_Last'Universal_Literal_String);
1667 end if;
1669 elsif Is_AAMP_Float (Id) then
1670 if Digs = AAMPS_Digits then
1671 Write_Str (AAMPS_First'Universal_Literal_String);
1672 Write_Str (" .. ");
1673 Write_Str (AAMPS_Last'Universal_Literal_String);
1675 else
1676 pragma Assert (Digs = AAMPL_Digits);
1677 Write_Str (AAMPL_First'Universal_Literal_String);
1678 Write_Str (" .. ");
1679 Write_Str (AAMPL_Last'Universal_Literal_String);
1680 end if;
1682 elsif Digs = IEEES_Digits then
1683 Write_Str (IEEES_First'Universal_Literal_String);
1684 Write_Str (" .. ");
1685 Write_Str (IEEES_Last'Universal_Literal_String);
1687 elsif Digs = IEEEL_Digits then
1688 Write_Str (IEEEL_First'Universal_Literal_String);
1689 Write_Str (" .. ");
1690 Write_Str (IEEEL_Last'Universal_Literal_String);
1692 else
1693 pragma Assert (Digs = IEEEX_Digits);
1695 Write_Str (IEEEX_First'Universal_Literal_String);
1696 Write_Str (" .. ");
1697 Write_Str (IEEEX_Last'Universal_Literal_String);
1698 end if;
1700 Write_Str (";");
1701 Write_Eol;
1702 end P_Float_Range;
1704 -----------------
1705 -- P_Int_Range --
1706 -----------------
1708 procedure P_Int_Range (Size : Pos) is
1709 begin
1710 Write_Str (" is range -(2 **");
1711 Write_Int (Size - 1);
1712 Write_Str (")");
1713 Write_Str (" .. +(2 **");
1714 Write_Int (Size - 1);
1715 Write_Str (" - 1);");
1716 Write_Eol;
1717 end P_Int_Range;
1719 -- Start of processing for Print_Standard
1721 begin
1722 P ("-- Representation of package Standard");
1723 Write_Eol;
1724 P ("-- This is not accurate Ada, since new base types cannot be ");
1725 P ("-- created, but the listing shows the target dependent");
1726 P ("-- characteristics of the Standard types for this compiler");
1727 Write_Eol;
1729 P ("package Standard is");
1730 P ("pragma Pure (Standard);");
1731 Write_Eol;
1733 P (" type Boolean is (False, True);");
1734 P (" for Boolean'Size use 1;");
1735 P (" for Boolean use (False => 0, True => 1);");
1736 Write_Eol;
1738 -- Integer types
1740 Write_Str (" type Integer");
1741 P_Int_Range (Standard_Integer_Size);
1742 Write_Str (" for Integer'Size use ");
1743 Write_Int (Standard_Integer_Size);
1744 P (";");
1745 Write_Eol;
1747 P (" subtype Natural is Integer range 0 .. Integer'Last;");
1748 P (" subtype Positive is Integer range 1 .. Integer'Last;");
1749 Write_Eol;
1751 Write_Str (" type Short_Short_Integer");
1752 P_Int_Range (Standard_Short_Short_Integer_Size);
1753 Write_Str (" for Short_Short_Integer'Size use ");
1754 Write_Int (Standard_Short_Short_Integer_Size);
1755 P (";");
1756 Write_Eol;
1758 Write_Str (" type Short_Integer");
1759 P_Int_Range (Standard_Short_Integer_Size);
1760 Write_Str (" for Short_Integer'Size use ");
1761 Write_Int (Standard_Short_Integer_Size);
1762 P (";");
1763 Write_Eol;
1765 Write_Str (" type Long_Integer");
1766 P_Int_Range (Standard_Long_Integer_Size);
1767 Write_Str (" for Long_Integer'Size use ");
1768 Write_Int (Standard_Long_Integer_Size);
1769 P (";");
1770 Write_Eol;
1772 Write_Str (" type Long_Long_Integer");
1773 P_Int_Range (Standard_Long_Long_Integer_Size);
1774 Write_Str (" for Long_Long_Integer'Size use ");
1775 Write_Int (Standard_Long_Long_Integer_Size);
1776 P (";");
1777 Write_Eol;
1779 -- Floating point types
1781 Write_Str (" type Short_Float is digits ");
1782 Write_Int (Standard_Short_Float_Digits);
1783 Write_Eol;
1784 P_Float_Range (Standard_Short_Float);
1785 Write_Str (" for Short_Float'Size use ");
1786 Write_Int (Standard_Short_Float_Size);
1787 P (";");
1788 Write_Eol;
1790 Write_Str (" type Float is digits ");
1791 Write_Int (Standard_Float_Digits);
1792 Write_Eol;
1793 P_Float_Range (Standard_Float);
1794 Write_Str (" for Float'Size use ");
1795 Write_Int (Standard_Float_Size);
1796 P (";");
1797 Write_Eol;
1799 Write_Str (" type Long_Float is digits ");
1800 Write_Int (Standard_Long_Float_Digits);
1801 Write_Eol;
1802 P_Float_Range (Standard_Long_Float);
1803 Write_Str (" for Long_Float'Size use ");
1804 Write_Int (Standard_Long_Float_Size);
1805 P (";");
1806 Write_Eol;
1808 Write_Str (" type Long_Long_Float is digits ");
1809 Write_Int (Standard_Long_Long_Float_Digits);
1810 Write_Eol;
1811 P_Float_Range (Standard_Long_Long_Float);
1812 Write_Str (" for Long_Long_Float'Size use ");
1813 Write_Int (Standard_Long_Long_Float_Size);
1814 P (";");
1815 Write_Eol;
1817 P (" type Character is (...)");
1818 Write_Str (" for Character'Size use ");
1819 Write_Int (Standard_Character_Size);
1820 P (";");
1821 P (" -- See RM A.1(35) for details of this type");
1822 Write_Eol;
1824 P (" type Wide_Character is (...)");
1825 Write_Str (" for Wide_Character'Size use ");
1826 Write_Int (Standard_Wide_Character_Size);
1827 P (";");
1828 P (" -- See RM A.1(36) for details of this type");
1829 Write_Eol;
1831 P (" type Wide_Wide_Character is (...)");
1832 Write_Str (" for Wide_Wide_Character'Size use ");
1833 Write_Int (Standard_Wide_Wide_Character_Size);
1834 P (";");
1835 P (" -- See RM A.1(36) for details of this type");
1837 P (" type String is array (Positive range <>) of Character;");
1838 P (" pragma Pack (String);");
1839 Write_Eol;
1841 P (" type Wide_String is array (Positive range <>)" &
1842 " of Wide_Character;");
1843 P (" pragma Pack (Wide_String);");
1844 Write_Eol;
1846 P (" type Wide_Wide_String is array (Positive range <>)" &
1847 " of Wide_Wide_Character;");
1848 P (" pragma Pack (Wide_Wide_String);");
1849 Write_Eol;
1851 -- Here it's OK to use the Duration type of the host compiler since
1852 -- the implementation of Duration in GNAT is target independent.
1854 if Duration_32_Bits_On_Target then
1855 P (" type Duration is delta 0.020");
1856 P (" range -((2 ** 31 - 1) * 0.020) ..");
1857 P (" +((2 ** 31 - 1) * 0.020);");
1858 P (" for Duration'Small use 0.020;");
1859 else
1860 P (" type Duration is delta 0.000000001");
1861 P (" range -((2 ** 63 - 1) * 0.000000001) ..");
1862 P (" +((2 ** 63 - 1) * 0.000000001);");
1863 P (" for Duration'Small use 0.000000001;");
1864 end if;
1866 Write_Eol;
1868 P (" Constraint_Error : exception;");
1869 P (" Program_Error : exception;");
1870 P (" Storage_Error : exception;");
1871 P (" Tasking_Error : exception;");
1872 P (" Numeric_Error : exception renames Constraint_Error;");
1873 Write_Eol;
1875 P ("end Standard;");
1876 end Print_Standard;
1878 ----------------------
1879 -- Set_Float_Bounds --
1880 ----------------------
1882 procedure Set_Float_Bounds (Id : Entity_Id) is
1883 L : Node_Id;
1884 -- Low bound of literal value
1886 H : Node_Id;
1887 -- High bound of literal value
1889 R : Node_Id;
1890 -- Range specification
1892 Digs : constant Nat := UI_To_Int (Digits_Value (Id));
1893 -- Digits value, used to select bounds
1895 begin
1896 -- Note: for the call from Cstand to initially create the types in
1897 -- Standard, Vax_Float will always be False. Circuitry in Sem_Vfpt
1898 -- will adjust these types appropriately in the Vax_Float case if
1899 -- a pragma Float_Representation (VAX_Float) is used.
1901 if Vax_Float (Id) then
1902 if Digs = VAXFF_Digits then
1903 L := Real_Convert
1904 (VAXFF_First'Universal_Literal_String);
1905 H := Real_Convert
1906 (VAXFF_Last'Universal_Literal_String);
1908 elsif Digs = VAXDF_Digits then
1909 L := Real_Convert
1910 (VAXDF_First'Universal_Literal_String);
1911 H := Real_Convert
1912 (VAXDF_Last'Universal_Literal_String);
1914 else
1915 pragma Assert (Digs = VAXGF_Digits);
1917 L := Real_Convert
1918 (VAXGF_First'Universal_Literal_String);
1919 H := Real_Convert
1920 (VAXGF_Last'Universal_Literal_String);
1921 end if;
1923 elsif Is_AAMP_Float (Id) then
1924 if Digs = AAMPS_Digits then
1925 L := Real_Convert
1926 (AAMPS_First'Universal_Literal_String);
1927 H := Real_Convert
1928 (AAMPS_Last'Universal_Literal_String);
1930 else
1931 pragma Assert (Digs = AAMPL_Digits);
1932 L := Real_Convert
1933 (AAMPL_First'Universal_Literal_String);
1934 H := Real_Convert
1935 (AAMPL_Last'Universal_Literal_String);
1936 end if;
1938 elsif Digs = IEEES_Digits then
1939 L := Real_Convert
1940 (IEEES_First'Universal_Literal_String);
1941 H := Real_Convert
1942 (IEEES_Last'Universal_Literal_String);
1944 elsif Digs = IEEEL_Digits then
1945 L := Real_Convert
1946 (IEEEL_First'Universal_Literal_String);
1947 H := Real_Convert
1948 (IEEEL_Last'Universal_Literal_String);
1950 else
1951 pragma Assert (Digs = IEEEX_Digits);
1953 L := Real_Convert
1954 (IEEEX_First'Universal_Literal_String);
1955 H := Real_Convert
1956 (IEEEX_Last'Universal_Literal_String);
1957 end if;
1959 Set_Etype (L, Id);
1960 Set_Is_Static_Expression (L);
1962 Set_Etype (H, Id);
1963 Set_Is_Static_Expression (H);
1965 R := New_Node (N_Range, Stloc);
1966 Set_Low_Bound (R, L);
1967 Set_High_Bound (R, H);
1968 Set_Includes_Infinities (R, True);
1969 Set_Scalar_Range (Id, R);
1970 Set_Etype (R, Id);
1971 Set_Parent (R, Id);
1972 end Set_Float_Bounds;
1974 ------------------------
1975 -- Set_Integer_Bounds --
1976 ------------------------
1978 procedure Set_Integer_Bounds
1979 (Id : Entity_Id;
1980 Typ : Entity_Id;
1981 Lb : Uint;
1982 Hb : Uint)
1984 L : Node_Id; -- Low bound of literal value
1985 H : Node_Id; -- High bound of literal value
1986 R : Node_Id; -- Range specification
1988 begin
1989 L := Make_Integer (Lb);
1990 H := Make_Integer (Hb);
1992 Set_Etype (L, Typ);
1993 Set_Etype (H, Typ);
1995 R := New_Node (N_Range, Stloc);
1996 Set_Low_Bound (R, L);
1997 Set_High_Bound (R, H);
1998 Set_Scalar_Range (Id, R);
1999 Set_Etype (R, Typ);
2000 Set_Parent (R, Id);
2001 Set_Is_Unsigned_Type (Id, Lb >= 0);
2002 end Set_Integer_Bounds;
2004 end CStand;