annotate gcc/ada/cstand.adb @ 111:04ced10e8804

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