Merge -r 127928:132243 from trunk
[official-gcc.git] / gcc / ada / cstand.adb
blob5d16e53b82699d62d4873cceee0ac678a2e9fd73
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-2007, 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 declaration nodes for standard types
384 for S in S_Types loop
385 Decl := New_Node (N_Full_Type_Declaration, Stloc);
386 Set_Defining_Identifier (Decl, Standard_Entity (S));
387 Set_Is_Frozen (Standard_Entity (S));
388 Set_Is_Public (Standard_Entity (S));
389 Append (Decl, Decl_S);
390 end loop;
392 -- Create type definition node for type Boolean. The Size is set to
393 -- 1 as required by Ada 95 and current ARG interpretations for Ada/83.
395 -- Note: Object_Size of Boolean is 8. This means that we do NOT in
396 -- general know that Boolean variables have valid values, so we do
397 -- not set the Is_Known_Valid flag.
399 Tdef_Node := New_Node (N_Enumeration_Type_Definition, Stloc);
400 Set_Literals (Tdef_Node, New_List);
401 Append (Standard_False, Literals (Tdef_Node));
402 Append (Standard_True, Literals (Tdef_Node));
403 Set_Type_Definition (Parent (Standard_Boolean), Tdef_Node);
405 Set_Ekind (Standard_Boolean, E_Enumeration_Type);
406 Set_First_Literal (Standard_Boolean, Standard_False);
407 Set_Etype (Standard_Boolean, Standard_Boolean);
408 Init_Esize (Standard_Boolean, Standard_Character_Size);
409 Init_RM_Size (Standard_Boolean, 1);
410 Set_Elem_Alignment (Standard_Boolean);
412 Set_Is_Unsigned_Type (Standard_Boolean);
413 Set_Size_Known_At_Compile_Time (Standard_Boolean);
415 Set_Ekind (Standard_True, E_Enumeration_Literal);
416 Set_Etype (Standard_True, Standard_Boolean);
417 Set_Enumeration_Pos (Standard_True, Uint_1);
418 Set_Enumeration_Rep (Standard_True, Uint_1);
419 Set_Is_Known_Valid (Standard_True, True);
421 Set_Ekind (Standard_False, E_Enumeration_Literal);
422 Set_Etype (Standard_False, Standard_Boolean);
423 Set_Enumeration_Pos (Standard_False, Uint_0);
424 Set_Enumeration_Rep (Standard_False, Uint_0);
425 Set_Is_Known_Valid (Standard_False, True);
427 -- For the bounds of Boolean, we create a range node corresponding to
429 -- range False .. True
431 -- where the occurrences of the literals must point to the
432 -- corresponding definition.
434 R_Node := New_Node (N_Range, Stloc);
435 B_Node := New_Node (N_Identifier, Stloc);
436 Set_Chars (B_Node, Chars (Standard_False));
437 Set_Entity (B_Node, Standard_False);
438 Set_Etype (B_Node, Standard_Boolean);
439 Set_Is_Static_Expression (B_Node);
440 Set_Low_Bound (R_Node, B_Node);
442 B_Node := New_Node (N_Identifier, Stloc);
443 Set_Chars (B_Node, Chars (Standard_True));
444 Set_Entity (B_Node, Standard_True);
445 Set_Etype (B_Node, Standard_Boolean);
446 Set_Is_Static_Expression (B_Node);
447 Set_High_Bound (R_Node, B_Node);
449 Set_Scalar_Range (Standard_Boolean, R_Node);
450 Set_Etype (R_Node, Standard_Boolean);
451 Set_Parent (R_Node, Standard_Boolean);
453 -- Record entity identifiers for boolean literals in the
454 -- Boolean_Literals array, for easy reference during expansion.
456 Boolean_Literals := (False => Standard_False, True => Standard_True);
458 -- Create type definition nodes for predefined integer types
460 Build_Signed_Integer_Type
461 (Standard_Short_Short_Integer, Standard_Short_Short_Integer_Size);
463 Build_Signed_Integer_Type
464 (Standard_Short_Integer, Standard_Short_Integer_Size);
466 Build_Signed_Integer_Type
467 (Standard_Integer, Standard_Integer_Size);
469 declare
470 LIS : Nat;
471 begin
472 if Debug_Flag_M then
473 LIS := 64;
474 else
475 LIS := Standard_Long_Integer_Size;
476 end if;
478 Build_Signed_Integer_Type (Standard_Long_Integer, LIS);
479 end;
481 Build_Signed_Integer_Type
482 (Standard_Long_Long_Integer, Standard_Long_Long_Integer_Size);
484 Create_Unconstrained_Base_Type
485 (Standard_Short_Short_Integer, E_Signed_Integer_Subtype);
487 Create_Unconstrained_Base_Type
488 (Standard_Short_Integer, E_Signed_Integer_Subtype);
490 Create_Unconstrained_Base_Type
491 (Standard_Integer, E_Signed_Integer_Subtype);
493 Create_Unconstrained_Base_Type
494 (Standard_Long_Integer, E_Signed_Integer_Subtype);
496 Create_Unconstrained_Base_Type
497 (Standard_Long_Long_Integer, E_Signed_Integer_Subtype);
499 -- Create type definition nodes for predefined float types
501 Build_Float_Type
502 (Standard_Short_Float,
503 Standard_Short_Float_Size,
504 Standard_Short_Float_Digits);
506 Build_Float_Type
507 (Standard_Float,
508 Standard_Float_Size,
509 Standard_Float_Digits);
511 Build_Float_Type
512 (Standard_Long_Float,
513 Standard_Long_Float_Size,
514 Standard_Long_Float_Digits);
516 Build_Float_Type
517 (Standard_Long_Long_Float,
518 Standard_Long_Long_Float_Size,
519 Standard_Long_Long_Float_Digits);
521 -- Create type definition node for type Character. Note that we do not
522 -- set the Literals field, since type Character is handled with special
523 -- routine that do not need a literal list.
525 Tdef_Node := New_Node (N_Enumeration_Type_Definition, Stloc);
526 Set_Type_Definition (Parent (Standard_Character), Tdef_Node);
528 Set_Ekind (Standard_Character, E_Enumeration_Type);
529 Set_Etype (Standard_Character, Standard_Character);
530 Init_Esize (Standard_Character, Standard_Character_Size);
531 Init_RM_Size (Standard_Character, 8);
532 Set_Elem_Alignment (Standard_Character);
534 Set_Is_Unsigned_Type (Standard_Character);
535 Set_Is_Character_Type (Standard_Character);
536 Set_Is_Known_Valid (Standard_Character);
537 Set_Size_Known_At_Compile_Time (Standard_Character);
539 -- Create the bounds for type Character
541 R_Node := New_Node (N_Range, Stloc);
543 -- Low bound for type Character (Standard.Nul)
545 B_Node := New_Node (N_Character_Literal, Stloc);
546 Set_Is_Static_Expression (B_Node);
547 Set_Chars (B_Node, No_Name);
548 Set_Char_Literal_Value (B_Node, Uint_0);
549 Set_Entity (B_Node, Empty);
550 Set_Etype (B_Node, Standard_Character);
551 Set_Low_Bound (R_Node, B_Node);
553 -- High bound for type Character
555 B_Node := New_Node (N_Character_Literal, Stloc);
556 Set_Is_Static_Expression (B_Node);
557 Set_Chars (B_Node, No_Name);
558 Set_Char_Literal_Value (B_Node, UI_From_Int (16#FF#));
559 Set_Entity (B_Node, Empty);
560 Set_Etype (B_Node, Standard_Character);
561 Set_High_Bound (R_Node, B_Node);
563 Set_Scalar_Range (Standard_Character, R_Node);
564 Set_Etype (R_Node, Standard_Character);
565 Set_Parent (R_Node, Standard_Character);
567 -- Create type definition for type Wide_Character. Note that we do not
568 -- set the Literals field, since type Wide_Character is handled with
569 -- special routines that do not need a literal list.
571 Tdef_Node := New_Node (N_Enumeration_Type_Definition, Stloc);
572 Set_Type_Definition (Parent (Standard_Wide_Character), Tdef_Node);
574 Set_Ekind (Standard_Wide_Character, E_Enumeration_Type);
575 Set_Etype (Standard_Wide_Character, Standard_Wide_Character);
576 Init_Size (Standard_Wide_Character, Standard_Wide_Character_Size);
578 Set_Elem_Alignment (Standard_Wide_Character);
579 Set_Is_Unsigned_Type (Standard_Wide_Character);
580 Set_Is_Character_Type (Standard_Wide_Character);
581 Set_Is_Known_Valid (Standard_Wide_Character);
582 Set_Size_Known_At_Compile_Time (Standard_Wide_Character);
584 -- Create the bounds for type Wide_Character
586 R_Node := New_Node (N_Range, Stloc);
588 -- Low bound for type Wide_Character
590 B_Node := New_Node (N_Character_Literal, Stloc);
591 Set_Is_Static_Expression (B_Node);
592 Set_Chars (B_Node, No_Name); -- ???
593 Set_Char_Literal_Value (B_Node, Uint_0);
594 Set_Entity (B_Node, Empty);
595 Set_Etype (B_Node, Standard_Wide_Character);
596 Set_Low_Bound (R_Node, B_Node);
598 -- High bound for type Wide_Character
600 B_Node := New_Node (N_Character_Literal, Stloc);
601 Set_Is_Static_Expression (B_Node);
602 Set_Chars (B_Node, No_Name); -- ???
603 Set_Char_Literal_Value (B_Node, UI_From_Int (16#FFFF#));
604 Set_Entity (B_Node, Empty);
605 Set_Etype (B_Node, Standard_Wide_Character);
606 Set_High_Bound (R_Node, B_Node);
608 Set_Scalar_Range (Standard_Wide_Character, R_Node);
609 Set_Etype (R_Node, Standard_Wide_Character);
610 Set_Parent (R_Node, Standard_Wide_Character);
612 -- Create type definition for type Wide_Wide_Character. Note that we
613 -- do not set the Literals field, since type Wide_Wide_Character is
614 -- handled with special routines that do not need a literal list.
616 Tdef_Node := New_Node (N_Enumeration_Type_Definition, Stloc);
617 Set_Type_Definition (Parent (Standard_Wide_Wide_Character), Tdef_Node);
619 Set_Ekind (Standard_Wide_Wide_Character, E_Enumeration_Type);
620 Set_Etype (Standard_Wide_Wide_Character,
621 Standard_Wide_Wide_Character);
622 Init_Size (Standard_Wide_Wide_Character,
623 Standard_Wide_Wide_Character_Size);
625 Set_Elem_Alignment (Standard_Wide_Wide_Character);
626 Set_Is_Unsigned_Type (Standard_Wide_Wide_Character);
627 Set_Is_Character_Type (Standard_Wide_Wide_Character);
628 Set_Is_Known_Valid (Standard_Wide_Wide_Character);
629 Set_Size_Known_At_Compile_Time (Standard_Wide_Wide_Character);
630 Set_Is_Ada_2005_Only (Standard_Wide_Wide_Character);
632 -- Create the bounds for type Wide_Wide_Character
634 R_Node := New_Node (N_Range, Stloc);
636 -- Low bound for type Wide_Wide_Character
638 B_Node := New_Node (N_Character_Literal, Stloc);
639 Set_Is_Static_Expression (B_Node);
640 Set_Chars (B_Node, No_Name); -- ???
641 Set_Char_Literal_Value (B_Node, Uint_0);
642 Set_Entity (B_Node, Empty);
643 Set_Etype (B_Node, Standard_Wide_Wide_Character);
644 Set_Low_Bound (R_Node, B_Node);
646 -- High bound for type Wide_Wide_Character
648 B_Node := New_Node (N_Character_Literal, Stloc);
649 Set_Is_Static_Expression (B_Node);
650 Set_Chars (B_Node, No_Name); -- ???
651 Set_Char_Literal_Value (B_Node, UI_From_Int (16#7FFF_FFFF#));
652 Set_Entity (B_Node, Empty);
653 Set_Etype (B_Node, Standard_Wide_Wide_Character);
654 Set_High_Bound (R_Node, B_Node);
656 Set_Scalar_Range (Standard_Wide_Wide_Character, R_Node);
657 Set_Etype (R_Node, Standard_Wide_Wide_Character);
658 Set_Parent (R_Node, Standard_Wide_Wide_Character);
660 -- Create type definition node for type String
662 Tdef_Node := New_Node (N_Unconstrained_Array_Definition, Stloc);
664 declare
665 CompDef_Node : Node_Id;
666 begin
667 CompDef_Node := New_Node (N_Component_Definition, Stloc);
668 Set_Aliased_Present (CompDef_Node, False);
669 Set_Access_Definition (CompDef_Node, Empty);
670 Set_Subtype_Indication (CompDef_Node, Identifier_For (S_Character));
671 Set_Component_Definition (Tdef_Node, CompDef_Node);
672 end;
674 Set_Subtype_Marks (Tdef_Node, New_List);
675 Append (Identifier_For (S_Positive), Subtype_Marks (Tdef_Node));
676 Set_Type_Definition (Parent (Standard_String), Tdef_Node);
678 Set_Ekind (Standard_String, E_String_Type);
679 Set_Etype (Standard_String, Standard_String);
680 Set_Component_Type (Standard_String, Standard_Character);
681 Set_Component_Size (Standard_String, Uint_8);
682 Init_Size_Align (Standard_String);
683 Set_Alignment (Standard_String, Uint_1);
685 -- On targets where a storage unit is larger than a byte (such as AAMP),
686 -- pragma Pack has a real effect on the representation of type String,
687 -- and the type must be marked as having a nonstandard representation.
689 if System_Storage_Unit > Uint_8 then
690 Set_Has_Non_Standard_Rep (Standard_String);
691 Set_Has_Pragma_Pack (Standard_String);
692 end if;
694 -- Set index type of String
696 E_Id := First
697 (Subtype_Marks (Type_Definition (Parent (Standard_String))));
698 Set_First_Index (Standard_String, E_Id);
699 Set_Entity (E_Id, Standard_Positive);
700 Set_Etype (E_Id, Standard_Positive);
702 -- Create type definition node for type Wide_String
704 Tdef_Node := New_Node (N_Unconstrained_Array_Definition, Stloc);
706 declare
707 CompDef_Node : Node_Id;
708 begin
709 CompDef_Node := New_Node (N_Component_Definition, Stloc);
710 Set_Aliased_Present (CompDef_Node, False);
711 Set_Access_Definition (CompDef_Node, Empty);
712 Set_Subtype_Indication (CompDef_Node,
713 Identifier_For (S_Wide_Character));
714 Set_Component_Definition (Tdef_Node, CompDef_Node);
715 end;
717 Set_Subtype_Marks (Tdef_Node, New_List);
718 Append (Identifier_For (S_Positive), Subtype_Marks (Tdef_Node));
719 Set_Type_Definition (Parent (Standard_Wide_String), Tdef_Node);
721 Set_Ekind (Standard_Wide_String, E_String_Type);
722 Set_Etype (Standard_Wide_String, Standard_Wide_String);
723 Set_Component_Type (Standard_Wide_String, Standard_Wide_Character);
724 Set_Component_Size (Standard_Wide_String, Uint_16);
725 Init_Size_Align (Standard_Wide_String);
727 -- Set index type of Wide_String
729 E_Id := First
730 (Subtype_Marks (Type_Definition (Parent (Standard_Wide_String))));
731 Set_First_Index (Standard_Wide_String, E_Id);
732 Set_Entity (E_Id, Standard_Positive);
733 Set_Etype (E_Id, Standard_Positive);
735 -- Create type definition node for type Wide_Wide_String
737 Tdef_Node := New_Node (N_Unconstrained_Array_Definition, Stloc);
739 declare
740 CompDef_Node : Node_Id;
741 begin
742 CompDef_Node := New_Node (N_Component_Definition, Stloc);
743 Set_Aliased_Present (CompDef_Node, False);
744 Set_Access_Definition (CompDef_Node, Empty);
745 Set_Subtype_Indication (CompDef_Node,
746 Identifier_For (S_Wide_Wide_Character));
747 Set_Component_Definition (Tdef_Node, CompDef_Node);
748 end;
750 Set_Subtype_Marks (Tdef_Node, New_List);
751 Append (Identifier_For (S_Positive), Subtype_Marks (Tdef_Node));
752 Set_Type_Definition (Parent (Standard_Wide_Wide_String), Tdef_Node);
754 Set_Ekind (Standard_Wide_Wide_String, E_String_Type);
755 Set_Etype (Standard_Wide_Wide_String,
756 Standard_Wide_Wide_String);
757 Set_Component_Type (Standard_Wide_Wide_String,
758 Standard_Wide_Wide_Character);
759 Set_Component_Size (Standard_Wide_Wide_String, Uint_32);
760 Init_Size_Align (Standard_Wide_Wide_String);
761 Set_Is_Ada_2005_Only (Standard_Wide_Wide_String);
763 -- Set index type of Wide_Wide_String
765 E_Id := First
766 (Subtype_Marks (Type_Definition (Parent (Standard_Wide_Wide_String))));
767 Set_First_Index (Standard_Wide_Wide_String, E_Id);
768 Set_Entity (E_Id, Standard_Positive);
769 Set_Etype (E_Id, Standard_Positive);
771 -- Create subtype declaration for Natural
773 Decl := New_Node (N_Subtype_Declaration, Stloc);
774 Set_Defining_Identifier (Decl, Standard_Natural);
775 Set_Subtype_Indication (Decl,
776 New_Occurrence_Of (Standard_Integer, Stloc));
777 Append (Decl, Decl_S);
779 Set_Ekind (Standard_Natural, E_Signed_Integer_Subtype);
780 Set_Etype (Standard_Natural, Base_Type (Standard_Integer));
781 Init_Esize (Standard_Natural, Standard_Integer_Size);
782 Init_RM_Size (Standard_Natural, Standard_Integer_Size - 1);
783 Set_Elem_Alignment (Standard_Natural);
784 Set_Size_Known_At_Compile_Time
785 (Standard_Natural);
786 Set_Integer_Bounds (Standard_Natural,
787 Typ => Base_Type (Standard_Integer),
788 Lb => Uint_0,
789 Hb => Intval (High_Bound (Scalar_Range (Standard_Integer))));
790 Set_Is_Constrained (Standard_Natural);
791 Set_Is_Frozen (Standard_Natural);
792 Set_Is_Public (Standard_Natural);
794 -- Create subtype declaration for Positive
796 Decl := New_Node (N_Subtype_Declaration, Stloc);
797 Set_Defining_Identifier (Decl, Standard_Positive);
798 Set_Subtype_Indication (Decl,
799 New_Occurrence_Of (Standard_Integer, Stloc));
800 Append (Decl, Decl_S);
802 Set_Ekind (Standard_Positive, E_Signed_Integer_Subtype);
803 Set_Etype (Standard_Positive, Base_Type (Standard_Integer));
804 Init_Esize (Standard_Positive, Standard_Integer_Size);
805 Init_RM_Size (Standard_Positive, Standard_Integer_Size - 1);
806 Set_Elem_Alignment (Standard_Positive);
808 Set_Size_Known_At_Compile_Time (Standard_Positive);
810 Set_Integer_Bounds (Standard_Positive,
811 Typ => Base_Type (Standard_Integer),
812 Lb => Uint_1,
813 Hb => Intval (High_Bound (Scalar_Range (Standard_Integer))));
814 Set_Is_Constrained (Standard_Positive);
815 Set_Is_Frozen (Standard_Positive);
816 Set_Is_Public (Standard_Positive);
818 -- Create declaration for package ASCII
820 Decl := New_Node (N_Package_Declaration, Stloc);
821 Append (Decl, Decl_S);
823 Pspec := New_Node (N_Package_Specification, Stloc);
824 Set_Specification (Decl, Pspec);
826 Set_Defining_Unit_Name (Pspec, Standard_Entity (S_ASCII));
827 Set_Ekind (Standard_Entity (S_ASCII), E_Package);
828 Set_Visible_Declarations (Pspec, Decl_A);
830 -- Create control character definitions in package ASCII. Note that
831 -- the character literal entries created here correspond to literal
832 -- values that are impossible in the source, but can be represented
833 -- internally with no difficulties.
835 Ccode := 16#00#;
837 for S in S_ASCII_Names loop
838 Decl := New_Node (N_Object_Declaration, Staloc);
839 Set_Constant_Present (Decl, True);
841 declare
842 A_Char : constant Entity_Id := Standard_Entity (S);
843 Expr_Decl : Node_Id;
845 begin
846 Set_Sloc (A_Char, Staloc);
847 Set_Ekind (A_Char, E_Constant);
848 Set_Never_Set_In_Source (A_Char, True);
849 Set_Is_True_Constant (A_Char, True);
850 Set_Etype (A_Char, Standard_Character);
851 Set_Scope (A_Char, Standard_Entity (S_ASCII));
852 Set_Is_Immediately_Visible (A_Char, False);
853 Set_Is_Public (A_Char, True);
854 Set_Is_Known_Valid (A_Char, True);
856 Append_Entity (A_Char, Standard_Entity (S_ASCII));
857 Set_Defining_Identifier (Decl, A_Char);
859 Set_Object_Definition (Decl, Identifier_For (S_Character));
860 Expr_Decl := New_Node (N_Character_Literal, Staloc);
861 Set_Expression (Decl, Expr_Decl);
863 Set_Is_Static_Expression (Expr_Decl);
864 Set_Chars (Expr_Decl, No_Name);
865 Set_Etype (Expr_Decl, Standard_Character);
866 Set_Char_Literal_Value (Expr_Decl, UI_From_Int (Int (Ccode)));
867 end;
869 Append (Decl, Decl_A);
871 -- Increment character code, dealing with non-contiguities
873 Ccode := Ccode + 1;
875 if Ccode = 16#20# then
876 Ccode := 16#21#;
877 elsif Ccode = 16#27# then
878 Ccode := 16#3A#;
879 elsif Ccode = 16#3C# then
880 Ccode := 16#3F#;
881 elsif Ccode = 16#41# then
882 Ccode := 16#5B#;
883 end if;
884 end loop;
886 -- Create semantic phase entities
888 Standard_Void_Type := New_Standard_Entity;
889 Set_Ekind (Standard_Void_Type, E_Void);
890 Set_Etype (Standard_Void_Type, Standard_Void_Type);
891 Set_Scope (Standard_Void_Type, Standard_Standard);
892 Make_Name (Standard_Void_Type, "_void_type");
894 -- The type field of packages is set to void
896 Set_Etype (Standard_Standard, Standard_Void_Type);
897 Set_Etype (Standard_ASCII, Standard_Void_Type);
899 -- Standard_A_String is actually used in generated code, so it has a
900 -- type name that is reasonable, but does not overlap any Ada name.
902 Standard_A_String := New_Standard_Entity;
903 Set_Ekind (Standard_A_String, E_Access_Type);
904 Set_Scope (Standard_A_String, Standard_Standard);
905 Set_Etype (Standard_A_String, Standard_A_String);
907 if Debug_Flag_6 then
908 Init_Size (Standard_A_String, System_Address_Size);
909 else
910 Init_Size (Standard_A_String, System_Address_Size * 2);
911 end if;
913 Init_Alignment (Standard_A_String);
915 Set_Directly_Designated_Type
916 (Standard_A_String, Standard_String);
917 Make_Name (Standard_A_String, "access_string");
919 Standard_A_Char := New_Standard_Entity;
920 Set_Ekind (Standard_A_Char, E_Access_Type);
921 Set_Scope (Standard_A_Char, Standard_Standard);
922 Set_Etype (Standard_A_Char, Standard_A_String);
923 Init_Size (Standard_A_Char, System_Address_Size);
924 Set_Elem_Alignment (Standard_A_Char);
926 Set_Directly_Designated_Type (Standard_A_Char, Standard_Character);
927 Make_Name (Standard_A_Char, "access_character");
929 -- Standard_Debug_Renaming_Type is used for the special objects created
930 -- to encode the names occurring in renaming declarations for use by the
931 -- debugger (see exp_dbug.adb). The type is a zero-sized subtype of
932 -- Standard.Integer.
934 Standard_Debug_Renaming_Type := New_Standard_Entity;
936 Set_Ekind (Standard_Debug_Renaming_Type, E_Signed_Integer_Subtype);
937 Set_Scope (Standard_Debug_Renaming_Type, Standard_Standard);
938 Set_Etype (Standard_Debug_Renaming_Type, Base_Type (Standard_Integer));
939 Init_Esize (Standard_Debug_Renaming_Type, 0);
940 Init_RM_Size (Standard_Debug_Renaming_Type, 0);
941 Set_Size_Known_At_Compile_Time (Standard_Debug_Renaming_Type);
942 Set_Integer_Bounds (Standard_Debug_Renaming_Type,
943 Typ => Base_Type (Standard_Debug_Renaming_Type),
944 Lb => Uint_1,
945 Hb => Uint_0);
946 Set_Is_Constrained (Standard_Debug_Renaming_Type);
947 Set_Has_Size_Clause (Standard_Debug_Renaming_Type);
949 Make_Name (Standard_Debug_Renaming_Type, "_renaming_type");
951 -- Note on type names. The type names for the following special types
952 -- are constructed so that they will look reasonable should they ever
953 -- appear in error messages etc, although in practice the use of the
954 -- special insertion character } for types results in special handling
955 -- of these type names in any case. The blanks in these names would
956 -- trouble in Gigi, but that's OK here, since none of these types
957 -- should ever get through to Gigi! Attributes of these types are
958 -- filled out to minimize problems with cascaded errors (for example,
959 -- Any_Integer is given reasonable and consistent type and size values)
961 Any_Type := New_Standard_Entity;
962 Decl := New_Node (N_Full_Type_Declaration, Stloc);
963 Set_Defining_Identifier (Decl, Any_Type);
964 Set_Scope (Any_Type, Standard_Standard);
965 Build_Signed_Integer_Type (Any_Type, Standard_Integer_Size);
966 Make_Name (Any_Type, "any type");
968 Any_Id := New_Standard_Entity;
969 Set_Ekind (Any_Id, E_Variable);
970 Set_Scope (Any_Id, Standard_Standard);
971 Set_Etype (Any_Id, Any_Type);
972 Init_Esize (Any_Id);
973 Init_Alignment (Any_Id);
974 Make_Name (Any_Id, "any id");
976 Any_Access := New_Standard_Entity;
977 Set_Ekind (Any_Access, E_Access_Type);
978 Set_Scope (Any_Access, Standard_Standard);
979 Set_Etype (Any_Access, Any_Access);
980 Init_Size (Any_Access, System_Address_Size);
981 Set_Elem_Alignment (Any_Access);
982 Make_Name (Any_Access, "an access type");
984 Any_Character := New_Standard_Entity;
985 Set_Ekind (Any_Character, E_Enumeration_Type);
986 Set_Scope (Any_Character, Standard_Standard);
987 Set_Etype (Any_Character, Any_Character);
988 Set_Is_Unsigned_Type (Any_Character);
989 Set_Is_Character_Type (Any_Character);
990 Init_Esize (Any_Character, Standard_Character_Size);
991 Init_RM_Size (Any_Character, 8);
992 Set_Elem_Alignment (Any_Character);
993 Set_Scalar_Range (Any_Character, Scalar_Range (Standard_Character));
994 Make_Name (Any_Character, "a character type");
996 Any_Array := New_Standard_Entity;
997 Set_Ekind (Any_Array, E_String_Type);
998 Set_Scope (Any_Array, Standard_Standard);
999 Set_Etype (Any_Array, Any_Array);
1000 Set_Component_Type (Any_Array, Any_Character);
1001 Init_Size_Align (Any_Array);
1002 Make_Name (Any_Array, "an array type");
1004 Any_Boolean := New_Standard_Entity;
1005 Set_Ekind (Any_Boolean, E_Enumeration_Type);
1006 Set_Scope (Any_Boolean, Standard_Standard);
1007 Set_Etype (Any_Boolean, Standard_Boolean);
1008 Init_Esize (Any_Boolean, Standard_Character_Size);
1009 Init_RM_Size (Any_Boolean, 1);
1010 Set_Elem_Alignment (Any_Boolean);
1011 Set_Is_Unsigned_Type (Any_Boolean);
1012 Set_Scalar_Range (Any_Boolean, Scalar_Range (Standard_Boolean));
1013 Make_Name (Any_Boolean, "a boolean type");
1015 Any_Composite := New_Standard_Entity;
1016 Set_Ekind (Any_Composite, E_Array_Type);
1017 Set_Scope (Any_Composite, Standard_Standard);
1018 Set_Etype (Any_Composite, Any_Composite);
1019 Set_Component_Size (Any_Composite, Uint_0);
1020 Set_Component_Type (Any_Composite, Standard_Integer);
1021 Init_Size_Align (Any_Composite);
1022 Make_Name (Any_Composite, "a composite type");
1024 Any_Discrete := New_Standard_Entity;
1025 Set_Ekind (Any_Discrete, E_Signed_Integer_Type);
1026 Set_Scope (Any_Discrete, Standard_Standard);
1027 Set_Etype (Any_Discrete, Any_Discrete);
1028 Init_Size (Any_Discrete, Standard_Integer_Size);
1029 Set_Elem_Alignment (Any_Discrete);
1030 Make_Name (Any_Discrete, "a discrete type");
1032 Any_Fixed := New_Standard_Entity;
1033 Set_Ekind (Any_Fixed, E_Ordinary_Fixed_Point_Type);
1034 Set_Scope (Any_Fixed, Standard_Standard);
1035 Set_Etype (Any_Fixed, Any_Fixed);
1036 Init_Size (Any_Fixed, Standard_Integer_Size);
1037 Set_Elem_Alignment (Any_Fixed);
1038 Make_Name (Any_Fixed, "a fixed-point type");
1040 Any_Integer := New_Standard_Entity;
1041 Set_Ekind (Any_Integer, E_Signed_Integer_Type);
1042 Set_Scope (Any_Integer, Standard_Standard);
1043 Set_Etype (Any_Integer, Standard_Long_Long_Integer);
1044 Init_Size (Any_Integer, Standard_Long_Long_Integer_Size);
1045 Set_Elem_Alignment (Any_Integer);
1047 Set_Integer_Bounds
1048 (Any_Integer,
1049 Typ => Base_Type (Standard_Integer),
1050 Lb => Uint_0,
1051 Hb => Intval (High_Bound (Scalar_Range (Standard_Integer))));
1052 Make_Name (Any_Integer, "an integer type");
1054 Any_Modular := New_Standard_Entity;
1055 Set_Ekind (Any_Modular, E_Modular_Integer_Type);
1056 Set_Scope (Any_Modular, Standard_Standard);
1057 Set_Etype (Any_Modular, Standard_Long_Long_Integer);
1058 Init_Size (Any_Modular, Standard_Long_Long_Integer_Size);
1059 Set_Elem_Alignment (Any_Modular);
1060 Set_Is_Unsigned_Type (Any_Modular);
1061 Make_Name (Any_Modular, "a modular type");
1063 Any_Numeric := New_Standard_Entity;
1064 Set_Ekind (Any_Numeric, E_Signed_Integer_Type);
1065 Set_Scope (Any_Numeric, Standard_Standard);
1066 Set_Etype (Any_Numeric, Standard_Long_Long_Integer);
1067 Init_Size (Any_Numeric, Standard_Long_Long_Integer_Size);
1068 Set_Elem_Alignment (Any_Numeric);
1069 Make_Name (Any_Numeric, "a numeric type");
1071 Any_Real := New_Standard_Entity;
1072 Set_Ekind (Any_Real, E_Floating_Point_Type);
1073 Set_Scope (Any_Real, Standard_Standard);
1074 Set_Etype (Any_Real, Standard_Long_Long_Float);
1075 Init_Size (Any_Real, Standard_Long_Long_Float_Size);
1076 Set_Elem_Alignment (Any_Real);
1077 Make_Name (Any_Real, "a real type");
1079 Any_Scalar := New_Standard_Entity;
1080 Set_Ekind (Any_Scalar, E_Signed_Integer_Type);
1081 Set_Scope (Any_Scalar, Standard_Standard);
1082 Set_Etype (Any_Scalar, Any_Scalar);
1083 Init_Size (Any_Scalar, Standard_Integer_Size);
1084 Set_Elem_Alignment (Any_Scalar);
1085 Make_Name (Any_Scalar, "a scalar type");
1087 Any_String := New_Standard_Entity;
1088 Set_Ekind (Any_String, E_String_Type);
1089 Set_Scope (Any_String, Standard_Standard);
1090 Set_Etype (Any_String, Any_String);
1091 Set_Component_Type (Any_String, Any_Character);
1092 Init_Size_Align (Any_String);
1093 Make_Name (Any_String, "a string type");
1095 declare
1096 Index : Node_Id;
1098 begin
1099 Index :=
1100 Make_Range (Stloc,
1101 Low_Bound => Make_Integer (Uint_0),
1102 High_Bound => Make_Integer (Uint_2 ** Standard_Integer_Size));
1103 Set_Etype (Index, Standard_Integer);
1104 Set_First_Index (Any_String, Index);
1105 end;
1107 Standard_Integer_8 := New_Standard_Entity;
1108 Decl := New_Node (N_Full_Type_Declaration, Stloc);
1109 Set_Defining_Identifier (Decl, Standard_Integer_8);
1110 Make_Name (Standard_Integer_8, "integer_8");
1111 Set_Scope (Standard_Integer_8, Standard_Standard);
1112 Build_Signed_Integer_Type (Standard_Integer_8, 8);
1114 Standard_Integer_16 := New_Standard_Entity;
1115 Decl := New_Node (N_Full_Type_Declaration, Stloc);
1116 Set_Defining_Identifier (Decl, Standard_Integer_16);
1117 Make_Name (Standard_Integer_16, "integer_16");
1118 Set_Scope (Standard_Integer_16, Standard_Standard);
1119 Build_Signed_Integer_Type (Standard_Integer_16, 16);
1121 Standard_Integer_32 := New_Standard_Entity;
1122 Decl := New_Node (N_Full_Type_Declaration, Stloc);
1123 Set_Defining_Identifier (Decl, Standard_Integer_32);
1124 Make_Name (Standard_Integer_32, "integer_32");
1125 Set_Scope (Standard_Integer_32, Standard_Standard);
1126 Build_Signed_Integer_Type (Standard_Integer_32, 32);
1128 Standard_Integer_64 := New_Standard_Entity;
1129 Decl := New_Node (N_Full_Type_Declaration, Stloc);
1130 Set_Defining_Identifier (Decl, Standard_Integer_64);
1131 Make_Name (Standard_Integer_64, "integer_64");
1132 Set_Scope (Standard_Integer_64, Standard_Standard);
1133 Build_Signed_Integer_Type (Standard_Integer_64, 64);
1135 Standard_Unsigned := New_Standard_Entity;
1136 Decl := New_Node (N_Full_Type_Declaration, Stloc);
1137 Set_Defining_Identifier (Decl, Standard_Unsigned);
1138 Make_Name (Standard_Unsigned, "unsigned");
1140 Set_Ekind (Standard_Unsigned, E_Modular_Integer_Type);
1141 Set_Scope (Standard_Unsigned, Standard_Standard);
1142 Set_Etype (Standard_Unsigned, Standard_Unsigned);
1143 Init_Size (Standard_Unsigned, Standard_Integer_Size);
1144 Set_Elem_Alignment (Standard_Unsigned);
1145 Set_Modulus (Standard_Unsigned,
1146 Uint_2 ** Standard_Integer_Size);
1147 Set_Is_Unsigned_Type (Standard_Unsigned);
1148 Set_Size_Known_At_Compile_Time
1149 (Standard_Unsigned);
1151 R_Node := New_Node (N_Range, Stloc);
1152 Set_Low_Bound (R_Node, Make_Integer (Uint_0));
1153 Set_High_Bound (R_Node, Make_Integer (Modulus (Standard_Unsigned) - 1));
1154 Set_Etype (Low_Bound (R_Node), Standard_Unsigned);
1155 Set_Etype (High_Bound (R_Node), Standard_Unsigned);
1156 Set_Scalar_Range (Standard_Unsigned, R_Node);
1158 -- Note: universal integer and universal real are constructed as fully
1159 -- formed signed numeric types, with parameters corresponding to the
1160 -- longest runtime types (Long_Long_Integer and Long_Long_Float). This
1161 -- allows Gigi to properly process references to universal types that
1162 -- are not folded at compile time.
1164 Universal_Integer := New_Standard_Entity;
1165 Decl := New_Node (N_Full_Type_Declaration, Stloc);
1166 Set_Defining_Identifier (Decl, Universal_Integer);
1167 Make_Name (Universal_Integer, "universal_integer");
1168 Set_Scope (Universal_Integer, Standard_Standard);
1169 Build_Signed_Integer_Type
1170 (Universal_Integer, Standard_Long_Long_Integer_Size);
1172 Universal_Real := New_Standard_Entity;
1173 Decl := New_Node (N_Full_Type_Declaration, Stloc);
1174 Set_Defining_Identifier (Decl, Universal_Real);
1175 Make_Name (Universal_Real, "universal_real");
1176 Set_Scope (Universal_Real, Standard_Standard);
1177 Build_Float_Type
1178 (Universal_Real,
1179 Standard_Long_Long_Float_Size,
1180 Standard_Long_Long_Float_Digits);
1182 -- Note: universal fixed, unlike universal integer and universal real,
1183 -- is never used at runtime, so it does not need to have bounds set.
1185 Universal_Fixed := New_Standard_Entity;
1186 Decl := New_Node (N_Full_Type_Declaration, Stloc);
1187 Set_Defining_Identifier (Decl, Universal_Fixed);
1188 Make_Name (Universal_Fixed, "universal_fixed");
1189 Set_Ekind (Universal_Fixed, E_Ordinary_Fixed_Point_Type);
1190 Set_Etype (Universal_Fixed, Universal_Fixed);
1191 Set_Scope (Universal_Fixed, Standard_Standard);
1192 Init_Size (Universal_Fixed, Standard_Long_Long_Integer_Size);
1193 Set_Elem_Alignment (Universal_Fixed);
1194 Set_Size_Known_At_Compile_Time
1195 (Universal_Fixed);
1197 -- Create type declaration for Duration, using a 64-bit size. The
1198 -- delta and size values depend on the mode set in system.ads.
1200 Build_Duration : declare
1201 Dlo : Uint;
1202 Dhi : Uint;
1203 Delta_Val : Ureal;
1205 begin
1206 -- In 32 bit mode, the size is 32 bits, and the delta and
1207 -- small values are set to 20 milliseconds (20.0**(10.0**(-3)).
1209 if Duration_32_Bits_On_Target then
1210 Dlo := Intval (Type_Low_Bound (Standard_Integer_32));
1211 Dhi := Intval (Type_High_Bound (Standard_Integer_32));
1212 Delta_Val := UR_From_Components (UI_From_Int (20), Uint_3, 10);
1214 -- In standard 64-bit mode, the size is 64-bits and the delta and
1215 -- small values are set to nanoseconds (1.0**(10.0**(-9))
1217 else
1218 Dlo := Intval (Type_Low_Bound (Standard_Integer_64));
1219 Dhi := Intval (Type_High_Bound (Standard_Integer_64));
1220 Delta_Val := UR_From_Components (Uint_1, Uint_9, 10);
1221 end if;
1223 Tdef_Node := Make_Ordinary_Fixed_Point_Definition (Stloc,
1224 Delta_Expression => Make_Real_Literal (Stloc, Delta_Val),
1225 Real_Range_Specification =>
1226 Make_Real_Range_Specification (Stloc,
1227 Low_Bound => Make_Real_Literal (Stloc,
1228 Realval => Dlo * Delta_Val),
1229 High_Bound => Make_Real_Literal (Stloc,
1230 Realval => Dhi * Delta_Val)));
1232 Set_Type_Definition (Parent (Standard_Duration), Tdef_Node);
1234 Set_Ekind (Standard_Duration, E_Ordinary_Fixed_Point_Type);
1235 Set_Etype (Standard_Duration, Standard_Duration);
1237 if Duration_32_Bits_On_Target then
1238 Init_Size (Standard_Duration, 32);
1239 else
1240 Init_Size (Standard_Duration, 64);
1241 end if;
1243 Set_Elem_Alignment (Standard_Duration);
1244 Set_Delta_Value (Standard_Duration, Delta_Val);
1245 Set_Small_Value (Standard_Duration, Delta_Val);
1246 Set_Scalar_Range (Standard_Duration,
1247 Real_Range_Specification
1248 (Type_Definition (Parent (Standard_Duration))));
1250 -- Normally it does not matter that nodes in package Standard are
1251 -- not marked as analyzed. The Scalar_Range of the fixed-point
1252 -- type Standard_Duration is an exception, because of the special
1253 -- test made in Freeze.Freeze_Fixed_Point_Type.
1255 Set_Analyzed (Scalar_Range (Standard_Duration));
1257 Set_Etype (Type_High_Bound (Standard_Duration), Standard_Duration);
1258 Set_Etype (Type_Low_Bound (Standard_Duration), Standard_Duration);
1260 Set_Is_Static_Expression (Type_High_Bound (Standard_Duration));
1261 Set_Is_Static_Expression (Type_Low_Bound (Standard_Duration));
1263 Set_Corresponding_Integer_Value
1264 (Type_High_Bound (Standard_Duration), Dhi);
1266 Set_Corresponding_Integer_Value
1267 (Type_Low_Bound (Standard_Duration), Dlo);
1269 Set_Size_Known_At_Compile_Time (Standard_Duration);
1270 end Build_Duration;
1272 -- Build standard exception type. Note that the type name here is
1273 -- actually used in the generated code, so it must be set correctly
1275 -- ??? Also note that the Import_Code component is now declared
1276 -- as a System.Standard_Library.Exception_Code to enforce run-time
1277 -- library implementation consistency. It's too early here to resort
1278 -- to rtsfind to get the proper node for that type, so we use the
1279 -- closest possible available type node at hand instead. We should
1280 -- probably be fixing this up at some point.
1282 Standard_Exception_Type := New_Standard_Entity;
1283 Set_Ekind (Standard_Exception_Type, E_Record_Type);
1284 Set_Etype (Standard_Exception_Type, Standard_Exception_Type);
1285 Set_Scope (Standard_Exception_Type, Standard_Standard);
1286 Set_Stored_Constraint
1287 (Standard_Exception_Type, No_Elist);
1288 Init_Size_Align (Standard_Exception_Type);
1289 Set_Size_Known_At_Compile_Time
1290 (Standard_Exception_Type, True);
1291 Make_Name (Standard_Exception_Type, "exception");
1293 Make_Component
1294 (Standard_Exception_Type, Standard_Boolean, "Not_Handled_By_Others");
1295 Make_Component
1296 (Standard_Exception_Type, Standard_Character, "Lang");
1297 Make_Component
1298 (Standard_Exception_Type, Standard_Natural, "Name_Length");
1299 Make_Component
1300 (Standard_Exception_Type, Standard_A_Char, "Full_Name");
1301 Make_Component
1302 (Standard_Exception_Type, Standard_A_Char, "HTable_Ptr");
1303 Make_Component
1304 (Standard_Exception_Type, Standard_Unsigned, "Import_Code");
1305 Make_Component
1306 (Standard_Exception_Type, Standard_A_Char, "Raise_Hook");
1308 -- Build tree for record declaration, for use by the back-end
1310 declare
1311 Comp_List : List_Id;
1312 Comp : Entity_Id;
1314 begin
1315 Comp := First_Entity (Standard_Exception_Type);
1316 Comp_List := New_List;
1318 while Present (Comp) loop
1319 Append (
1320 Make_Component_Declaration (Stloc,
1321 Defining_Identifier => Comp,
1322 Component_Definition =>
1323 Make_Component_Definition (Stloc,
1324 Aliased_Present => False,
1325 Subtype_Indication => New_Occurrence_Of (Etype (Comp),
1326 Stloc))),
1327 Comp_List);
1329 Next_Entity (Comp);
1330 end loop;
1332 Decl := Make_Full_Type_Declaration (Stloc,
1333 Defining_Identifier => Standard_Exception_Type,
1334 Type_Definition =>
1335 Make_Record_Definition (Stloc,
1336 End_Label => Empty,
1337 Component_List =>
1338 Make_Component_List (Stloc,
1339 Component_Items => Comp_List)));
1340 end;
1342 Append (Decl, Decl_S);
1344 Layout_Type (Standard_Exception_Type);
1346 -- Create declarations of standard exceptions
1348 Build_Exception (S_Constraint_Error);
1349 Build_Exception (S_Program_Error);
1350 Build_Exception (S_Storage_Error);
1351 Build_Exception (S_Tasking_Error);
1353 -- Numeric_Error is a normal exception in Ada 83, but in Ada 95
1354 -- it is a renaming of Constraint_Error. Is this test too early???
1356 if Ada_Version = Ada_83 then
1357 Build_Exception (S_Numeric_Error);
1359 else
1360 Decl := New_Node (N_Exception_Renaming_Declaration, Stloc);
1361 E_Id := Standard_Entity (S_Numeric_Error);
1363 Set_Ekind (E_Id, E_Exception);
1364 Set_Exception_Code (E_Id, Uint_0);
1365 Set_Etype (E_Id, Standard_Exception_Type);
1366 Set_Is_Public (E_Id);
1367 Set_Renamed_Entity (E_Id, Standard_Entity (S_Constraint_Error));
1369 Set_Defining_Identifier (Decl, E_Id);
1370 Append (Decl, Decl_S);
1372 Ident_Node := New_Node (N_Identifier, Stloc);
1373 Set_Chars (Ident_Node, Chars (Standard_Entity (S_Constraint_Error)));
1374 Set_Entity (Ident_Node, Standard_Entity (S_Constraint_Error));
1375 Set_Name (Decl, Ident_Node);
1376 end if;
1378 -- Abort_Signal is an entity that does not get made visible
1380 Abort_Signal := New_Standard_Entity;
1381 Set_Chars (Abort_Signal, Name_uAbort_Signal);
1382 Set_Ekind (Abort_Signal, E_Exception);
1383 Set_Exception_Code (Abort_Signal, Uint_0);
1384 Set_Etype (Abort_Signal, Standard_Exception_Type);
1385 Set_Scope (Abort_Signal, Standard_Standard);
1386 Set_Is_Public (Abort_Signal, True);
1387 Decl :=
1388 Make_Exception_Declaration (Stloc,
1389 Defining_Identifier => Abort_Signal);
1391 -- Create defining identifiers for shift operator entities. Note
1392 -- that these entities are used only for marking shift operators
1393 -- generated internally, and hence need no structure, just a name
1394 -- and a unique identity.
1396 Standard_Op_Rotate_Left := New_Standard_Entity;
1397 Set_Chars (Standard_Op_Rotate_Left, Name_Rotate_Left);
1398 Set_Ekind (Standard_Op_Rotate_Left, E_Operator);
1400 Standard_Op_Rotate_Right := New_Standard_Entity;
1401 Set_Chars (Standard_Op_Rotate_Right, Name_Rotate_Right);
1402 Set_Ekind (Standard_Op_Rotate_Right, E_Operator);
1404 Standard_Op_Shift_Left := New_Standard_Entity;
1405 Set_Chars (Standard_Op_Shift_Left, Name_Shift_Left);
1406 Set_Ekind (Standard_Op_Shift_Left, E_Operator);
1408 Standard_Op_Shift_Right := New_Standard_Entity;
1409 Set_Chars (Standard_Op_Shift_Right, Name_Shift_Right);
1410 Set_Ekind (Standard_Op_Shift_Right, E_Operator);
1412 Standard_Op_Shift_Right_Arithmetic := New_Standard_Entity;
1413 Set_Chars (Standard_Op_Shift_Right_Arithmetic,
1414 Name_Shift_Right_Arithmetic);
1415 Set_Ekind (Standard_Op_Shift_Right_Arithmetic,
1416 E_Operator);
1418 -- Create standard operator declarations
1420 Create_Operators;
1422 -- Initialize visibility table with entities in Standard
1424 for E in Standard_Entity_Type loop
1425 if Ekind (Standard_Entity (E)) /= E_Operator then
1426 Set_Name_Entity_Id
1427 (Chars (Standard_Entity (E)), Standard_Entity (E));
1428 Set_Homonym (Standard_Entity (E), Empty);
1429 end if;
1431 if E not in S_ASCII_Names then
1432 Set_Scope (Standard_Entity (E), Standard_Standard);
1433 Set_Is_Immediately_Visible (Standard_Entity (E));
1434 end if;
1435 end loop;
1437 -- The predefined package Standard itself does not have a scope;
1438 -- it is the only entity in the system not to have one, and this
1439 -- is what identifies the package to Gigi.
1441 Set_Scope (Standard_Standard, Empty);
1443 -- Set global variables indicating last Id values and version
1445 Last_Standard_Node_Id := Last_Node_Id;
1446 Last_Standard_List_Id := Last_List_Id;
1448 -- The Error node has an Etype of Any_Type to help error recovery
1450 Set_Etype (Error, Any_Type);
1452 -- Print representation of standard if switch set
1454 if Opt.Print_Standard then
1455 Print_Standard;
1456 end if;
1457 end Create_Standard;
1459 ------------------------------------
1460 -- Create_Unconstrained_Base_Type --
1461 ------------------------------------
1463 procedure Create_Unconstrained_Base_Type
1464 (E : Entity_Id;
1465 K : Entity_Kind)
1467 New_Ent : constant Entity_Id := New_Copy (E);
1469 begin
1470 Set_Ekind (E, K);
1471 Set_Is_Constrained (E, True);
1472 Set_Is_First_Subtype (E, True);
1473 Set_Etype (E, New_Ent);
1475 Append_Entity (New_Ent, Standard_Standard);
1476 Set_Is_Constrained (New_Ent, False);
1477 Set_Etype (New_Ent, New_Ent);
1478 Set_Is_Known_Valid (New_Ent, True);
1480 if K = E_Signed_Integer_Subtype then
1481 Set_Etype (Low_Bound (Scalar_Range (E)), New_Ent);
1482 Set_Etype (High_Bound (Scalar_Range (E)), New_Ent);
1483 end if;
1485 end Create_Unconstrained_Base_Type;
1487 --------------------
1488 -- Identifier_For --
1489 --------------------
1491 function Identifier_For (S : Standard_Entity_Type) return Node_Id is
1492 Ident_Node : Node_Id;
1494 begin
1495 Ident_Node := New_Node (N_Identifier, Stloc);
1496 Set_Chars (Ident_Node, Chars (Standard_Entity (S)));
1497 return Ident_Node;
1498 end Identifier_For;
1500 --------------------
1501 -- Make_Component --
1502 --------------------
1504 procedure Make_Component
1505 (Rec : Entity_Id;
1506 Typ : Entity_Id;
1507 Nam : String)
1509 Id : constant Entity_Id := New_Standard_Entity;
1511 begin
1512 Set_Ekind (Id, E_Component);
1513 Set_Etype (Id, Typ);
1514 Set_Scope (Id, Rec);
1515 Init_Component_Location (Id);
1517 Set_Original_Record_Component (Id, Id);
1518 Make_Name (Id, Nam);
1519 Append_Entity (Id, Rec);
1520 end Make_Component;
1522 -----------------
1523 -- Make_Formal --
1524 -----------------
1526 function Make_Formal
1527 (Typ : Entity_Id;
1528 Formal_Name : String) return Entity_Id
1530 Formal : Entity_Id;
1532 begin
1533 Formal := New_Standard_Entity;
1535 Set_Ekind (Formal, E_In_Parameter);
1536 Set_Mechanism (Formal, Default_Mechanism);
1537 Set_Scope (Formal, Standard_Standard);
1538 Set_Etype (Formal, Typ);
1539 Make_Name (Formal, Formal_Name);
1541 return Formal;
1542 end Make_Formal;
1544 ------------------
1545 -- Make_Integer --
1546 ------------------
1548 function Make_Integer (V : Uint) return Node_Id is
1549 N : constant Node_Id := Make_Integer_Literal (Stloc, V);
1550 begin
1551 Set_Is_Static_Expression (N);
1552 return N;
1553 end Make_Integer;
1555 ---------------
1556 -- Make_Name --
1557 ---------------
1559 procedure Make_Name (Id : Entity_Id; Nam : String) is
1560 begin
1561 for J in 1 .. Nam'Length loop
1562 Name_Buffer (J) := Fold_Lower (Nam (Nam'First + (J - 1)));
1563 end loop;
1565 Name_Len := Nam'Length;
1566 Set_Chars (Id, Name_Find);
1567 end Make_Name;
1569 ------------------
1570 -- New_Operator --
1571 ------------------
1573 function New_Operator (Op : Name_Id; Typ : Entity_Id) return Entity_Id is
1574 Ident_Node : Entity_Id;
1576 begin
1577 Ident_Node := Make_Defining_Identifier (Stloc, Op);
1579 Set_Is_Pure (Ident_Node, True);
1580 Set_Ekind (Ident_Node, E_Operator);
1581 Set_Etype (Ident_Node, Typ);
1582 Set_Scope (Ident_Node, Standard_Standard);
1583 Set_Homonym (Ident_Node, Get_Name_Entity_Id (Op));
1584 Set_Convention (Ident_Node, Convention_Intrinsic);
1586 Set_Is_Immediately_Visible (Ident_Node, True);
1587 Set_Is_Intrinsic_Subprogram (Ident_Node, True);
1589 Set_Name_Entity_Id (Op, Ident_Node);
1590 Append_Entity (Ident_Node, Standard_Standard);
1591 return Ident_Node;
1592 end New_Operator;
1594 -------------------------
1595 -- New_Standard_Entity --
1596 -------------------------
1598 function New_Standard_Entity
1599 (New_Node_Kind : Node_Kind := N_Defining_Identifier) return Entity_Id
1601 E : constant Entity_Id := New_Entity (New_Node_Kind, Stloc);
1603 begin
1604 -- All standard entities are Pure and Public
1606 Set_Is_Pure (E);
1607 Set_Is_Public (E);
1609 -- All standard entity names are analyzed manually, and are thus
1610 -- frozen as soon as they are created.
1612 Set_Is_Frozen (E);
1614 -- Set debug information required for all standard types
1616 Set_Needs_Debug_Info (E);
1618 -- All standard entities are built with fully qualified names, so
1619 -- set the flag to prevent an abortive attempt at requalification!
1621 Set_Has_Qualified_Name (E);
1623 -- Return newly created entity to be completed by caller
1625 return E;
1626 end New_Standard_Entity;
1628 --------------------
1629 -- Print_Standard --
1630 --------------------
1632 procedure Print_Standard is
1634 procedure P (Item : String) renames Output.Write_Line;
1635 -- Short-hand, since we do a lot of line writes here!
1637 procedure P_Int_Range (Size : Pos);
1638 -- Prints the range of an integer based on its Size
1640 procedure P_Float_Range (Id : Entity_Id);
1641 -- Prints the bounds range for the given float type entity
1643 -------------------
1644 -- P_Float_Range --
1645 -------------------
1647 procedure P_Float_Range (Id : Entity_Id) is
1648 Digs : constant Nat := UI_To_Int (Digits_Value (Id));
1650 begin
1651 Write_Str (" range ");
1653 if Vax_Float (Id) then
1654 if Digs = VAXFF_Digits then
1655 Write_Str (VAXFF_First'Universal_Literal_String);
1656 Write_Str (" .. ");
1657 Write_Str (VAXFF_Last'Universal_Literal_String);
1659 elsif Digs = VAXDF_Digits then
1660 Write_Str (VAXDF_First'Universal_Literal_String);
1661 Write_Str (" .. ");
1662 Write_Str (VAXDF_Last'Universal_Literal_String);
1664 else
1665 pragma Assert (Digs = VAXGF_Digits);
1667 Write_Str (VAXGF_First'Universal_Literal_String);
1668 Write_Str (" .. ");
1669 Write_Str (VAXGF_Last'Universal_Literal_String);
1670 end if;
1672 elsif Is_AAMP_Float (Id) then
1673 if Digs = AAMPS_Digits then
1674 Write_Str (AAMPS_First'Universal_Literal_String);
1675 Write_Str (" .. ");
1676 Write_Str (AAMPS_Last'Universal_Literal_String);
1678 else
1679 pragma Assert (Digs = AAMPL_Digits);
1680 Write_Str (AAMPL_First'Universal_Literal_String);
1681 Write_Str (" .. ");
1682 Write_Str (AAMPL_Last'Universal_Literal_String);
1683 end if;
1685 elsif Digs = IEEES_Digits then
1686 Write_Str (IEEES_First'Universal_Literal_String);
1687 Write_Str (" .. ");
1688 Write_Str (IEEES_Last'Universal_Literal_String);
1690 elsif Digs = IEEEL_Digits then
1691 Write_Str (IEEEL_First'Universal_Literal_String);
1692 Write_Str (" .. ");
1693 Write_Str (IEEEL_Last'Universal_Literal_String);
1695 else
1696 pragma Assert (Digs = IEEEX_Digits);
1698 Write_Str (IEEEX_First'Universal_Literal_String);
1699 Write_Str (" .. ");
1700 Write_Str (IEEEX_Last'Universal_Literal_String);
1701 end if;
1703 Write_Str (";");
1704 Write_Eol;
1705 end P_Float_Range;
1707 -----------------
1708 -- P_Int_Range --
1709 -----------------
1711 procedure P_Int_Range (Size : Pos) is
1712 begin
1713 Write_Str (" is range -(2 **");
1714 Write_Int (Size - 1);
1715 Write_Str (")");
1716 Write_Str (" .. +(2 **");
1717 Write_Int (Size - 1);
1718 Write_Str (" - 1);");
1719 Write_Eol;
1720 end P_Int_Range;
1722 -- Start of processing for Print_Standard
1724 begin
1725 P ("-- Representation of package Standard");
1726 Write_Eol;
1727 P ("-- This is not accurate Ada, since new base types cannot be ");
1728 P ("-- created, but the listing shows the target dependent");
1729 P ("-- characteristics of the Standard types for this compiler");
1730 Write_Eol;
1732 P ("package Standard is");
1733 P ("pragma Pure(Standard);");
1734 Write_Eol;
1736 P (" type Boolean is (False, True);");
1737 P (" for Boolean'Size use 1;");
1738 P (" for Boolean use (False => 0, True => 1);");
1739 Write_Eol;
1741 -- Integer types
1743 Write_Str (" type Integer");
1744 P_Int_Range (Standard_Integer_Size);
1745 Write_Str (" for Integer'Size use ");
1746 Write_Int (Standard_Integer_Size);
1747 P (";");
1748 Write_Eol;
1750 P (" subtype Natural is Integer range 0 .. Integer'Last;");
1751 P (" subtype Positive is Integer range 1 .. Integer'Last;");
1752 Write_Eol;
1754 Write_Str (" type Short_Short_Integer");
1755 P_Int_Range (Standard_Short_Short_Integer_Size);
1756 Write_Str (" for Short_Short_Integer'Size use ");
1757 Write_Int (Standard_Short_Short_Integer_Size);
1758 P (";");
1759 Write_Eol;
1761 Write_Str (" type Short_Integer");
1762 P_Int_Range (Standard_Short_Integer_Size);
1763 Write_Str (" for Short_Integer'Size use ");
1764 Write_Int (Standard_Short_Integer_Size);
1765 P (";");
1766 Write_Eol;
1768 Write_Str (" type Long_Integer");
1769 P_Int_Range (Standard_Long_Integer_Size);
1770 Write_Str (" for Long_Integer'Size use ");
1771 Write_Int (Standard_Long_Integer_Size);
1772 P (";");
1773 Write_Eol;
1775 Write_Str (" type Long_Long_Integer");
1776 P_Int_Range (Standard_Long_Long_Integer_Size);
1777 Write_Str (" for Long_Long_Integer'Size use ");
1778 Write_Int (Standard_Long_Long_Integer_Size);
1779 P (";");
1780 Write_Eol;
1782 -- Floating point types
1784 Write_Str (" type Short_Float is digits ");
1785 Write_Int (Standard_Short_Float_Digits);
1786 Write_Eol;
1787 P_Float_Range (Standard_Short_Float);
1788 Write_Str (" for Short_Float'Size use ");
1789 Write_Int (Standard_Short_Float_Size);
1790 P (";");
1791 Write_Eol;
1793 Write_Str (" type Float is digits ");
1794 Write_Int (Standard_Float_Digits);
1795 Write_Eol;
1796 P_Float_Range (Standard_Float);
1797 Write_Str (" for Float'Size use ");
1798 Write_Int (Standard_Float_Size);
1799 P (";");
1800 Write_Eol;
1802 Write_Str (" type Long_Float is digits ");
1803 Write_Int (Standard_Long_Float_Digits);
1804 Write_Eol;
1805 P_Float_Range (Standard_Long_Float);
1806 Write_Str (" for Long_Float'Size use ");
1807 Write_Int (Standard_Long_Float_Size);
1808 P (";");
1809 Write_Eol;
1811 Write_Str (" type Long_Long_Float is digits ");
1812 Write_Int (Standard_Long_Long_Float_Digits);
1813 Write_Eol;
1814 P_Float_Range (Standard_Long_Long_Float);
1815 Write_Str (" for Long_Long_Float'Size use ");
1816 Write_Int (Standard_Long_Long_Float_Size);
1817 P (";");
1818 Write_Eol;
1820 P (" type Character is (...)");
1821 Write_Str (" for Character'Size use ");
1822 Write_Int (Standard_Character_Size);
1823 P (";");
1824 P (" -- See RM A.1(35) for details of this type");
1825 Write_Eol;
1827 P (" type Wide_Character is (...)");
1828 Write_Str (" for Wide_Character'Size use ");
1829 Write_Int (Standard_Wide_Character_Size);
1830 P (";");
1831 P (" -- See RM A.1(36) for details of this type");
1832 Write_Eol;
1834 P (" type Wide_Wide_Character is (...)");
1835 Write_Str (" for Wide_Character'Size use ");
1836 Write_Int (Standard_Wide_Wide_Character_Size);
1837 P (";");
1838 P (" -- See RM A.1(36) for details of this type");
1840 P (" type String is array (Positive range <>) of Character;");
1841 P (" pragma Pack (String);");
1842 Write_Eol;
1844 P (" type Wide_String is array (Positive range <>)" &
1845 " of Wide_Character;");
1846 P (" pragma Pack (Wide_String);");
1847 Write_Eol;
1849 P (" type Wide_Wide_String is array (Positive range <>)" &
1850 " of Wide_Wide_Character;");
1851 P (" pragma Pack (Wide_Wide_String);");
1852 Write_Eol;
1854 -- Here it's OK to use the Duration type of the host compiler since
1855 -- the implementation of Duration in GNAT is target independent.
1857 if Duration_32_Bits_On_Target then
1858 P (" type Duration is delta 0.020");
1859 P (" range -((2 ** 31 - 1) * 0.020) ..");
1860 P (" +((2 ** 31 - 1) * 0.020);");
1861 P (" for Duration'Small use 0.020;");
1862 else
1863 P (" type Duration is delta 0.000000001");
1864 P (" range -((2 ** 63 - 1) * 0.000000001) ..");
1865 P (" +((2 ** 63 - 1) * 0.000000001);");
1866 P (" for Duration'Small use 0.000000001;");
1867 end if;
1869 Write_Eol;
1871 P (" Constraint_Error : exception;");
1872 P (" Program_Error : exception;");
1873 P (" Storage_Error : exception;");
1874 P (" Tasking_Error : exception;");
1875 P (" Numeric_Error : exception renames Constraint_Error;");
1876 Write_Eol;
1878 P ("end Standard;");
1879 end Print_Standard;
1881 ----------------------
1882 -- Set_Float_Bounds --
1883 ----------------------
1885 procedure Set_Float_Bounds (Id : Entity_Id) is
1886 L : Node_Id;
1887 -- Low bound of literal value
1889 H : Node_Id;
1890 -- High bound of literal value
1892 R : Node_Id;
1893 -- Range specification
1895 Digs : constant Nat := UI_To_Int (Digits_Value (Id));
1896 -- Digits value, used to select bounds
1898 begin
1899 -- Note: for the call from Cstand to initially create the types in
1900 -- Standard, Vax_Float will always be False. Circuitry in Sem_Vfpt
1901 -- will adjust these types appropriately in the Vax_Float case if
1902 -- a pragma Float_Representation (VAX_Float) is used.
1904 if Vax_Float (Id) then
1905 if Digs = VAXFF_Digits then
1906 L := Real_Convert
1907 (VAXFF_First'Universal_Literal_String);
1908 H := Real_Convert
1909 (VAXFF_Last'Universal_Literal_String);
1911 elsif Digs = VAXDF_Digits then
1912 L := Real_Convert
1913 (VAXDF_First'Universal_Literal_String);
1914 H := Real_Convert
1915 (VAXDF_Last'Universal_Literal_String);
1917 else
1918 pragma Assert (Digs = VAXGF_Digits);
1920 L := Real_Convert
1921 (VAXGF_First'Universal_Literal_String);
1922 H := Real_Convert
1923 (VAXGF_Last'Universal_Literal_String);
1924 end if;
1926 elsif Is_AAMP_Float (Id) then
1927 if Digs = AAMPS_Digits then
1928 L := Real_Convert
1929 (AAMPS_First'Universal_Literal_String);
1930 H := Real_Convert
1931 (AAMPS_Last'Universal_Literal_String);
1933 else
1934 pragma Assert (Digs = AAMPL_Digits);
1935 L := Real_Convert
1936 (AAMPL_First'Universal_Literal_String);
1937 H := Real_Convert
1938 (AAMPL_Last'Universal_Literal_String);
1939 end if;
1941 elsif Digs = IEEES_Digits then
1942 L := Real_Convert
1943 (IEEES_First'Universal_Literal_String);
1944 H := Real_Convert
1945 (IEEES_Last'Universal_Literal_String);
1947 elsif Digs = IEEEL_Digits then
1948 L := Real_Convert
1949 (IEEEL_First'Universal_Literal_String);
1950 H := Real_Convert
1951 (IEEEL_Last'Universal_Literal_String);
1953 else
1954 pragma Assert (Digs = IEEEX_Digits);
1956 L := Real_Convert
1957 (IEEEX_First'Universal_Literal_String);
1958 H := Real_Convert
1959 (IEEEX_Last'Universal_Literal_String);
1960 end if;
1962 Set_Etype (L, Id);
1963 Set_Is_Static_Expression (L);
1965 Set_Etype (H, Id);
1966 Set_Is_Static_Expression (H);
1968 R := New_Node (N_Range, Stloc);
1969 Set_Low_Bound (R, L);
1970 Set_High_Bound (R, H);
1971 Set_Includes_Infinities (R, True);
1972 Set_Scalar_Range (Id, R);
1973 Set_Etype (R, Id);
1974 Set_Parent (R, Id);
1975 end Set_Float_Bounds;
1977 ------------------------
1978 -- Set_Integer_Bounds --
1979 ------------------------
1981 procedure Set_Integer_Bounds
1982 (Id : Entity_Id;
1983 Typ : Entity_Id;
1984 Lb : Uint;
1985 Hb : Uint)
1987 L : Node_Id; -- Low bound of literal value
1988 H : Node_Id; -- High bound of literal value
1989 R : Node_Id; -- Range specification
1991 begin
1992 L := Make_Integer (Lb);
1993 H := Make_Integer (Hb);
1995 Set_Etype (L, Typ);
1996 Set_Etype (H, Typ);
1998 R := New_Node (N_Range, Stloc);
1999 Set_Low_Bound (R, L);
2000 Set_High_Bound (R, H);
2001 Set_Scalar_Range (Id, R);
2002 Set_Etype (R, Typ);
2003 Set_Parent (R, Id);
2004 Set_Is_Unsigned_Type (Id, Lb >= 0);
2005 end Set_Integer_Bounds;
2007 end CStand;