]>
Commit | Line | Data |
---|---|---|
70482933 RK |
1 | ------------------------------------------------------------------------------ |
2 | -- -- | |
3 | -- GNAT COMPILER COMPONENTS -- | |
4 | -- -- | |
5 | -- C S T A N D -- | |
6 | -- -- | |
7 | -- B o d y -- | |
8 | -- -- | |
fbf5a39b | 9 | -- Copyright (C) 1992-2003 Free Software Foundation, Inc. -- |
70482933 RK |
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 2, 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 COPYING. If not, write -- | |
19 | -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, -- | |
20 | -- MA 02111-1307, USA. -- | |
21 | -- -- | |
22 | -- GNAT was originally developed by the GNAT team at New York University. -- | |
71ff80dc | 23 | -- Extensive contributions were provided by Ada Core Technologies Inc. -- |
70482933 RK |
24 | -- -- |
25 | ------------------------------------------------------------------------------ | |
26 | ||
27 | with Atree; use Atree; | |
28 | with Csets; use Csets; | |
29 | with Debug; use Debug; | |
30 | with Einfo; use Einfo; | |
31 | with Layout; use Layout; | |
32 | with Namet; use Namet; | |
33 | with Nlists; use Nlists; | |
34 | with Nmake; use Nmake; | |
35 | with Opt; use Opt; | |
fbf5a39b | 36 | with Targparm; use Targparm; |
70482933 RK |
37 | with Tbuild; use Tbuild; |
38 | with Ttypes; use Ttypes; | |
39 | with Ttypef; use Ttypef; | |
40 | with Sem_Mech; use Sem_Mech; | |
41 | with Sem_Util; use Sem_Util; | |
42 | with Sinfo; use Sinfo; | |
43 | with Snames; use Snames; | |
44 | with Stand; use Stand; | |
45 | with Uintp; use Uintp; | |
46 | with Urealp; use Urealp; | |
47 | ||
48 | package body CStand is | |
49 | ||
50 | Stloc : constant Source_Ptr := Standard_Location; | |
51 | Staloc : constant Source_Ptr := Standard_ASCII_Location; | |
52 | -- Standard abbreviations used throughout this package | |
53 | ||
54 | ----------------------- | |
55 | -- Local Subprograms -- | |
56 | ----------------------- | |
57 | ||
58 | procedure Build_Float_Type (E : Entity_Id; Siz : Int; Digs : Int); | |
59 | -- Procedure to build standard predefined float base type. The first | |
60 | -- parameter is the entity for the type, and the second parameter | |
61 | -- is the size in bits. The third parameter is the digits value. | |
62 | ||
63 | procedure Build_Signed_Integer_Type (E : Entity_Id; Siz : Int); | |
64 | -- Procedure to build standard predefined signed integer subtype. The | |
65 | -- first parameter is the entity for the subtype. The second parameter | |
66 | -- is the size in bits. The corresponding base type is not built by | |
67 | -- this routine but instead must be built by the caller where needed. | |
68 | ||
69 | procedure Create_Operators; | |
70 | -- Make entries for each of the predefined operators in Standard | |
71 | ||
72 | procedure Create_Unconstrained_Base_Type | |
73 | (E : Entity_Id; | |
74 | K : Entity_Kind); | |
75 | -- The predefined signed integer types are constrained subtypes which | |
76 | -- must have a corresponding unconstrained base type. This type is almost | |
77 | -- useless. The only place it has semantics is Subtypes_Statically_Match. | |
78 | -- Consequently, we arrange for it to be identical apart from the setting | |
79 | -- of the constrained bit. This routine takes an entity E for the Type, | |
80 | -- copies it to estabish the base type, then resets the Ekind of the | |
81 | -- original entity to K (the Ekind for the subtype). The Etype field of | |
82 | -- E is set by the call (to point to the created base type entity), and | |
83 | -- also the Is_Constrained flag of E is set. | |
84 | -- | |
85 | -- To understand the exact requirement for this, see RM 3.5.4(11) which | |
86 | -- makes it clear that Integer, for example, is constrained, with the | |
87 | -- constraint bounds matching the bounds of the (unconstrained) base | |
88 | -- type. The point is that Integer and Integer'Base have identical | |
89 | -- bounds, but do not statically match, since a subtype with constraints | |
90 | -- never matches a subtype with no constraints. | |
91 | ||
92 | function Identifier_For (S : Standard_Entity_Type) return Node_Id; | |
93 | -- Returns an identifier node with the same name as the defining | |
94 | -- identifier corresponding to the given Standard_Entity_Type value | |
95 | ||
96 | procedure Make_Component | |
97 | (Rec : Entity_Id; | |
98 | Typ : Entity_Id; | |
99 | Nam : String); | |
100 | -- Build a record component with the given type and name, and append to | |
101 | -- the list of components of Rec. | |
102 | ||
103 | function Make_Formal | |
104 | (Typ : Entity_Id; | |
105 | Formal_Name : String) | |
106 | return Entity_Id; | |
107 | -- Construct entity for subprogram formal with given name and type | |
108 | ||
109 | function Make_Integer (V : Uint) return Node_Id; | |
110 | -- Builds integer literal with given value | |
111 | ||
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 | |
114 | ||
115 | function New_Operator (Op : Name_Id; Typ : Entity_Id) return Entity_Id; | |
116 | -- Build entity for standard operator with given name and type. | |
117 | ||
118 | function New_Standard_Entity | |
119 | (New_Node_Kind : Node_Kind := N_Defining_Identifier) | |
120 | return Entity_Id; | |
121 | -- Builds a new entity for Standard | |
122 | ||
123 | procedure Set_Integer_Bounds | |
124 | (Id : Entity_Id; | |
125 | Typ : Entity_Id; | |
126 | Lb : Uint; | |
127 | Hb : Uint); | |
128 | -- Procedure to set bounds for integer type or subtype. Id is the entity | |
129 | -- whose bounds and type are to be set. The Typ parameter is the Etype | |
130 | -- value for the entity (which will be the same as Id for all predefined | |
131 | -- integer base types. The third and fourth parameters are the bounds. | |
132 | ||
133 | ---------------------- | |
134 | -- Build_Float_Type -- | |
135 | ---------------------- | |
136 | ||
137 | procedure Build_Float_Type (E : Entity_Id; Siz : Int; Digs : Int) is | |
138 | begin | |
139 | Set_Type_Definition (Parent (E), | |
140 | Make_Floating_Point_Definition (Stloc, | |
141 | Digits_Expression => Make_Integer (UI_From_Int (Digs)))); | |
142 | Set_Ekind (E, E_Floating_Point_Type); | |
143 | Set_Etype (E, E); | |
144 | Init_Size (E, Siz); | |
145 | Set_Prim_Alignment (E); | |
146 | Init_Digits_Value (E, Digs); | |
147 | Set_Float_Bounds (E); | |
148 | Set_Is_Frozen (E); | |
149 | Set_Is_Public (E); | |
150 | Set_Size_Known_At_Compile_Time (E); | |
151 | end Build_Float_Type; | |
152 | ||
153 | ------------------------------- | |
154 | -- Build_Signed_Integer_Type -- | |
155 | ------------------------------- | |
156 | ||
157 | procedure Build_Signed_Integer_Type (E : Entity_Id; Siz : Int) is | |
158 | U2Siz1 : constant Uint := 2 ** (Siz - 1); | |
159 | Lbound : constant Uint := -U2Siz1; | |
160 | Ubound : constant Uint := U2Siz1 - 1; | |
161 | ||
162 | begin | |
163 | Set_Type_Definition (Parent (E), | |
164 | Make_Signed_Integer_Type_Definition (Stloc, | |
165 | Low_Bound => Make_Integer (Lbound), | |
166 | High_Bound => Make_Integer (Ubound))); | |
167 | ||
168 | Set_Ekind (E, E_Signed_Integer_Type); | |
169 | Set_Etype (E, E); | |
170 | Init_Size (E, Siz); | |
171 | Set_Prim_Alignment (E); | |
172 | Set_Integer_Bounds (E, E, Lbound, Ubound); | |
173 | Set_Is_Frozen (E); | |
174 | Set_Is_Public (E); | |
175 | Set_Is_Known_Valid (E); | |
176 | Set_Size_Known_At_Compile_Time (E); | |
177 | end Build_Signed_Integer_Type; | |
178 | ||
179 | ---------------------- | |
180 | -- Create_Operators -- | |
181 | ---------------------- | |
182 | ||
183 | -- Each operator has an abbreviated signature. The formals have the names | |
184 | -- LEFT and RIGHT. Their types are not actually used for resolution. | |
185 | ||
186 | procedure Create_Operators is | |
187 | Op_Node : Entity_Id; | |
188 | ||
189 | -- Following list has two entries for concatenation, to include | |
190 | -- explicitly the operation on wide strings. | |
191 | ||
192 | Binary_Ops : constant array (S_Binary_Ops) of Name_Id := | |
193 | (Name_Op_Add, Name_Op_And, Name_Op_Concat, Name_Op_Concat, | |
194 | Name_Op_Divide, Name_Op_Eq, Name_Op_Expon, Name_Op_Ge, | |
195 | Name_Op_Gt, Name_Op_Le, Name_Op_Lt, Name_Op_Mod, | |
196 | Name_Op_Multiply, Name_Op_Ne, Name_Op_Or, Name_Op_Rem, | |
197 | Name_Op_Subtract, Name_Op_Xor); | |
198 | ||
199 | Bin_Op_Types : constant array (S_Binary_Ops) of Entity_Id := | |
200 | (Universal_Integer, Standard_Boolean, | |
201 | Standard_String, Standard_Wide_String, | |
202 | Universal_Integer, Standard_Boolean, | |
203 | Universal_Integer, Standard_Boolean, | |
204 | Standard_Boolean, Standard_Boolean, | |
205 | Standard_Boolean, Universal_Integer, | |
206 | Universal_Integer, Standard_Boolean, | |
207 | Standard_Boolean, Universal_Integer, | |
208 | Universal_Integer, Standard_Boolean); | |
209 | ||
210 | Unary_Ops : constant array (S_Unary_Ops) of Name_Id := | |
211 | (Name_Op_Abs, Name_Op_Subtract, Name_Op_Not, Name_Op_Add); | |
212 | ||
213 | Unary_Op_Types : constant array (S_Unary_Ops) of Entity_Id := | |
214 | (Universal_Integer, Universal_Integer, | |
215 | Standard_Boolean, Universal_Integer); | |
216 | ||
217 | -- Corresponding to Abs, Minus, Not, and Plus. | |
218 | ||
219 | begin | |
220 | for J in S_Binary_Ops loop | |
221 | Op_Node := New_Operator (Binary_Ops (J), Bin_Op_Types (J)); | |
222 | SE (J) := Op_Node; | |
223 | Append_Entity (Make_Formal (Any_Type, "LEFT"), Op_Node); | |
224 | Append_Entity (Make_Formal (Any_Type, "RIGHT"), Op_Node); | |
225 | end loop; | |
226 | ||
227 | for J in S_Unary_Ops loop | |
228 | Op_Node := New_Operator (Unary_Ops (J), Unary_Op_Types (J)); | |
229 | SE (J) := Op_Node; | |
230 | Append_Entity (Make_Formal (Any_Type, "RIGHT"), Op_Node); | |
231 | end loop; | |
232 | ||
233 | -- For concatenation, we create a separate operator for each | |
234 | -- array type. This simplifies the resolution of the component- | |
235 | -- component concatenation operation. In Standard, we set the types | |
236 | -- of the formals for string and wide string concatenation. | |
237 | ||
238 | Set_Etype (First_Entity (Standard_Op_Concat), Standard_String); | |
239 | Set_Etype (Last_Entity (Standard_Op_Concat), Standard_String); | |
240 | ||
241 | Set_Etype (First_Entity (Standard_Op_Concatw), Standard_Wide_String); | |
242 | Set_Etype (Last_Entity (Standard_Op_Concatw), Standard_Wide_String); | |
243 | ||
244 | end Create_Operators; | |
245 | ||
246 | --------------------- | |
247 | -- Create_Standard -- | |
248 | --------------------- | |
249 | ||
250 | -- The tree for the package Standard is prefixed to all compilations. | |
251 | -- Several entities required by semantic analysis are denoted by global | |
252 | -- variables that are initialized to point to the corresponding | |
44d6a706 | 253 | -- occurrences in STANDARD. The visible entities of STANDARD are |
70482933 RK |
254 | -- created here. The private entities defined in STANDARD are created |
255 | -- by Initialize_Standard in the semantics module. | |
256 | ||
257 | procedure Create_Standard is | |
258 | Decl_S : List_Id; | |
259 | -- List of declarations in Standard | |
260 | ||
261 | Decl_A : List_Id; | |
262 | -- List of declarations in ASCII | |
263 | ||
264 | Decl : Node_Id; | |
265 | Pspec : Node_Id; | |
266 | Tdef_Node : Node_Id; | |
267 | Ident_Node : Node_Id; | |
268 | Ccode : Char_Code; | |
269 | E_Id : Entity_Id; | |
270 | R_Node : Node_Id; | |
271 | B_Node : Node_Id; | |
272 | ||
273 | procedure Build_Exception (S : Standard_Entity_Type); | |
274 | -- Procedure to declare given entity as an exception | |
275 | ||
276 | --------------------- | |
277 | -- Build_Exception -- | |
278 | --------------------- | |
279 | ||
280 | procedure Build_Exception (S : Standard_Entity_Type) is | |
281 | begin | |
282 | Set_Ekind (Standard_Entity (S), E_Exception); | |
283 | Set_Etype (Standard_Entity (S), Standard_Exception_Type); | |
284 | Set_Exception_Code (Standard_Entity (S), Uint_0); | |
285 | Set_Is_Public (Standard_Entity (S), True); | |
286 | ||
287 | Decl := | |
288 | Make_Exception_Declaration (Stloc, | |
289 | Defining_Identifier => Standard_Entity (S)); | |
290 | Append (Decl, Decl_S); | |
291 | end Build_Exception; | |
292 | ||
293 | -- Start of processing for Create_Standard | |
294 | ||
295 | begin | |
296 | Decl_S := New_List; | |
297 | ||
298 | -- First step is to create defining identifiers for each entity | |
299 | ||
300 | for S in Standard_Entity_Type loop | |
301 | declare | |
302 | S_Name : constant String := Standard_Entity_Type'Image (S); | |
303 | -- Name of entity (note we skip S_ at the start) | |
304 | ||
305 | Ident_Node : Node_Id; | |
306 | -- Defining identifier node | |
307 | ||
308 | begin | |
309 | Ident_Node := New_Standard_Entity; | |
310 | Make_Name (Ident_Node, S_Name (3 .. S_Name'Length)); | |
311 | Standard_Entity (S) := Ident_Node; | |
312 | end; | |
313 | end loop; | |
314 | ||
315 | -- Create package declaration node for package Standard | |
316 | ||
317 | Standard_Package_Node := New_Node (N_Package_Declaration, Stloc); | |
318 | ||
319 | Pspec := New_Node (N_Package_Specification, Stloc); | |
320 | Set_Specification (Standard_Package_Node, Pspec); | |
321 | ||
322 | Set_Defining_Unit_Name (Pspec, Standard_Standard); | |
323 | Set_Visible_Declarations (Pspec, Decl_S); | |
324 | ||
325 | Set_Ekind (Standard_Standard, E_Package); | |
326 | Set_Is_Pure (Standard_Standard); | |
327 | Set_Is_Compilation_Unit (Standard_Standard); | |
328 | ||
329 | -- Create type declaration nodes for standard types | |
330 | ||
331 | for S in S_Types loop | |
332 | Decl := New_Node (N_Full_Type_Declaration, Stloc); | |
333 | Set_Defining_Identifier (Decl, Standard_Entity (S)); | |
334 | Set_Is_Frozen (Standard_Entity (S)); | |
335 | Set_Is_Public (Standard_Entity (S)); | |
336 | Append (Decl, Decl_S); | |
337 | end loop; | |
338 | ||
339 | -- Create type definition node for type Boolean. The Size is set to | |
340 | -- 1 as required by Ada 95 and current ARG interpretations for Ada/83. | |
341 | ||
342 | -- Note: Object_Size of Boolean is 8. This means that we do NOT in | |
343 | -- general know that Boolean variables have valid values, so we do | |
344 | -- not set the Is_Known_Valid flag. | |
345 | ||
346 | Tdef_Node := New_Node (N_Enumeration_Type_Definition, Stloc); | |
347 | Set_Literals (Tdef_Node, New_List); | |
348 | Append (Standard_False, Literals (Tdef_Node)); | |
349 | Append (Standard_True, Literals (Tdef_Node)); | |
350 | Set_Type_Definition (Parent (Standard_Boolean), Tdef_Node); | |
351 | ||
352 | Set_Ekind (Standard_Boolean, E_Enumeration_Type); | |
353 | Set_First_Literal (Standard_Boolean, Standard_False); | |
354 | Set_Etype (Standard_Boolean, Standard_Boolean); | |
07fc65c4 | 355 | Init_Esize (Standard_Boolean, Standard_Character_Size); |
70482933 RK |
356 | Init_RM_Size (Standard_Boolean, 1); |
357 | Set_Prim_Alignment (Standard_Boolean); | |
358 | ||
359 | Set_Is_Unsigned_Type (Standard_Boolean); | |
360 | Set_Size_Known_At_Compile_Time (Standard_Boolean); | |
361 | ||
362 | Set_Ekind (Standard_True, E_Enumeration_Literal); | |
363 | Set_Etype (Standard_True, Standard_Boolean); | |
364 | Set_Enumeration_Pos (Standard_True, Uint_1); | |
365 | Set_Enumeration_Rep (Standard_True, Uint_1); | |
366 | Set_Is_Known_Valid (Standard_True, True); | |
367 | ||
368 | Set_Ekind (Standard_False, E_Enumeration_Literal); | |
369 | Set_Etype (Standard_False, Standard_Boolean); | |
370 | Set_Enumeration_Pos (Standard_False, Uint_0); | |
371 | Set_Enumeration_Rep (Standard_False, Uint_0); | |
372 | Set_Is_Known_Valid (Standard_False, True); | |
373 | ||
374 | -- For the bounds of Boolean, we create a range node corresponding to | |
375 | ||
376 | -- range False .. True | |
377 | ||
378 | -- where the occurrences of the literals must point to the | |
379 | -- corresponding definition. | |
380 | ||
381 | R_Node := New_Node (N_Range, Stloc); | |
382 | B_Node := New_Node (N_Identifier, Stloc); | |
383 | Set_Chars (B_Node, Chars (Standard_False)); | |
384 | Set_Entity (B_Node, Standard_False); | |
385 | Set_Etype (B_Node, Standard_Boolean); | |
386 | Set_Is_Static_Expression (B_Node); | |
387 | Set_Low_Bound (R_Node, B_Node); | |
388 | ||
389 | B_Node := New_Node (N_Identifier, Stloc); | |
390 | Set_Chars (B_Node, Chars (Standard_True)); | |
391 | Set_Entity (B_Node, Standard_True); | |
392 | Set_Etype (B_Node, Standard_Boolean); | |
393 | Set_Is_Static_Expression (B_Node); | |
394 | Set_High_Bound (R_Node, B_Node); | |
395 | ||
396 | Set_Scalar_Range (Standard_Boolean, R_Node); | |
397 | Set_Etype (R_Node, Standard_Boolean); | |
398 | Set_Parent (R_Node, Standard_Boolean); | |
399 | ||
400 | -- Create type definition nodes for predefined integer types | |
401 | ||
402 | Build_Signed_Integer_Type | |
403 | (Standard_Short_Short_Integer, Standard_Short_Short_Integer_Size); | |
404 | ||
405 | Build_Signed_Integer_Type | |
406 | (Standard_Short_Integer, Standard_Short_Integer_Size); | |
407 | ||
408 | Build_Signed_Integer_Type | |
409 | (Standard_Integer, Standard_Integer_Size); | |
410 | ||
411 | declare | |
412 | LIS : Nat; | |
413 | ||
414 | begin | |
415 | if Debug_Flag_M then | |
416 | LIS := 64; | |
417 | else | |
418 | LIS := Standard_Long_Integer_Size; | |
419 | end if; | |
420 | ||
421 | Build_Signed_Integer_Type (Standard_Long_Integer, LIS); | |
422 | end; | |
423 | ||
424 | Build_Signed_Integer_Type | |
425 | (Standard_Long_Long_Integer, Standard_Long_Long_Integer_Size); | |
426 | ||
427 | Create_Unconstrained_Base_Type | |
428 | (Standard_Short_Short_Integer, E_Signed_Integer_Subtype); | |
429 | ||
430 | Create_Unconstrained_Base_Type | |
431 | (Standard_Short_Integer, E_Signed_Integer_Subtype); | |
432 | ||
433 | Create_Unconstrained_Base_Type | |
434 | (Standard_Integer, E_Signed_Integer_Subtype); | |
435 | ||
436 | Create_Unconstrained_Base_Type | |
437 | (Standard_Long_Integer, E_Signed_Integer_Subtype); | |
438 | ||
439 | Create_Unconstrained_Base_Type | |
440 | (Standard_Long_Long_Integer, E_Signed_Integer_Subtype); | |
441 | ||
442 | -- Create type definition nodes for predefined float types | |
443 | ||
444 | Build_Float_Type | |
445 | (Standard_Short_Float, | |
446 | Standard_Short_Float_Size, | |
447 | Standard_Short_Float_Digits); | |
448 | ||
449 | Build_Float_Type | |
450 | (Standard_Float, | |
451 | Standard_Float_Size, | |
452 | Standard_Float_Digits); | |
453 | ||
454 | Build_Float_Type | |
455 | (Standard_Long_Float, | |
456 | Standard_Long_Float_Size, | |
457 | Standard_Long_Float_Digits); | |
458 | ||
459 | Build_Float_Type | |
460 | (Standard_Long_Long_Float, | |
461 | Standard_Long_Long_Float_Size, | |
462 | Standard_Long_Long_Float_Digits); | |
463 | ||
464 | -- Create type definition node for type Character. Note that we do not | |
465 | -- set the Literals field, since type Character is handled with special | |
466 | -- routine that do not need a literal list. | |
467 | ||
468 | Tdef_Node := New_Node (N_Enumeration_Type_Definition, Stloc); | |
469 | Set_Type_Definition (Parent (Standard_Character), Tdef_Node); | |
470 | ||
471 | Set_Ekind (Standard_Character, E_Enumeration_Type); | |
472 | Set_Etype (Standard_Character, Standard_Character); | |
07fc65c4 GB |
473 | Init_Esize (Standard_Character, Standard_Character_Size); |
474 | Init_RM_Size (Standard_Character, 8); | |
70482933 RK |
475 | Set_Prim_Alignment (Standard_Character); |
476 | ||
477 | Set_Is_Unsigned_Type (Standard_Character); | |
478 | Set_Is_Character_Type (Standard_Character); | |
479 | Set_Is_Known_Valid (Standard_Character); | |
480 | Set_Size_Known_At_Compile_Time (Standard_Character); | |
481 | ||
482 | -- Create the bounds for type Character. | |
483 | ||
484 | R_Node := New_Node (N_Range, Stloc); | |
485 | ||
486 | -- Low bound for type Character (Standard.Nul) | |
487 | ||
488 | B_Node := New_Node (N_Character_Literal, Stloc); | |
489 | Set_Is_Static_Expression (B_Node); | |
490 | Set_Chars (B_Node, No_Name); | |
491 | Set_Char_Literal_Value (B_Node, 16#00#); | |
492 | Set_Entity (B_Node, Empty); | |
493 | Set_Etype (B_Node, Standard_Character); | |
494 | Set_Low_Bound (R_Node, B_Node); | |
495 | ||
496 | -- High bound for type Character | |
497 | ||
498 | B_Node := New_Node (N_Character_Literal, Stloc); | |
499 | Set_Is_Static_Expression (B_Node); | |
500 | Set_Chars (B_Node, No_Name); | |
501 | Set_Char_Literal_Value (B_Node, 16#FF#); | |
502 | Set_Entity (B_Node, Empty); | |
503 | Set_Etype (B_Node, Standard_Character); | |
504 | Set_High_Bound (R_Node, B_Node); | |
505 | ||
506 | Set_Scalar_Range (Standard_Character, R_Node); | |
507 | Set_Etype (R_Node, Standard_Character); | |
508 | Set_Parent (R_Node, Standard_Character); | |
509 | ||
510 | -- Create type definition for type Wide_Character. Note that we do not | |
511 | -- set the Literals field, since type Wide_Character is handled with | |
512 | -- special routines that do not need a literal list. | |
513 | ||
514 | Tdef_Node := New_Node (N_Enumeration_Type_Definition, Stloc); | |
515 | Set_Type_Definition (Parent (Standard_Wide_Character), Tdef_Node); | |
516 | ||
517 | Set_Ekind (Standard_Wide_Character, E_Enumeration_Type); | |
518 | Set_Etype (Standard_Wide_Character, Standard_Wide_Character); | |
519 | Init_Size (Standard_Wide_Character, Standard_Wide_Character_Size); | |
520 | ||
521 | Set_Prim_Alignment (Standard_Wide_Character); | |
522 | Set_Is_Unsigned_Type (Standard_Wide_Character); | |
523 | Set_Is_Character_Type (Standard_Wide_Character); | |
524 | Set_Is_Known_Valid (Standard_Wide_Character); | |
525 | Set_Size_Known_At_Compile_Time (Standard_Wide_Character); | |
526 | ||
527 | -- Create the bounds for type Wide_Character. | |
528 | ||
529 | R_Node := New_Node (N_Range, Stloc); | |
530 | ||
531 | -- Low bound for type Wide_Character | |
532 | ||
533 | B_Node := New_Node (N_Character_Literal, Stloc); | |
534 | Set_Is_Static_Expression (B_Node); | |
535 | Set_Chars (B_Node, No_Name); -- ??? | |
536 | Set_Char_Literal_Value (B_Node, 16#0000#); | |
537 | Set_Entity (B_Node, Empty); | |
538 | Set_Etype (B_Node, Standard_Wide_Character); | |
539 | Set_Low_Bound (R_Node, B_Node); | |
540 | ||
541 | -- High bound for type Wide_Character | |
542 | ||
543 | B_Node := New_Node (N_Character_Literal, Stloc); | |
544 | Set_Is_Static_Expression (B_Node); | |
545 | Set_Chars (B_Node, No_Name); -- ??? | |
546 | Set_Char_Literal_Value (B_Node, 16#FFFF#); | |
547 | Set_Entity (B_Node, Empty); | |
548 | Set_Etype (B_Node, Standard_Wide_Character); | |
549 | Set_High_Bound (R_Node, B_Node); | |
550 | ||
551 | Set_Scalar_Range (Standard_Wide_Character, R_Node); | |
552 | Set_Etype (R_Node, Standard_Wide_Character); | |
553 | Set_Parent (R_Node, Standard_Wide_Character); | |
554 | ||
555 | -- Create type definition node for type String | |
556 | ||
557 | Tdef_Node := New_Node (N_Unconstrained_Array_Definition, Stloc); | |
558 | Set_Subtype_Indication (Tdef_Node, Identifier_For (S_Character)); | |
559 | Set_Subtype_Marks (Tdef_Node, New_List); | |
560 | Append (Identifier_For (S_Positive), Subtype_Marks (Tdef_Node)); | |
561 | Set_Type_Definition (Parent (Standard_String), Tdef_Node); | |
562 | ||
563 | Set_Ekind (Standard_String, E_String_Type); | |
564 | Set_Etype (Standard_String, Standard_String); | |
565 | Set_Component_Type (Standard_String, Standard_Character); | |
566 | Set_Component_Size (Standard_String, Uint_8); | |
567 | Init_Size_Align (Standard_String); | |
568 | ||
569 | -- Set index type of String | |
570 | ||
571 | E_Id := First | |
572 | (Subtype_Marks (Type_Definition (Parent (Standard_String)))); | |
573 | Set_First_Index (Standard_String, E_Id); | |
574 | Set_Entity (E_Id, Standard_Positive); | |
575 | Set_Etype (E_Id, Standard_Positive); | |
576 | ||
577 | -- Create type definition node for type Wide_String | |
578 | ||
579 | Tdef_Node := New_Node (N_Unconstrained_Array_Definition, Stloc); | |
580 | Set_Subtype_Indication (Tdef_Node, Identifier_For (S_Wide_Character)); | |
581 | Set_Subtype_Marks (Tdef_Node, New_List); | |
582 | Append (Identifier_For (S_Positive), Subtype_Marks (Tdef_Node)); | |
583 | Set_Type_Definition (Parent (Standard_Wide_String), Tdef_Node); | |
584 | ||
585 | Set_Ekind (Standard_Wide_String, E_String_Type); | |
586 | Set_Etype (Standard_Wide_String, Standard_Wide_String); | |
587 | Set_Component_Type (Standard_Wide_String, Standard_Wide_Character); | |
588 | Set_Component_Size (Standard_Wide_String, Uint_16); | |
589 | Init_Size_Align (Standard_Wide_String); | |
590 | ||
591 | -- Set index type of Wide_String | |
592 | ||
593 | E_Id := First | |
594 | (Subtype_Marks (Type_Definition (Parent (Standard_Wide_String)))); | |
595 | Set_First_Index (Standard_Wide_String, E_Id); | |
596 | Set_Entity (E_Id, Standard_Positive); | |
597 | Set_Etype (E_Id, Standard_Positive); | |
598 | ||
599 | -- Create subtype declaration for Natural | |
600 | ||
601 | Decl := New_Node (N_Subtype_Declaration, Stloc); | |
602 | Set_Defining_Identifier (Decl, Standard_Natural); | |
603 | Set_Subtype_Indication (Decl, | |
604 | New_Occurrence_Of (Standard_Integer, Stloc)); | |
605 | Append (Decl, Decl_S); | |
606 | ||
607 | Set_Ekind (Standard_Natural, E_Signed_Integer_Subtype); | |
608 | Set_Etype (Standard_Natural, Base_Type (Standard_Integer)); | |
609 | Init_Esize (Standard_Natural, Standard_Integer_Size); | |
610 | Init_RM_Size (Standard_Natural, Standard_Integer_Size - 1); | |
611 | Set_Prim_Alignment (Standard_Natural); | |
612 | Set_Size_Known_At_Compile_Time | |
613 | (Standard_Natural); | |
614 | Set_Integer_Bounds (Standard_Natural, | |
615 | Typ => Base_Type (Standard_Integer), | |
616 | Lb => Uint_0, | |
617 | Hb => Intval (High_Bound (Scalar_Range (Standard_Integer)))); | |
618 | Set_Is_Constrained (Standard_Natural); | |
619 | Set_Is_Frozen (Standard_Natural); | |
620 | Set_Is_Public (Standard_Natural); | |
621 | ||
622 | -- Create subtype declaration for Positive | |
623 | ||
624 | Decl := New_Node (N_Subtype_Declaration, Stloc); | |
625 | Set_Defining_Identifier (Decl, Standard_Positive); | |
626 | Set_Subtype_Indication (Decl, | |
627 | New_Occurrence_Of (Standard_Integer, Stloc)); | |
628 | Append (Decl, Decl_S); | |
629 | ||
630 | Set_Ekind (Standard_Positive, E_Signed_Integer_Subtype); | |
631 | Set_Etype (Standard_Positive, Base_Type (Standard_Integer)); | |
632 | Init_Esize (Standard_Positive, Standard_Integer_Size); | |
633 | Init_RM_Size (Standard_Positive, Standard_Integer_Size - 1); | |
634 | Set_Prim_Alignment (Standard_Positive); | |
635 | ||
636 | Set_Size_Known_At_Compile_Time (Standard_Positive); | |
637 | ||
638 | Set_Integer_Bounds (Standard_Positive, | |
639 | Typ => Base_Type (Standard_Integer), | |
640 | Lb => Uint_1, | |
641 | Hb => Intval (High_Bound (Scalar_Range (Standard_Integer)))); | |
642 | Set_Is_Constrained (Standard_Positive); | |
643 | Set_Is_Frozen (Standard_Positive); | |
644 | Set_Is_Public (Standard_Positive); | |
645 | ||
646 | -- Create declaration for package ASCII | |
647 | ||
648 | Decl := New_Node (N_Package_Declaration, Stloc); | |
649 | Append (Decl, Decl_S); | |
650 | ||
651 | Pspec := New_Node (N_Package_Specification, Stloc); | |
652 | Set_Specification (Decl, Pspec); | |
653 | ||
654 | Set_Defining_Unit_Name (Pspec, Standard_Entity (S_ASCII)); | |
655 | Set_Ekind (Standard_Entity (S_ASCII), E_Package); | |
656 | Decl_A := New_List; -- for ASCII declarations | |
657 | Set_Visible_Declarations (Pspec, Decl_A); | |
658 | ||
659 | -- Create control character definitions in package ASCII. Note that | |
660 | -- the character literal entries created here correspond to literal | |
661 | -- values that are impossible in the source, but can be represented | |
662 | -- internally with no difficulties. | |
663 | ||
664 | Ccode := 16#00#; | |
665 | ||
666 | for S in S_ASCII_Names loop | |
667 | Decl := New_Node (N_Object_Declaration, Staloc); | |
668 | Set_Constant_Present (Decl, True); | |
669 | ||
670 | declare | |
fbf5a39b | 671 | A_Char : constant Entity_Id := Standard_Entity (S); |
70482933 RK |
672 | Expr_Decl : Node_Id; |
673 | ||
674 | begin | |
675 | Set_Sloc (A_Char, Staloc); | |
676 | Set_Ekind (A_Char, E_Constant); | |
fbf5a39b | 677 | Set_Never_Set_In_Source (A_Char, True); |
70482933 RK |
678 | Set_Is_True_Constant (A_Char, True); |
679 | Set_Etype (A_Char, Standard_Character); | |
680 | Set_Scope (A_Char, Standard_Entity (S_ASCII)); | |
681 | Set_Is_Immediately_Visible (A_Char, False); | |
682 | Set_Is_Public (A_Char, True); | |
683 | Set_Is_Known_Valid (A_Char, True); | |
684 | ||
685 | Append_Entity (A_Char, Standard_Entity (S_ASCII)); | |
686 | Set_Defining_Identifier (Decl, A_Char); | |
687 | ||
688 | Set_Object_Definition (Decl, Identifier_For (S_Character)); | |
689 | Expr_Decl := New_Node (N_Character_Literal, Staloc); | |
690 | Set_Expression (Decl, Expr_Decl); | |
691 | ||
692 | Set_Is_Static_Expression (Expr_Decl); | |
693 | Set_Chars (Expr_Decl, No_Name); | |
694 | Set_Etype (Expr_Decl, Standard_Character); | |
695 | Set_Char_Literal_Value (Expr_Decl, Ccode); | |
696 | end; | |
697 | ||
698 | Append (Decl, Decl_A); | |
699 | ||
700 | -- Increment character code, dealing with non-contiguities | |
701 | ||
702 | Ccode := Ccode + 1; | |
703 | ||
704 | if Ccode = 16#20# then | |
705 | Ccode := 16#21#; | |
706 | elsif Ccode = 16#27# then | |
707 | Ccode := 16#3A#; | |
708 | elsif Ccode = 16#3C# then | |
709 | Ccode := 16#3F#; | |
710 | elsif Ccode = 16#41# then | |
711 | Ccode := 16#5B#; | |
712 | end if; | |
713 | end loop; | |
714 | ||
715 | -- Create semantic phase entities | |
716 | ||
717 | Standard_Void_Type := New_Standard_Entity; | |
718 | Set_Ekind (Standard_Void_Type, E_Void); | |
719 | Set_Etype (Standard_Void_Type, Standard_Void_Type); | |
70482933 RK |
720 | Set_Scope (Standard_Void_Type, Standard_Standard); |
721 | Make_Name (Standard_Void_Type, "_void_type"); | |
722 | ||
723 | -- The type field of packages is set to void | |
724 | ||
725 | Set_Etype (Standard_Standard, Standard_Void_Type); | |
726 | Set_Etype (Standard_ASCII, Standard_Void_Type); | |
727 | ||
728 | -- Standard_A_String is actually used in generated code, so it has a | |
729 | -- type name that is reasonable, but does not overlap any Ada name. | |
730 | ||
731 | Standard_A_String := New_Standard_Entity; | |
732 | Set_Ekind (Standard_A_String, E_Access_Type); | |
733 | Set_Scope (Standard_A_String, Standard_Standard); | |
734 | Set_Etype (Standard_A_String, Standard_A_String); | |
735 | ||
736 | if Debug_Flag_6 then | |
737 | Init_Size (Standard_A_String, System_Address_Size); | |
738 | else | |
739 | Init_Size (Standard_A_String, System_Address_Size * 2); | |
740 | end if; | |
741 | ||
742 | Init_Alignment (Standard_A_String); | |
743 | ||
744 | Set_Directly_Designated_Type | |
745 | (Standard_A_String, Standard_String); | |
746 | Make_Name (Standard_A_String, "access_string"); | |
747 | ||
748 | Standard_A_Char := New_Standard_Entity; | |
749 | Set_Ekind (Standard_A_Char, E_Access_Type); | |
750 | Set_Scope (Standard_A_Char, Standard_Standard); | |
751 | Set_Etype (Standard_A_Char, Standard_A_String); | |
752 | Init_Size (Standard_A_Char, System_Address_Size); | |
753 | Set_Prim_Alignment (Standard_A_Char); | |
754 | ||
755 | Set_Directly_Designated_Type (Standard_A_Char, Standard_Character); | |
756 | Make_Name (Standard_A_Char, "access_character"); | |
757 | ||
758 | -- Note on type names. The type names for the following special types | |
759 | -- are constructed so that they will look reasonable should they ever | |
760 | -- appear in error messages etc, although in practice the use of the | |
761 | -- special insertion character } for types results in special handling | |
762 | -- of these type names in any case. The blanks in these names would | |
763 | -- trouble in Gigi, but that's OK here, since none of these types | |
764 | -- should ever get through to Gigi! Attributes of these types are | |
765 | -- filled out to minimize problems with cascaded errors (for example, | |
766 | -- Any_Integer is given reasonable and consistent type and size values) | |
767 | ||
768 | Any_Type := New_Standard_Entity; | |
769 | Decl := New_Node (N_Full_Type_Declaration, Stloc); | |
770 | Set_Defining_Identifier (Decl, Any_Type); | |
771 | Set_Scope (Any_Type, Standard_Standard); | |
772 | Build_Signed_Integer_Type (Any_Type, Standard_Integer_Size); | |
773 | Make_Name (Any_Type, "any type"); | |
774 | ||
775 | Any_Id := New_Standard_Entity; | |
776 | Set_Ekind (Any_Id, E_Variable); | |
777 | Set_Scope (Any_Id, Standard_Standard); | |
778 | Set_Etype (Any_Id, Any_Type); | |
779 | Init_Size_Align (Any_Id); | |
780 | Make_Name (Any_Id, "any id"); | |
781 | ||
782 | Any_Access := New_Standard_Entity; | |
783 | Set_Ekind (Any_Access, E_Access_Type); | |
784 | Set_Scope (Any_Access, Standard_Standard); | |
785 | Set_Etype (Any_Access, Any_Access); | |
786 | Init_Size (Any_Access, System_Address_Size); | |
787 | Set_Prim_Alignment (Any_Access); | |
788 | Make_Name (Any_Access, "an access type"); | |
789 | ||
790 | Any_Array := New_Standard_Entity; | |
791 | Set_Ekind (Any_Array, E_String_Type); | |
792 | Set_Scope (Any_Array, Standard_Standard); | |
793 | Set_Etype (Any_Array, Any_Array); | |
794 | Set_Component_Type (Any_Array, Any_Character); | |
795 | Init_Size_Align (Any_Array); | |
796 | Make_Name (Any_Array, "an array type"); | |
797 | ||
798 | Any_Boolean := New_Standard_Entity; | |
799 | Set_Ekind (Any_Boolean, E_Enumeration_Type); | |
800 | Set_Scope (Any_Boolean, Standard_Standard); | |
801 | Set_Etype (Any_Boolean, Standard_Boolean); | |
07fc65c4 | 802 | Init_Esize (Any_Boolean, Standard_Character_Size); |
70482933 RK |
803 | Init_RM_Size (Any_Boolean, 1); |
804 | Set_Prim_Alignment (Any_Boolean); | |
805 | Set_Is_Unsigned_Type (Any_Boolean); | |
806 | Set_Scalar_Range (Any_Boolean, Scalar_Range (Standard_Boolean)); | |
807 | Make_Name (Any_Boolean, "a boolean type"); | |
808 | ||
809 | Any_Character := New_Standard_Entity; | |
810 | Set_Ekind (Any_Character, E_Enumeration_Type); | |
811 | Set_Scope (Any_Character, Standard_Standard); | |
812 | Set_Etype (Any_Character, Any_Character); | |
813 | Set_Is_Unsigned_Type (Any_Character); | |
814 | Set_Is_Character_Type (Any_Character); | |
07fc65c4 GB |
815 | Init_Esize (Any_Character, Standard_Character_Size); |
816 | Init_RM_Size (Any_Character, 8); | |
70482933 RK |
817 | Set_Prim_Alignment (Any_Character); |
818 | Set_Scalar_Range (Any_Character, Scalar_Range (Standard_Character)); | |
819 | Make_Name (Any_Character, "a character type"); | |
820 | ||
821 | Any_Composite := New_Standard_Entity; | |
822 | Set_Ekind (Any_Composite, E_Array_Type); | |
823 | Set_Scope (Any_Composite, Standard_Standard); | |
824 | Set_Etype (Any_Composite, Any_Composite); | |
825 | Set_Component_Size (Any_Composite, Uint_0); | |
826 | Set_Component_Type (Any_Composite, Standard_Integer); | |
827 | Init_Size_Align (Any_Composite); | |
828 | Make_Name (Any_Composite, "a composite type"); | |
829 | ||
830 | Any_Discrete := New_Standard_Entity; | |
831 | Set_Ekind (Any_Discrete, E_Signed_Integer_Type); | |
832 | Set_Scope (Any_Discrete, Standard_Standard); | |
833 | Set_Etype (Any_Discrete, Any_Discrete); | |
834 | Init_Size (Any_Discrete, Standard_Integer_Size); | |
835 | Set_Prim_Alignment (Any_Discrete); | |
836 | Make_Name (Any_Discrete, "a discrete type"); | |
837 | ||
838 | Any_Fixed := New_Standard_Entity; | |
839 | Set_Ekind (Any_Fixed, E_Ordinary_Fixed_Point_Type); | |
840 | Set_Scope (Any_Fixed, Standard_Standard); | |
841 | Set_Etype (Any_Fixed, Any_Fixed); | |
842 | Init_Size (Any_Fixed, Standard_Integer_Size); | |
843 | Set_Prim_Alignment (Any_Fixed); | |
844 | Make_Name (Any_Fixed, "a fixed-point type"); | |
845 | ||
846 | Any_Integer := New_Standard_Entity; | |
847 | Set_Ekind (Any_Integer, E_Signed_Integer_Type); | |
848 | Set_Scope (Any_Integer, Standard_Standard); | |
849 | Set_Etype (Any_Integer, Standard_Long_Long_Integer); | |
850 | Init_Size (Any_Integer, Standard_Long_Long_Integer_Size); | |
851 | Set_Prim_Alignment (Any_Integer); | |
852 | ||
853 | Set_Integer_Bounds | |
854 | (Any_Integer, | |
855 | Typ => Base_Type (Standard_Integer), | |
856 | Lb => Uint_0, | |
857 | Hb => Intval (High_Bound (Scalar_Range (Standard_Integer)))); | |
858 | Make_Name (Any_Integer, "an integer type"); | |
859 | ||
860 | Any_Modular := New_Standard_Entity; | |
861 | Set_Ekind (Any_Modular, E_Modular_Integer_Type); | |
862 | Set_Scope (Any_Modular, Standard_Standard); | |
863 | Set_Etype (Any_Modular, Standard_Long_Long_Integer); | |
864 | Init_Size (Any_Modular, Standard_Long_Long_Integer_Size); | |
865 | Set_Prim_Alignment (Any_Modular); | |
866 | Set_Is_Unsigned_Type (Any_Modular); | |
867 | Make_Name (Any_Modular, "a modular type"); | |
868 | ||
869 | Any_Numeric := New_Standard_Entity; | |
870 | Set_Ekind (Any_Numeric, E_Signed_Integer_Type); | |
871 | Set_Scope (Any_Numeric, Standard_Standard); | |
872 | Set_Etype (Any_Numeric, Standard_Long_Long_Integer); | |
873 | Init_Size (Any_Numeric, Standard_Long_Long_Integer_Size); | |
874 | Set_Prim_Alignment (Any_Numeric); | |
875 | Make_Name (Any_Numeric, "a numeric type"); | |
876 | ||
877 | Any_Real := New_Standard_Entity; | |
878 | Set_Ekind (Any_Real, E_Floating_Point_Type); | |
879 | Set_Scope (Any_Real, Standard_Standard); | |
880 | Set_Etype (Any_Real, Standard_Long_Long_Float); | |
881 | Init_Size (Any_Real, Standard_Long_Long_Float_Size); | |
882 | Set_Prim_Alignment (Any_Real); | |
883 | Make_Name (Any_Real, "a real type"); | |
884 | ||
885 | Any_Scalar := New_Standard_Entity; | |
886 | Set_Ekind (Any_Scalar, E_Signed_Integer_Type); | |
887 | Set_Scope (Any_Scalar, Standard_Standard); | |
888 | Set_Etype (Any_Scalar, Any_Scalar); | |
889 | Init_Size (Any_Scalar, Standard_Integer_Size); | |
890 | Set_Prim_Alignment (Any_Scalar); | |
891 | Make_Name (Any_Scalar, "a scalar type"); | |
892 | ||
893 | Any_String := New_Standard_Entity; | |
894 | Set_Ekind (Any_String, E_String_Type); | |
895 | Set_Scope (Any_String, Standard_Standard); | |
896 | Set_Etype (Any_String, Any_String); | |
897 | Set_Component_Type (Any_String, Any_Character); | |
898 | Init_Size_Align (Any_String); | |
899 | Make_Name (Any_String, "a string type"); | |
900 | ||
901 | declare | |
902 | Index : Node_Id; | |
70482933 RK |
903 | |
904 | begin | |
905 | Index := | |
906 | Make_Range (Stloc, | |
907 | Low_Bound => Make_Integer (Uint_0), | |
908 | High_Bound => Make_Integer (Uint_2 ** Standard_Integer_Size)); | |
70482933 RK |
909 | Set_Etype (Index, Standard_Integer); |
910 | Set_First_Index (Any_String, Index); | |
911 | end; | |
912 | ||
913 | Standard_Integer_8 := New_Standard_Entity; | |
914 | Decl := New_Node (N_Full_Type_Declaration, Stloc); | |
915 | Set_Defining_Identifier (Decl, Standard_Integer_8); | |
916 | Make_Name (Standard_Integer_8, "integer_8"); | |
917 | Set_Scope (Standard_Integer_8, Standard_Standard); | |
918 | Build_Signed_Integer_Type (Standard_Integer_8, 8); | |
919 | ||
920 | Standard_Integer_16 := New_Standard_Entity; | |
921 | Decl := New_Node (N_Full_Type_Declaration, Stloc); | |
922 | Set_Defining_Identifier (Decl, Standard_Integer_16); | |
923 | Make_Name (Standard_Integer_16, "integer_16"); | |
924 | Set_Scope (Standard_Integer_16, Standard_Standard); | |
925 | Build_Signed_Integer_Type (Standard_Integer_16, 16); | |
926 | ||
927 | Standard_Integer_32 := New_Standard_Entity; | |
928 | Decl := New_Node (N_Full_Type_Declaration, Stloc); | |
929 | Set_Defining_Identifier (Decl, Standard_Integer_32); | |
930 | Make_Name (Standard_Integer_32, "integer_32"); | |
931 | Set_Scope (Standard_Integer_32, Standard_Standard); | |
932 | Build_Signed_Integer_Type (Standard_Integer_32, 32); | |
933 | ||
934 | Standard_Integer_64 := New_Standard_Entity; | |
935 | Decl := New_Node (N_Full_Type_Declaration, Stloc); | |
936 | Set_Defining_Identifier (Decl, Standard_Integer_64); | |
937 | Make_Name (Standard_Integer_64, "integer_64"); | |
938 | Set_Scope (Standard_Integer_64, Standard_Standard); | |
939 | Build_Signed_Integer_Type (Standard_Integer_64, 64); | |
940 | ||
941 | Standard_Unsigned := New_Standard_Entity; | |
942 | Decl := New_Node (N_Full_Type_Declaration, Stloc); | |
943 | Set_Defining_Identifier (Decl, Standard_Unsigned); | |
944 | Make_Name (Standard_Unsigned, "unsigned"); | |
945 | ||
946 | Set_Ekind (Standard_Unsigned, E_Modular_Integer_Type); | |
947 | Set_Scope (Standard_Unsigned, Standard_Standard); | |
948 | Set_Etype (Standard_Unsigned, Standard_Unsigned); | |
949 | Init_Size (Standard_Unsigned, Standard_Integer_Size); | |
950 | Set_Prim_Alignment (Standard_Unsigned); | |
951 | Set_Modulus (Standard_Unsigned, | |
952 | Uint_2 ** Standard_Integer_Size); | |
70482933 | 953 | Set_Is_Unsigned_Type (Standard_Unsigned); |
fbf5a39b AC |
954 | Set_Size_Known_At_Compile_Time |
955 | (Standard_Unsigned); | |
70482933 RK |
956 | |
957 | R_Node := New_Node (N_Range, Stloc); | |
fbf5a39b AC |
958 | Set_Low_Bound (R_Node, Make_Integer (Uint_0)); |
959 | Set_High_Bound (R_Node, Make_Integer (Modulus (Standard_Unsigned) - 1)); | |
960 | Set_Etype (Low_Bound (R_Node), Standard_Unsigned); | |
961 | Set_Etype (High_Bound (R_Node), Standard_Unsigned); | |
70482933 RK |
962 | Set_Scalar_Range (Standard_Unsigned, R_Node); |
963 | ||
964 | -- Note: universal integer and universal real are constructed as fully | |
965 | -- formed signed numeric types, with parameters corresponding to the | |
966 | -- longest runtime types (Long_Long_Integer and Long_Long_Float). This | |
967 | -- allows Gigi to properly process references to universal types that | |
968 | -- are not folded at compile time. | |
969 | ||
970 | Universal_Integer := New_Standard_Entity; | |
971 | Decl := New_Node (N_Full_Type_Declaration, Stloc); | |
972 | Set_Defining_Identifier (Decl, Universal_Integer); | |
973 | Make_Name (Universal_Integer, "universal_integer"); | |
974 | Set_Scope (Universal_Integer, Standard_Standard); | |
975 | Build_Signed_Integer_Type | |
976 | (Universal_Integer, Standard_Long_Long_Integer_Size); | |
977 | ||
978 | Universal_Real := New_Standard_Entity; | |
979 | Decl := New_Node (N_Full_Type_Declaration, Stloc); | |
980 | Set_Defining_Identifier (Decl, Universal_Real); | |
981 | Make_Name (Universal_Real, "universal_real"); | |
982 | Set_Scope (Universal_Real, Standard_Standard); | |
983 | Build_Float_Type | |
984 | (Universal_Real, | |
985 | Standard_Long_Long_Float_Size, | |
986 | Standard_Long_Long_Float_Digits); | |
987 | ||
988 | -- Note: universal fixed, unlike universal integer and universal real, | |
989 | -- is never used at runtime, so it does not need to have bounds set. | |
990 | ||
991 | Universal_Fixed := New_Standard_Entity; | |
992 | Decl := New_Node (N_Full_Type_Declaration, Stloc); | |
993 | Set_Defining_Identifier (Decl, Universal_Fixed); | |
994 | Make_Name (Universal_Fixed, "universal_fixed"); | |
995 | Set_Ekind (Universal_Fixed, E_Ordinary_Fixed_Point_Type); | |
996 | Set_Etype (Universal_Fixed, Universal_Fixed); | |
997 | Set_Scope (Universal_Fixed, Standard_Standard); | |
998 | Init_Size (Universal_Fixed, Standard_Long_Long_Integer_Size); | |
999 | Set_Prim_Alignment (Universal_Fixed); | |
1000 | Set_Size_Known_At_Compile_Time | |
1001 | (Universal_Fixed); | |
1002 | ||
17c5c8a5 | 1003 | -- Create type declaration for Duration, using a 64-bit size. The |
fbf5a39b | 1004 | -- delta and size values depend on the mode set in system.ads. |
70482933 RK |
1005 | |
1006 | Build_Duration : declare | |
6510f4c9 GB |
1007 | Dlo : Uint; |
1008 | Dhi : Uint; | |
1009 | Delta_Val : Ureal; | |
70482933 RK |
1010 | |
1011 | begin | |
fbf5a39b AC |
1012 | -- In 32 bit mode, the size is 32 bits, and the delta and |
1013 | -- small values are set to 20 milliseconds (20.0**(10.0**(-3)). | |
1014 | ||
1015 | if Duration_32_Bits_On_Target then | |
6510f4c9 GB |
1016 | Dlo := Intval (Type_Low_Bound (Standard_Integer_32)); |
1017 | Dhi := Intval (Type_High_Bound (Standard_Integer_32)); | |
fbf5a39b AC |
1018 | Delta_Val := UR_From_Components (UI_From_Int (20), Uint_3, 10); |
1019 | ||
1020 | -- In standard 64-bit mode, the size is 64-bits and the delta and | |
1021 | -- amll values are set to nanoseconds (1.0**(10.0**(-9)) | |
17c5c8a5 | 1022 | |
6510f4c9 GB |
1023 | else |
1024 | Dlo := Intval (Type_Low_Bound (Standard_Integer_64)); | |
1025 | Dhi := Intval (Type_High_Bound (Standard_Integer_64)); | |
1026 | Delta_Val := UR_From_Components (Uint_1, Uint_9, 10); | |
1027 | end if; | |
1028 | ||
70482933 RK |
1029 | Decl := |
1030 | Make_Full_Type_Declaration (Stloc, | |
1031 | Defining_Identifier => Standard_Duration, | |
1032 | Type_Definition => | |
1033 | Make_Ordinary_Fixed_Point_Definition (Stloc, | |
1034 | Delta_Expression => Make_Real_Literal (Stloc, Delta_Val), | |
1035 | Real_Range_Specification => | |
1036 | Make_Real_Range_Specification (Stloc, | |
1037 | Low_Bound => Make_Real_Literal (Stloc, | |
1038 | Realval => Dlo * Delta_Val), | |
1039 | High_Bound => Make_Real_Literal (Stloc, | |
1040 | Realval => Dhi * Delta_Val)))); | |
1041 | ||
6510f4c9 GB |
1042 | Set_Ekind (Standard_Duration, E_Ordinary_Fixed_Point_Type); |
1043 | Set_Etype (Standard_Duration, Standard_Duration); | |
1044 | ||
fbf5a39b | 1045 | if Duration_32_Bits_On_Target then |
6510f4c9 GB |
1046 | Init_Size (Standard_Duration, 32); |
1047 | else | |
1048 | Init_Size (Standard_Duration, 64); | |
1049 | end if; | |
1050 | ||
70482933 RK |
1051 | Set_Prim_Alignment (Standard_Duration); |
1052 | Set_Delta_Value (Standard_Duration, Delta_Val); | |
1053 | Set_Small_Value (Standard_Duration, Delta_Val); | |
1054 | Set_Scalar_Range (Standard_Duration, | |
1055 | Real_Range_Specification | |
1056 | (Type_Definition (Decl))); | |
1057 | ||
1058 | -- Normally it does not matter that nodes in package Standard are | |
1059 | -- not marked as analyzed. The Scalar_Range of the fixed-point | |
1060 | -- type Standard_Duration is an exception, because of the special | |
1061 | -- test made in Freeze.Freeze_Fixed_Point_Type. | |
1062 | ||
1063 | Set_Analyzed (Scalar_Range (Standard_Duration)); | |
1064 | ||
1065 | Set_Etype (Type_High_Bound (Standard_Duration), Standard_Duration); | |
1066 | Set_Etype (Type_Low_Bound (Standard_Duration), Standard_Duration); | |
1067 | ||
1068 | Set_Is_Static_Expression (Type_High_Bound (Standard_Duration)); | |
1069 | Set_Is_Static_Expression (Type_Low_Bound (Standard_Duration)); | |
1070 | ||
1071 | Set_Corresponding_Integer_Value | |
1072 | (Type_High_Bound (Standard_Duration), Dhi); | |
1073 | ||
1074 | Set_Corresponding_Integer_Value | |
1075 | (Type_Low_Bound (Standard_Duration), Dlo); | |
1076 | ||
1077 | Set_Size_Known_At_Compile_Time (Standard_Duration); | |
1078 | end Build_Duration; | |
1079 | ||
1080 | -- Build standard exception type. Note that the type name here is | |
1081 | -- actually used in the generated code, so it must be set correctly | |
1082 | ||
1083 | Standard_Exception_Type := New_Standard_Entity; | |
1084 | Set_Ekind (Standard_Exception_Type, E_Record_Type); | |
1085 | Set_Etype (Standard_Exception_Type, Standard_Exception_Type); | |
1086 | Set_Scope (Standard_Exception_Type, Standard_Standard); | |
fbf5a39b | 1087 | Set_Stored_Constraint |
70482933 RK |
1088 | (Standard_Exception_Type, No_Elist); |
1089 | Init_Size_Align (Standard_Exception_Type); | |
1090 | Set_Size_Known_At_Compile_Time | |
1091 | (Standard_Exception_Type, True); | |
1092 | Make_Name (Standard_Exception_Type, "exception"); | |
1093 | ||
1094 | Make_Component (Standard_Exception_Type, Standard_Boolean, | |
1095 | "Not_Handled_By_Others"); | |
1096 | Make_Component (Standard_Exception_Type, Standard_Character, "Lang"); | |
1097 | Make_Component (Standard_Exception_Type, Standard_Natural, | |
1098 | "Name_Length"); | |
1099 | Make_Component (Standard_Exception_Type, Standard_A_Char, | |
1100 | "Full_Name"); | |
1101 | Make_Component (Standard_Exception_Type, Standard_A_Char, | |
1102 | "HTable_Ptr"); | |
1103 | Make_Component (Standard_Exception_Type, Standard_Integer, | |
1104 | "Import_Code"); | |
fbf5a39b AC |
1105 | Make_Component (Standard_Exception_Type, Standard_A_Char, |
1106 | "Raise_Hook"); | |
70482933 RK |
1107 | -- Build tree for record declaration, for use by the back-end. |
1108 | ||
1109 | declare | |
1110 | Comp_List : List_Id; | |
1111 | Comp : Entity_Id; | |
1112 | ||
1113 | begin | |
1114 | Comp := First_Entity (Standard_Exception_Type); | |
1115 | Comp_List := New_List; | |
1116 | ||
1117 | while Present (Comp) loop | |
1118 | Append ( | |
1119 | Make_Component_Declaration (Stloc, | |
1120 | Defining_Identifier => Comp, | |
1121 | Subtype_Indication => New_Occurrence_Of (Etype (Comp), Stloc)), | |
1122 | Comp_List); | |
1123 | ||
1124 | Next_Entity (Comp); | |
1125 | end loop; | |
1126 | ||
1127 | Decl := Make_Full_Type_Declaration (Stloc, | |
1128 | Defining_Identifier => Standard_Exception_Type, | |
1129 | Type_Definition => | |
1130 | Make_Record_Definition (Stloc, | |
1131 | End_Label => Empty, | |
1132 | Component_List => | |
1133 | Make_Component_List (Stloc, | |
1134 | Component_Items => Comp_List))); | |
1135 | end; | |
1136 | ||
1137 | Append (Decl, Decl_S); | |
1138 | ||
fbf5a39b AC |
1139 | Layout_Type (Standard_Exception_Type); |
1140 | ||
70482933 RK |
1141 | -- Create declarations of standard exceptions |
1142 | ||
1143 | Build_Exception (S_Constraint_Error); | |
1144 | Build_Exception (S_Program_Error); | |
1145 | Build_Exception (S_Storage_Error); | |
1146 | Build_Exception (S_Tasking_Error); | |
1147 | ||
1148 | -- Numeric_Error is a normal exception in Ada 83, but in Ada 95 | |
1149 | -- it is a renaming of Constraint_Error | |
1150 | ||
1151 | if Ada_83 then | |
1152 | Build_Exception (S_Numeric_Error); | |
1153 | ||
1154 | else | |
1155 | Decl := New_Node (N_Exception_Renaming_Declaration, Stloc); | |
1156 | E_Id := Standard_Entity (S_Numeric_Error); | |
1157 | ||
1158 | Set_Ekind (E_Id, E_Exception); | |
1159 | Set_Exception_Code (E_Id, Uint_0); | |
1160 | Set_Etype (E_Id, Standard_Exception_Type); | |
1161 | Set_Is_Public (E_Id); | |
1162 | Set_Renamed_Entity (E_Id, Standard_Entity (S_Constraint_Error)); | |
1163 | ||
1164 | Set_Defining_Identifier (Decl, E_Id); | |
1165 | Append (Decl, Decl_S); | |
1166 | ||
1167 | Ident_Node := New_Node (N_Identifier, Stloc); | |
1168 | Set_Chars (Ident_Node, Chars (Standard_Entity (S_Constraint_Error))); | |
1169 | Set_Entity (Ident_Node, Standard_Entity (S_Constraint_Error)); | |
1170 | Set_Name (Decl, Ident_Node); | |
1171 | end if; | |
1172 | ||
1173 | -- Abort_Signal is an entity that does not get made visible | |
1174 | ||
1175 | Abort_Signal := New_Standard_Entity; | |
1176 | Set_Chars (Abort_Signal, Name_uAbort_Signal); | |
1177 | Set_Ekind (Abort_Signal, E_Exception); | |
1178 | Set_Exception_Code (Abort_Signal, Uint_0); | |
1179 | Set_Etype (Abort_Signal, Standard_Exception_Type); | |
1180 | Set_Scope (Abort_Signal, Standard_Standard); | |
1181 | Set_Is_Public (Abort_Signal, True); | |
1182 | Decl := | |
1183 | Make_Exception_Declaration (Stloc, | |
1184 | Defining_Identifier => Abort_Signal); | |
1185 | ||
1186 | -- Create defining identifiers for shift operator entities. Note | |
1187 | -- that these entities are used only for marking shift operators | |
1188 | -- generated internally, and hence need no structure, just a name | |
1189 | -- and a unique identity. | |
1190 | ||
1191 | Standard_Op_Rotate_Left := New_Standard_Entity; | |
1192 | Set_Chars (Standard_Op_Rotate_Left, Name_Rotate_Left); | |
1193 | Set_Ekind (Standard_Op_Rotate_Left, E_Operator); | |
1194 | ||
1195 | Standard_Op_Rotate_Right := New_Standard_Entity; | |
1196 | Set_Chars (Standard_Op_Rotate_Right, Name_Rotate_Right); | |
1197 | Set_Ekind (Standard_Op_Rotate_Right, E_Operator); | |
1198 | ||
1199 | Standard_Op_Shift_Left := New_Standard_Entity; | |
1200 | Set_Chars (Standard_Op_Shift_Left, Name_Shift_Left); | |
1201 | Set_Ekind (Standard_Op_Shift_Left, E_Operator); | |
1202 | ||
1203 | Standard_Op_Shift_Right := New_Standard_Entity; | |
1204 | Set_Chars (Standard_Op_Shift_Right, Name_Shift_Right); | |
1205 | Set_Ekind (Standard_Op_Shift_Right, E_Operator); | |
1206 | ||
1207 | Standard_Op_Shift_Right_Arithmetic := New_Standard_Entity; | |
1208 | Set_Chars (Standard_Op_Shift_Right_Arithmetic, | |
1209 | Name_Shift_Right_Arithmetic); | |
1210 | Set_Ekind (Standard_Op_Shift_Right_Arithmetic, | |
1211 | E_Operator); | |
1212 | ||
1213 | -- Create standard operator declarations | |
1214 | ||
1215 | Create_Operators; | |
1216 | ||
1217 | -- Initialize visibility table with entities in Standard | |
1218 | ||
1219 | for E in Standard_Entity_Type loop | |
1220 | if Ekind (Standard_Entity (E)) /= E_Operator then | |
1221 | Set_Name_Entity_Id | |
1222 | (Chars (Standard_Entity (E)), Standard_Entity (E)); | |
1223 | Set_Homonym (Standard_Entity (E), Empty); | |
1224 | end if; | |
1225 | ||
1226 | if E not in S_ASCII_Names then | |
1227 | Set_Scope (Standard_Entity (E), Standard_Standard); | |
1228 | Set_Is_Immediately_Visible (Standard_Entity (E)); | |
1229 | end if; | |
1230 | end loop; | |
1231 | ||
1232 | -- The predefined package Standard itself does not have a scope; | |
1233 | -- it is the only entity in the system not to have one, and this | |
1234 | -- is what identifies the package to Gigi. | |
1235 | ||
1236 | Set_Scope (Standard_Standard, Empty); | |
1237 | ||
1238 | -- Set global variables indicating last Id values and version | |
1239 | ||
1240 | Last_Standard_Node_Id := Last_Node_Id; | |
1241 | Last_Standard_List_Id := Last_List_Id; | |
1242 | ||
5c736541 RD |
1243 | -- The Error node has an Etype of Any_Type to help error recovery |
1244 | ||
1245 | Set_Etype (Error, Any_Type); | |
70482933 RK |
1246 | end Create_Standard; |
1247 | ||
1248 | ------------------------------------ | |
1249 | -- Create_Unconstrained_Base_Type -- | |
1250 | ------------------------------------ | |
1251 | ||
1252 | procedure Create_Unconstrained_Base_Type | |
1253 | (E : Entity_Id; | |
1254 | K : Entity_Kind) | |
1255 | is | |
1256 | New_Ent : constant Entity_Id := New_Copy (E); | |
1257 | ||
1258 | begin | |
fbf5a39b AC |
1259 | Set_Ekind (E, K); |
1260 | Set_Is_Constrained (E, True); | |
1261 | Set_Is_First_Subtype (E, True); | |
1262 | Set_Etype (E, New_Ent); | |
70482933 RK |
1263 | |
1264 | Append_Entity (New_Ent, Standard_Standard); | |
1265 | Set_Is_Constrained (New_Ent, False); | |
1266 | Set_Etype (New_Ent, New_Ent); | |
1267 | Set_Is_Known_Valid (New_Ent, True); | |
1268 | ||
1269 | if K = E_Signed_Integer_Subtype then | |
1270 | Set_Etype (Low_Bound (Scalar_Range (E)), New_Ent); | |
1271 | Set_Etype (High_Bound (Scalar_Range (E)), New_Ent); | |
1272 | end if; | |
1273 | ||
1274 | end Create_Unconstrained_Base_Type; | |
1275 | ||
1276 | -------------------- | |
1277 | -- Identifier_For -- | |
1278 | -------------------- | |
1279 | ||
1280 | function Identifier_For (S : Standard_Entity_Type) return Node_Id is | |
1281 | Ident_Node : Node_Id; | |
1282 | ||
1283 | begin | |
1284 | Ident_Node := New_Node (N_Identifier, Stloc); | |
1285 | Set_Chars (Ident_Node, Chars (Standard_Entity (S))); | |
1286 | return Ident_Node; | |
1287 | end Identifier_For; | |
1288 | ||
1289 | -------------------- | |
1290 | -- Make_Component -- | |
1291 | -------------------- | |
1292 | ||
1293 | procedure Make_Component | |
1294 | (Rec : Entity_Id; | |
1295 | Typ : Entity_Id; | |
1296 | Nam : String) | |
1297 | is | |
fbf5a39b | 1298 | Id : constant Entity_Id := New_Standard_Entity; |
70482933 RK |
1299 | |
1300 | begin | |
1301 | Set_Ekind (Id, E_Component); | |
1302 | Set_Etype (Id, Typ); | |
1303 | Set_Scope (Id, Rec); | |
1304 | Init_Component_Location (Id); | |
1305 | ||
1306 | Set_Original_Record_Component (Id, Id); | |
1307 | Make_Name (Id, Nam); | |
1308 | Append_Entity (Id, Rec); | |
1309 | end Make_Component; | |
1310 | ||
1311 | ----------------- | |
1312 | -- Make_Formal -- | |
1313 | ----------------- | |
1314 | ||
1315 | function Make_Formal | |
1316 | (Typ : Entity_Id; | |
1317 | Formal_Name : String) | |
1318 | return Entity_Id | |
1319 | is | |
1320 | Formal : Entity_Id; | |
1321 | ||
1322 | begin | |
1323 | Formal := New_Standard_Entity; | |
1324 | ||
1325 | Set_Ekind (Formal, E_In_Parameter); | |
1326 | Set_Mechanism (Formal, Default_Mechanism); | |
1327 | Set_Scope (Formal, Standard_Standard); | |
1328 | Set_Etype (Formal, Typ); | |
1329 | Make_Name (Formal, Formal_Name); | |
1330 | ||
1331 | return Formal; | |
1332 | end Make_Formal; | |
1333 | ||
1334 | ------------------ | |
1335 | -- Make_Integer -- | |
1336 | ------------------ | |
1337 | ||
1338 | function Make_Integer (V : Uint) return Node_Id is | |
1339 | N : constant Node_Id := Make_Integer_Literal (Stloc, V); | |
1340 | ||
1341 | begin | |
1342 | Set_Is_Static_Expression (N); | |
1343 | return N; | |
1344 | end Make_Integer; | |
1345 | ||
1346 | --------------- | |
1347 | -- Make_Name -- | |
1348 | --------------- | |
1349 | ||
1350 | procedure Make_Name (Id : Entity_Id; Nam : String) is | |
1351 | begin | |
1352 | for J in 1 .. Nam'Length loop | |
1353 | Name_Buffer (J) := Fold_Lower (Nam (Nam'First + (J - 1))); | |
1354 | end loop; | |
1355 | ||
1356 | Name_Len := Nam'Length; | |
1357 | Set_Chars (Id, Name_Find); | |
1358 | end Make_Name; | |
1359 | ||
1360 | ------------------ | |
1361 | -- New_Operator -- | |
1362 | ------------------ | |
1363 | ||
1364 | function New_Operator (Op : Name_Id; Typ : Entity_Id) return Entity_Id is | |
1365 | Ident_Node : Entity_Id; | |
1366 | ||
1367 | begin | |
1368 | Ident_Node := Make_Defining_Identifier (Stloc, Op); | |
1369 | ||
1370 | Set_Is_Pure (Ident_Node, True); | |
1371 | Set_Ekind (Ident_Node, E_Operator); | |
1372 | Set_Etype (Ident_Node, Typ); | |
1373 | Set_Scope (Ident_Node, Standard_Standard); | |
1374 | Set_Homonym (Ident_Node, Get_Name_Entity_Id (Op)); | |
1375 | Set_Convention (Ident_Node, Convention_Intrinsic); | |
1376 | ||
1377 | Set_Is_Immediately_Visible (Ident_Node, True); | |
1378 | Set_Is_Intrinsic_Subprogram (Ident_Node, True); | |
1379 | ||
1380 | Set_Name_Entity_Id (Op, Ident_Node); | |
1381 | Append_Entity (Ident_Node, Standard_Standard); | |
1382 | return Ident_Node; | |
1383 | end New_Operator; | |
1384 | ||
1385 | ------------------------- | |
1386 | -- New_Standard_Entity -- | |
1387 | ------------------------- | |
1388 | ||
1389 | function New_Standard_Entity | |
1390 | (New_Node_Kind : Node_Kind := N_Defining_Identifier) | |
1391 | return Entity_Id | |
1392 | is | |
1393 | E : constant Entity_Id := New_Entity (New_Node_Kind, Stloc); | |
1394 | ||
1395 | begin | |
1396 | -- All standard entities are Pure and Public | |
1397 | ||
1398 | Set_Is_Pure (E); | |
1399 | Set_Is_Public (E); | |
1400 | ||
1401 | -- All standard entity names are analyzed manually, and are thus | |
1402 | -- frozen as soon as they are created. | |
1403 | ||
1404 | Set_Is_Frozen (E); | |
1405 | ||
1406 | -- Set debug information required for all standard types | |
1407 | ||
1408 | Set_Needs_Debug_Info (E); | |
1409 | ||
1410 | -- All standard entities are built with fully qualified names, so | |
1411 | -- set the flag to prevent an abortive attempt at requalification! | |
1412 | ||
1413 | Set_Has_Qualified_Name (E); | |
1414 | ||
1415 | -- Return newly created entity to be completed by caller | |
1416 | ||
1417 | return E; | |
1418 | end New_Standard_Entity; | |
1419 | ||
1420 | ---------------------- | |
1421 | -- Set_Float_Bounds -- | |
1422 | ---------------------- | |
1423 | ||
1424 | procedure Set_Float_Bounds (Id : Entity_Id) is | |
1425 | L : Node_Id; | |
1426 | -- Low bound of literal value | |
1427 | ||
1428 | H : Node_Id; | |
1429 | -- High bound of literal value | |
1430 | ||
1431 | R : Node_Id; | |
1432 | -- Range specification | |
1433 | ||
1434 | Digs : constant Nat := UI_To_Int (Digits_Value (Id)); | |
1435 | -- Digits value, used to select bounds | |
1436 | ||
1437 | begin | |
1438 | -- Note: for the call from Cstand to initially create the types in | |
1439 | -- Standard, Vax_Float will always be False. Circuitry in Sem_Vfpt | |
1440 | -- will adjust these types appropriately in the Vax_Float case if | |
1441 | -- a pragma Float_Representation (VAX_Float) is used. | |
1442 | ||
1443 | if Vax_Float (Id) then | |
1444 | if Digs = VAXFF_Digits then | |
1445 | L := Real_Convert | |
1446 | (VAXFF_First'Universal_Literal_String); | |
1447 | H := Real_Convert | |
1448 | (VAXFF_Last'Universal_Literal_String); | |
1449 | ||
1450 | elsif Digs = VAXDF_Digits then | |
1451 | L := Real_Convert | |
1452 | (VAXDF_First'Universal_Literal_String); | |
1453 | H := Real_Convert | |
1454 | (VAXDF_Last'Universal_Literal_String); | |
1455 | ||
1456 | else | |
1457 | pragma Assert (Digs = VAXGF_Digits); | |
1458 | ||
1459 | L := Real_Convert | |
1460 | (VAXGF_First'Universal_Literal_String); | |
1461 | H := Real_Convert | |
1462 | (VAXGF_Last'Universal_Literal_String); | |
1463 | end if; | |
1464 | ||
1465 | elsif Is_AAMP_Float (Id) then | |
1466 | if Digs = AAMPS_Digits then | |
1467 | L := Real_Convert | |
1468 | (AAMPS_First'Universal_Literal_String); | |
1469 | H := Real_Convert | |
1470 | (AAMPS_Last'Universal_Literal_String); | |
1471 | ||
1472 | else | |
1473 | pragma Assert (Digs = AAMPL_Digits); | |
1474 | L := Real_Convert | |
1475 | (AAMPL_First'Universal_Literal_String); | |
1476 | H := Real_Convert | |
1477 | (AAMPL_Last'Universal_Literal_String); | |
1478 | end if; | |
1479 | ||
1480 | elsif Digs = IEEES_Digits then | |
1481 | L := Real_Convert | |
1482 | (IEEES_First'Universal_Literal_String); | |
1483 | H := Real_Convert | |
1484 | (IEEES_Last'Universal_Literal_String); | |
1485 | ||
1486 | elsif Digs = IEEEL_Digits then | |
1487 | L := Real_Convert | |
1488 | (IEEEL_First'Universal_Literal_String); | |
1489 | H := Real_Convert | |
1490 | (IEEEL_Last'Universal_Literal_String); | |
1491 | ||
1492 | else | |
1493 | pragma Assert (Digs = IEEEX_Digits); | |
1494 | ||
1495 | L := Real_Convert | |
1496 | (IEEEX_First'Universal_Literal_String); | |
1497 | H := Real_Convert | |
1498 | (IEEEX_Last'Universal_Literal_String); | |
1499 | end if; | |
1500 | ||
1501 | Set_Etype (L, Id); | |
1502 | Set_Is_Static_Expression (L); | |
1503 | ||
1504 | Set_Etype (H, Id); | |
1505 | Set_Is_Static_Expression (H); | |
1506 | ||
1507 | R := New_Node (N_Range, Stloc); | |
1508 | Set_Low_Bound (R, L); | |
1509 | Set_High_Bound (R, H); | |
1510 | Set_Includes_Infinities (R, True); | |
1511 | Set_Scalar_Range (Id, R); | |
1512 | Set_Etype (R, Id); | |
1513 | Set_Parent (R, Id); | |
1514 | end Set_Float_Bounds; | |
1515 | ||
1516 | ------------------------ | |
1517 | -- Set_Integer_Bounds -- | |
1518 | ------------------------ | |
1519 | ||
1520 | procedure Set_Integer_Bounds | |
1521 | (Id : Entity_Id; | |
1522 | Typ : Entity_Id; | |
1523 | Lb : Uint; | |
1524 | Hb : Uint) | |
1525 | is | |
1526 | L : Node_Id; -- Low bound of literal value | |
1527 | H : Node_Id; -- High bound of literal value | |
1528 | R : Node_Id; -- Range specification | |
1529 | ||
1530 | begin | |
1531 | L := Make_Integer (Lb); | |
1532 | H := Make_Integer (Hb); | |
1533 | ||
1534 | Set_Etype (L, Typ); | |
1535 | Set_Etype (H, Typ); | |
1536 | ||
1537 | R := New_Node (N_Range, Stloc); | |
1538 | Set_Low_Bound (R, L); | |
1539 | Set_High_Bound (R, H); | |
1540 | Set_Scalar_Range (Id, R); | |
1541 | Set_Etype (R, Typ); | |
1542 | Set_Parent (R, Id); | |
1543 | Set_Is_Unsigned_Type (Id, Lb >= 0); | |
1544 | end Set_Integer_Bounds; | |
1545 | ||
1546 | end CStand; |