]>
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 | -- -- | |
1d005acc | 9 | -- Copyright (C) 1992-2019, 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- -- | |
b5c84c3c | 13 | -- ware Foundation; either version 3, or (at your option) any later ver- -- |
70482933 RK |
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 -- | |
b5c84c3c RD |
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. -- | |
70482933 RK |
20 | -- -- |
21 | -- GNAT was originally developed by the GNAT team at New York University. -- | |
71ff80dc | 22 | -- Extensive contributions were provided by Ada Core Technologies Inc. -- |
70482933 RK |
23 | -- -- |
24 | ------------------------------------------------------------------------------ | |
25 | ||
26 | with Atree; use Atree; | |
27 | with Csets; use Csets; | |
28 | with Debug; use Debug; | |
29 | with Einfo; use Einfo; | |
70c34e1c | 30 | with Elists; use Elists; |
70482933 RK |
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; | |
9596236a | 36 | with Output; use Output; |
289a994b | 37 | with Set_Targ; use Set_Targ; |
fbf5a39b | 38 | with Targparm; use Targparm; |
70482933 RK |
39 | with Tbuild; use Tbuild; |
40 | with Ttypes; use Ttypes; | |
70482933 RK |
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; | |
48 | ||
49 | package body CStand is | |
50 | ||
51 | Stloc : constant Source_Ptr := Standard_Location; | |
52 | Staloc : constant Source_Ptr := Standard_ASCII_Location; | |
53 | -- Standard abbreviations used throughout this package | |
54 | ||
70c34e1c | 55 | Back_End_Float_Types : Elist_Id := No_Elist; |
f8726f2b AC |
56 | -- List used for any floating point supported by the back end. This needs |
57 | -- to be at the library level, because the call back procedures retrieving | |
58 | -- this information are at that level. | |
59 | ||
70482933 RK |
60 | ----------------------- |
61 | -- Local Subprograms -- | |
62 | ----------------------- | |
63 | ||
f8726f2b | 64 | procedure Build_Float_Type |
2e60feb5 PMR |
65 | (E : Entity_Id; |
66 | Digs : Int; | |
67 | Rep : Float_Rep_Kind; | |
68 | Siz : Int; | |
69 | Align : Int); | |
70482933 | 70 | -- Procedure to build standard predefined float base type. The first |
2e60feb5 PMR |
71 | -- parameter is the entity for the type. The second parameter is the |
72 | -- digits value. The third parameter indicates the representation to | |
73 | -- be used for the type. The fourth parameter is the size in bits. | |
74 | -- The fifth parameter is the alignment in storage units. Each type | |
f8726f2b | 75 | -- is added to the list of predefined floating point types. |
2e60feb5 PMR |
76 | -- |
77 | -- Note that both RM_Size and Esize are set to the specified size, i.e. | |
78 | -- we do not set the RM_Size to the precision passed by the back end. | |
79 | -- This is consistent with the semantics of 'Size specified in the RM | |
80 | -- because we cannot pack components of the type tighter than this size. | |
70482933 | 81 | |
2c9f8c0a | 82 | procedure Build_Signed_Integer_Type (E : Entity_Id; Siz : Nat); |
70482933 RK |
83 | -- Procedure to build standard predefined signed integer subtype. The |
84 | -- first parameter is the entity for the subtype. The second parameter | |
85 | -- is the size in bits. The corresponding base type is not built by | |
86 | -- this routine but instead must be built by the caller where needed. | |
87 | ||
2c9f8c0a AC |
88 | procedure Build_Unsigned_Integer_Type |
89 | (Uns : Entity_Id; | |
90 | Siz : Nat; | |
91 | Nam : String); | |
92 | -- Procedure to build standard predefined unsigned integer subtype. These | |
93 | -- subtypes are not user visible, but they are used internally. The first | |
94 | -- parameter is the entity for the subtype. The second parameter is the | |
95 | -- size in bits. The third parameter is an identifying name. | |
96 | ||
f8726f2b AC |
97 | procedure Copy_Float_Type (To : Entity_Id; From : Entity_Id); |
98 | -- Build a floating point type, copying representation details from From. | |
99 | -- This is used to create predefined floating point types based on | |
100 | -- available types in the back end. | |
101 | ||
70482933 RK |
102 | procedure Create_Operators; |
103 | -- Make entries for each of the predefined operators in Standard | |
104 | ||
105 | procedure Create_Unconstrained_Base_Type | |
106 | (E : Entity_Id; | |
107 | K : Entity_Kind); | |
108 | -- The predefined signed integer types are constrained subtypes which | |
109 | -- must have a corresponding unconstrained base type. This type is almost | |
110 | -- useless. The only place it has semantics is Subtypes_Statically_Match. | |
111 | -- Consequently, we arrange for it to be identical apart from the setting | |
112 | -- of the constrained bit. This routine takes an entity E for the Type, | |
113 | -- copies it to estabish the base type, then resets the Ekind of the | |
114 | -- original entity to K (the Ekind for the subtype). The Etype field of | |
115 | -- E is set by the call (to point to the created base type entity), and | |
116 | -- also the Is_Constrained flag of E is set. | |
117 | -- | |
118 | -- To understand the exact requirement for this, see RM 3.5.4(11) which | |
119 | -- makes it clear that Integer, for example, is constrained, with the | |
120 | -- constraint bounds matching the bounds of the (unconstrained) base | |
121 | -- type. The point is that Integer and Integer'Base have identical | |
122 | -- bounds, but do not statically match, since a subtype with constraints | |
123 | -- never matches a subtype with no constraints. | |
124 | ||
f8726f2b AC |
125 | function Find_Back_End_Float_Type (Name : String) return Entity_Id; |
126 | -- Return the first float type in Back_End_Float_Types with the given name. | |
127 | -- Names of entities in back end types, are either type names of C | |
128 | -- predefined types (all lower case), or mode names (upper case). | |
129 | -- These are not generally valid identifier names. | |
130 | ||
70482933 RK |
131 | function Identifier_For (S : Standard_Entity_Type) return Node_Id; |
132 | -- Returns an identifier node with the same name as the defining | |
133 | -- identifier corresponding to the given Standard_Entity_Type value | |
134 | ||
135 | procedure Make_Component | |
136 | (Rec : Entity_Id; | |
137 | Typ : Entity_Id; | |
138 | Nam : String); | |
139 | -- Build a record component with the given type and name, and append to | |
140 | -- the list of components of Rec. | |
141 | ||
142 | function Make_Formal | |
143 | (Typ : Entity_Id; | |
891a6e79 | 144 | Formal_Name : String) return Entity_Id; |
70482933 RK |
145 | -- Construct entity for subprogram formal with given name and type |
146 | ||
147 | function Make_Integer (V : Uint) return Node_Id; | |
148 | -- Builds integer literal with given value | |
149 | ||
150 | procedure Make_Name (Id : Entity_Id; Nam : String); | |
151 | -- Make an entry in the names table for Nam, and set as Chars field of Id | |
152 | ||
153 | function New_Operator (Op : Name_Id; Typ : Entity_Id) return Entity_Id; | |
a2cb348e | 154 | -- Build entity for standard operator with given name and type |
70482933 RK |
155 | |
156 | function New_Standard_Entity | |
891a6e79 | 157 | (New_Node_Kind : Node_Kind := N_Defining_Identifier) return Entity_Id; |
70482933 RK |
158 | -- Builds a new entity for Standard |
159 | ||
41a58113 RD |
160 | function New_Standard_Entity (S : String) return Entity_Id; |
161 | -- Builds a new entity for Standard with Nkind = N_Defining_Identifier, | |
162 | -- and Chars of this defining identifier set to the given string S. | |
163 | ||
9596236a AC |
164 | procedure Print_Standard; |
165 | -- Print representation of package Standard if switch set | |
166 | ||
f8726f2b | 167 | procedure Register_Float_Type |
289a994b AC |
168 | (Name : String; |
169 | Digs : Positive; | |
170 | Float_Rep : Float_Rep_Kind; | |
00c5acd3 | 171 | Precision : Positive; |
289a994b AC |
172 | Size : Positive; |
173 | Alignment : Natural); | |
174 | -- Registers a single back end floating-point type (from FPT_Mode_Table in | |
175 | -- Set_Targ). This will create a predefined floating-point base type for | |
176 | -- one of the floating point types reported by the back end, and add it | |
177 | -- to the list of predefined float types. Name is the name of the type | |
178 | -- as a normal format (non-null-terminated) string. Digs is the number of | |
179 | -- digits, which is always non-zero, since non-floating-point types were | |
180 | -- filtered out earlier. Float_Rep indicates the kind of floating-point | |
00c5acd3 EB |
181 | -- type, and Precision, Size and Alignment are the precision, size and |
182 | -- alignment in bits. | |
f8726f2b | 183 | |
70482933 RK |
184 | procedure Set_Integer_Bounds |
185 | (Id : Entity_Id; | |
186 | Typ : Entity_Id; | |
187 | Lb : Uint; | |
188 | Hb : Uint); | |
189 | -- Procedure to set bounds for integer type or subtype. Id is the entity | |
190 | -- whose bounds and type are to be set. The Typ parameter is the Etype | |
191 | -- value for the entity (which will be the same as Id for all predefined | |
192 | -- integer base types. The third and fourth parameters are the bounds. | |
193 | ||
194 | ---------------------- | |
195 | -- Build_Float_Type -- | |
196 | ---------------------- | |
197 | ||
f8726f2b | 198 | procedure Build_Float_Type |
2e60feb5 PMR |
199 | (E : Entity_Id; |
200 | Digs : Int; | |
201 | Rep : Float_Rep_Kind; | |
202 | Siz : Int; | |
203 | Align : Int) | |
f8726f2b | 204 | is |
70482933 RK |
205 | begin |
206 | Set_Type_Definition (Parent (E), | |
207 | Make_Floating_Point_Definition (Stloc, | |
208 | Digits_Expression => Make_Integer (UI_From_Int (Digs)))); | |
23c799b1 | 209 | |
70482933 RK |
210 | Set_Ekind (E, E_Floating_Point_Type); |
211 | Set_Etype (E, E); | |
70482933 | 212 | Init_Digits_Value (E, Digs); |
2e60feb5 PMR |
213 | Set_Float_Rep (E, Rep); |
214 | Init_Size (E, Siz); | |
92b751fd | 215 | Set_Elem_Alignment (E, Align); |
70482933 RK |
216 | Set_Float_Bounds (E); |
217 | Set_Is_Frozen (E); | |
218 | Set_Is_Public (E); | |
219 | Set_Size_Known_At_Compile_Time (E); | |
220 | end Build_Float_Type; | |
221 | ||
ded8909b | 222 | ------------------------------ |
f8726f2b | 223 | -- Find_Back_End_Float_Type -- |
ded8909b | 224 | ------------------------------ |
f8726f2b AC |
225 | |
226 | function Find_Back_End_Float_Type (Name : String) return Entity_Id is | |
ded8909b | 227 | N : Elmt_Id; |
f8726f2b AC |
228 | |
229 | begin | |
ded8909b | 230 | N := First_Elmt (Back_End_Float_Types); |
70c34e1c AC |
231 | while Present (N) and then Get_Name_String (Chars (Node (N))) /= Name |
232 | loop | |
233 | Next_Elmt (N); | |
f8726f2b AC |
234 | end loop; |
235 | ||
70c34e1c | 236 | return Node (N); |
f8726f2b AC |
237 | end Find_Back_End_Float_Type; |
238 | ||
70482933 RK |
239 | ------------------------------- |
240 | -- Build_Signed_Integer_Type -- | |
241 | ------------------------------- | |
242 | ||
2c9f8c0a | 243 | procedure Build_Signed_Integer_Type (E : Entity_Id; Siz : Nat) is |
70482933 RK |
244 | U2Siz1 : constant Uint := 2 ** (Siz - 1); |
245 | Lbound : constant Uint := -U2Siz1; | |
246 | Ubound : constant Uint := U2Siz1 - 1; | |
247 | ||
248 | begin | |
249 | Set_Type_Definition (Parent (E), | |
250 | Make_Signed_Integer_Type_Definition (Stloc, | |
251 | Low_Bound => Make_Integer (Lbound), | |
252 | High_Bound => Make_Integer (Ubound))); | |
253 | ||
254 | Set_Ekind (E, E_Signed_Integer_Type); | |
255 | Set_Etype (E, E); | |
256 | Init_Size (E, Siz); | |
15ce9ca2 | 257 | Set_Elem_Alignment (E); |
70482933 RK |
258 | Set_Integer_Bounds (E, E, Lbound, Ubound); |
259 | Set_Is_Frozen (E); | |
260 | Set_Is_Public (E); | |
261 | Set_Is_Known_Valid (E); | |
262 | Set_Size_Known_At_Compile_Time (E); | |
263 | end Build_Signed_Integer_Type; | |
264 | ||
2c9f8c0a AC |
265 | --------------------------------- |
266 | -- Build_Unsigned_Integer_Type -- | |
267 | --------------------------------- | |
268 | ||
269 | procedure Build_Unsigned_Integer_Type | |
270 | (Uns : Entity_Id; | |
271 | Siz : Nat; | |
272 | Nam : String) | |
273 | is | |
274 | Decl : Node_Id; | |
275 | R_Node : Node_Id; | |
276 | ||
277 | begin | |
278 | Decl := New_Node (N_Full_Type_Declaration, Stloc); | |
279 | Set_Defining_Identifier (Decl, Uns); | |
280 | Make_Name (Uns, Nam); | |
281 | ||
282 | Set_Ekind (Uns, E_Modular_Integer_Type); | |
283 | Set_Scope (Uns, Standard_Standard); | |
284 | Set_Etype (Uns, Uns); | |
285 | Init_Size (Uns, Siz); | |
286 | Set_Elem_Alignment (Uns); | |
287 | Set_Modulus (Uns, Uint_2 ** Siz); | |
288 | Set_Is_Unsigned_Type (Uns); | |
289 | Set_Size_Known_At_Compile_Time (Uns); | |
290 | Set_Is_Known_Valid (Uns, True); | |
291 | ||
292 | R_Node := New_Node (N_Range, Stloc); | |
293 | Set_Low_Bound (R_Node, Make_Integer (Uint_0)); | |
294 | Set_High_Bound (R_Node, Make_Integer (Modulus (Uns) - 1)); | |
295 | Set_Etype (Low_Bound (R_Node), Uns); | |
296 | Set_Etype (High_Bound (R_Node), Uns); | |
297 | Set_Scalar_Range (Uns, R_Node); | |
298 | end Build_Unsigned_Integer_Type; | |
299 | ||
f8726f2b AC |
300 | --------------------- |
301 | -- Copy_Float_Type -- | |
302 | --------------------- | |
303 | ||
304 | procedure Copy_Float_Type (To : Entity_Id; From : Entity_Id) is | |
305 | begin | |
2e60feb5 PMR |
306 | Build_Float_Type |
307 | (To, UI_To_Int (Digits_Value (From)), Float_Rep (From), | |
308 | UI_To_Int (Esize (From)), UI_To_Int (Alignment (From))); | |
f8726f2b AC |
309 | end Copy_Float_Type; |
310 | ||
70482933 RK |
311 | ---------------------- |
312 | -- Create_Operators -- | |
313 | ---------------------- | |
314 | ||
315 | -- Each operator has an abbreviated signature. The formals have the names | |
316 | -- LEFT and RIGHT. Their types are not actually used for resolution. | |
317 | ||
318 | procedure Create_Operators is | |
319 | Op_Node : Entity_Id; | |
320 | ||
87b3f81f AC |
321 | -- The following tables define the binary and unary operators and their |
322 | -- corresponding result type. | |
70482933 RK |
323 | |
324 | Binary_Ops : constant array (S_Binary_Ops) of Name_Id := | |
87b3f81f AC |
325 | |
326 | -- There is one entry here for each binary operator, except for the | |
82c80734 RD |
327 | -- case of concatenation, where there are three entries, one for a |
328 | -- String result, one for Wide_String, and one for Wide_Wide_String. | |
87b3f81f AC |
329 | |
330 | (Name_Op_Add, | |
331 | Name_Op_And, | |
332 | Name_Op_Concat, | |
333 | Name_Op_Concat, | |
82c80734 | 334 | Name_Op_Concat, |
87b3f81f AC |
335 | Name_Op_Divide, |
336 | Name_Op_Eq, | |
337 | Name_Op_Expon, | |
338 | Name_Op_Ge, | |
339 | Name_Op_Gt, | |
340 | Name_Op_Le, | |
341 | Name_Op_Lt, | |
342 | Name_Op_Mod, | |
343 | Name_Op_Multiply, | |
344 | Name_Op_Ne, | |
345 | Name_Op_Or, | |
346 | Name_Op_Rem, | |
347 | Name_Op_Subtract, | |
348 | Name_Op_Xor); | |
70482933 RK |
349 | |
350 | Bin_Op_Types : constant array (S_Binary_Ops) of Entity_Id := | |
87b3f81f AC |
351 | |
352 | -- This table has the corresponding result types. The entries are | |
353 | -- ordered so they correspond to the Binary_Ops array above. | |
354 | ||
82c80734 RD |
355 | (Universal_Integer, -- Add |
356 | Standard_Boolean, -- And | |
357 | Standard_String, -- Concat (String) | |
358 | Standard_Wide_String, -- Concat (Wide_String) | |
359 | Standard_Wide_Wide_String, -- Concat (Wide_Wide_String) | |
360 | Universal_Integer, -- Divide | |
361 | Standard_Boolean, -- Eq | |
362 | Universal_Integer, -- Expon | |
363 | Standard_Boolean, -- Ge | |
364 | Standard_Boolean, -- Gt | |
365 | Standard_Boolean, -- Le | |
366 | Standard_Boolean, -- Lt | |
367 | Universal_Integer, -- Mod | |
368 | Universal_Integer, -- Multiply | |
369 | Standard_Boolean, -- Ne | |
370 | Standard_Boolean, -- Or | |
371 | Universal_Integer, -- Rem | |
372 | Universal_Integer, -- Subtract | |
373 | Standard_Boolean); -- Xor | |
70482933 RK |
374 | |
375 | Unary_Ops : constant array (S_Unary_Ops) of Name_Id := | |
87b3f81f AC |
376 | |
377 | -- There is one entry here for each unary operator | |
378 | ||
379 | (Name_Op_Abs, | |
380 | Name_Op_Subtract, | |
381 | Name_Op_Not, | |
382 | Name_Op_Add); | |
70482933 RK |
383 | |
384 | Unary_Op_Types : constant array (S_Unary_Ops) of Entity_Id := | |
70482933 | 385 | |
87b3f81f AC |
386 | -- This table has the corresponding result types. The entries are |
387 | -- ordered so they correspond to the Unary_Ops array above. | |
388 | ||
389 | (Universal_Integer, -- Abs | |
390 | Universal_Integer, -- Subtract | |
391 | Standard_Boolean, -- Not | |
392 | Universal_Integer); -- Add | |
70482933 RK |
393 | |
394 | begin | |
395 | for J in S_Binary_Ops loop | |
396 | Op_Node := New_Operator (Binary_Ops (J), Bin_Op_Types (J)); | |
397 | SE (J) := Op_Node; | |
398 | Append_Entity (Make_Formal (Any_Type, "LEFT"), Op_Node); | |
399 | Append_Entity (Make_Formal (Any_Type, "RIGHT"), Op_Node); | |
400 | end loop; | |
401 | ||
402 | for J in S_Unary_Ops loop | |
403 | Op_Node := New_Operator (Unary_Ops (J), Unary_Op_Types (J)); | |
404 | SE (J) := Op_Node; | |
405 | Append_Entity (Make_Formal (Any_Type, "RIGHT"), Op_Node); | |
406 | end loop; | |
407 | ||
408 | -- For concatenation, we create a separate operator for each | |
409 | -- array type. This simplifies the resolution of the component- | |
410 | -- component concatenation operation. In Standard, we set the types | |
82c80734 | 411 | -- of the formals for string, wide [wide]_string, concatenations. |
70482933 RK |
412 | |
413 | Set_Etype (First_Entity (Standard_Op_Concat), Standard_String); | |
414 | Set_Etype (Last_Entity (Standard_Op_Concat), Standard_String); | |
415 | ||
416 | Set_Etype (First_Entity (Standard_Op_Concatw), Standard_Wide_String); | |
417 | Set_Etype (Last_Entity (Standard_Op_Concatw), Standard_Wide_String); | |
82c80734 RD |
418 | |
419 | Set_Etype (First_Entity (Standard_Op_Concatww), | |
879e23f0 | 420 | Standard_Wide_Wide_String); |
82c80734 RD |
421 | |
422 | Set_Etype (Last_Entity (Standard_Op_Concatww), | |
879e23f0 | 423 | Standard_Wide_Wide_String); |
70482933 RK |
424 | end Create_Operators; |
425 | ||
426 | --------------------- | |
427 | -- Create_Standard -- | |
428 | --------------------- | |
429 | ||
430 | -- The tree for the package Standard is prefixed to all compilations. | |
431 | -- Several entities required by semantic analysis are denoted by global | |
f8726f2b AC |
432 | -- variables that are initialized to point to the corresponding occurrences |
433 | -- in Standard. The visible entities of Standard are created here. Special | |
434 | -- entities maybe created here as well or may be created from the semantics | |
435 | -- module. By not adding them to the Decls list of Standard they will not | |
436 | -- be visible to Ada programs. | |
70482933 RK |
437 | |
438 | procedure Create_Standard is | |
91b1417d | 439 | Decl_S : constant List_Id := New_List; |
70482933 RK |
440 | -- List of declarations in Standard |
441 | ||
91b1417d | 442 | Decl_A : constant List_Id := New_List; |
70482933 RK |
443 | -- List of declarations in ASCII |
444 | ||
445 | Decl : Node_Id; | |
446 | Pspec : Node_Id; | |
447 | Tdef_Node : Node_Id; | |
448 | Ident_Node : Node_Id; | |
449 | Ccode : Char_Code; | |
450 | E_Id : Entity_Id; | |
451 | R_Node : Node_Id; | |
452 | B_Node : Node_Id; | |
453 | ||
454 | procedure Build_Exception (S : Standard_Entity_Type); | |
455 | -- Procedure to declare given entity as an exception | |
456 | ||
f8726f2b AC |
457 | procedure Create_Back_End_Float_Types; |
458 | -- Initialize the Back_End_Float_Types list by having the back end | |
459 | -- enumerate all available types and building type entities for them. | |
460 | ||
461 | procedure Create_Float_Types; | |
462 | -- Creates entities for all predefined floating point types, and | |
463 | -- adds these to the Predefined_Float_Types list in package Standard. | |
464 | ||
f8c79ade AC |
465 | procedure Make_Dummy_Index (E : Entity_Id); |
466 | -- Called to provide a dummy index field value for Any_Array/Any_String | |
467 | ||
17bb3f18 | 468 | procedure Pack_String_Type (String_Type : Entity_Id); |
5b599df4 AC |
469 | -- Generate proper tree for pragma Pack that applies to given type, and |
470 | -- mark type as having the pragma. | |
17bb3f18 | 471 | |
70482933 RK |
472 | --------------------- |
473 | -- Build_Exception -- | |
474 | --------------------- | |
475 | ||
476 | procedure Build_Exception (S : Standard_Entity_Type) is | |
477 | begin | |
ea0c8cfb RD |
478 | Set_Ekind (Standard_Entity (S), E_Exception); |
479 | Set_Etype (Standard_Entity (S), Standard_Exception_Type); | |
480 | Set_Is_Public (Standard_Entity (S), True); | |
70482933 RK |
481 | |
482 | Decl := | |
483 | Make_Exception_Declaration (Stloc, | |
484 | Defining_Identifier => Standard_Entity (S)); | |
485 | Append (Decl, Decl_S); | |
486 | end Build_Exception; | |
487 | ||
289a994b | 488 | --------------------------------- |
f8726f2b | 489 | -- Create_Back_End_Float_Types -- |
289a994b | 490 | --------------------------------- |
f8726f2b AC |
491 | |
492 | procedure Create_Back_End_Float_Types is | |
493 | begin | |
289a994b AC |
494 | for J in 1 .. Num_FPT_Modes loop |
495 | declare | |
496 | E : FPT_Mode_Entry renames FPT_Mode_Table (J); | |
497 | begin | |
498 | Register_Float_Type | |
00c5acd3 EB |
499 | (E.NAME.all, E.DIGS, E.FLOAT_REP, E.PRECISION, E.SIZE, |
500 | E.ALIGNMENT); | |
289a994b AC |
501 | end; |
502 | end loop; | |
f8726f2b AC |
503 | end Create_Back_End_Float_Types; |
504 | ||
505 | ------------------------ | |
506 | -- Create_Float_Types -- | |
507 | ------------------------ | |
508 | ||
509 | procedure Create_Float_Types is | |
510 | begin | |
511 | -- Create type definition nodes for predefined float types | |
512 | ||
df177175 RD |
513 | Copy_Float_Type |
514 | (Standard_Short_Float, | |
72eaa365 | 515 | Find_Back_End_Float_Type (C_Type_For (S_Short_Float))); |
df177175 | 516 | Set_Is_Implementation_Defined (Standard_Short_Float); |
f8726f2b AC |
517 | |
518 | Copy_Float_Type (Standard_Float, Standard_Short_Float); | |
519 | ||
72eaa365 AC |
520 | Copy_Float_Type |
521 | (Standard_Long_Float, | |
522 | Find_Back_End_Float_Type (C_Type_For (S_Long_Float))); | |
523 | ||
524 | Copy_Float_Type | |
525 | (Standard_Long_Long_Float, | |
526 | Find_Back_End_Float_Type (C_Type_For (S_Long_Long_Float))); | |
527 | Set_Is_Implementation_Defined (Standard_Long_Long_Float); | |
f8726f2b | 528 | |
70c34e1c | 529 | Predefined_Float_Types := New_Elmt_List; |
72eaa365 | 530 | |
70c34e1c AC |
531 | Append_Elmt (Standard_Short_Float, Predefined_Float_Types); |
532 | Append_Elmt (Standard_Float, Predefined_Float_Types); | |
533 | Append_Elmt (Standard_Long_Float, Predefined_Float_Types); | |
72eaa365 | 534 | Append_Elmt (Standard_Long_Long_Float, Predefined_Float_Types); |
f8726f2b | 535 | |
70c34e1c AC |
536 | -- Any other back end types are appended at the end of the list of |
537 | -- predefined float types, and will only be selected if the none of | |
538 | -- the types in Standard is suitable, or if a specific named type is | |
539 | -- requested through a pragma Import. | |
540 | ||
541 | while not Is_Empty_Elmt_List (Back_End_Float_Types) loop | |
542 | declare | |
543 | E : constant Elmt_Id := First_Elmt (Back_End_Float_Types); | |
544 | begin | |
545 | Append_Elmt (Node (E), To => Predefined_Float_Types); | |
546 | Remove_Elmt (Back_End_Float_Types, E); | |
547 | end; | |
548 | end loop; | |
f8726f2b AC |
549 | end Create_Float_Types; |
550 | ||
f8c79ade AC |
551 | ---------------------- |
552 | -- Make_Dummy_Index -- | |
553 | ---------------------- | |
554 | ||
555 | procedure Make_Dummy_Index (E : Entity_Id) is | |
556 | Index : Node_Id; | |
557 | Dummy : List_Id; | |
558 | ||
559 | begin | |
560 | Index := | |
561 | Make_Range (Sloc (E), | |
562 | Low_Bound => Make_Integer (Uint_0), | |
563 | High_Bound => Make_Integer (Uint_2 ** Standard_Integer_Size)); | |
564 | Set_Etype (Index, Standard_Integer); | |
565 | Set_First_Index (E, Index); | |
566 | ||
567 | -- Make sure Index is a list as required, so Next_Index is Empty | |
568 | ||
569 | Dummy := New_List (Index); | |
570 | end Make_Dummy_Index; | |
571 | ||
17bb3f18 RD |
572 | ---------------------- |
573 | -- Pack_String_Type -- | |
574 | ---------------------- | |
575 | ||
576 | procedure Pack_String_Type (String_Type : Entity_Id) is | |
577 | Prag : constant Node_Id := | |
15f0f591 AC |
578 | Make_Pragma (Stloc, |
579 | Chars => Name_Pack, | |
580 | Pragma_Argument_Associations => | |
581 | New_List ( | |
582 | Make_Pragma_Argument_Association (Stloc, | |
583 | Expression => New_Occurrence_Of (String_Type, Stloc)))); | |
17bb3f18 RD |
584 | begin |
585 | Append (Prag, Decl_S); | |
586 | Record_Rep_Item (String_Type, Prag); | |
5b599df4 | 587 | Set_Has_Pragma_Pack (String_Type, True); |
17bb3f18 RD |
588 | end Pack_String_Type; |
589 | ||
70482933 RK |
590 | -- Start of processing for Create_Standard |
591 | ||
592 | begin | |
70482933 RK |
593 | -- First step is to create defining identifiers for each entity |
594 | ||
595 | for S in Standard_Entity_Type loop | |
596 | declare | |
597 | S_Name : constant String := Standard_Entity_Type'Image (S); | |
598 | -- Name of entity (note we skip S_ at the start) | |
599 | ||
600 | Ident_Node : Node_Id; | |
601 | -- Defining identifier node | |
602 | ||
603 | begin | |
604 | Ident_Node := New_Standard_Entity; | |
605 | Make_Name (Ident_Node, S_Name (3 .. S_Name'Length)); | |
606 | Standard_Entity (S) := Ident_Node; | |
607 | end; | |
608 | end loop; | |
609 | ||
610 | -- Create package declaration node for package Standard | |
611 | ||
612 | Standard_Package_Node := New_Node (N_Package_Declaration, Stloc); | |
613 | ||
614 | Pspec := New_Node (N_Package_Specification, Stloc); | |
615 | Set_Specification (Standard_Package_Node, Pspec); | |
616 | ||
617 | Set_Defining_Unit_Name (Pspec, Standard_Standard); | |
618 | Set_Visible_Declarations (Pspec, Decl_S); | |
619 | ||
620 | Set_Ekind (Standard_Standard, E_Package); | |
621 | Set_Is_Pure (Standard_Standard); | |
622 | Set_Is_Compilation_Unit (Standard_Standard); | |
623 | ||
454a86dc | 624 | -- Create type/subtype declaration nodes for standard types |
70482933 RK |
625 | |
626 | for S in S_Types loop | |
454a86dc RD |
627 | |
628 | -- Subtype declaration case | |
629 | ||
630 | if S = S_Natural or else S = S_Positive then | |
631 | Decl := New_Node (N_Subtype_Declaration, Stloc); | |
632 | Set_Subtype_Indication (Decl, | |
633 | New_Occurrence_Of (Standard_Integer, Stloc)); | |
634 | ||
635 | -- Full type declaration case | |
636 | ||
637 | else | |
638 | Decl := New_Node (N_Full_Type_Declaration, Stloc); | |
639 | end if; | |
640 | ||
70482933 RK |
641 | Set_Is_Frozen (Standard_Entity (S)); |
642 | Set_Is_Public (Standard_Entity (S)); | |
454a86dc | 643 | Set_Defining_Identifier (Decl, Standard_Entity (S)); |
70482933 RK |
644 | Append (Decl, Decl_S); |
645 | end loop; | |
646 | ||
f8726f2b AC |
647 | Create_Back_End_Float_Types; |
648 | ||
70482933 RK |
649 | -- Create type definition node for type Boolean. The Size is set to |
650 | -- 1 as required by Ada 95 and current ARG interpretations for Ada/83. | |
651 | ||
652 | -- Note: Object_Size of Boolean is 8. This means that we do NOT in | |
653 | -- general know that Boolean variables have valid values, so we do | |
654 | -- not set the Is_Known_Valid flag. | |
655 | ||
656 | Tdef_Node := New_Node (N_Enumeration_Type_Definition, Stloc); | |
657 | Set_Literals (Tdef_Node, New_List); | |
658 | Append (Standard_False, Literals (Tdef_Node)); | |
659 | Append (Standard_True, Literals (Tdef_Node)); | |
660 | Set_Type_Definition (Parent (Standard_Boolean), Tdef_Node); | |
661 | ||
662 | Set_Ekind (Standard_Boolean, E_Enumeration_Type); | |
663 | Set_First_Literal (Standard_Boolean, Standard_False); | |
664 | Set_Etype (Standard_Boolean, Standard_Boolean); | |
07fc65c4 | 665 | Init_Esize (Standard_Boolean, Standard_Character_Size); |
70482933 | 666 | Init_RM_Size (Standard_Boolean, 1); |
15ce9ca2 | 667 | Set_Elem_Alignment (Standard_Boolean); |
70482933 RK |
668 | |
669 | Set_Is_Unsigned_Type (Standard_Boolean); | |
670 | Set_Size_Known_At_Compile_Time (Standard_Boolean); | |
bd29d519 | 671 | Set_Has_Pragma_Ordered (Standard_Boolean); |
70482933 RK |
672 | |
673 | Set_Ekind (Standard_True, E_Enumeration_Literal); | |
674 | Set_Etype (Standard_True, Standard_Boolean); | |
675 | Set_Enumeration_Pos (Standard_True, Uint_1); | |
676 | Set_Enumeration_Rep (Standard_True, Uint_1); | |
677 | Set_Is_Known_Valid (Standard_True, True); | |
678 | ||
679 | Set_Ekind (Standard_False, E_Enumeration_Literal); | |
680 | Set_Etype (Standard_False, Standard_Boolean); | |
681 | Set_Enumeration_Pos (Standard_False, Uint_0); | |
682 | Set_Enumeration_Rep (Standard_False, Uint_0); | |
683 | Set_Is_Known_Valid (Standard_False, True); | |
684 | ||
685 | -- For the bounds of Boolean, we create a range node corresponding to | |
686 | ||
687 | -- range False .. True | |
688 | ||
689 | -- where the occurrences of the literals must point to the | |
a99ada67 | 690 | -- corresponding definition. |
70482933 RK |
691 | |
692 | R_Node := New_Node (N_Range, Stloc); | |
693 | B_Node := New_Node (N_Identifier, Stloc); | |
694 | Set_Chars (B_Node, Chars (Standard_False)); | |
695 | Set_Entity (B_Node, Standard_False); | |
696 | Set_Etype (B_Node, Standard_Boolean); | |
697 | Set_Is_Static_Expression (B_Node); | |
698 | Set_Low_Bound (R_Node, B_Node); | |
699 | ||
700 | B_Node := New_Node (N_Identifier, Stloc); | |
701 | Set_Chars (B_Node, Chars (Standard_True)); | |
702 | Set_Entity (B_Node, Standard_True); | |
703 | Set_Etype (B_Node, Standard_Boolean); | |
704 | Set_Is_Static_Expression (B_Node); | |
705 | Set_High_Bound (R_Node, B_Node); | |
706 | ||
707 | Set_Scalar_Range (Standard_Boolean, R_Node); | |
708 | Set_Etype (R_Node, Standard_Boolean); | |
709 | Set_Parent (R_Node, Standard_Boolean); | |
710 | ||
aa720a54 AC |
711 | -- Record entity identifiers for boolean literals in the |
712 | -- Boolean_Literals array, for easy reference during expansion. | |
713 | ||
714 | Boolean_Literals := (False => Standard_False, True => Standard_True); | |
715 | ||
70482933 RK |
716 | -- Create type definition nodes for predefined integer types |
717 | ||
718 | Build_Signed_Integer_Type | |
719 | (Standard_Short_Short_Integer, Standard_Short_Short_Integer_Size); | |
2b0451b7 | 720 | Set_Is_Implementation_Defined (Standard_Short_Short_Integer); |
70482933 RK |
721 | |
722 | Build_Signed_Integer_Type | |
723 | (Standard_Short_Integer, Standard_Short_Integer_Size); | |
99425ec3 | 724 | Set_Is_Implementation_Defined (Standard_Short_Integer); |
70482933 RK |
725 | |
726 | Build_Signed_Integer_Type | |
727 | (Standard_Integer, Standard_Integer_Size); | |
728 | ||
d1e0e148 AC |
729 | Build_Signed_Integer_Type |
730 | (Standard_Long_Integer, Standard_Long_Integer_Size); | |
70482933 RK |
731 | |
732 | Build_Signed_Integer_Type | |
733 | (Standard_Long_Long_Integer, Standard_Long_Long_Integer_Size); | |
df177175 | 734 | Set_Is_Implementation_Defined (Standard_Long_Long_Integer); |
70482933 RK |
735 | |
736 | Create_Unconstrained_Base_Type | |
737 | (Standard_Short_Short_Integer, E_Signed_Integer_Subtype); | |
738 | ||
739 | Create_Unconstrained_Base_Type | |
740 | (Standard_Short_Integer, E_Signed_Integer_Subtype); | |
741 | ||
742 | Create_Unconstrained_Base_Type | |
743 | (Standard_Integer, E_Signed_Integer_Subtype); | |
744 | ||
745 | Create_Unconstrained_Base_Type | |
746 | (Standard_Long_Integer, E_Signed_Integer_Subtype); | |
747 | ||
748 | Create_Unconstrained_Base_Type | |
749 | (Standard_Long_Long_Integer, E_Signed_Integer_Subtype); | |
750 | ||
f8726f2b | 751 | Create_Float_Types; |
70482933 RK |
752 | |
753 | -- Create type definition node for type Character. Note that we do not | |
754 | -- set the Literals field, since type Character is handled with special | |
755 | -- routine that do not need a literal list. | |
756 | ||
757 | Tdef_Node := New_Node (N_Enumeration_Type_Definition, Stloc); | |
758 | Set_Type_Definition (Parent (Standard_Character), Tdef_Node); | |
759 | ||
760 | Set_Ekind (Standard_Character, E_Enumeration_Type); | |
761 | Set_Etype (Standard_Character, Standard_Character); | |
07fc65c4 GB |
762 | Init_Esize (Standard_Character, Standard_Character_Size); |
763 | Init_RM_Size (Standard_Character, 8); | |
15ce9ca2 | 764 | Set_Elem_Alignment (Standard_Character); |
70482933 | 765 | |
bd29d519 | 766 | Set_Has_Pragma_Ordered (Standard_Character); |
70482933 RK |
767 | Set_Is_Unsigned_Type (Standard_Character); |
768 | Set_Is_Character_Type (Standard_Character); | |
769 | Set_Is_Known_Valid (Standard_Character); | |
770 | Set_Size_Known_At_Compile_Time (Standard_Character); | |
771 | ||
a2cb348e | 772 | -- Create the bounds for type Character |
70482933 RK |
773 | |
774 | R_Node := New_Node (N_Range, Stloc); | |
775 | ||
776 | -- Low bound for type Character (Standard.Nul) | |
777 | ||
778 | B_Node := New_Node (N_Character_Literal, Stloc); | |
779 | Set_Is_Static_Expression (B_Node); | |
780 | Set_Chars (B_Node, No_Name); | |
82c80734 RD |
781 | Set_Char_Literal_Value (B_Node, Uint_0); |
782 | Set_Entity (B_Node, Empty); | |
70482933 RK |
783 | Set_Etype (B_Node, Standard_Character); |
784 | Set_Low_Bound (R_Node, B_Node); | |
785 | ||
786 | -- High bound for type Character | |
787 | ||
788 | B_Node := New_Node (N_Character_Literal, Stloc); | |
789 | Set_Is_Static_Expression (B_Node); | |
790 | Set_Chars (B_Node, No_Name); | |
82c80734 RD |
791 | Set_Char_Literal_Value (B_Node, UI_From_Int (16#FF#)); |
792 | Set_Entity (B_Node, Empty); | |
70482933 RK |
793 | Set_Etype (B_Node, Standard_Character); |
794 | Set_High_Bound (R_Node, B_Node); | |
795 | ||
796 | Set_Scalar_Range (Standard_Character, R_Node); | |
797 | Set_Etype (R_Node, Standard_Character); | |
798 | Set_Parent (R_Node, Standard_Character); | |
799 | ||
800 | -- Create type definition for type Wide_Character. Note that we do not | |
801 | -- set the Literals field, since type Wide_Character is handled with | |
802 | -- special routines that do not need a literal list. | |
803 | ||
804 | Tdef_Node := New_Node (N_Enumeration_Type_Definition, Stloc); | |
805 | Set_Type_Definition (Parent (Standard_Wide_Character), Tdef_Node); | |
806 | ||
807 | Set_Ekind (Standard_Wide_Character, E_Enumeration_Type); | |
808 | Set_Etype (Standard_Wide_Character, Standard_Wide_Character); | |
809 | Init_Size (Standard_Wide_Character, Standard_Wide_Character_Size); | |
810 | ||
15ce9ca2 | 811 | Set_Elem_Alignment (Standard_Wide_Character); |
bd29d519 | 812 | Set_Has_Pragma_Ordered (Standard_Wide_Character); |
70482933 RK |
813 | Set_Is_Unsigned_Type (Standard_Wide_Character); |
814 | Set_Is_Character_Type (Standard_Wide_Character); | |
815 | Set_Is_Known_Valid (Standard_Wide_Character); | |
816 | Set_Size_Known_At_Compile_Time (Standard_Wide_Character); | |
817 | ||
a2cb348e | 818 | -- Create the bounds for type Wide_Character |
70482933 RK |
819 | |
820 | R_Node := New_Node (N_Range, Stloc); | |
821 | ||
822 | -- Low bound for type Wide_Character | |
823 | ||
824 | B_Node := New_Node (N_Character_Literal, Stloc); | |
825 | Set_Is_Static_Expression (B_Node); | |
826 | Set_Chars (B_Node, No_Name); -- ??? | |
82c80734 RD |
827 | Set_Char_Literal_Value (B_Node, Uint_0); |
828 | Set_Entity (B_Node, Empty); | |
70482933 RK |
829 | Set_Etype (B_Node, Standard_Wide_Character); |
830 | Set_Low_Bound (R_Node, B_Node); | |
831 | ||
832 | -- High bound for type Wide_Character | |
833 | ||
834 | B_Node := New_Node (N_Character_Literal, Stloc); | |
835 | Set_Is_Static_Expression (B_Node); | |
836 | Set_Chars (B_Node, No_Name); -- ??? | |
82c80734 RD |
837 | Set_Char_Literal_Value (B_Node, UI_From_Int (16#FFFF#)); |
838 | Set_Entity (B_Node, Empty); | |
70482933 RK |
839 | Set_Etype (B_Node, Standard_Wide_Character); |
840 | Set_High_Bound (R_Node, B_Node); | |
841 | ||
842 | Set_Scalar_Range (Standard_Wide_Character, R_Node); | |
843 | Set_Etype (R_Node, Standard_Wide_Character); | |
844 | Set_Parent (R_Node, Standard_Wide_Character); | |
845 | ||
82c80734 RD |
846 | -- Create type definition for type Wide_Wide_Character. Note that we |
847 | -- do not set the Literals field, since type Wide_Wide_Character is | |
848 | -- handled with special routines that do not need a literal list. | |
849 | ||
850 | Tdef_Node := New_Node (N_Enumeration_Type_Definition, Stloc); | |
851 | Set_Type_Definition (Parent (Standard_Wide_Wide_Character), Tdef_Node); | |
852 | ||
853 | Set_Ekind (Standard_Wide_Wide_Character, E_Enumeration_Type); | |
854 | Set_Etype (Standard_Wide_Wide_Character, | |
855 | Standard_Wide_Wide_Character); | |
856 | Init_Size (Standard_Wide_Wide_Character, | |
857 | Standard_Wide_Wide_Character_Size); | |
858 | ||
859 | Set_Elem_Alignment (Standard_Wide_Wide_Character); | |
bd29d519 | 860 | Set_Has_Pragma_Ordered (Standard_Wide_Wide_Character); |
82c80734 RD |
861 | Set_Is_Unsigned_Type (Standard_Wide_Wide_Character); |
862 | Set_Is_Character_Type (Standard_Wide_Wide_Character); | |
863 | Set_Is_Known_Valid (Standard_Wide_Wide_Character); | |
864 | Set_Size_Known_At_Compile_Time (Standard_Wide_Wide_Character); | |
bfc8aa81 | 865 | Set_Is_Ada_2005_Only (Standard_Wide_Wide_Character); |
82c80734 RD |
866 | |
867 | -- Create the bounds for type Wide_Wide_Character | |
868 | ||
869 | R_Node := New_Node (N_Range, Stloc); | |
870 | ||
871 | -- Low bound for type Wide_Wide_Character | |
872 | ||
873 | B_Node := New_Node (N_Character_Literal, Stloc); | |
874 | Set_Is_Static_Expression (B_Node); | |
875 | Set_Chars (B_Node, No_Name); -- ??? | |
876 | Set_Char_Literal_Value (B_Node, Uint_0); | |
877 | Set_Entity (B_Node, Empty); | |
878 | Set_Etype (B_Node, Standard_Wide_Wide_Character); | |
879 | Set_Low_Bound (R_Node, B_Node); | |
880 | ||
881 | -- High bound for type Wide_Wide_Character | |
882 | ||
883 | B_Node := New_Node (N_Character_Literal, Stloc); | |
884 | Set_Is_Static_Expression (B_Node); | |
885 | Set_Chars (B_Node, No_Name); -- ??? | |
886 | Set_Char_Literal_Value (B_Node, UI_From_Int (16#7FFF_FFFF#)); | |
887 | Set_Entity (B_Node, Empty); | |
888 | Set_Etype (B_Node, Standard_Wide_Wide_Character); | |
889 | Set_High_Bound (R_Node, B_Node); | |
890 | ||
891 | Set_Scalar_Range (Standard_Wide_Wide_Character, R_Node); | |
892 | Set_Etype (R_Node, Standard_Wide_Wide_Character); | |
893 | Set_Parent (R_Node, Standard_Wide_Wide_Character); | |
894 | ||
70482933 RK |
895 | -- Create type definition node for type String |
896 | ||
897 | Tdef_Node := New_Node (N_Unconstrained_Array_Definition, Stloc); | |
9bc43c53 | 898 | |
a397db96 AC |
899 | declare |
900 | CompDef_Node : Node_Id; | |
901 | begin | |
902 | CompDef_Node := New_Node (N_Component_Definition, Stloc); | |
82c80734 RD |
903 | Set_Aliased_Present (CompDef_Node, False); |
904 | Set_Access_Definition (CompDef_Node, Empty); | |
905 | Set_Subtype_Indication (CompDef_Node, Identifier_For (S_Character)); | |
a397db96 AC |
906 | Set_Component_Definition (Tdef_Node, CompDef_Node); |
907 | end; | |
9bc43c53 | 908 | |
70482933 RK |
909 | Set_Subtype_Marks (Tdef_Node, New_List); |
910 | Append (Identifier_For (S_Positive), Subtype_Marks (Tdef_Node)); | |
911 | Set_Type_Definition (Parent (Standard_String), Tdef_Node); | |
912 | ||
f8c79ade | 913 | Set_Ekind (Standard_String, E_Array_Type); |
bb10b891 AC |
914 | Set_Etype (Standard_String, Standard_String); |
915 | Set_Component_Type (Standard_String, Standard_Character); | |
916 | Set_Component_Size (Standard_String, Uint_8); | |
917 | Init_Size_Align (Standard_String); | |
918 | Set_Alignment (Standard_String, Uint_1); | |
ea7f928b | 919 | Pack_String_Type (Standard_String); |
70482933 | 920 | |
41ccd2d8 GD |
921 | -- On targets where a storage unit is larger than a byte (such as AAMP), |
922 | -- pragma Pack has a real effect on the representation of type String, | |
923 | -- and the type must be marked as having a nonstandard representation. | |
924 | ||
925 | if System_Storage_Unit > Uint_8 then | |
926 | Set_Has_Non_Standard_Rep (Standard_String); | |
927 | Set_Has_Pragma_Pack (Standard_String); | |
928 | end if; | |
929 | ||
70482933 RK |
930 | -- Set index type of String |
931 | ||
f8c79ade AC |
932 | E_Id := |
933 | First (Subtype_Marks (Type_Definition (Parent (Standard_String)))); | |
70482933 RK |
934 | Set_First_Index (Standard_String, E_Id); |
935 | Set_Entity (E_Id, Standard_Positive); | |
936 | Set_Etype (E_Id, Standard_Positive); | |
937 | ||
938 | -- Create type definition node for type Wide_String | |
939 | ||
940 | Tdef_Node := New_Node (N_Unconstrained_Array_Definition, Stloc); | |
82c80734 | 941 | |
a397db96 AC |
942 | declare |
943 | CompDef_Node : Node_Id; | |
944 | begin | |
945 | CompDef_Node := New_Node (N_Component_Definition, Stloc); | |
946 | Set_Aliased_Present (CompDef_Node, False); | |
6e937c1c | 947 | Set_Access_Definition (CompDef_Node, Empty); |
a397db96 AC |
948 | Set_Subtype_Indication (CompDef_Node, |
949 | Identifier_For (S_Wide_Character)); | |
950 | Set_Component_Definition (Tdef_Node, CompDef_Node); | |
951 | end; | |
82c80734 | 952 | |
70482933 RK |
953 | Set_Subtype_Marks (Tdef_Node, New_List); |
954 | Append (Identifier_For (S_Positive), Subtype_Marks (Tdef_Node)); | |
955 | Set_Type_Definition (Parent (Standard_Wide_String), Tdef_Node); | |
956 | ||
f8c79ade | 957 | Set_Ekind (Standard_Wide_String, E_Array_Type); |
bb10b891 AC |
958 | Set_Etype (Standard_Wide_String, Standard_Wide_String); |
959 | Set_Component_Type (Standard_Wide_String, Standard_Wide_Character); | |
960 | Set_Component_Size (Standard_Wide_String, Uint_16); | |
961 | Init_Size_Align (Standard_Wide_String); | |
ea7f928b | 962 | Pack_String_Type (Standard_Wide_String); |
70482933 RK |
963 | |
964 | -- Set index type of Wide_String | |
965 | ||
f8c79ade AC |
966 | E_Id := |
967 | First | |
968 | (Subtype_Marks (Type_Definition (Parent (Standard_Wide_String)))); | |
70482933 RK |
969 | Set_First_Index (Standard_Wide_String, E_Id); |
970 | Set_Entity (E_Id, Standard_Positive); | |
971 | Set_Etype (E_Id, Standard_Positive); | |
972 | ||
82c80734 RD |
973 | -- Create type definition node for type Wide_Wide_String |
974 | ||
975 | Tdef_Node := New_Node (N_Unconstrained_Array_Definition, Stloc); | |
976 | ||
977 | declare | |
978 | CompDef_Node : Node_Id; | |
979 | begin | |
980 | CompDef_Node := New_Node (N_Component_Definition, Stloc); | |
981 | Set_Aliased_Present (CompDef_Node, False); | |
982 | Set_Access_Definition (CompDef_Node, Empty); | |
983 | Set_Subtype_Indication (CompDef_Node, | |
984 | Identifier_For (S_Wide_Wide_Character)); | |
985 | Set_Component_Definition (Tdef_Node, CompDef_Node); | |
986 | end; | |
987 | ||
988 | Set_Subtype_Marks (Tdef_Node, New_List); | |
989 | Append (Identifier_For (S_Positive), Subtype_Marks (Tdef_Node)); | |
990 | Set_Type_Definition (Parent (Standard_Wide_Wide_String), Tdef_Node); | |
991 | ||
f8c79ade | 992 | Set_Ekind (Standard_Wide_Wide_String, E_Array_Type); |
bfc8aa81 RD |
993 | Set_Etype (Standard_Wide_Wide_String, |
994 | Standard_Wide_Wide_String); | |
995 | Set_Component_Type (Standard_Wide_Wide_String, | |
996 | Standard_Wide_Wide_Character); | |
997 | Set_Component_Size (Standard_Wide_Wide_String, Uint_32); | |
998 | Init_Size_Align (Standard_Wide_Wide_String); | |
999 | Set_Is_Ada_2005_Only (Standard_Wide_Wide_String); | |
ea7f928b | 1000 | Pack_String_Type (Standard_Wide_Wide_String); |
82c80734 RD |
1001 | |
1002 | -- Set index type of Wide_Wide_String | |
1003 | ||
f8c79ade AC |
1004 | E_Id := |
1005 | First | |
1006 | (Subtype_Marks | |
1007 | (Type_Definition (Parent (Standard_Wide_Wide_String)))); | |
82c80734 RD |
1008 | Set_First_Index (Standard_Wide_Wide_String, E_Id); |
1009 | Set_Entity (E_Id, Standard_Positive); | |
1010 | Set_Etype (E_Id, Standard_Positive); | |
1011 | ||
3d6c3bd7 | 1012 | -- Setup entity for Natural |
70482933 RK |
1013 | |
1014 | Set_Ekind (Standard_Natural, E_Signed_Integer_Subtype); | |
1015 | Set_Etype (Standard_Natural, Base_Type (Standard_Integer)); | |
1016 | Init_Esize (Standard_Natural, Standard_Integer_Size); | |
1017 | Init_RM_Size (Standard_Natural, Standard_Integer_Size - 1); | |
15ce9ca2 | 1018 | Set_Elem_Alignment (Standard_Natural); |
70482933 RK |
1019 | Set_Size_Known_At_Compile_Time |
1020 | (Standard_Natural); | |
1021 | Set_Integer_Bounds (Standard_Natural, | |
1022 | Typ => Base_Type (Standard_Integer), | |
1023 | Lb => Uint_0, | |
1024 | Hb => Intval (High_Bound (Scalar_Range (Standard_Integer)))); | |
1025 | Set_Is_Constrained (Standard_Natural); | |
70482933 | 1026 | |
454a86dc | 1027 | -- Setup entity for Positive |
70482933 RK |
1028 | |
1029 | Set_Ekind (Standard_Positive, E_Signed_Integer_Subtype); | |
1030 | Set_Etype (Standard_Positive, Base_Type (Standard_Integer)); | |
1031 | Init_Esize (Standard_Positive, Standard_Integer_Size); | |
1032 | Init_RM_Size (Standard_Positive, Standard_Integer_Size - 1); | |
15ce9ca2 | 1033 | Set_Elem_Alignment (Standard_Positive); |
70482933 RK |
1034 | |
1035 | Set_Size_Known_At_Compile_Time (Standard_Positive); | |
1036 | ||
1037 | Set_Integer_Bounds (Standard_Positive, | |
1038 | Typ => Base_Type (Standard_Integer), | |
1039 | Lb => Uint_1, | |
1040 | Hb => Intval (High_Bound (Scalar_Range (Standard_Integer)))); | |
1041 | Set_Is_Constrained (Standard_Positive); | |
70482933 RK |
1042 | |
1043 | -- Create declaration for package ASCII | |
1044 | ||
1045 | Decl := New_Node (N_Package_Declaration, Stloc); | |
1046 | Append (Decl, Decl_S); | |
1047 | ||
1048 | Pspec := New_Node (N_Package_Specification, Stloc); | |
1049 | Set_Specification (Decl, Pspec); | |
1050 | ||
1051 | Set_Defining_Unit_Name (Pspec, Standard_Entity (S_ASCII)); | |
1052 | Set_Ekind (Standard_Entity (S_ASCII), E_Package); | |
70482933 RK |
1053 | Set_Visible_Declarations (Pspec, Decl_A); |
1054 | ||
1055 | -- Create control character definitions in package ASCII. Note that | |
1056 | -- the character literal entries created here correspond to literal | |
1057 | -- values that are impossible in the source, but can be represented | |
1058 | -- internally with no difficulties. | |
1059 | ||
1060 | Ccode := 16#00#; | |
1061 | ||
1062 | for S in S_ASCII_Names loop | |
1063 | Decl := New_Node (N_Object_Declaration, Staloc); | |
1064 | Set_Constant_Present (Decl, True); | |
1065 | ||
1066 | declare | |
fbf5a39b | 1067 | A_Char : constant Entity_Id := Standard_Entity (S); |
70482933 RK |
1068 | Expr_Decl : Node_Id; |
1069 | ||
1070 | begin | |
1071 | Set_Sloc (A_Char, Staloc); | |
1072 | Set_Ekind (A_Char, E_Constant); | |
fbf5a39b | 1073 | Set_Never_Set_In_Source (A_Char, True); |
70482933 RK |
1074 | Set_Is_True_Constant (A_Char, True); |
1075 | Set_Etype (A_Char, Standard_Character); | |
1076 | Set_Scope (A_Char, Standard_Entity (S_ASCII)); | |
1077 | Set_Is_Immediately_Visible (A_Char, False); | |
1078 | Set_Is_Public (A_Char, True); | |
1079 | Set_Is_Known_Valid (A_Char, True); | |
1080 | ||
1081 | Append_Entity (A_Char, Standard_Entity (S_ASCII)); | |
1082 | Set_Defining_Identifier (Decl, A_Char); | |
1083 | ||
1084 | Set_Object_Definition (Decl, Identifier_For (S_Character)); | |
1085 | Expr_Decl := New_Node (N_Character_Literal, Staloc); | |
1086 | Set_Expression (Decl, Expr_Decl); | |
1087 | ||
1088 | Set_Is_Static_Expression (Expr_Decl); | |
1089 | Set_Chars (Expr_Decl, No_Name); | |
1090 | Set_Etype (Expr_Decl, Standard_Character); | |
82c80734 | 1091 | Set_Char_Literal_Value (Expr_Decl, UI_From_Int (Int (Ccode))); |
70482933 RK |
1092 | end; |
1093 | ||
1094 | Append (Decl, Decl_A); | |
1095 | ||
1096 | -- Increment character code, dealing with non-contiguities | |
1097 | ||
1098 | Ccode := Ccode + 1; | |
1099 | ||
1100 | if Ccode = 16#20# then | |
1101 | Ccode := 16#21#; | |
1102 | elsif Ccode = 16#27# then | |
1103 | Ccode := 16#3A#; | |
1104 | elsif Ccode = 16#3C# then | |
1105 | Ccode := 16#3F#; | |
1106 | elsif Ccode = 16#41# then | |
1107 | Ccode := 16#5B#; | |
1108 | end if; | |
1109 | end loop; | |
1110 | ||
1111 | -- Create semantic phase entities | |
1112 | ||
1113 | Standard_Void_Type := New_Standard_Entity; | |
1114 | Set_Ekind (Standard_Void_Type, E_Void); | |
1115 | Set_Etype (Standard_Void_Type, Standard_Void_Type); | |
70482933 RK |
1116 | Set_Scope (Standard_Void_Type, Standard_Standard); |
1117 | Make_Name (Standard_Void_Type, "_void_type"); | |
1118 | ||
1119 | -- The type field of packages is set to void | |
1120 | ||
1121 | Set_Etype (Standard_Standard, Standard_Void_Type); | |
1122 | Set_Etype (Standard_ASCII, Standard_Void_Type); | |
1123 | ||
1124 | -- Standard_A_String is actually used in generated code, so it has a | |
1125 | -- type name that is reasonable, but does not overlap any Ada name. | |
1126 | ||
1127 | Standard_A_String := New_Standard_Entity; | |
1128 | Set_Ekind (Standard_A_String, E_Access_Type); | |
1129 | Set_Scope (Standard_A_String, Standard_Standard); | |
1130 | Set_Etype (Standard_A_String, Standard_A_String); | |
1131 | ||
1132 | if Debug_Flag_6 then | |
1133 | Init_Size (Standard_A_String, System_Address_Size); | |
1134 | else | |
1135 | Init_Size (Standard_A_String, System_Address_Size * 2); | |
1136 | end if; | |
1137 | ||
1138 | Init_Alignment (Standard_A_String); | |
1139 | ||
1140 | Set_Directly_Designated_Type | |
1141 | (Standard_A_String, Standard_String); | |
1142 | Make_Name (Standard_A_String, "access_string"); | |
1143 | ||
1144 | Standard_A_Char := New_Standard_Entity; | |
1145 | Set_Ekind (Standard_A_Char, E_Access_Type); | |
1146 | Set_Scope (Standard_A_Char, Standard_Standard); | |
1147 | Set_Etype (Standard_A_Char, Standard_A_String); | |
1148 | Init_Size (Standard_A_Char, System_Address_Size); | |
15ce9ca2 | 1149 | Set_Elem_Alignment (Standard_A_Char); |
70482933 RK |
1150 | |
1151 | Set_Directly_Designated_Type (Standard_A_Char, Standard_Character); | |
1152 | Make_Name (Standard_A_Char, "access_character"); | |
1153 | ||
4c8e94ab GD |
1154 | -- Standard_Debug_Renaming_Type is used for the special objects created |
1155 | -- to encode the names occurring in renaming declarations for use by the | |
1156 | -- debugger (see exp_dbug.adb). The type is a zero-sized subtype of | |
1157 | -- Standard.Integer. | |
1158 | ||
1159 | Standard_Debug_Renaming_Type := New_Standard_Entity; | |
1160 | ||
1161 | Set_Ekind (Standard_Debug_Renaming_Type, E_Signed_Integer_Subtype); | |
1162 | Set_Scope (Standard_Debug_Renaming_Type, Standard_Standard); | |
1163 | Set_Etype (Standard_Debug_Renaming_Type, Base_Type (Standard_Integer)); | |
8dc2ddaf RD |
1164 | Init_Esize (Standard_Debug_Renaming_Type, 0); |
1165 | Init_RM_Size (Standard_Debug_Renaming_Type, 0); | |
4c8e94ab | 1166 | Set_Size_Known_At_Compile_Time (Standard_Debug_Renaming_Type); |
8dc2ddaf RD |
1167 | Set_Integer_Bounds (Standard_Debug_Renaming_Type, |
1168 | Typ => Base_Type (Standard_Debug_Renaming_Type), | |
4c8e94ab GD |
1169 | Lb => Uint_1, |
1170 | Hb => Uint_0); | |
8dc2ddaf | 1171 | Set_Is_Constrained (Standard_Debug_Renaming_Type); |
4c8e94ab GD |
1172 | Set_Has_Size_Clause (Standard_Debug_Renaming_Type); |
1173 | ||
8dc2ddaf | 1174 | Make_Name (Standard_Debug_Renaming_Type, "_renaming_type"); |
4c8e94ab | 1175 | |
70482933 RK |
1176 | -- Note on type names. The type names for the following special types |
1177 | -- are constructed so that they will look reasonable should they ever | |
1178 | -- appear in error messages etc, although in practice the use of the | |
1179 | -- special insertion character } for types results in special handling | |
1180 | -- of these type names in any case. The blanks in these names would | |
1181 | -- trouble in Gigi, but that's OK here, since none of these types | |
a90bd866 | 1182 | -- should ever get through to Gigi. Attributes of these types are |
70482933 RK |
1183 | -- filled out to minimize problems with cascaded errors (for example, |
1184 | -- Any_Integer is given reasonable and consistent type and size values) | |
1185 | ||
41a58113 | 1186 | Any_Type := New_Standard_Entity ("any type"); |
e77e2429 | 1187 | Decl := New_Node (N_Full_Type_Declaration, Stloc); |
70482933 RK |
1188 | Set_Defining_Identifier (Decl, Any_Type); |
1189 | Set_Scope (Any_Type, Standard_Standard); | |
1190 | Build_Signed_Integer_Type (Any_Type, Standard_Integer_Size); | |
70482933 | 1191 | |
41a58113 | 1192 | Any_Id := New_Standard_Entity ("any id"); |
70482933 RK |
1193 | Set_Ekind (Any_Id, E_Variable); |
1194 | Set_Scope (Any_Id, Standard_Standard); | |
1195 | Set_Etype (Any_Id, Any_Type); | |
b11e8d6f RD |
1196 | Init_Esize (Any_Id); |
1197 | Init_Alignment (Any_Id); | |
70482933 | 1198 | |
41a58113 | 1199 | Any_Access := New_Standard_Entity ("an access type"); |
70482933 RK |
1200 | Set_Ekind (Any_Access, E_Access_Type); |
1201 | Set_Scope (Any_Access, Standard_Standard); | |
1202 | Set_Etype (Any_Access, Any_Access); | |
1203 | Init_Size (Any_Access, System_Address_Size); | |
15ce9ca2 | 1204 | Set_Elem_Alignment (Any_Access); |
e77e2429 AC |
1205 | Set_Directly_Designated_Type |
1206 | (Any_Access, Any_Type); | |
70482933 | 1207 | |
41a58113 | 1208 | Any_Character := New_Standard_Entity ("a character type"); |
f1f9fe30 AC |
1209 | Set_Ekind (Any_Character, E_Enumeration_Type); |
1210 | Set_Scope (Any_Character, Standard_Standard); | |
1211 | Set_Etype (Any_Character, Any_Character); | |
1212 | Set_Is_Unsigned_Type (Any_Character); | |
1213 | Set_Is_Character_Type (Any_Character); | |
1214 | Init_Esize (Any_Character, Standard_Character_Size); | |
1215 | Init_RM_Size (Any_Character, 8); | |
15ce9ca2 | 1216 | Set_Elem_Alignment (Any_Character); |
f1f9fe30 | 1217 | Set_Scalar_Range (Any_Character, Scalar_Range (Standard_Character)); |
f1f9fe30 | 1218 | |
41a58113 | 1219 | Any_Array := New_Standard_Entity ("an array type"); |
f8c79ade | 1220 | Set_Ekind (Any_Array, E_Array_Type); |
70482933 RK |
1221 | Set_Scope (Any_Array, Standard_Standard); |
1222 | Set_Etype (Any_Array, Any_Array); | |
1223 | Set_Component_Type (Any_Array, Any_Character); | |
1224 | Init_Size_Align (Any_Array); | |
f8c79ade | 1225 | Make_Dummy_Index (Any_Array); |
70482933 | 1226 | |
41a58113 | 1227 | Any_Boolean := New_Standard_Entity ("a boolean type"); |
70482933 RK |
1228 | Set_Ekind (Any_Boolean, E_Enumeration_Type); |
1229 | Set_Scope (Any_Boolean, Standard_Standard); | |
1230 | Set_Etype (Any_Boolean, Standard_Boolean); | |
07fc65c4 | 1231 | Init_Esize (Any_Boolean, Standard_Character_Size); |
70482933 | 1232 | Init_RM_Size (Any_Boolean, 1); |
15ce9ca2 | 1233 | Set_Elem_Alignment (Any_Boolean); |
70482933 RK |
1234 | Set_Is_Unsigned_Type (Any_Boolean); |
1235 | Set_Scalar_Range (Any_Boolean, Scalar_Range (Standard_Boolean)); | |
70482933 | 1236 | |
41a58113 | 1237 | Any_Composite := New_Standard_Entity ("a composite type"); |
70482933 RK |
1238 | Set_Ekind (Any_Composite, E_Array_Type); |
1239 | Set_Scope (Any_Composite, Standard_Standard); | |
1240 | Set_Etype (Any_Composite, Any_Composite); | |
1241 | Set_Component_Size (Any_Composite, Uint_0); | |
1242 | Set_Component_Type (Any_Composite, Standard_Integer); | |
1243 | Init_Size_Align (Any_Composite); | |
70482933 | 1244 | |
41a58113 | 1245 | Any_Discrete := New_Standard_Entity ("a discrete type"); |
70482933 RK |
1246 | Set_Ekind (Any_Discrete, E_Signed_Integer_Type); |
1247 | Set_Scope (Any_Discrete, Standard_Standard); | |
1248 | Set_Etype (Any_Discrete, Any_Discrete); | |
1249 | Init_Size (Any_Discrete, Standard_Integer_Size); | |
15ce9ca2 | 1250 | Set_Elem_Alignment (Any_Discrete); |
70482933 | 1251 | |
41a58113 | 1252 | Any_Fixed := New_Standard_Entity ("a fixed-point type"); |
70482933 RK |
1253 | Set_Ekind (Any_Fixed, E_Ordinary_Fixed_Point_Type); |
1254 | Set_Scope (Any_Fixed, Standard_Standard); | |
1255 | Set_Etype (Any_Fixed, Any_Fixed); | |
1256 | Init_Size (Any_Fixed, Standard_Integer_Size); | |
15ce9ca2 | 1257 | Set_Elem_Alignment (Any_Fixed); |
70482933 | 1258 | |
41a58113 | 1259 | Any_Integer := New_Standard_Entity ("an integer type"); |
70482933 RK |
1260 | Set_Ekind (Any_Integer, E_Signed_Integer_Type); |
1261 | Set_Scope (Any_Integer, Standard_Standard); | |
1262 | Set_Etype (Any_Integer, Standard_Long_Long_Integer); | |
1263 | Init_Size (Any_Integer, Standard_Long_Long_Integer_Size); | |
15ce9ca2 | 1264 | Set_Elem_Alignment (Any_Integer); |
70482933 RK |
1265 | |
1266 | Set_Integer_Bounds | |
1267 | (Any_Integer, | |
1268 | Typ => Base_Type (Standard_Integer), | |
1269 | Lb => Uint_0, | |
1270 | Hb => Intval (High_Bound (Scalar_Range (Standard_Integer)))); | |
70482933 | 1271 | |
41a58113 | 1272 | Any_Modular := New_Standard_Entity ("a modular type"); |
70482933 RK |
1273 | Set_Ekind (Any_Modular, E_Modular_Integer_Type); |
1274 | Set_Scope (Any_Modular, Standard_Standard); | |
1275 | Set_Etype (Any_Modular, Standard_Long_Long_Integer); | |
1276 | Init_Size (Any_Modular, Standard_Long_Long_Integer_Size); | |
15ce9ca2 | 1277 | Set_Elem_Alignment (Any_Modular); |
70482933 | 1278 | Set_Is_Unsigned_Type (Any_Modular); |
70482933 | 1279 | |
41a58113 | 1280 | Any_Numeric := New_Standard_Entity ("a numeric type"); |
70482933 RK |
1281 | Set_Ekind (Any_Numeric, E_Signed_Integer_Type); |
1282 | Set_Scope (Any_Numeric, Standard_Standard); | |
1283 | Set_Etype (Any_Numeric, Standard_Long_Long_Integer); | |
1284 | Init_Size (Any_Numeric, Standard_Long_Long_Integer_Size); | |
15ce9ca2 | 1285 | Set_Elem_Alignment (Any_Numeric); |
70482933 | 1286 | |
41a58113 | 1287 | Any_Real := New_Standard_Entity ("a real type"); |
70482933 RK |
1288 | Set_Ekind (Any_Real, E_Floating_Point_Type); |
1289 | Set_Scope (Any_Real, Standard_Standard); | |
1290 | Set_Etype (Any_Real, Standard_Long_Long_Float); | |
9eea4346 GB |
1291 | Init_Size (Any_Real, |
1292 | UI_To_Int (Esize (Standard_Long_Long_Float))); | |
15ce9ca2 | 1293 | Set_Elem_Alignment (Any_Real); |
70482933 | 1294 | |
41a58113 | 1295 | Any_Scalar := New_Standard_Entity ("a scalar type"); |
70482933 RK |
1296 | Set_Ekind (Any_Scalar, E_Signed_Integer_Type); |
1297 | Set_Scope (Any_Scalar, Standard_Standard); | |
1298 | Set_Etype (Any_Scalar, Any_Scalar); | |
1299 | Init_Size (Any_Scalar, Standard_Integer_Size); | |
15ce9ca2 | 1300 | Set_Elem_Alignment (Any_Scalar); |
70482933 | 1301 | |
41a58113 | 1302 | Any_String := New_Standard_Entity ("a string type"); |
f8c79ade | 1303 | Set_Ekind (Any_String, E_Array_Type); |
70482933 RK |
1304 | Set_Scope (Any_String, Standard_Standard); |
1305 | Set_Etype (Any_String, Any_String); | |
1306 | Set_Component_Type (Any_String, Any_Character); | |
1307 | Init_Size_Align (Any_String); | |
f8c79ade | 1308 | Make_Dummy_Index (Any_String); |
70482933 | 1309 | |
41a58113 | 1310 | Raise_Type := New_Standard_Entity ("raise type"); |
3e586e10 AC |
1311 | Decl := New_Node (N_Full_Type_Declaration, Stloc); |
1312 | Set_Defining_Identifier (Decl, Raise_Type); | |
1313 | Set_Scope (Raise_Type, Standard_Standard); | |
1314 | Build_Signed_Integer_Type (Raise_Type, Standard_Integer_Size); | |
3e586e10 | 1315 | |
41a58113 | 1316 | Standard_Integer_8 := New_Standard_Entity ("integer_8"); |
70482933 RK |
1317 | Decl := New_Node (N_Full_Type_Declaration, Stloc); |
1318 | Set_Defining_Identifier (Decl, Standard_Integer_8); | |
70482933 RK |
1319 | Set_Scope (Standard_Integer_8, Standard_Standard); |
1320 | Build_Signed_Integer_Type (Standard_Integer_8, 8); | |
1321 | ||
41a58113 | 1322 | Standard_Integer_16 := New_Standard_Entity ("integer_16"); |
70482933 RK |
1323 | Decl := New_Node (N_Full_Type_Declaration, Stloc); |
1324 | Set_Defining_Identifier (Decl, Standard_Integer_16); | |
70482933 RK |
1325 | Set_Scope (Standard_Integer_16, Standard_Standard); |
1326 | Build_Signed_Integer_Type (Standard_Integer_16, 16); | |
1327 | ||
41a58113 | 1328 | Standard_Integer_32 := New_Standard_Entity ("integer_32"); |
70482933 RK |
1329 | Decl := New_Node (N_Full_Type_Declaration, Stloc); |
1330 | Set_Defining_Identifier (Decl, Standard_Integer_32); | |
70482933 RK |
1331 | Set_Scope (Standard_Integer_32, Standard_Standard); |
1332 | Build_Signed_Integer_Type (Standard_Integer_32, 32); | |
1333 | ||
41a58113 | 1334 | Standard_Integer_64 := New_Standard_Entity ("integer_64"); |
70482933 RK |
1335 | Decl := New_Node (N_Full_Type_Declaration, Stloc); |
1336 | Set_Defining_Identifier (Decl, Standard_Integer_64); | |
70482933 RK |
1337 | Set_Scope (Standard_Integer_64, Standard_Standard); |
1338 | Build_Signed_Integer_Type (Standard_Integer_64, 64); | |
1339 | ||
2c9f8c0a AC |
1340 | -- Standard_*_Unsigned subtypes are not user visible, but they are |
1341 | -- used internally. They are unsigned types with the same length as | |
1342 | -- the correspondingly named signed integer types. | |
c1645ac8 | 1343 | |
2c9f8c0a AC |
1344 | Standard_Short_Short_Unsigned := New_Standard_Entity; |
1345 | Build_Unsigned_Integer_Type | |
1346 | (Standard_Short_Short_Unsigned, | |
1347 | Standard_Short_Short_Integer_Size, | |
1348 | "short_short_unsigned"); | |
70482933 | 1349 | |
2c9f8c0a AC |
1350 | Standard_Short_Unsigned := New_Standard_Entity; |
1351 | Build_Unsigned_Integer_Type | |
1352 | (Standard_Short_Unsigned, | |
1353 | Standard_Short_Integer_Size, | |
1354 | "short_unsigned"); | |
1355 | ||
1356 | Standard_Unsigned := New_Standard_Entity; | |
1357 | Build_Unsigned_Integer_Type | |
1358 | (Standard_Unsigned, | |
1359 | Standard_Integer_Size, | |
1360 | "unsigned"); | |
1361 | ||
1362 | Standard_Long_Unsigned := New_Standard_Entity; | |
1363 | Build_Unsigned_Integer_Type | |
1364 | (Standard_Long_Unsigned, | |
1365 | Standard_Long_Integer_Size, | |
1366 | "long_unsigned"); | |
1367 | ||
1368 | Standard_Long_Long_Unsigned := New_Standard_Entity; | |
1369 | Build_Unsigned_Integer_Type | |
1370 | (Standard_Long_Long_Unsigned, | |
1371 | Standard_Long_Long_Integer_Size, | |
1372 | "long_long_unsigned"); | |
70482933 | 1373 | |
c1645ac8 AC |
1374 | -- Standard_Unsigned_64 is not user visible, but is used internally. It |
1375 | -- is an unsigned type mod 2**64, 64-bits unsigned, size is 64. | |
1376 | ||
1377 | Standard_Unsigned_64 := New_Standard_Entity; | |
2c9f8c0a | 1378 | Build_Unsigned_Integer_Type (Standard_Unsigned_64, 64, "unsigned_64"); |
c1645ac8 | 1379 | |
70482933 RK |
1380 | -- Note: universal integer and universal real are constructed as fully |
1381 | -- formed signed numeric types, with parameters corresponding to the | |
1382 | -- longest runtime types (Long_Long_Integer and Long_Long_Float). This | |
1383 | -- allows Gigi to properly process references to universal types that | |
1384 | -- are not folded at compile time. | |
1385 | ||
1386 | Universal_Integer := New_Standard_Entity; | |
1387 | Decl := New_Node (N_Full_Type_Declaration, Stloc); | |
1388 | Set_Defining_Identifier (Decl, Universal_Integer); | |
1389 | Make_Name (Universal_Integer, "universal_integer"); | |
1390 | Set_Scope (Universal_Integer, Standard_Standard); | |
1391 | Build_Signed_Integer_Type | |
1392 | (Universal_Integer, Standard_Long_Long_Integer_Size); | |
1393 | ||
1394 | Universal_Real := New_Standard_Entity; | |
1395 | Decl := New_Node (N_Full_Type_Declaration, Stloc); | |
1396 | Set_Defining_Identifier (Decl, Universal_Real); | |
1397 | Make_Name (Universal_Real, "universal_real"); | |
1398 | Set_Scope (Universal_Real, Standard_Standard); | |
f8726f2b | 1399 | Copy_Float_Type (Universal_Real, Standard_Long_Long_Float); |
70482933 RK |
1400 | |
1401 | -- Note: universal fixed, unlike universal integer and universal real, | |
1402 | -- is never used at runtime, so it does not need to have bounds set. | |
1403 | ||
1404 | Universal_Fixed := New_Standard_Entity; | |
1405 | Decl := New_Node (N_Full_Type_Declaration, Stloc); | |
1406 | Set_Defining_Identifier (Decl, Universal_Fixed); | |
1407 | Make_Name (Universal_Fixed, "universal_fixed"); | |
1408 | Set_Ekind (Universal_Fixed, E_Ordinary_Fixed_Point_Type); | |
1409 | Set_Etype (Universal_Fixed, Universal_Fixed); | |
1410 | Set_Scope (Universal_Fixed, Standard_Standard); | |
1411 | Init_Size (Universal_Fixed, Standard_Long_Long_Integer_Size); | |
15ce9ca2 | 1412 | Set_Elem_Alignment (Universal_Fixed); |
70482933 RK |
1413 | Set_Size_Known_At_Compile_Time |
1414 | (Universal_Fixed); | |
1415 | ||
17c5c8a5 | 1416 | -- Create type declaration for Duration, using a 64-bit size. The |
fbf5a39b | 1417 | -- delta and size values depend on the mode set in system.ads. |
70482933 RK |
1418 | |
1419 | Build_Duration : declare | |
891a6e79 AC |
1420 | Dlo : Uint; |
1421 | Dhi : Uint; | |
1422 | Delta_Val : Ureal; | |
70482933 RK |
1423 | |
1424 | begin | |
fbf5a39b | 1425 | -- In 32 bit mode, the size is 32 bits, and the delta and |
9c25bb25 | 1426 | -- small values are set to 20 milliseconds (20.0*(10.0**(-3)). |
fbf5a39b AC |
1427 | |
1428 | if Duration_32_Bits_On_Target then | |
6510f4c9 GB |
1429 | Dlo := Intval (Type_Low_Bound (Standard_Integer_32)); |
1430 | Dhi := Intval (Type_High_Bound (Standard_Integer_32)); | |
fbf5a39b AC |
1431 | Delta_Val := UR_From_Components (UI_From_Int (20), Uint_3, 10); |
1432 | ||
47b79f78 AC |
1433 | -- In 64-bit mode, the size is 64-bits and the delta and |
1434 | -- small values are set to nanoseconds (1.0*(10.0**(-9)). | |
17c5c8a5 | 1435 | |
6510f4c9 GB |
1436 | else |
1437 | Dlo := Intval (Type_Low_Bound (Standard_Integer_64)); | |
1438 | Dhi := Intval (Type_High_Bound (Standard_Integer_64)); | |
1439 | Delta_Val := UR_From_Components (Uint_1, Uint_9, 10); | |
1440 | end if; | |
1441 | ||
891a6e79 | 1442 | Tdef_Node := Make_Ordinary_Fixed_Point_Definition (Stloc, |
70482933 RK |
1443 | Delta_Expression => Make_Real_Literal (Stloc, Delta_Val), |
1444 | Real_Range_Specification => | |
1445 | Make_Real_Range_Specification (Stloc, | |
1446 | Low_Bound => Make_Real_Literal (Stloc, | |
1447 | Realval => Dlo * Delta_Val), | |
1448 | High_Bound => Make_Real_Literal (Stloc, | |
891a6e79 AC |
1449 | Realval => Dhi * Delta_Val))); |
1450 | ||
1451 | Set_Type_Definition (Parent (Standard_Duration), Tdef_Node); | |
70482933 | 1452 | |
6510f4c9 GB |
1453 | Set_Ekind (Standard_Duration, E_Ordinary_Fixed_Point_Type); |
1454 | Set_Etype (Standard_Duration, Standard_Duration); | |
1455 | ||
fbf5a39b | 1456 | if Duration_32_Bits_On_Target then |
6510f4c9 GB |
1457 | Init_Size (Standard_Duration, 32); |
1458 | else | |
1459 | Init_Size (Standard_Duration, 64); | |
1460 | end if; | |
1461 | ||
15ce9ca2 | 1462 | Set_Elem_Alignment (Standard_Duration); |
70482933 RK |
1463 | Set_Delta_Value (Standard_Duration, Delta_Val); |
1464 | Set_Small_Value (Standard_Duration, Delta_Val); | |
1465 | Set_Scalar_Range (Standard_Duration, | |
1466 | Real_Range_Specification | |
891a6e79 | 1467 | (Type_Definition (Parent (Standard_Duration)))); |
70482933 RK |
1468 | |
1469 | -- Normally it does not matter that nodes in package Standard are | |
0247964d AC |
1470 | -- not marked as analyzed. The Scalar_Range of the fixed-point type |
1471 | -- Standard_Duration is an exception, because of the special test | |
1472 | -- made in Freeze.Freeze_Fixed_Point_Type. | |
70482933 RK |
1473 | |
1474 | Set_Analyzed (Scalar_Range (Standard_Duration)); | |
1475 | ||
1476 | Set_Etype (Type_High_Bound (Standard_Duration), Standard_Duration); | |
1477 | Set_Etype (Type_Low_Bound (Standard_Duration), Standard_Duration); | |
1478 | ||
1479 | Set_Is_Static_Expression (Type_High_Bound (Standard_Duration)); | |
1480 | Set_Is_Static_Expression (Type_Low_Bound (Standard_Duration)); | |
1481 | ||
1482 | Set_Corresponding_Integer_Value | |
1483 | (Type_High_Bound (Standard_Duration), Dhi); | |
1484 | ||
1485 | Set_Corresponding_Integer_Value | |
1486 | (Type_Low_Bound (Standard_Duration), Dlo); | |
1487 | ||
1488 | Set_Size_Known_At_Compile_Time (Standard_Duration); | |
1489 | end Build_Duration; | |
1490 | ||
1491 | -- Build standard exception type. Note that the type name here is | |
e443f142 | 1492 | -- actually used in the generated code, so it must be set correctly. |
0247964d AC |
1493 | -- The type Standard_Exception_Type must be consistent with the type |
1494 | -- System.Standard_Library.Exception_Data, as the latter is what is | |
1495 | -- known by the run-time. Components of the record are documented in | |
1496 | -- the declaration in System.Standard_Library. | |
e6f69614 | 1497 | |
70482933 RK |
1498 | Standard_Exception_Type := New_Standard_Entity; |
1499 | Set_Ekind (Standard_Exception_Type, E_Record_Type); | |
1500 | Set_Etype (Standard_Exception_Type, Standard_Exception_Type); | |
1501 | Set_Scope (Standard_Exception_Type, Standard_Standard); | |
fbf5a39b | 1502 | Set_Stored_Constraint |
70482933 RK |
1503 | (Standard_Exception_Type, No_Elist); |
1504 | Init_Size_Align (Standard_Exception_Type); | |
1505 | Set_Size_Known_At_Compile_Time | |
1506 | (Standard_Exception_Type, True); | |
1507 | Make_Name (Standard_Exception_Type, "exception"); | |
1508 | ||
a2cb348e RD |
1509 | Make_Component |
1510 | (Standard_Exception_Type, Standard_Boolean, "Not_Handled_By_Others"); | |
1511 | Make_Component | |
1512 | (Standard_Exception_Type, Standard_Character, "Lang"); | |
1513 | Make_Component | |
1514 | (Standard_Exception_Type, Standard_Natural, "Name_Length"); | |
1515 | Make_Component | |
1516 | (Standard_Exception_Type, Standard_A_Char, "Full_Name"); | |
1517 | Make_Component | |
1518 | (Standard_Exception_Type, Standard_A_Char, "HTable_Ptr"); | |
1519 | Make_Component | |
e443f142 | 1520 | (Standard_Exception_Type, Standard_A_Char, "Foreign_Data"); |
a2cb348e RD |
1521 | Make_Component |
1522 | (Standard_Exception_Type, Standard_A_Char, "Raise_Hook"); | |
1523 | ||
1524 | -- Build tree for record declaration, for use by the back-end | |
70482933 RK |
1525 | |
1526 | declare | |
1527 | Comp_List : List_Id; | |
1528 | Comp : Entity_Id; | |
1529 | ||
1530 | begin | |
1531 | Comp := First_Entity (Standard_Exception_Type); | |
1532 | Comp_List := New_List; | |
70482933 RK |
1533 | while Present (Comp) loop |
1534 | Append ( | |
1535 | Make_Component_Declaration (Stloc, | |
1536 | Defining_Identifier => Comp, | |
a397db96 AC |
1537 | Component_Definition => |
1538 | Make_Component_Definition (Stloc, | |
1539 | Aliased_Present => False, | |
1540 | Subtype_Indication => New_Occurrence_Of (Etype (Comp), | |
1541 | Stloc))), | |
70482933 RK |
1542 | Comp_List); |
1543 | ||
1544 | Next_Entity (Comp); | |
1545 | end loop; | |
1546 | ||
1547 | Decl := Make_Full_Type_Declaration (Stloc, | |
1548 | Defining_Identifier => Standard_Exception_Type, | |
1549 | Type_Definition => | |
1550 | Make_Record_Definition (Stloc, | |
1551 | End_Label => Empty, | |
1552 | Component_List => | |
1553 | Make_Component_List (Stloc, | |
1554 | Component_Items => Comp_List))); | |
1555 | end; | |
1556 | ||
1557 | Append (Decl, Decl_S); | |
1558 | ||
fbf5a39b AC |
1559 | Layout_Type (Standard_Exception_Type); |
1560 | ||
70482933 RK |
1561 | -- Create declarations of standard exceptions |
1562 | ||
1563 | Build_Exception (S_Constraint_Error); | |
1564 | Build_Exception (S_Program_Error); | |
1565 | Build_Exception (S_Storage_Error); | |
1566 | Build_Exception (S_Tasking_Error); | |
1567 | ||
1568 | -- Numeric_Error is a normal exception in Ada 83, but in Ada 95 | |
0ab80019 | 1569 | -- it is a renaming of Constraint_Error. Is this test too early??? |
70482933 | 1570 | |
0ab80019 | 1571 | if Ada_Version = Ada_83 then |
70482933 RK |
1572 | Build_Exception (S_Numeric_Error); |
1573 | ||
1574 | else | |
1575 | Decl := New_Node (N_Exception_Renaming_Declaration, Stloc); | |
1576 | E_Id := Standard_Entity (S_Numeric_Error); | |
1577 | ||
1578 | Set_Ekind (E_Id, E_Exception); | |
70482933 RK |
1579 | Set_Etype (E_Id, Standard_Exception_Type); |
1580 | Set_Is_Public (E_Id); | |
1581 | Set_Renamed_Entity (E_Id, Standard_Entity (S_Constraint_Error)); | |
1582 | ||
1583 | Set_Defining_Identifier (Decl, E_Id); | |
1584 | Append (Decl, Decl_S); | |
1585 | ||
1586 | Ident_Node := New_Node (N_Identifier, Stloc); | |
1587 | Set_Chars (Ident_Node, Chars (Standard_Entity (S_Constraint_Error))); | |
1588 | Set_Entity (Ident_Node, Standard_Entity (S_Constraint_Error)); | |
1589 | Set_Name (Decl, Ident_Node); | |
1590 | end if; | |
1591 | ||
1592 | -- Abort_Signal is an entity that does not get made visible | |
1593 | ||
1594 | Abort_Signal := New_Standard_Entity; | |
ea0c8cfb RD |
1595 | Set_Chars (Abort_Signal, Name_uAbort_Signal); |
1596 | Set_Ekind (Abort_Signal, E_Exception); | |
1597 | Set_Etype (Abort_Signal, Standard_Exception_Type); | |
1598 | Set_Scope (Abort_Signal, Standard_Standard); | |
1599 | Set_Is_Public (Abort_Signal, True); | |
70482933 RK |
1600 | Decl := |
1601 | Make_Exception_Declaration (Stloc, | |
1602 | Defining_Identifier => Abort_Signal); | |
1603 | ||
1604 | -- Create defining identifiers for shift operator entities. Note | |
1605 | -- that these entities are used only for marking shift operators | |
1606 | -- generated internally, and hence need no structure, just a name | |
1607 | -- and a unique identity. | |
1608 | ||
1609 | Standard_Op_Rotate_Left := New_Standard_Entity; | |
1610 | Set_Chars (Standard_Op_Rotate_Left, Name_Rotate_Left); | |
1611 | Set_Ekind (Standard_Op_Rotate_Left, E_Operator); | |
1612 | ||
1613 | Standard_Op_Rotate_Right := New_Standard_Entity; | |
1614 | Set_Chars (Standard_Op_Rotate_Right, Name_Rotate_Right); | |
1615 | Set_Ekind (Standard_Op_Rotate_Right, E_Operator); | |
1616 | ||
1617 | Standard_Op_Shift_Left := New_Standard_Entity; | |
1618 | Set_Chars (Standard_Op_Shift_Left, Name_Shift_Left); | |
1619 | Set_Ekind (Standard_Op_Shift_Left, E_Operator); | |
1620 | ||
1621 | Standard_Op_Shift_Right := New_Standard_Entity; | |
1622 | Set_Chars (Standard_Op_Shift_Right, Name_Shift_Right); | |
1623 | Set_Ekind (Standard_Op_Shift_Right, E_Operator); | |
1624 | ||
1625 | Standard_Op_Shift_Right_Arithmetic := New_Standard_Entity; | |
1626 | Set_Chars (Standard_Op_Shift_Right_Arithmetic, | |
1627 | Name_Shift_Right_Arithmetic); | |
1628 | Set_Ekind (Standard_Op_Shift_Right_Arithmetic, | |
1629 | E_Operator); | |
1630 | ||
1631 | -- Create standard operator declarations | |
1632 | ||
1633 | Create_Operators; | |
1634 | ||
1635 | -- Initialize visibility table with entities in Standard | |
1636 | ||
1637 | for E in Standard_Entity_Type loop | |
1638 | if Ekind (Standard_Entity (E)) /= E_Operator then | |
1639 | Set_Name_Entity_Id | |
1640 | (Chars (Standard_Entity (E)), Standard_Entity (E)); | |
1641 | Set_Homonym (Standard_Entity (E), Empty); | |
1642 | end if; | |
1643 | ||
1644 | if E not in S_ASCII_Names then | |
1645 | Set_Scope (Standard_Entity (E), Standard_Standard); | |
1646 | Set_Is_Immediately_Visible (Standard_Entity (E)); | |
1647 | end if; | |
1648 | end loop; | |
1649 | ||
1650 | -- The predefined package Standard itself does not have a scope; | |
1651 | -- it is the only entity in the system not to have one, and this | |
1652 | -- is what identifies the package to Gigi. | |
1653 | ||
1654 | Set_Scope (Standard_Standard, Empty); | |
1655 | ||
1656 | -- Set global variables indicating last Id values and version | |
1657 | ||
1658 | Last_Standard_Node_Id := Last_Node_Id; | |
1659 | Last_Standard_List_Id := Last_List_Id; | |
1660 | ||
5c736541 RD |
1661 | -- The Error node has an Etype of Any_Type to help error recovery |
1662 | ||
1663 | Set_Etype (Error, Any_Type); | |
9596236a AC |
1664 | |
1665 | -- Print representation of standard if switch set | |
1666 | ||
1667 | if Opt.Print_Standard then | |
1668 | Print_Standard; | |
1669 | end if; | |
70482933 RK |
1670 | end Create_Standard; |
1671 | ||
1672 | ------------------------------------ | |
1673 | -- Create_Unconstrained_Base_Type -- | |
1674 | ------------------------------------ | |
1675 | ||
1676 | procedure Create_Unconstrained_Base_Type | |
1677 | (E : Entity_Id; | |
1678 | K : Entity_Kind) | |
1679 | is | |
1680 | New_Ent : constant Entity_Id := New_Copy (E); | |
1681 | ||
1682 | begin | |
fbf5a39b AC |
1683 | Set_Ekind (E, K); |
1684 | Set_Is_Constrained (E, True); | |
1685 | Set_Is_First_Subtype (E, True); | |
1686 | Set_Etype (E, New_Ent); | |
70482933 RK |
1687 | |
1688 | Append_Entity (New_Ent, Standard_Standard); | |
1689 | Set_Is_Constrained (New_Ent, False); | |
1690 | Set_Etype (New_Ent, New_Ent); | |
1691 | Set_Is_Known_Valid (New_Ent, True); | |
1692 | ||
1693 | if K = E_Signed_Integer_Subtype then | |
1694 | Set_Etype (Low_Bound (Scalar_Range (E)), New_Ent); | |
1695 | Set_Etype (High_Bound (Scalar_Range (E)), New_Ent); | |
1696 | end if; | |
1697 | ||
1698 | end Create_Unconstrained_Base_Type; | |
1699 | ||
1700 | -------------------- | |
1701 | -- Identifier_For -- | |
1702 | -------------------- | |
1703 | ||
1704 | function Identifier_For (S : Standard_Entity_Type) return Node_Id is | |
1705 | Ident_Node : Node_Id; | |
70482933 RK |
1706 | begin |
1707 | Ident_Node := New_Node (N_Identifier, Stloc); | |
1708 | Set_Chars (Ident_Node, Chars (Standard_Entity (S))); | |
6a2e5d0f | 1709 | Set_Entity (Ident_Node, Standard_Entity (S)); |
70482933 RK |
1710 | return Ident_Node; |
1711 | end Identifier_For; | |
1712 | ||
1713 | -------------------- | |
1714 | -- Make_Component -- | |
1715 | -------------------- | |
1716 | ||
1717 | procedure Make_Component | |
1718 | (Rec : Entity_Id; | |
1719 | Typ : Entity_Id; | |
1720 | Nam : String) | |
1721 | is | |
fbf5a39b | 1722 | Id : constant Entity_Id := New_Standard_Entity; |
70482933 RK |
1723 | |
1724 | begin | |
1725 | Set_Ekind (Id, E_Component); | |
1726 | Set_Etype (Id, Typ); | |
1727 | Set_Scope (Id, Rec); | |
1728 | Init_Component_Location (Id); | |
1729 | ||
1730 | Set_Original_Record_Component (Id, Id); | |
1731 | Make_Name (Id, Nam); | |
1732 | Append_Entity (Id, Rec); | |
1733 | end Make_Component; | |
1734 | ||
1735 | ----------------- | |
1736 | -- Make_Formal -- | |
1737 | ----------------- | |
1738 | ||
1739 | function Make_Formal | |
1740 | (Typ : Entity_Id; | |
891a6e79 | 1741 | Formal_Name : String) return Entity_Id |
70482933 RK |
1742 | is |
1743 | Formal : Entity_Id; | |
1744 | ||
1745 | begin | |
1746 | Formal := New_Standard_Entity; | |
1747 | ||
1748 | Set_Ekind (Formal, E_In_Parameter); | |
1749 | Set_Mechanism (Formal, Default_Mechanism); | |
1750 | Set_Scope (Formal, Standard_Standard); | |
1751 | Set_Etype (Formal, Typ); | |
1752 | Make_Name (Formal, Formal_Name); | |
1753 | ||
1754 | return Formal; | |
1755 | end Make_Formal; | |
1756 | ||
1757 | ------------------ | |
1758 | -- Make_Integer -- | |
1759 | ------------------ | |
1760 | ||
1761 | function Make_Integer (V : Uint) return Node_Id is | |
1762 | N : constant Node_Id := Make_Integer_Literal (Stloc, V); | |
70482933 RK |
1763 | begin |
1764 | Set_Is_Static_Expression (N); | |
1765 | return N; | |
1766 | end Make_Integer; | |
1767 | ||
1768 | --------------- | |
1769 | -- Make_Name -- | |
1770 | --------------- | |
1771 | ||
1772 | procedure Make_Name (Id : Entity_Id; Nam : String) is | |
1773 | begin | |
1774 | for J in 1 .. Nam'Length loop | |
1775 | Name_Buffer (J) := Fold_Lower (Nam (Nam'First + (J - 1))); | |
1776 | end loop; | |
1777 | ||
1778 | Name_Len := Nam'Length; | |
1779 | Set_Chars (Id, Name_Find); | |
1780 | end Make_Name; | |
1781 | ||
1782 | ------------------ | |
1783 | -- New_Operator -- | |
1784 | ------------------ | |
1785 | ||
1786 | function New_Operator (Op : Name_Id; Typ : Entity_Id) return Entity_Id is | |
1787 | Ident_Node : Entity_Id; | |
1788 | ||
1789 | begin | |
1790 | Ident_Node := Make_Defining_Identifier (Stloc, Op); | |
1791 | ||
1792 | Set_Is_Pure (Ident_Node, True); | |
1793 | Set_Ekind (Ident_Node, E_Operator); | |
1794 | Set_Etype (Ident_Node, Typ); | |
1795 | Set_Scope (Ident_Node, Standard_Standard); | |
1796 | Set_Homonym (Ident_Node, Get_Name_Entity_Id (Op)); | |
1797 | Set_Convention (Ident_Node, Convention_Intrinsic); | |
1798 | ||
1799 | Set_Is_Immediately_Visible (Ident_Node, True); | |
1800 | Set_Is_Intrinsic_Subprogram (Ident_Node, True); | |
1801 | ||
1802 | Set_Name_Entity_Id (Op, Ident_Node); | |
1803 | Append_Entity (Ident_Node, Standard_Standard); | |
1804 | return Ident_Node; | |
1805 | end New_Operator; | |
1806 | ||
1807 | ------------------------- | |
1808 | -- New_Standard_Entity -- | |
1809 | ------------------------- | |
1810 | ||
1811 | function New_Standard_Entity | |
891a6e79 | 1812 | (New_Node_Kind : Node_Kind := N_Defining_Identifier) return Entity_Id |
70482933 RK |
1813 | is |
1814 | E : constant Entity_Id := New_Entity (New_Node_Kind, Stloc); | |
1815 | ||
1816 | begin | |
1817 | -- All standard entities are Pure and Public | |
1818 | ||
1819 | Set_Is_Pure (E); | |
1820 | Set_Is_Public (E); | |
1821 | ||
1822 | -- All standard entity names are analyzed manually, and are thus | |
1823 | -- frozen as soon as they are created. | |
1824 | ||
1825 | Set_Is_Frozen (E); | |
1826 | ||
1827 | -- Set debug information required for all standard types | |
1828 | ||
1829 | Set_Needs_Debug_Info (E); | |
1830 | ||
1831 | -- All standard entities are built with fully qualified names, so | |
a90bd866 | 1832 | -- set the flag to prevent an abortive attempt at requalification. |
70482933 RK |
1833 | |
1834 | Set_Has_Qualified_Name (E); | |
1835 | ||
1836 | -- Return newly created entity to be completed by caller | |
1837 | ||
1838 | return E; | |
1839 | end New_Standard_Entity; | |
1840 | ||
41a58113 RD |
1841 | function New_Standard_Entity (S : String) return Entity_Id is |
1842 | Ent : constant Entity_Id := New_Standard_Entity; | |
1843 | begin | |
1844 | Make_Name (Ent, S); | |
1845 | return Ent; | |
1846 | end New_Standard_Entity; | |
1847 | ||
9596236a AC |
1848 | -------------------- |
1849 | -- Print_Standard -- | |
1850 | -------------------- | |
1851 | ||
1852 | procedure Print_Standard is | |
1853 | ||
1854 | procedure P (Item : String) renames Output.Write_Line; | |
a90bd866 | 1855 | -- Short-hand, since we do a lot of line writes here |
9596236a AC |
1856 | |
1857 | procedure P_Int_Range (Size : Pos); | |
1858 | -- Prints the range of an integer based on its Size | |
1859 | ||
1860 | procedure P_Float_Range (Id : Entity_Id); | |
1861 | -- Prints the bounds range for the given float type entity | |
1862 | ||
c7f0d2c0 AC |
1863 | procedure P_Float_Type (Id : Entity_Id); |
1864 | -- Prints the type declaration of the given float type entity | |
1865 | ||
1866 | procedure P_Mixed_Name (Id : Name_Id); | |
1867 | -- Prints Id in mixed case | |
1868 | ||
9596236a AC |
1869 | ------------------- |
1870 | -- P_Float_Range -- | |
1871 | ------------------- | |
1872 | ||
1873 | procedure P_Float_Range (Id : Entity_Id) is | |
9596236a AC |
1874 | begin |
1875 | Write_Str (" range "); | |
d32e3cee GB |
1876 | UR_Write (Realval (Type_Low_Bound (Id))); |
1877 | Write_Str (" .. "); | |
1878 | UR_Write (Realval (Type_High_Bound (Id))); | |
9596236a AC |
1879 | Write_Str (";"); |
1880 | Write_Eol; | |
1881 | end P_Float_Range; | |
1882 | ||
c7f0d2c0 AC |
1883 | ------------------ |
1884 | -- P_Float_Type -- | |
1885 | ------------------ | |
1886 | ||
1887 | procedure P_Float_Type (Id : Entity_Id) is | |
1888 | begin | |
1889 | Write_Str (" type "); | |
1890 | P_Mixed_Name (Chars (Id)); | |
1891 | Write_Str (" is digits "); | |
1892 | Write_Int (UI_To_Int (Digits_Value (Id))); | |
1893 | Write_Eol; | |
1894 | P_Float_Range (Id); | |
1895 | Write_Str (" for "); | |
1896 | P_Mixed_Name (Chars (Id)); | |
1897 | Write_Str ("'Size use "); | |
1898 | Write_Int (UI_To_Int (RM_Size (Id))); | |
1899 | Write_Line (";"); | |
1900 | Write_Eol; | |
1901 | end P_Float_Type; | |
1902 | ||
9596236a AC |
1903 | ----------------- |
1904 | -- P_Int_Range -- | |
1905 | ----------------- | |
1906 | ||
1907 | procedure P_Int_Range (Size : Pos) is | |
1908 | begin | |
1909 | Write_Str (" is range -(2 **"); | |
1910 | Write_Int (Size - 1); | |
1911 | Write_Str (")"); | |
1912 | Write_Str (" .. +(2 **"); | |
1913 | Write_Int (Size - 1); | |
1914 | Write_Str (" - 1);"); | |
1915 | Write_Eol; | |
1916 | end P_Int_Range; | |
1917 | ||
c7f0d2c0 AC |
1918 | ------------------ |
1919 | -- P_Mixed_Name -- | |
1920 | ------------------ | |
1921 | ||
1922 | procedure P_Mixed_Name (Id : Name_Id) is | |
1923 | begin | |
1924 | Get_Name_String (Id); | |
1925 | ||
1926 | for J in 1 .. Name_Len loop | |
1927 | if J = 1 or else Name_Buffer (J - 1) = '_' then | |
1928 | Name_Buffer (J) := Fold_Upper (Name_Buffer (J)); | |
1929 | end if; | |
1930 | end loop; | |
1931 | ||
1932 | Write_Str (Name_Buffer (1 .. Name_Len)); | |
1933 | end P_Mixed_Name; | |
1934 | ||
9596236a AC |
1935 | -- Start of processing for Print_Standard |
1936 | ||
1937 | begin | |
1938 | P ("-- Representation of package Standard"); | |
1939 | Write_Eol; | |
1940 | P ("-- This is not accurate Ada, since new base types cannot be "); | |
1941 | P ("-- created, but the listing shows the target dependent"); | |
1942 | P ("-- characteristics of the Standard types for this compiler"); | |
1943 | Write_Eol; | |
1944 | ||
1945 | P ("package Standard is"); | |
efde9617 | 1946 | P ("pragma Pure (Standard);"); |
9596236a AC |
1947 | Write_Eol; |
1948 | ||
1949 | P (" type Boolean is (False, True);"); | |
1950 | P (" for Boolean'Size use 1;"); | |
1951 | P (" for Boolean use (False => 0, True => 1);"); | |
1952 | Write_Eol; | |
1953 | ||
1954 | -- Integer types | |
1955 | ||
1956 | Write_Str (" type Integer"); | |
1957 | P_Int_Range (Standard_Integer_Size); | |
1958 | Write_Str (" for Integer'Size use "); | |
1959 | Write_Int (Standard_Integer_Size); | |
1960 | P (";"); | |
1961 | Write_Eol; | |
1962 | ||
1963 | P (" subtype Natural is Integer range 0 .. Integer'Last;"); | |
1964 | P (" subtype Positive is Integer range 1 .. Integer'Last;"); | |
1965 | Write_Eol; | |
1966 | ||
1967 | Write_Str (" type Short_Short_Integer"); | |
1968 | P_Int_Range (Standard_Short_Short_Integer_Size); | |
1969 | Write_Str (" for Short_Short_Integer'Size use "); | |
1970 | Write_Int (Standard_Short_Short_Integer_Size); | |
1971 | P (";"); | |
1972 | Write_Eol; | |
1973 | ||
1974 | Write_Str (" type Short_Integer"); | |
1975 | P_Int_Range (Standard_Short_Integer_Size); | |
1976 | Write_Str (" for Short_Integer'Size use "); | |
1977 | Write_Int (Standard_Short_Integer_Size); | |
1978 | P (";"); | |
1979 | Write_Eol; | |
1980 | ||
1981 | Write_Str (" type Long_Integer"); | |
1982 | P_Int_Range (Standard_Long_Integer_Size); | |
1983 | Write_Str (" for Long_Integer'Size use "); | |
1984 | Write_Int (Standard_Long_Integer_Size); | |
1985 | P (";"); | |
1986 | Write_Eol; | |
1987 | ||
1988 | Write_Str (" type Long_Long_Integer"); | |
1989 | P_Int_Range (Standard_Long_Long_Integer_Size); | |
1990 | Write_Str (" for Long_Long_Integer'Size use "); | |
1991 | Write_Int (Standard_Long_Long_Integer_Size); | |
1992 | P (";"); | |
1993 | Write_Eol; | |
1994 | ||
1995 | -- Floating point types | |
1996 | ||
c7f0d2c0 AC |
1997 | P_Float_Type (Standard_Short_Float); |
1998 | P_Float_Type (Standard_Float); | |
1999 | P_Float_Type (Standard_Long_Float); | |
2000 | P_Float_Type (Standard_Long_Long_Float); | |
9596236a AC |
2001 | |
2002 | P (" type Character is (...)"); | |
2003 | Write_Str (" for Character'Size use "); | |
2004 | Write_Int (Standard_Character_Size); | |
2005 | P (";"); | |
2006 | P (" -- See RM A.1(35) for details of this type"); | |
2007 | Write_Eol; | |
2008 | ||
2009 | P (" type Wide_Character is (...)"); | |
2010 | Write_Str (" for Wide_Character'Size use "); | |
2011 | Write_Int (Standard_Wide_Character_Size); | |
2012 | P (";"); | |
2013 | P (" -- See RM A.1(36) for details of this type"); | |
2014 | Write_Eol; | |
2015 | ||
82c80734 | 2016 | P (" type Wide_Wide_Character is (...)"); |
5b6a0e43 | 2017 | Write_Str (" for Wide_Wide_Character'Size use "); |
82c80734 RD |
2018 | Write_Int (Standard_Wide_Wide_Character_Size); |
2019 | P (";"); | |
2020 | P (" -- See RM A.1(36) for details of this type"); | |
2021 | ||
9596236a AC |
2022 | P (" type String is array (Positive range <>) of Character;"); |
2023 | P (" pragma Pack (String);"); | |
2024 | Write_Eol; | |
2025 | ||
2026 | P (" type Wide_String is array (Positive range <>)" & | |
2027 | " of Wide_Character;"); | |
2028 | P (" pragma Pack (Wide_String);"); | |
2029 | Write_Eol; | |
2030 | ||
82c80734 RD |
2031 | P (" type Wide_Wide_String is array (Positive range <>)" & |
2032 | " of Wide_Wide_Character;"); | |
2033 | P (" pragma Pack (Wide_Wide_String);"); | |
2034 | Write_Eol; | |
2035 | ||
3d6c3bd7 GB |
2036 | -- We only have one representation each for 32-bit and 64-bit sizes, |
2037 | -- so select the right one based on Duration_32_Bits_On_Target. | |
9596236a AC |
2038 | |
2039 | if Duration_32_Bits_On_Target then | |
2040 | P (" type Duration is delta 0.020"); | |
cad97339 | 2041 | P (" range -((2 ** 31) * 0.020) .."); |
9596236a AC |
2042 | P (" +((2 ** 31 - 1) * 0.020);"); |
2043 | P (" for Duration'Small use 0.020;"); | |
3d6c3bd7 | 2044 | |
9596236a AC |
2045 | else |
2046 | P (" type Duration is delta 0.000000001"); | |
cad97339 | 2047 | P (" range -((2 ** 63) * 0.000000001) .."); |
9596236a AC |
2048 | P (" +((2 ** 63 - 1) * 0.000000001);"); |
2049 | P (" for Duration'Small use 0.000000001;"); | |
2050 | end if; | |
2051 | ||
2052 | Write_Eol; | |
2053 | ||
2054 | P (" Constraint_Error : exception;"); | |
2055 | P (" Program_Error : exception;"); | |
2056 | P (" Storage_Error : exception;"); | |
2057 | P (" Tasking_Error : exception;"); | |
2058 | P (" Numeric_Error : exception renames Constraint_Error;"); | |
2059 | Write_Eol; | |
2060 | ||
2061 | P ("end Standard;"); | |
2062 | end Print_Standard; | |
2063 | ||
f8726f2b AC |
2064 | ------------------------- |
2065 | -- Register_Float_Type -- | |
2066 | ------------------------- | |
2067 | ||
2068 | procedure Register_Float_Type | |
289a994b AC |
2069 | (Name : String; |
2070 | Digs : Positive; | |
f8726f2b | 2071 | Float_Rep : Float_Rep_Kind; |
00c5acd3 | 2072 | Precision : Positive; |
f8726f2b AC |
2073 | Size : Positive; |
2074 | Alignment : Natural) | |
2075 | is | |
2e60feb5 PMR |
2076 | pragma Unreferenced (Precision); |
2077 | -- See Build_Float_Type for the rationale | |
2078 | ||
00c5acd3 | 2079 | Ent : constant Entity_Id := New_Standard_Entity; |
f8726f2b AC |
2080 | |
2081 | begin | |
289a994b AC |
2082 | Set_Defining_Identifier (New_Node (N_Full_Type_Declaration, Stloc), Ent); |
2083 | Make_Name (Ent, Name); | |
2084 | Set_Scope (Ent, Standard_Standard); | |
2e60feb5 PMR |
2085 | Build_Float_Type |
2086 | (Ent, Pos (Digs), Float_Rep, Int (Size), Int (Alignment / 8)); | |
289a994b AC |
2087 | |
2088 | if No (Back_End_Float_Types) then | |
2089 | Back_End_Float_Types := New_Elmt_List; | |
15b682ca GB |
2090 | end if; |
2091 | ||
289a994b | 2092 | Append_Elmt (Ent, Back_End_Float_Types); |
f8726f2b AC |
2093 | end Register_Float_Type; |
2094 | ||
70482933 RK |
2095 | ---------------------- |
2096 | -- Set_Float_Bounds -- | |
2097 | ---------------------- | |
2098 | ||
2099 | procedure Set_Float_Bounds (Id : Entity_Id) is | |
d32e3cee | 2100 | L : Node_Id; |
d32e3cee | 2101 | H : Node_Id; |
289a994b | 2102 | -- Low and high bounds of literal value |
70482933 | 2103 | |
d32e3cee | 2104 | R : Node_Id; |
70482933 RK |
2105 | -- Range specification |
2106 | ||
d32e3cee GB |
2107 | Radix : constant Uint := Machine_Radix_Value (Id); |
2108 | Mantissa : constant Uint := Machine_Mantissa_Value (Id); | |
2109 | Emax : constant Uint := Machine_Emax_Value (Id); | |
2110 | Significand : constant Uint := Radix ** Mantissa - 1; | |
2111 | Exponent : constant Uint := Emax - Mantissa; | |
70482933 RK |
2112 | |
2113 | begin | |
d32e3cee GB |
2114 | H := Make_Float_Literal (Stloc, Radix, Significand, Exponent); |
2115 | L := Make_Float_Literal (Stloc, Radix, -Significand, Exponent); | |
70482933 RK |
2116 | |
2117 | Set_Etype (L, Id); | |
2118 | Set_Is_Static_Expression (L); | |
2119 | ||
2120 | Set_Etype (H, Id); | |
2121 | Set_Is_Static_Expression (H); | |
2122 | ||
2123 | R := New_Node (N_Range, Stloc); | |
2124 | Set_Low_Bound (R, L); | |
2125 | Set_High_Bound (R, H); | |
2126 | Set_Includes_Infinities (R, True); | |
2127 | Set_Scalar_Range (Id, R); | |
2128 | Set_Etype (R, Id); | |
2129 | Set_Parent (R, Id); | |
2130 | end Set_Float_Bounds; | |
2131 | ||
2132 | ------------------------ | |
2133 | -- Set_Integer_Bounds -- | |
2134 | ------------------------ | |
2135 | ||
2136 | procedure Set_Integer_Bounds | |
2137 | (Id : Entity_Id; | |
2138 | Typ : Entity_Id; | |
2139 | Lb : Uint; | |
2140 | Hb : Uint) | |
2141 | is | |
289a994b AC |
2142 | L : Node_Id; |
2143 | H : Node_Id; | |
2144 | -- Low and high bounds of literal value | |
2145 | ||
2146 | R : Node_Id; | |
2147 | -- Range specification | |
70482933 RK |
2148 | |
2149 | begin | |
2150 | L := Make_Integer (Lb); | |
2151 | H := Make_Integer (Hb); | |
2152 | ||
2153 | Set_Etype (L, Typ); | |
2154 | Set_Etype (H, Typ); | |
2155 | ||
2156 | R := New_Node (N_Range, Stloc); | |
2157 | Set_Low_Bound (R, L); | |
2158 | Set_High_Bound (R, H); | |
2159 | Set_Scalar_Range (Id, R); | |
2160 | Set_Etype (R, Typ); | |
2161 | Set_Parent (R, Id); | |
2162 | Set_Is_Unsigned_Type (Id, Lb >= 0); | |
2163 | end Set_Integer_Bounds; | |
2164 | ||
2165 | end CStand; |