annotate gcc/ada/cstand.adb @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
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 -- --
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
9 -- Copyright (C) 1992-2019, Free Software Foundation, Inc. --
111
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);
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
720 Set_Is_Implementation_Defined (Standard_Short_Short_Integer);
111
kono
parents:
diff changeset
721
kono
parents:
diff changeset
722 Build_Signed_Integer_Type
kono
parents:
diff changeset
723 (Standard_Short_Integer, Standard_Short_Integer_Size);
kono
parents:
diff changeset
724 Set_Is_Implementation_Defined (Standard_Short_Integer);
kono
parents:
diff changeset
725
kono
parents:
diff changeset
726 Build_Signed_Integer_Type
kono
parents:
diff changeset
727 (Standard_Integer, Standard_Integer_Size);
kono
parents:
diff changeset
728
kono
parents:
diff changeset
729 Build_Signed_Integer_Type
kono
parents:
diff changeset
730 (Standard_Long_Integer, Standard_Long_Integer_Size);
kono
parents:
diff changeset
731
kono
parents:
diff changeset
732 Build_Signed_Integer_Type
kono
parents:
diff changeset
733 (Standard_Long_Long_Integer, Standard_Long_Long_Integer_Size);
kono
parents:
diff changeset
734 Set_Is_Implementation_Defined (Standard_Long_Long_Integer);
kono
parents:
diff changeset
735
kono
parents:
diff changeset
736 Create_Unconstrained_Base_Type
kono
parents:
diff changeset
737 (Standard_Short_Short_Integer, E_Signed_Integer_Subtype);
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
kono
parents:
diff changeset
751 Create_Float_Types;
kono
parents:
diff changeset
752
kono
parents:
diff changeset
753 -- Create type definition node for type Character. Note that we do not
kono
parents:
diff changeset
754 -- set the Literals field, since type Character is handled with special
kono
parents:
diff changeset
755 -- routine that do not need a literal list.
kono
parents:
diff changeset
756
kono
parents:
diff changeset
757 Tdef_Node := New_Node (N_Enumeration_Type_Definition, Stloc);
kono
parents:
diff changeset
758 Set_Type_Definition (Parent (Standard_Character), Tdef_Node);
kono
parents:
diff changeset
759
kono
parents:
diff changeset
760 Set_Ekind (Standard_Character, E_Enumeration_Type);
kono
parents:
diff changeset
761 Set_Etype (Standard_Character, Standard_Character);
kono
parents:
diff changeset
762 Init_Esize (Standard_Character, Standard_Character_Size);
kono
parents:
diff changeset
763 Init_RM_Size (Standard_Character, 8);
kono
parents:
diff changeset
764 Set_Elem_Alignment (Standard_Character);
kono
parents:
diff changeset
765
kono
parents:
diff changeset
766 Set_Has_Pragma_Ordered (Standard_Character);
kono
parents:
diff changeset
767 Set_Is_Unsigned_Type (Standard_Character);
kono
parents:
diff changeset
768 Set_Is_Character_Type (Standard_Character);
kono
parents:
diff changeset
769 Set_Is_Known_Valid (Standard_Character);
kono
parents:
diff changeset
770 Set_Size_Known_At_Compile_Time (Standard_Character);
kono
parents:
diff changeset
771
kono
parents:
diff changeset
772 -- Create the bounds for type Character
kono
parents:
diff changeset
773
kono
parents:
diff changeset
774 R_Node := New_Node (N_Range, Stloc);
kono
parents:
diff changeset
775
kono
parents:
diff changeset
776 -- Low bound for type Character (Standard.Nul)
kono
parents:
diff changeset
777
kono
parents:
diff changeset
778 B_Node := New_Node (N_Character_Literal, Stloc);
kono
parents:
diff changeset
779 Set_Is_Static_Expression (B_Node);
kono
parents:
diff changeset
780 Set_Chars (B_Node, No_Name);
kono
parents:
diff changeset
781 Set_Char_Literal_Value (B_Node, Uint_0);
kono
parents:
diff changeset
782 Set_Entity (B_Node, Empty);
kono
parents:
diff changeset
783 Set_Etype (B_Node, Standard_Character);
kono
parents:
diff changeset
784 Set_Low_Bound (R_Node, B_Node);
kono
parents:
diff changeset
785
kono
parents:
diff changeset
786 -- High bound for type Character
kono
parents:
diff changeset
787
kono
parents:
diff changeset
788 B_Node := New_Node (N_Character_Literal, Stloc);
kono
parents:
diff changeset
789 Set_Is_Static_Expression (B_Node);
kono
parents:
diff changeset
790 Set_Chars (B_Node, No_Name);
kono
parents:
diff changeset
791 Set_Char_Literal_Value (B_Node, UI_From_Int (16#FF#));
kono
parents:
diff changeset
792 Set_Entity (B_Node, Empty);
kono
parents:
diff changeset
793 Set_Etype (B_Node, Standard_Character);
kono
parents:
diff changeset
794 Set_High_Bound (R_Node, B_Node);
kono
parents:
diff changeset
795
kono
parents:
diff changeset
796 Set_Scalar_Range (Standard_Character, R_Node);
kono
parents:
diff changeset
797 Set_Etype (R_Node, Standard_Character);
kono
parents:
diff changeset
798 Set_Parent (R_Node, Standard_Character);
kono
parents:
diff changeset
799
kono
parents:
diff changeset
800 -- Create type definition for type Wide_Character. Note that we do not
kono
parents:
diff changeset
801 -- set the Literals field, since type Wide_Character is handled with
kono
parents:
diff changeset
802 -- special routines that do not need a literal list.
kono
parents:
diff changeset
803
kono
parents:
diff changeset
804 Tdef_Node := New_Node (N_Enumeration_Type_Definition, Stloc);
kono
parents:
diff changeset
805 Set_Type_Definition (Parent (Standard_Wide_Character), Tdef_Node);
kono
parents:
diff changeset
806
kono
parents:
diff changeset
807 Set_Ekind (Standard_Wide_Character, E_Enumeration_Type);
kono
parents:
diff changeset
808 Set_Etype (Standard_Wide_Character, Standard_Wide_Character);
kono
parents:
diff changeset
809 Init_Size (Standard_Wide_Character, Standard_Wide_Character_Size);
kono
parents:
diff changeset
810
kono
parents:
diff changeset
811 Set_Elem_Alignment (Standard_Wide_Character);
kono
parents:
diff changeset
812 Set_Has_Pragma_Ordered (Standard_Wide_Character);
kono
parents:
diff changeset
813 Set_Is_Unsigned_Type (Standard_Wide_Character);
kono
parents:
diff changeset
814 Set_Is_Character_Type (Standard_Wide_Character);
kono
parents:
diff changeset
815 Set_Is_Known_Valid (Standard_Wide_Character);
kono
parents:
diff changeset
816 Set_Size_Known_At_Compile_Time (Standard_Wide_Character);
kono
parents:
diff changeset
817
kono
parents:
diff changeset
818 -- Create the bounds for type Wide_Character
kono
parents:
diff changeset
819
kono
parents:
diff changeset
820 R_Node := New_Node (N_Range, Stloc);
kono
parents:
diff changeset
821
kono
parents:
diff changeset
822 -- Low bound for type Wide_Character
kono
parents:
diff changeset
823
kono
parents:
diff changeset
824 B_Node := New_Node (N_Character_Literal, Stloc);
kono
parents:
diff changeset
825 Set_Is_Static_Expression (B_Node);
kono
parents:
diff changeset
826 Set_Chars (B_Node, No_Name); -- ???
kono
parents:
diff changeset
827 Set_Char_Literal_Value (B_Node, Uint_0);
kono
parents:
diff changeset
828 Set_Entity (B_Node, Empty);
kono
parents:
diff changeset
829 Set_Etype (B_Node, Standard_Wide_Character);
kono
parents:
diff changeset
830 Set_Low_Bound (R_Node, B_Node);
kono
parents:
diff changeset
831
kono
parents:
diff changeset
832 -- High bound for type Wide_Character
kono
parents:
diff changeset
833
kono
parents:
diff changeset
834 B_Node := New_Node (N_Character_Literal, Stloc);
kono
parents:
diff changeset
835 Set_Is_Static_Expression (B_Node);
kono
parents:
diff changeset
836 Set_Chars (B_Node, No_Name); -- ???
kono
parents:
diff changeset
837 Set_Char_Literal_Value (B_Node, UI_From_Int (16#FFFF#));
kono
parents:
diff changeset
838 Set_Entity (B_Node, Empty);
kono
parents:
diff changeset
839 Set_Etype (B_Node, Standard_Wide_Character);
kono
parents:
diff changeset
840 Set_High_Bound (R_Node, B_Node);
kono
parents:
diff changeset
841
kono
parents:
diff changeset
842 Set_Scalar_Range (Standard_Wide_Character, R_Node);
kono
parents:
diff changeset
843 Set_Etype (R_Node, Standard_Wide_Character);
kono
parents:
diff changeset
844 Set_Parent (R_Node, Standard_Wide_Character);
kono
parents:
diff changeset
845
kono
parents:
diff changeset
846 -- Create type definition for type Wide_Wide_Character. Note that we
kono
parents:
diff changeset
847 -- do not set the Literals field, since type Wide_Wide_Character is
kono
parents:
diff changeset
848 -- handled with special routines that do not need a literal list.
kono
parents:
diff changeset
849
kono
parents:
diff changeset
850 Tdef_Node := New_Node (N_Enumeration_Type_Definition, Stloc);
kono
parents:
diff changeset
851 Set_Type_Definition (Parent (Standard_Wide_Wide_Character), Tdef_Node);
kono
parents:
diff changeset
852
kono
parents:
diff changeset
853 Set_Ekind (Standard_Wide_Wide_Character, E_Enumeration_Type);
kono
parents:
diff changeset
854 Set_Etype (Standard_Wide_Wide_Character,
kono
parents:
diff changeset
855 Standard_Wide_Wide_Character);
kono
parents:
diff changeset
856 Init_Size (Standard_Wide_Wide_Character,
kono
parents:
diff changeset
857 Standard_Wide_Wide_Character_Size);
kono
parents:
diff changeset
858
kono
parents:
diff changeset
859 Set_Elem_Alignment (Standard_Wide_Wide_Character);
kono
parents:
diff changeset
860 Set_Has_Pragma_Ordered (Standard_Wide_Wide_Character);
kono
parents:
diff changeset
861 Set_Is_Unsigned_Type (Standard_Wide_Wide_Character);
kono
parents:
diff changeset
862 Set_Is_Character_Type (Standard_Wide_Wide_Character);
kono
parents:
diff changeset
863 Set_Is_Known_Valid (Standard_Wide_Wide_Character);
kono
parents:
diff changeset
864 Set_Size_Known_At_Compile_Time (Standard_Wide_Wide_Character);
kono
parents:
diff changeset
865 Set_Is_Ada_2005_Only (Standard_Wide_Wide_Character);
kono
parents:
diff changeset
866
kono
parents:
diff changeset
867 -- Create the bounds for type Wide_Wide_Character
kono
parents:
diff changeset
868
kono
parents:
diff changeset
869 R_Node := New_Node (N_Range, Stloc);
kono
parents:
diff changeset
870
kono
parents:
diff changeset
871 -- Low bound for type Wide_Wide_Character
kono
parents:
diff changeset
872
kono
parents:
diff changeset
873 B_Node := New_Node (N_Character_Literal, Stloc);
kono
parents:
diff changeset
874 Set_Is_Static_Expression (B_Node);
kono
parents:
diff changeset
875 Set_Chars (B_Node, No_Name); -- ???
kono
parents:
diff changeset
876 Set_Char_Literal_Value (B_Node, Uint_0);
kono
parents:
diff changeset
877 Set_Entity (B_Node, Empty);
kono
parents:
diff changeset
878 Set_Etype (B_Node, Standard_Wide_Wide_Character);
kono
parents:
diff changeset
879 Set_Low_Bound (R_Node, B_Node);
kono
parents:
diff changeset
880
kono
parents:
diff changeset
881 -- High bound for type Wide_Wide_Character
kono
parents:
diff changeset
882
kono
parents:
diff changeset
883 B_Node := New_Node (N_Character_Literal, Stloc);
kono
parents:
diff changeset
884 Set_Is_Static_Expression (B_Node);
kono
parents:
diff changeset
885 Set_Chars (B_Node, No_Name); -- ???
kono
parents:
diff changeset
886 Set_Char_Literal_Value (B_Node, UI_From_Int (16#7FFF_FFFF#));
kono
parents:
diff changeset
887 Set_Entity (B_Node, Empty);
kono
parents:
diff changeset
888 Set_Etype (B_Node, Standard_Wide_Wide_Character);
kono
parents:
diff changeset
889 Set_High_Bound (R_Node, B_Node);
kono
parents:
diff changeset
890
kono
parents:
diff changeset
891 Set_Scalar_Range (Standard_Wide_Wide_Character, R_Node);
kono
parents:
diff changeset
892 Set_Etype (R_Node, Standard_Wide_Wide_Character);
kono
parents:
diff changeset
893 Set_Parent (R_Node, Standard_Wide_Wide_Character);
kono
parents:
diff changeset
894
kono
parents:
diff changeset
895 -- Create type definition node for type String
kono
parents:
diff changeset
896
kono
parents:
diff changeset
897 Tdef_Node := New_Node (N_Unconstrained_Array_Definition, Stloc);
kono
parents:
diff changeset
898
kono
parents:
diff changeset
899 declare
kono
parents:
diff changeset
900 CompDef_Node : Node_Id;
kono
parents:
diff changeset
901 begin
kono
parents:
diff changeset
902 CompDef_Node := New_Node (N_Component_Definition, Stloc);
kono
parents:
diff changeset
903 Set_Aliased_Present (CompDef_Node, False);
kono
parents:
diff changeset
904 Set_Access_Definition (CompDef_Node, Empty);
kono
parents:
diff changeset
905 Set_Subtype_Indication (CompDef_Node, Identifier_For (S_Character));
kono
parents:
diff changeset
906 Set_Component_Definition (Tdef_Node, CompDef_Node);
kono
parents:
diff changeset
907 end;
kono
parents:
diff changeset
908
kono
parents:
diff changeset
909 Set_Subtype_Marks (Tdef_Node, New_List);
kono
parents:
diff changeset
910 Append (Identifier_For (S_Positive), Subtype_Marks (Tdef_Node));
kono
parents:
diff changeset
911 Set_Type_Definition (Parent (Standard_String), Tdef_Node);
kono
parents:
diff changeset
912
kono
parents:
diff changeset
913 Set_Ekind (Standard_String, E_Array_Type);
kono
parents:
diff changeset
914 Set_Etype (Standard_String, Standard_String);
kono
parents:
diff changeset
915 Set_Component_Type (Standard_String, Standard_Character);
kono
parents:
diff changeset
916 Set_Component_Size (Standard_String, Uint_8);
kono
parents:
diff changeset
917 Init_Size_Align (Standard_String);
kono
parents:
diff changeset
918 Set_Alignment (Standard_String, Uint_1);
kono
parents:
diff changeset
919 Pack_String_Type (Standard_String);
kono
parents:
diff changeset
920
kono
parents:
diff changeset
921 -- On targets where a storage unit is larger than a byte (such as AAMP),
kono
parents:
diff changeset
922 -- pragma Pack has a real effect on the representation of type String,
kono
parents:
diff changeset
923 -- and the type must be marked as having a nonstandard representation.
kono
parents:
diff changeset
924
kono
parents:
diff changeset
925 if System_Storage_Unit > Uint_8 then
kono
parents:
diff changeset
926 Set_Has_Non_Standard_Rep (Standard_String);
kono
parents:
diff changeset
927 Set_Has_Pragma_Pack (Standard_String);
kono
parents:
diff changeset
928 end if;
kono
parents:
diff changeset
929
kono
parents:
diff changeset
930 -- Set index type of String
kono
parents:
diff changeset
931
kono
parents:
diff changeset
932 E_Id :=
kono
parents:
diff changeset
933 First (Subtype_Marks (Type_Definition (Parent (Standard_String))));
kono
parents:
diff changeset
934 Set_First_Index (Standard_String, E_Id);
kono
parents:
diff changeset
935 Set_Entity (E_Id, Standard_Positive);
kono
parents:
diff changeset
936 Set_Etype (E_Id, Standard_Positive);
kono
parents:
diff changeset
937
kono
parents:
diff changeset
938 -- Create type definition node for type Wide_String
kono
parents:
diff changeset
939
kono
parents:
diff changeset
940 Tdef_Node := New_Node (N_Unconstrained_Array_Definition, Stloc);
kono
parents:
diff changeset
941
kono
parents:
diff changeset
942 declare
kono
parents:
diff changeset
943 CompDef_Node : Node_Id;
kono
parents:
diff changeset
944 begin
kono
parents:
diff changeset
945 CompDef_Node := New_Node (N_Component_Definition, Stloc);
kono
parents:
diff changeset
946 Set_Aliased_Present (CompDef_Node, False);
kono
parents:
diff changeset
947 Set_Access_Definition (CompDef_Node, Empty);
kono
parents:
diff changeset
948 Set_Subtype_Indication (CompDef_Node,
kono
parents:
diff changeset
949 Identifier_For (S_Wide_Character));
kono
parents:
diff changeset
950 Set_Component_Definition (Tdef_Node, CompDef_Node);
kono
parents:
diff changeset
951 end;
kono
parents:
diff changeset
952
kono
parents:
diff changeset
953 Set_Subtype_Marks (Tdef_Node, New_List);
kono
parents:
diff changeset
954 Append (Identifier_For (S_Positive), Subtype_Marks (Tdef_Node));
kono
parents:
diff changeset
955 Set_Type_Definition (Parent (Standard_Wide_String), Tdef_Node);
kono
parents:
diff changeset
956
kono
parents:
diff changeset
957 Set_Ekind (Standard_Wide_String, E_Array_Type);
kono
parents:
diff changeset
958 Set_Etype (Standard_Wide_String, Standard_Wide_String);
kono
parents:
diff changeset
959 Set_Component_Type (Standard_Wide_String, Standard_Wide_Character);
kono
parents:
diff changeset
960 Set_Component_Size (Standard_Wide_String, Uint_16);
kono
parents:
diff changeset
961 Init_Size_Align (Standard_Wide_String);
kono
parents:
diff changeset
962 Pack_String_Type (Standard_Wide_String);
kono
parents:
diff changeset
963
kono
parents:
diff changeset
964 -- Set index type of Wide_String
kono
parents:
diff changeset
965
kono
parents:
diff changeset
966 E_Id :=
kono
parents:
diff changeset
967 First
kono
parents:
diff changeset
968 (Subtype_Marks (Type_Definition (Parent (Standard_Wide_String))));
kono
parents:
diff changeset
969 Set_First_Index (Standard_Wide_String, E_Id);
kono
parents:
diff changeset
970 Set_Entity (E_Id, Standard_Positive);
kono
parents:
diff changeset
971 Set_Etype (E_Id, Standard_Positive);
kono
parents:
diff changeset
972
kono
parents:
diff changeset
973 -- Create type definition node for type Wide_Wide_String
kono
parents:
diff changeset
974
kono
parents:
diff changeset
975 Tdef_Node := New_Node (N_Unconstrained_Array_Definition, Stloc);
kono
parents:
diff changeset
976
kono
parents:
diff changeset
977 declare
kono
parents:
diff changeset
978 CompDef_Node : Node_Id;
kono
parents:
diff changeset
979 begin
kono
parents:
diff changeset
980 CompDef_Node := New_Node (N_Component_Definition, Stloc);
kono
parents:
diff changeset
981 Set_Aliased_Present (CompDef_Node, False);
kono
parents:
diff changeset
982 Set_Access_Definition (CompDef_Node, Empty);
kono
parents:
diff changeset
983 Set_Subtype_Indication (CompDef_Node,
kono
parents:
diff changeset
984 Identifier_For (S_Wide_Wide_Character));
kono
parents:
diff changeset
985 Set_Component_Definition (Tdef_Node, CompDef_Node);
kono
parents:
diff changeset
986 end;
kono
parents:
diff changeset
987
kono
parents:
diff changeset
988 Set_Subtype_Marks (Tdef_Node, New_List);
kono
parents:
diff changeset
989 Append (Identifier_For (S_Positive), Subtype_Marks (Tdef_Node));
kono
parents:
diff changeset
990 Set_Type_Definition (Parent (Standard_Wide_Wide_String), Tdef_Node);
kono
parents:
diff changeset
991
kono
parents:
diff changeset
992 Set_Ekind (Standard_Wide_Wide_String, E_Array_Type);
kono
parents:
diff changeset
993 Set_Etype (Standard_Wide_Wide_String,
kono
parents:
diff changeset
994 Standard_Wide_Wide_String);
kono
parents:
diff changeset
995 Set_Component_Type (Standard_Wide_Wide_String,
kono
parents:
diff changeset
996 Standard_Wide_Wide_Character);
kono
parents:
diff changeset
997 Set_Component_Size (Standard_Wide_Wide_String, Uint_32);
kono
parents:
diff changeset
998 Init_Size_Align (Standard_Wide_Wide_String);
kono
parents:
diff changeset
999 Set_Is_Ada_2005_Only (Standard_Wide_Wide_String);
kono
parents:
diff changeset
1000 Pack_String_Type (Standard_Wide_Wide_String);
kono
parents:
diff changeset
1001
kono
parents:
diff changeset
1002 -- Set index type of Wide_Wide_String
kono
parents:
diff changeset
1003
kono
parents:
diff changeset
1004 E_Id :=
kono
parents:
diff changeset
1005 First
kono
parents:
diff changeset
1006 (Subtype_Marks
kono
parents:
diff changeset
1007 (Type_Definition (Parent (Standard_Wide_Wide_String))));
kono
parents:
diff changeset
1008 Set_First_Index (Standard_Wide_Wide_String, E_Id);
kono
parents:
diff changeset
1009 Set_Entity (E_Id, Standard_Positive);
kono
parents:
diff changeset
1010 Set_Etype (E_Id, Standard_Positive);
kono
parents:
diff changeset
1011
kono
parents:
diff changeset
1012 -- Setup entity for Natural
kono
parents:
diff changeset
1013
kono
parents:
diff changeset
1014 Set_Ekind (Standard_Natural, E_Signed_Integer_Subtype);
kono
parents:
diff changeset
1015 Set_Etype (Standard_Natural, Base_Type (Standard_Integer));
kono
parents:
diff changeset
1016 Init_Esize (Standard_Natural, Standard_Integer_Size);
kono
parents:
diff changeset
1017 Init_RM_Size (Standard_Natural, Standard_Integer_Size - 1);
kono
parents:
diff changeset
1018 Set_Elem_Alignment (Standard_Natural);
kono
parents:
diff changeset
1019 Set_Size_Known_At_Compile_Time
kono
parents:
diff changeset
1020 (Standard_Natural);
kono
parents:
diff changeset
1021 Set_Integer_Bounds (Standard_Natural,
kono
parents:
diff changeset
1022 Typ => Base_Type (Standard_Integer),
kono
parents:
diff changeset
1023 Lb => Uint_0,
kono
parents:
diff changeset
1024 Hb => Intval (High_Bound (Scalar_Range (Standard_Integer))));
kono
parents:
diff changeset
1025 Set_Is_Constrained (Standard_Natural);
kono
parents:
diff changeset
1026
kono
parents:
diff changeset
1027 -- Setup entity for Positive
kono
parents:
diff changeset
1028
kono
parents:
diff changeset
1029 Set_Ekind (Standard_Positive, E_Signed_Integer_Subtype);
kono
parents:
diff changeset
1030 Set_Etype (Standard_Positive, Base_Type (Standard_Integer));
kono
parents:
diff changeset
1031 Init_Esize (Standard_Positive, Standard_Integer_Size);
kono
parents:
diff changeset
1032 Init_RM_Size (Standard_Positive, Standard_Integer_Size - 1);
kono
parents:
diff changeset
1033 Set_Elem_Alignment (Standard_Positive);
kono
parents:
diff changeset
1034
kono
parents:
diff changeset
1035 Set_Size_Known_At_Compile_Time (Standard_Positive);
kono
parents:
diff changeset
1036
kono
parents:
diff changeset
1037 Set_Integer_Bounds (Standard_Positive,
kono
parents:
diff changeset
1038 Typ => Base_Type (Standard_Integer),
kono
parents:
diff changeset
1039 Lb => Uint_1,
kono
parents:
diff changeset
1040 Hb => Intval (High_Bound (Scalar_Range (Standard_Integer))));
kono
parents:
diff changeset
1041 Set_Is_Constrained (Standard_Positive);
kono
parents:
diff changeset
1042
kono
parents:
diff changeset
1043 -- Create declaration for package ASCII
kono
parents:
diff changeset
1044
kono
parents:
diff changeset
1045 Decl := New_Node (N_Package_Declaration, Stloc);
kono
parents:
diff changeset
1046 Append (Decl, Decl_S);
kono
parents:
diff changeset
1047
kono
parents:
diff changeset
1048 Pspec := New_Node (N_Package_Specification, Stloc);
kono
parents:
diff changeset
1049 Set_Specification (Decl, Pspec);
kono
parents:
diff changeset
1050
kono
parents:
diff changeset
1051 Set_Defining_Unit_Name (Pspec, Standard_Entity (S_ASCII));
kono
parents:
diff changeset
1052 Set_Ekind (Standard_Entity (S_ASCII), E_Package);
kono
parents:
diff changeset
1053 Set_Visible_Declarations (Pspec, Decl_A);
kono
parents:
diff changeset
1054
kono
parents:
diff changeset
1055 -- Create control character definitions in package ASCII. Note that
kono
parents:
diff changeset
1056 -- the character literal entries created here correspond to literal
kono
parents:
diff changeset
1057 -- values that are impossible in the source, but can be represented
kono
parents:
diff changeset
1058 -- internally with no difficulties.
kono
parents:
diff changeset
1059
kono
parents:
diff changeset
1060 Ccode := 16#00#;
kono
parents:
diff changeset
1061
kono
parents:
diff changeset
1062 for S in S_ASCII_Names loop
kono
parents:
diff changeset
1063 Decl := New_Node (N_Object_Declaration, Staloc);
kono
parents:
diff changeset
1064 Set_Constant_Present (Decl, True);
kono
parents:
diff changeset
1065
kono
parents:
diff changeset
1066 declare
kono
parents:
diff changeset
1067 A_Char : constant Entity_Id := Standard_Entity (S);
kono
parents:
diff changeset
1068 Expr_Decl : Node_Id;
kono
parents:
diff changeset
1069
kono
parents:
diff changeset
1070 begin
kono
parents:
diff changeset
1071 Set_Sloc (A_Char, Staloc);
kono
parents:
diff changeset
1072 Set_Ekind (A_Char, E_Constant);
kono
parents:
diff changeset
1073 Set_Never_Set_In_Source (A_Char, True);
kono
parents:
diff changeset
1074 Set_Is_True_Constant (A_Char, True);
kono
parents:
diff changeset
1075 Set_Etype (A_Char, Standard_Character);
kono
parents:
diff changeset
1076 Set_Scope (A_Char, Standard_Entity (S_ASCII));
kono
parents:
diff changeset
1077 Set_Is_Immediately_Visible (A_Char, False);
kono
parents:
diff changeset
1078 Set_Is_Public (A_Char, True);
kono
parents:
diff changeset
1079 Set_Is_Known_Valid (A_Char, True);
kono
parents:
diff changeset
1080
kono
parents:
diff changeset
1081 Append_Entity (A_Char, Standard_Entity (S_ASCII));
kono
parents:
diff changeset
1082 Set_Defining_Identifier (Decl, A_Char);
kono
parents:
diff changeset
1083
kono
parents:
diff changeset
1084 Set_Object_Definition (Decl, Identifier_For (S_Character));
kono
parents:
diff changeset
1085 Expr_Decl := New_Node (N_Character_Literal, Staloc);
kono
parents:
diff changeset
1086 Set_Expression (Decl, Expr_Decl);
kono
parents:
diff changeset
1087
kono
parents:
diff changeset
1088 Set_Is_Static_Expression (Expr_Decl);
kono
parents:
diff changeset
1089 Set_Chars (Expr_Decl, No_Name);
kono
parents:
diff changeset
1090 Set_Etype (Expr_Decl, Standard_Character);
kono
parents:
diff changeset
1091 Set_Char_Literal_Value (Expr_Decl, UI_From_Int (Int (Ccode)));
kono
parents:
diff changeset
1092 end;
kono
parents:
diff changeset
1093
kono
parents:
diff changeset
1094 Append (Decl, Decl_A);
kono
parents:
diff changeset
1095
kono
parents:
diff changeset
1096 -- Increment character code, dealing with non-contiguities
kono
parents:
diff changeset
1097
kono
parents:
diff changeset
1098 Ccode := Ccode + 1;
kono
parents:
diff changeset
1099
kono
parents:
diff changeset
1100 if Ccode = 16#20# then
kono
parents:
diff changeset
1101 Ccode := 16#21#;
kono
parents:
diff changeset
1102 elsif Ccode = 16#27# then
kono
parents:
diff changeset
1103 Ccode := 16#3A#;
kono
parents:
diff changeset
1104 elsif Ccode = 16#3C# then
kono
parents:
diff changeset
1105 Ccode := 16#3F#;
kono
parents:
diff changeset
1106 elsif Ccode = 16#41# then
kono
parents:
diff changeset
1107 Ccode := 16#5B#;
kono
parents:
diff changeset
1108 end if;
kono
parents:
diff changeset
1109 end loop;
kono
parents:
diff changeset
1110
kono
parents:
diff changeset
1111 -- Create semantic phase entities
kono
parents:
diff changeset
1112
kono
parents:
diff changeset
1113 Standard_Void_Type := New_Standard_Entity;
kono
parents:
diff changeset
1114 Set_Ekind (Standard_Void_Type, E_Void);
kono
parents:
diff changeset
1115 Set_Etype (Standard_Void_Type, Standard_Void_Type);
kono
parents:
diff changeset
1116 Set_Scope (Standard_Void_Type, Standard_Standard);
kono
parents:
diff changeset
1117 Make_Name (Standard_Void_Type, "_void_type");
kono
parents:
diff changeset
1118
kono
parents:
diff changeset
1119 -- The type field of packages is set to void
kono
parents:
diff changeset
1120
kono
parents:
diff changeset
1121 Set_Etype (Standard_Standard, Standard_Void_Type);
kono
parents:
diff changeset
1122 Set_Etype (Standard_ASCII, Standard_Void_Type);
kono
parents:
diff changeset
1123
kono
parents:
diff changeset
1124 -- Standard_A_String is actually used in generated code, so it has a
kono
parents:
diff changeset
1125 -- type name that is reasonable, but does not overlap any Ada name.
kono
parents:
diff changeset
1126
kono
parents:
diff changeset
1127 Standard_A_String := New_Standard_Entity;
kono
parents:
diff changeset
1128 Set_Ekind (Standard_A_String, E_Access_Type);
kono
parents:
diff changeset
1129 Set_Scope (Standard_A_String, Standard_Standard);
kono
parents:
diff changeset
1130 Set_Etype (Standard_A_String, Standard_A_String);
kono
parents:
diff changeset
1131
kono
parents:
diff changeset
1132 if Debug_Flag_6 then
kono
parents:
diff changeset
1133 Init_Size (Standard_A_String, System_Address_Size);
kono
parents:
diff changeset
1134 else
kono
parents:
diff changeset
1135 Init_Size (Standard_A_String, System_Address_Size * 2);
kono
parents:
diff changeset
1136 end if;
kono
parents:
diff changeset
1137
kono
parents:
diff changeset
1138 Init_Alignment (Standard_A_String);
kono
parents:
diff changeset
1139
kono
parents:
diff changeset
1140 Set_Directly_Designated_Type
kono
parents:
diff changeset
1141 (Standard_A_String, Standard_String);
kono
parents:
diff changeset
1142 Make_Name (Standard_A_String, "access_string");
kono
parents:
diff changeset
1143
kono
parents:
diff changeset
1144 Standard_A_Char := New_Standard_Entity;
kono
parents:
diff changeset
1145 Set_Ekind (Standard_A_Char, E_Access_Type);
kono
parents:
diff changeset
1146 Set_Scope (Standard_A_Char, Standard_Standard);
kono
parents:
diff changeset
1147 Set_Etype (Standard_A_Char, Standard_A_String);
kono
parents:
diff changeset
1148 Init_Size (Standard_A_Char, System_Address_Size);
kono
parents:
diff changeset
1149 Set_Elem_Alignment (Standard_A_Char);
kono
parents:
diff changeset
1150
kono
parents:
diff changeset
1151 Set_Directly_Designated_Type (Standard_A_Char, Standard_Character);
kono
parents:
diff changeset
1152 Make_Name (Standard_A_Char, "access_character");
kono
parents:
diff changeset
1153
kono
parents:
diff changeset
1154 -- Standard_Debug_Renaming_Type is used for the special objects created
kono
parents:
diff changeset
1155 -- to encode the names occurring in renaming declarations for use by the
kono
parents:
diff changeset
1156 -- debugger (see exp_dbug.adb). The type is a zero-sized subtype of
kono
parents:
diff changeset
1157 -- Standard.Integer.
kono
parents:
diff changeset
1158
kono
parents:
diff changeset
1159 Standard_Debug_Renaming_Type := New_Standard_Entity;
kono
parents:
diff changeset
1160
kono
parents:
diff changeset
1161 Set_Ekind (Standard_Debug_Renaming_Type, E_Signed_Integer_Subtype);
kono
parents:
diff changeset
1162 Set_Scope (Standard_Debug_Renaming_Type, Standard_Standard);
kono
parents:
diff changeset
1163 Set_Etype (Standard_Debug_Renaming_Type, Base_Type (Standard_Integer));
kono
parents:
diff changeset
1164 Init_Esize (Standard_Debug_Renaming_Type, 0);
kono
parents:
diff changeset
1165 Init_RM_Size (Standard_Debug_Renaming_Type, 0);
kono
parents:
diff changeset
1166 Set_Size_Known_At_Compile_Time (Standard_Debug_Renaming_Type);
kono
parents:
diff changeset
1167 Set_Integer_Bounds (Standard_Debug_Renaming_Type,
kono
parents:
diff changeset
1168 Typ => Base_Type (Standard_Debug_Renaming_Type),
kono
parents:
diff changeset
1169 Lb => Uint_1,
kono
parents:
diff changeset
1170 Hb => Uint_0);
kono
parents:
diff changeset
1171 Set_Is_Constrained (Standard_Debug_Renaming_Type);
kono
parents:
diff changeset
1172 Set_Has_Size_Clause (Standard_Debug_Renaming_Type);
kono
parents:
diff changeset
1173
kono
parents:
diff changeset
1174 Make_Name (Standard_Debug_Renaming_Type, "_renaming_type");
kono
parents:
diff changeset
1175
kono
parents:
diff changeset
1176 -- Note on type names. The type names for the following special types
kono
parents:
diff changeset
1177 -- are constructed so that they will look reasonable should they ever
kono
parents:
diff changeset
1178 -- appear in error messages etc, although in practice the use of the
kono
parents:
diff changeset
1179 -- special insertion character } for types results in special handling
kono
parents:
diff changeset
1180 -- of these type names in any case. The blanks in these names would
kono
parents:
diff changeset
1181 -- trouble in Gigi, but that's OK here, since none of these types
kono
parents:
diff changeset
1182 -- should ever get through to Gigi. Attributes of these types are
kono
parents:
diff changeset
1183 -- filled out to minimize problems with cascaded errors (for example,
kono
parents:
diff changeset
1184 -- Any_Integer is given reasonable and consistent type and size values)
kono
parents:
diff changeset
1185
kono
parents:
diff changeset
1186 Any_Type := New_Standard_Entity ("any type");
kono
parents:
diff changeset
1187 Decl := New_Node (N_Full_Type_Declaration, Stloc);
kono
parents:
diff changeset
1188 Set_Defining_Identifier (Decl, Any_Type);
kono
parents:
diff changeset
1189 Set_Scope (Any_Type, Standard_Standard);
kono
parents:
diff changeset
1190 Build_Signed_Integer_Type (Any_Type, Standard_Integer_Size);
kono
parents:
diff changeset
1191
kono
parents:
diff changeset
1192 Any_Id := New_Standard_Entity ("any id");
kono
parents:
diff changeset
1193 Set_Ekind (Any_Id, E_Variable);
kono
parents:
diff changeset
1194 Set_Scope (Any_Id, Standard_Standard);
kono
parents:
diff changeset
1195 Set_Etype (Any_Id, Any_Type);
kono
parents:
diff changeset
1196 Init_Esize (Any_Id);
kono
parents:
diff changeset
1197 Init_Alignment (Any_Id);
kono
parents:
diff changeset
1198
kono
parents:
diff changeset
1199 Any_Access := New_Standard_Entity ("an access type");
kono
parents:
diff changeset
1200 Set_Ekind (Any_Access, E_Access_Type);
kono
parents:
diff changeset
1201 Set_Scope (Any_Access, Standard_Standard);
kono
parents:
diff changeset
1202 Set_Etype (Any_Access, Any_Access);
kono
parents:
diff changeset
1203 Init_Size (Any_Access, System_Address_Size);
kono
parents:
diff changeset
1204 Set_Elem_Alignment (Any_Access);
kono
parents:
diff changeset
1205 Set_Directly_Designated_Type
kono
parents:
diff changeset
1206 (Any_Access, Any_Type);
kono
parents:
diff changeset
1207
kono
parents:
diff changeset
1208 Any_Character := New_Standard_Entity ("a character type");
kono
parents:
diff changeset
1209 Set_Ekind (Any_Character, E_Enumeration_Type);
kono
parents:
diff changeset
1210 Set_Scope (Any_Character, Standard_Standard);
kono
parents:
diff changeset
1211 Set_Etype (Any_Character, Any_Character);
kono
parents:
diff changeset
1212 Set_Is_Unsigned_Type (Any_Character);
kono
parents:
diff changeset
1213 Set_Is_Character_Type (Any_Character);
kono
parents:
diff changeset
1214 Init_Esize (Any_Character, Standard_Character_Size);
kono
parents:
diff changeset
1215 Init_RM_Size (Any_Character, 8);
kono
parents:
diff changeset
1216 Set_Elem_Alignment (Any_Character);
kono
parents:
diff changeset
1217 Set_Scalar_Range (Any_Character, Scalar_Range (Standard_Character));
kono
parents:
diff changeset
1218
kono
parents:
diff changeset
1219 Any_Array := New_Standard_Entity ("an array type");
kono
parents:
diff changeset
1220 Set_Ekind (Any_Array, E_Array_Type);
kono
parents:
diff changeset
1221 Set_Scope (Any_Array, Standard_Standard);
kono
parents:
diff changeset
1222 Set_Etype (Any_Array, Any_Array);
kono
parents:
diff changeset
1223 Set_Component_Type (Any_Array, Any_Character);
kono
parents:
diff changeset
1224 Init_Size_Align (Any_Array);
kono
parents:
diff changeset
1225 Make_Dummy_Index (Any_Array);
kono
parents:
diff changeset
1226
kono
parents:
diff changeset
1227 Any_Boolean := New_Standard_Entity ("a boolean type");
kono
parents:
diff changeset
1228 Set_Ekind (Any_Boolean, E_Enumeration_Type);
kono
parents:
diff changeset
1229 Set_Scope (Any_Boolean, Standard_Standard);
kono
parents:
diff changeset
1230 Set_Etype (Any_Boolean, Standard_Boolean);
kono
parents:
diff changeset
1231 Init_Esize (Any_Boolean, Standard_Character_Size);
kono
parents:
diff changeset
1232 Init_RM_Size (Any_Boolean, 1);
kono
parents:
diff changeset
1233 Set_Elem_Alignment (Any_Boolean);
kono
parents:
diff changeset
1234 Set_Is_Unsigned_Type (Any_Boolean);
kono
parents:
diff changeset
1235 Set_Scalar_Range (Any_Boolean, Scalar_Range (Standard_Boolean));
kono
parents:
diff changeset
1236
kono
parents:
diff changeset
1237 Any_Composite := New_Standard_Entity ("a composite type");
kono
parents:
diff changeset
1238 Set_Ekind (Any_Composite, E_Array_Type);
kono
parents:
diff changeset
1239 Set_Scope (Any_Composite, Standard_Standard);
kono
parents:
diff changeset
1240 Set_Etype (Any_Composite, Any_Composite);
kono
parents:
diff changeset
1241 Set_Component_Size (Any_Composite, Uint_0);
kono
parents:
diff changeset
1242 Set_Component_Type (Any_Composite, Standard_Integer);
kono
parents:
diff changeset
1243 Init_Size_Align (Any_Composite);
kono
parents:
diff changeset
1244
kono
parents:
diff changeset
1245 Any_Discrete := New_Standard_Entity ("a discrete type");
kono
parents:
diff changeset
1246 Set_Ekind (Any_Discrete, E_Signed_Integer_Type);
kono
parents:
diff changeset
1247 Set_Scope (Any_Discrete, Standard_Standard);
kono
parents:
diff changeset
1248 Set_Etype (Any_Discrete, Any_Discrete);
kono
parents:
diff changeset
1249 Init_Size (Any_Discrete, Standard_Integer_Size);
kono
parents:
diff changeset
1250 Set_Elem_Alignment (Any_Discrete);
kono
parents:
diff changeset
1251
kono
parents:
diff changeset
1252 Any_Fixed := New_Standard_Entity ("a fixed-point type");
kono
parents:
diff changeset
1253 Set_Ekind (Any_Fixed, E_Ordinary_Fixed_Point_Type);
kono
parents:
diff changeset
1254 Set_Scope (Any_Fixed, Standard_Standard);
kono
parents:
diff changeset
1255 Set_Etype (Any_Fixed, Any_Fixed);
kono
parents:
diff changeset
1256 Init_Size (Any_Fixed, Standard_Integer_Size);
kono
parents:
diff changeset
1257 Set_Elem_Alignment (Any_Fixed);
kono
parents:
diff changeset
1258
kono
parents:
diff changeset
1259 Any_Integer := New_Standard_Entity ("an integer type");
kono
parents:
diff changeset
1260 Set_Ekind (Any_Integer, E_Signed_Integer_Type);
kono
parents:
diff changeset
1261 Set_Scope (Any_Integer, Standard_Standard);
kono
parents:
diff changeset
1262 Set_Etype (Any_Integer, Standard_Long_Long_Integer);
kono
parents:
diff changeset
1263 Init_Size (Any_Integer, Standard_Long_Long_Integer_Size);
kono
parents:
diff changeset
1264 Set_Elem_Alignment (Any_Integer);
kono
parents:
diff changeset
1265
kono
parents:
diff changeset
1266 Set_Integer_Bounds
kono
parents:
diff changeset
1267 (Any_Integer,
kono
parents:
diff changeset
1268 Typ => Base_Type (Standard_Integer),
kono
parents:
diff changeset
1269 Lb => Uint_0,
kono
parents:
diff changeset
1270 Hb => Intval (High_Bound (Scalar_Range (Standard_Integer))));
kono
parents:
diff changeset
1271
kono
parents:
diff changeset
1272 Any_Modular := New_Standard_Entity ("a modular type");
kono
parents:
diff changeset
1273 Set_Ekind (Any_Modular, E_Modular_Integer_Type);
kono
parents:
diff changeset
1274 Set_Scope (Any_Modular, Standard_Standard);
kono
parents:
diff changeset
1275 Set_Etype (Any_Modular, Standard_Long_Long_Integer);
kono
parents:
diff changeset
1276 Init_Size (Any_Modular, Standard_Long_Long_Integer_Size);
kono
parents:
diff changeset
1277 Set_Elem_Alignment (Any_Modular);
kono
parents:
diff changeset
1278 Set_Is_Unsigned_Type (Any_Modular);
kono
parents:
diff changeset
1279
kono
parents:
diff changeset
1280 Any_Numeric := New_Standard_Entity ("a numeric type");
kono
parents:
diff changeset
1281 Set_Ekind (Any_Numeric, E_Signed_Integer_Type);
kono
parents:
diff changeset
1282 Set_Scope (Any_Numeric, Standard_Standard);
kono
parents:
diff changeset
1283 Set_Etype (Any_Numeric, Standard_Long_Long_Integer);
kono
parents:
diff changeset
1284 Init_Size (Any_Numeric, Standard_Long_Long_Integer_Size);
kono
parents:
diff changeset
1285 Set_Elem_Alignment (Any_Numeric);
kono
parents:
diff changeset
1286
kono
parents:
diff changeset
1287 Any_Real := New_Standard_Entity ("a real type");
kono
parents:
diff changeset
1288 Set_Ekind (Any_Real, E_Floating_Point_Type);
kono
parents:
diff changeset
1289 Set_Scope (Any_Real, Standard_Standard);
kono
parents:
diff changeset
1290 Set_Etype (Any_Real, Standard_Long_Long_Float);
kono
parents:
diff changeset
1291 Init_Size (Any_Real,
kono
parents:
diff changeset
1292 UI_To_Int (Esize (Standard_Long_Long_Float)));
kono
parents:
diff changeset
1293 Set_Elem_Alignment (Any_Real);
kono
parents:
diff changeset
1294
kono
parents:
diff changeset
1295 Any_Scalar := New_Standard_Entity ("a scalar type");
kono
parents:
diff changeset
1296 Set_Ekind (Any_Scalar, E_Signed_Integer_Type);
kono
parents:
diff changeset
1297 Set_Scope (Any_Scalar, Standard_Standard);
kono
parents:
diff changeset
1298 Set_Etype (Any_Scalar, Any_Scalar);
kono
parents:
diff changeset
1299 Init_Size (Any_Scalar, Standard_Integer_Size);
kono
parents:
diff changeset
1300 Set_Elem_Alignment (Any_Scalar);
kono
parents:
diff changeset
1301
kono
parents:
diff changeset
1302 Any_String := New_Standard_Entity ("a string type");
kono
parents:
diff changeset
1303 Set_Ekind (Any_String, E_Array_Type);
kono
parents:
diff changeset
1304 Set_Scope (Any_String, Standard_Standard);
kono
parents:
diff changeset
1305 Set_Etype (Any_String, Any_String);
kono
parents:
diff changeset
1306 Set_Component_Type (Any_String, Any_Character);
kono
parents:
diff changeset
1307 Init_Size_Align (Any_String);
kono
parents:
diff changeset
1308 Make_Dummy_Index (Any_String);
kono
parents:
diff changeset
1309
kono
parents:
diff changeset
1310 Raise_Type := New_Standard_Entity ("raise type");
kono
parents:
diff changeset
1311 Decl := New_Node (N_Full_Type_Declaration, Stloc);
kono
parents:
diff changeset
1312 Set_Defining_Identifier (Decl, Raise_Type);
kono
parents:
diff changeset
1313 Set_Scope (Raise_Type, Standard_Standard);
kono
parents:
diff changeset
1314 Build_Signed_Integer_Type (Raise_Type, Standard_Integer_Size);
kono
parents:
diff changeset
1315
kono
parents:
diff changeset
1316 Standard_Integer_8 := New_Standard_Entity ("integer_8");
kono
parents:
diff changeset
1317 Decl := New_Node (N_Full_Type_Declaration, Stloc);
kono
parents:
diff changeset
1318 Set_Defining_Identifier (Decl, Standard_Integer_8);
kono
parents:
diff changeset
1319 Set_Scope (Standard_Integer_8, Standard_Standard);
kono
parents:
diff changeset
1320 Build_Signed_Integer_Type (Standard_Integer_8, 8);
kono
parents:
diff changeset
1321
kono
parents:
diff changeset
1322 Standard_Integer_16 := New_Standard_Entity ("integer_16");
kono
parents:
diff changeset
1323 Decl := New_Node (N_Full_Type_Declaration, Stloc);
kono
parents:
diff changeset
1324 Set_Defining_Identifier (Decl, Standard_Integer_16);
kono
parents:
diff changeset
1325 Set_Scope (Standard_Integer_16, Standard_Standard);
kono
parents:
diff changeset
1326 Build_Signed_Integer_Type (Standard_Integer_16, 16);
kono
parents:
diff changeset
1327
kono
parents:
diff changeset
1328 Standard_Integer_32 := New_Standard_Entity ("integer_32");
kono
parents:
diff changeset
1329 Decl := New_Node (N_Full_Type_Declaration, Stloc);
kono
parents:
diff changeset
1330 Set_Defining_Identifier (Decl, Standard_Integer_32);
kono
parents:
diff changeset
1331 Set_Scope (Standard_Integer_32, Standard_Standard);
kono
parents:
diff changeset
1332 Build_Signed_Integer_Type (Standard_Integer_32, 32);
kono
parents:
diff changeset
1333
kono
parents:
diff changeset
1334 Standard_Integer_64 := New_Standard_Entity ("integer_64");
kono
parents:
diff changeset
1335 Decl := New_Node (N_Full_Type_Declaration, Stloc);
kono
parents:
diff changeset
1336 Set_Defining_Identifier (Decl, Standard_Integer_64);
kono
parents:
diff changeset
1337 Set_Scope (Standard_Integer_64, Standard_Standard);
kono
parents:
diff changeset
1338 Build_Signed_Integer_Type (Standard_Integer_64, 64);
kono
parents:
diff changeset
1339
kono
parents:
diff changeset
1340 -- Standard_*_Unsigned subtypes are not user visible, but they are
kono
parents:
diff changeset
1341 -- used internally. They are unsigned types with the same length as
kono
parents:
diff changeset
1342 -- the correspondingly named signed integer types.
kono
parents:
diff changeset
1343
kono
parents:
diff changeset
1344 Standard_Short_Short_Unsigned := New_Standard_Entity;
kono
parents:
diff changeset
1345 Build_Unsigned_Integer_Type
kono
parents:
diff changeset
1346 (Standard_Short_Short_Unsigned,
kono
parents:
diff changeset
1347 Standard_Short_Short_Integer_Size,
kono
parents:
diff changeset
1348 "short_short_unsigned");
kono
parents:
diff changeset
1349
kono
parents:
diff changeset
1350 Standard_Short_Unsigned := New_Standard_Entity;
kono
parents:
diff changeset
1351 Build_Unsigned_Integer_Type
kono
parents:
diff changeset
1352 (Standard_Short_Unsigned,
kono
parents:
diff changeset
1353 Standard_Short_Integer_Size,
kono
parents:
diff changeset
1354 "short_unsigned");
kono
parents:
diff changeset
1355
kono
parents:
diff changeset
1356 Standard_Unsigned := New_Standard_Entity;
kono
parents:
diff changeset
1357 Build_Unsigned_Integer_Type
kono
parents:
diff changeset
1358 (Standard_Unsigned,
kono
parents:
diff changeset
1359 Standard_Integer_Size,
kono
parents:
diff changeset
1360 "unsigned");
kono
parents:
diff changeset
1361
kono
parents:
diff changeset
1362 Standard_Long_Unsigned := New_Standard_Entity;
kono
parents:
diff changeset
1363 Build_Unsigned_Integer_Type
kono
parents:
diff changeset
1364 (Standard_Long_Unsigned,
kono
parents:
diff changeset
1365 Standard_Long_Integer_Size,
kono
parents:
diff changeset
1366 "long_unsigned");
kono
parents:
diff changeset
1367
kono
parents:
diff changeset
1368 Standard_Long_Long_Unsigned := New_Standard_Entity;
kono
parents:
diff changeset
1369 Build_Unsigned_Integer_Type
kono
parents:
diff changeset
1370 (Standard_Long_Long_Unsigned,
kono
parents:
diff changeset
1371 Standard_Long_Long_Integer_Size,
kono
parents:
diff changeset
1372 "long_long_unsigned");
kono
parents:
diff changeset
1373
kono
parents:
diff changeset
1374 -- Standard_Unsigned_64 is not user visible, but is used internally. It
kono
parents:
diff changeset
1375 -- is an unsigned type mod 2**64, 64-bits unsigned, size is 64.
kono
parents:
diff changeset
1376
kono
parents:
diff changeset
1377 Standard_Unsigned_64 := New_Standard_Entity;
kono
parents:
diff changeset
1378 Build_Unsigned_Integer_Type (Standard_Unsigned_64, 64, "unsigned_64");
kono
parents:
diff changeset
1379
kono
parents:
diff changeset
1380 -- Note: universal integer and universal real are constructed as fully
kono
parents:
diff changeset
1381 -- formed signed numeric types, with parameters corresponding to the
kono
parents:
diff changeset
1382 -- longest runtime types (Long_Long_Integer and Long_Long_Float). This
kono
parents:
diff changeset
1383 -- allows Gigi to properly process references to universal types that
kono
parents:
diff changeset
1384 -- are not folded at compile time.
kono
parents:
diff changeset
1385
kono
parents:
diff changeset
1386 Universal_Integer := New_Standard_Entity;
kono
parents:
diff changeset
1387 Decl := New_Node (N_Full_Type_Declaration, Stloc);
kono
parents:
diff changeset
1388 Set_Defining_Identifier (Decl, Universal_Integer);
kono
parents:
diff changeset
1389 Make_Name (Universal_Integer, "universal_integer");
kono
parents:
diff changeset
1390 Set_Scope (Universal_Integer, Standard_Standard);
kono
parents:
diff changeset
1391 Build_Signed_Integer_Type
kono
parents:
diff changeset
1392 (Universal_Integer, Standard_Long_Long_Integer_Size);
kono
parents:
diff changeset
1393
kono
parents:
diff changeset
1394 Universal_Real := New_Standard_Entity;
kono
parents:
diff changeset
1395 Decl := New_Node (N_Full_Type_Declaration, Stloc);
kono
parents:
diff changeset
1396 Set_Defining_Identifier (Decl, Universal_Real);
kono
parents:
diff changeset
1397 Make_Name (Universal_Real, "universal_real");
kono
parents:
diff changeset
1398 Set_Scope (Universal_Real, Standard_Standard);
kono
parents:
diff changeset
1399 Copy_Float_Type (Universal_Real, Standard_Long_Long_Float);
kono
parents:
diff changeset
1400
kono
parents:
diff changeset
1401 -- Note: universal fixed, unlike universal integer and universal real,
kono
parents:
diff changeset
1402 -- is never used at runtime, so it does not need to have bounds set.
kono
parents:
diff changeset
1403
kono
parents:
diff changeset
1404 Universal_Fixed := New_Standard_Entity;
kono
parents:
diff changeset
1405 Decl := New_Node (N_Full_Type_Declaration, Stloc);
kono
parents:
diff changeset
1406 Set_Defining_Identifier (Decl, Universal_Fixed);
kono
parents:
diff changeset
1407 Make_Name (Universal_Fixed, "universal_fixed");
kono
parents:
diff changeset
1408 Set_Ekind (Universal_Fixed, E_Ordinary_Fixed_Point_Type);
kono
parents:
diff changeset
1409 Set_Etype (Universal_Fixed, Universal_Fixed);
kono
parents:
diff changeset
1410 Set_Scope (Universal_Fixed, Standard_Standard);
kono
parents:
diff changeset
1411 Init_Size (Universal_Fixed, Standard_Long_Long_Integer_Size);
kono
parents:
diff changeset
1412 Set_Elem_Alignment (Universal_Fixed);
kono
parents:
diff changeset
1413 Set_Size_Known_At_Compile_Time
kono
parents:
diff changeset
1414 (Universal_Fixed);
kono
parents:
diff changeset
1415
kono
parents:
diff changeset
1416 -- Create type declaration for Duration, using a 64-bit size. The
kono
parents:
diff changeset
1417 -- delta and size values depend on the mode set in system.ads.
kono
parents:
diff changeset
1418
kono
parents:
diff changeset
1419 Build_Duration : declare
kono
parents:
diff changeset
1420 Dlo : Uint;
kono
parents:
diff changeset
1421 Dhi : Uint;
kono
parents:
diff changeset
1422 Delta_Val : Ureal;
kono
parents:
diff changeset
1423
kono
parents:
diff changeset
1424 begin
kono
parents:
diff changeset
1425 -- In 32 bit mode, the size is 32 bits, and the delta and
kono
parents:
diff changeset
1426 -- small values are set to 20 milliseconds (20.0*(10.0**(-3)).
kono
parents:
diff changeset
1427
kono
parents:
diff changeset
1428 if Duration_32_Bits_On_Target then
kono
parents:
diff changeset
1429 Dlo := Intval (Type_Low_Bound (Standard_Integer_32));
kono
parents:
diff changeset
1430 Dhi := Intval (Type_High_Bound (Standard_Integer_32));
kono
parents:
diff changeset
1431 Delta_Val := UR_From_Components (UI_From_Int (20), Uint_3, 10);
kono
parents:
diff changeset
1432
kono
parents:
diff changeset
1433 -- In 64-bit mode, the size is 64-bits and the delta and
kono
parents:
diff changeset
1434 -- small values are set to nanoseconds (1.0*(10.0**(-9)).
kono
parents:
diff changeset
1435
kono
parents:
diff changeset
1436 else
kono
parents:
diff changeset
1437 Dlo := Intval (Type_Low_Bound (Standard_Integer_64));
kono
parents:
diff changeset
1438 Dhi := Intval (Type_High_Bound (Standard_Integer_64));
kono
parents:
diff changeset
1439 Delta_Val := UR_From_Components (Uint_1, Uint_9, 10);
kono
parents:
diff changeset
1440 end if;
kono
parents:
diff changeset
1441
kono
parents:
diff changeset
1442 Tdef_Node := Make_Ordinary_Fixed_Point_Definition (Stloc,
kono
parents:
diff changeset
1443 Delta_Expression => Make_Real_Literal (Stloc, Delta_Val),
kono
parents:
diff changeset
1444 Real_Range_Specification =>
kono
parents:
diff changeset
1445 Make_Real_Range_Specification (Stloc,
kono
parents:
diff changeset
1446 Low_Bound => Make_Real_Literal (Stloc,
kono
parents:
diff changeset
1447 Realval => Dlo * Delta_Val),
kono
parents:
diff changeset
1448 High_Bound => Make_Real_Literal (Stloc,
kono
parents:
diff changeset
1449 Realval => Dhi * Delta_Val)));
kono
parents:
diff changeset
1450
kono
parents:
diff changeset
1451 Set_Type_Definition (Parent (Standard_Duration), Tdef_Node);
kono
parents:
diff changeset
1452
kono
parents:
diff changeset
1453 Set_Ekind (Standard_Duration, E_Ordinary_Fixed_Point_Type);
kono
parents:
diff changeset
1454 Set_Etype (Standard_Duration, Standard_Duration);
kono
parents:
diff changeset
1455
kono
parents:
diff changeset
1456 if Duration_32_Bits_On_Target then
kono
parents:
diff changeset
1457 Init_Size (Standard_Duration, 32);
kono
parents:
diff changeset
1458 else
kono
parents:
diff changeset
1459 Init_Size (Standard_Duration, 64);
kono
parents:
diff changeset
1460 end if;
kono
parents:
diff changeset
1461
kono
parents:
diff changeset
1462 Set_Elem_Alignment (Standard_Duration);
kono
parents:
diff changeset
1463 Set_Delta_Value (Standard_Duration, Delta_Val);
kono
parents:
diff changeset
1464 Set_Small_Value (Standard_Duration, Delta_Val);
kono
parents:
diff changeset
1465 Set_Scalar_Range (Standard_Duration,
kono
parents:
diff changeset
1466 Real_Range_Specification
kono
parents:
diff changeset
1467 (Type_Definition (Parent (Standard_Duration))));
kono
parents:
diff changeset
1468
kono
parents:
diff changeset
1469 -- Normally it does not matter that nodes in package Standard are
kono
parents:
diff changeset
1470 -- not marked as analyzed. The Scalar_Range of the fixed-point type
kono
parents:
diff changeset
1471 -- Standard_Duration is an exception, because of the special test
kono
parents:
diff changeset
1472 -- made in Freeze.Freeze_Fixed_Point_Type.
kono
parents:
diff changeset
1473
kono
parents:
diff changeset
1474 Set_Analyzed (Scalar_Range (Standard_Duration));
kono
parents:
diff changeset
1475
kono
parents:
diff changeset
1476 Set_Etype (Type_High_Bound (Standard_Duration), Standard_Duration);
kono
parents:
diff changeset
1477 Set_Etype (Type_Low_Bound (Standard_Duration), Standard_Duration);
kono
parents:
diff changeset
1478
kono
parents:
diff changeset
1479 Set_Is_Static_Expression (Type_High_Bound (Standard_Duration));
kono
parents:
diff changeset
1480 Set_Is_Static_Expression (Type_Low_Bound (Standard_Duration));
kono
parents:
diff changeset
1481
kono
parents:
diff changeset
1482 Set_Corresponding_Integer_Value
kono
parents:
diff changeset
1483 (Type_High_Bound (Standard_Duration), Dhi);
kono
parents:
diff changeset
1484
kono
parents:
diff changeset
1485 Set_Corresponding_Integer_Value
kono
parents:
diff changeset
1486 (Type_Low_Bound (Standard_Duration), Dlo);
kono
parents:
diff changeset
1487
kono
parents:
diff changeset
1488 Set_Size_Known_At_Compile_Time (Standard_Duration);
kono
parents:
diff changeset
1489 end Build_Duration;
kono
parents:
diff changeset
1490
kono
parents:
diff changeset
1491 -- Build standard exception type. Note that the type name here is
kono
parents:
diff changeset
1492 -- actually used in the generated code, so it must be set correctly.
kono
parents:
diff changeset
1493 -- The type Standard_Exception_Type must be consistent with the type
kono
parents:
diff changeset
1494 -- System.Standard_Library.Exception_Data, as the latter is what is
kono
parents:
diff changeset
1495 -- known by the run-time. Components of the record are documented in
kono
parents:
diff changeset
1496 -- the declaration in System.Standard_Library.
kono
parents:
diff changeset
1497
kono
parents:
diff changeset
1498 Standard_Exception_Type := New_Standard_Entity;
kono
parents:
diff changeset
1499 Set_Ekind (Standard_Exception_Type, E_Record_Type);
kono
parents:
diff changeset
1500 Set_Etype (Standard_Exception_Type, Standard_Exception_Type);
kono
parents:
diff changeset
1501 Set_Scope (Standard_Exception_Type, Standard_Standard);
kono
parents:
diff changeset
1502 Set_Stored_Constraint
kono
parents:
diff changeset
1503 (Standard_Exception_Type, No_Elist);
kono
parents:
diff changeset
1504 Init_Size_Align (Standard_Exception_Type);
kono
parents:
diff changeset
1505 Set_Size_Known_At_Compile_Time
kono
parents:
diff changeset
1506 (Standard_Exception_Type, True);
kono
parents:
diff changeset
1507 Make_Name (Standard_Exception_Type, "exception");
kono
parents:
diff changeset
1508
kono
parents:
diff changeset
1509 Make_Component
kono
parents:
diff changeset
1510 (Standard_Exception_Type, Standard_Boolean, "Not_Handled_By_Others");
kono
parents:
diff changeset
1511 Make_Component
kono
parents:
diff changeset
1512 (Standard_Exception_Type, Standard_Character, "Lang");
kono
parents:
diff changeset
1513 Make_Component
kono
parents:
diff changeset
1514 (Standard_Exception_Type, Standard_Natural, "Name_Length");
kono
parents:
diff changeset
1515 Make_Component
kono
parents:
diff changeset
1516 (Standard_Exception_Type, Standard_A_Char, "Full_Name");
kono
parents:
diff changeset
1517 Make_Component
kono
parents:
diff changeset
1518 (Standard_Exception_Type, Standard_A_Char, "HTable_Ptr");
kono
parents:
diff changeset
1519 Make_Component
kono
parents:
diff changeset
1520 (Standard_Exception_Type, Standard_A_Char, "Foreign_Data");
kono
parents:
diff changeset
1521 Make_Component
kono
parents:
diff changeset
1522 (Standard_Exception_Type, Standard_A_Char, "Raise_Hook");
kono
parents:
diff changeset
1523
kono
parents:
diff changeset
1524 -- Build tree for record declaration, for use by the back-end
kono
parents:
diff changeset
1525
kono
parents:
diff changeset
1526 declare
kono
parents:
diff changeset
1527 Comp_List : List_Id;
kono
parents:
diff changeset
1528 Comp : Entity_Id;
kono
parents:
diff changeset
1529
kono
parents:
diff changeset
1530 begin
kono
parents:
diff changeset
1531 Comp := First_Entity (Standard_Exception_Type);
kono
parents:
diff changeset
1532 Comp_List := New_List;
kono
parents:
diff changeset
1533 while Present (Comp) loop
kono
parents:
diff changeset
1534 Append (
kono
parents:
diff changeset
1535 Make_Component_Declaration (Stloc,
kono
parents:
diff changeset
1536 Defining_Identifier => Comp,
kono
parents:
diff changeset
1537 Component_Definition =>
kono
parents:
diff changeset
1538 Make_Component_Definition (Stloc,
kono
parents:
diff changeset
1539 Aliased_Present => False,
kono
parents:
diff changeset
1540 Subtype_Indication => New_Occurrence_Of (Etype (Comp),
kono
parents:
diff changeset
1541 Stloc))),
kono
parents:
diff changeset
1542 Comp_List);
kono
parents:
diff changeset
1543
kono
parents:
diff changeset
1544 Next_Entity (Comp);
kono
parents:
diff changeset
1545 end loop;
kono
parents:
diff changeset
1546
kono
parents:
diff changeset
1547 Decl := Make_Full_Type_Declaration (Stloc,
kono
parents:
diff changeset
1548 Defining_Identifier => Standard_Exception_Type,
kono
parents:
diff changeset
1549 Type_Definition =>
kono
parents:
diff changeset
1550 Make_Record_Definition (Stloc,
kono
parents:
diff changeset
1551 End_Label => Empty,
kono
parents:
diff changeset
1552 Component_List =>
kono
parents:
diff changeset
1553 Make_Component_List (Stloc,
kono
parents:
diff changeset
1554 Component_Items => Comp_List)));
kono
parents:
diff changeset
1555 end;
kono
parents:
diff changeset
1556
kono
parents:
diff changeset
1557 Append (Decl, Decl_S);
kono
parents:
diff changeset
1558
kono
parents:
diff changeset
1559 Layout_Type (Standard_Exception_Type);
kono
parents:
diff changeset
1560
kono
parents:
diff changeset
1561 -- Create declarations of standard exceptions
kono
parents:
diff changeset
1562
kono
parents:
diff changeset
1563 Build_Exception (S_Constraint_Error);
kono
parents:
diff changeset
1564 Build_Exception (S_Program_Error);
kono
parents:
diff changeset
1565 Build_Exception (S_Storage_Error);
kono
parents:
diff changeset
1566 Build_Exception (S_Tasking_Error);
kono
parents:
diff changeset
1567
kono
parents:
diff changeset
1568 -- Numeric_Error is a normal exception in Ada 83, but in Ada 95
kono
parents:
diff changeset
1569 -- it is a renaming of Constraint_Error. Is this test too early???
kono
parents:
diff changeset
1570
kono
parents:
diff changeset
1571 if Ada_Version = Ada_83 then
kono
parents:
diff changeset
1572 Build_Exception (S_Numeric_Error);
kono
parents:
diff changeset
1573
kono
parents:
diff changeset
1574 else
kono
parents:
diff changeset
1575 Decl := New_Node (N_Exception_Renaming_Declaration, Stloc);
kono
parents:
diff changeset
1576 E_Id := Standard_Entity (S_Numeric_Error);
kono
parents:
diff changeset
1577
kono
parents:
diff changeset
1578 Set_Ekind (E_Id, E_Exception);
kono
parents:
diff changeset
1579 Set_Etype (E_Id, Standard_Exception_Type);
kono
parents:
diff changeset
1580 Set_Is_Public (E_Id);
kono
parents:
diff changeset
1581 Set_Renamed_Entity (E_Id, Standard_Entity (S_Constraint_Error));
kono
parents:
diff changeset
1582
kono
parents:
diff changeset
1583 Set_Defining_Identifier (Decl, E_Id);
kono
parents:
diff changeset
1584 Append (Decl, Decl_S);
kono
parents:
diff changeset
1585
kono
parents:
diff changeset
1586 Ident_Node := New_Node (N_Identifier, Stloc);
kono
parents:
diff changeset
1587 Set_Chars (Ident_Node, Chars (Standard_Entity (S_Constraint_Error)));
kono
parents:
diff changeset
1588 Set_Entity (Ident_Node, Standard_Entity (S_Constraint_Error));
kono
parents:
diff changeset
1589 Set_Name (Decl, Ident_Node);
kono
parents:
diff changeset
1590 end if;
kono
parents:
diff changeset
1591
kono
parents:
diff changeset
1592 -- Abort_Signal is an entity that does not get made visible
kono
parents:
diff changeset
1593
kono
parents:
diff changeset
1594 Abort_Signal := New_Standard_Entity;
kono
parents:
diff changeset
1595 Set_Chars (Abort_Signal, Name_uAbort_Signal);
kono
parents:
diff changeset
1596 Set_Ekind (Abort_Signal, E_Exception);
kono
parents:
diff changeset
1597 Set_Etype (Abort_Signal, Standard_Exception_Type);
kono
parents:
diff changeset
1598 Set_Scope (Abort_Signal, Standard_Standard);
kono
parents:
diff changeset
1599 Set_Is_Public (Abort_Signal, True);
kono
parents:
diff changeset
1600 Decl :=
kono
parents:
diff changeset
1601 Make_Exception_Declaration (Stloc,
kono
parents:
diff changeset
1602 Defining_Identifier => Abort_Signal);
kono
parents:
diff changeset
1603
kono
parents:
diff changeset
1604 -- Create defining identifiers for shift operator entities. Note
kono
parents:
diff changeset
1605 -- that these entities are used only for marking shift operators
kono
parents:
diff changeset
1606 -- generated internally, and hence need no structure, just a name
kono
parents:
diff changeset
1607 -- and a unique identity.
kono
parents:
diff changeset
1608
kono
parents:
diff changeset
1609 Standard_Op_Rotate_Left := New_Standard_Entity;
kono
parents:
diff changeset
1610 Set_Chars (Standard_Op_Rotate_Left, Name_Rotate_Left);
kono
parents:
diff changeset
1611 Set_Ekind (Standard_Op_Rotate_Left, E_Operator);
kono
parents:
diff changeset
1612
kono
parents:
diff changeset
1613 Standard_Op_Rotate_Right := New_Standard_Entity;
kono
parents:
diff changeset
1614 Set_Chars (Standard_Op_Rotate_Right, Name_Rotate_Right);
kono
parents:
diff changeset
1615 Set_Ekind (Standard_Op_Rotate_Right, E_Operator);
kono
parents:
diff changeset
1616
kono
parents:
diff changeset
1617 Standard_Op_Shift_Left := New_Standard_Entity;
kono
parents:
diff changeset
1618 Set_Chars (Standard_Op_Shift_Left, Name_Shift_Left);
kono
parents:
diff changeset
1619 Set_Ekind (Standard_Op_Shift_Left, E_Operator);
kono
parents:
diff changeset
1620
kono
parents:
diff changeset
1621 Standard_Op_Shift_Right := New_Standard_Entity;
kono
parents:
diff changeset
1622 Set_Chars (Standard_Op_Shift_Right, Name_Shift_Right);
kono
parents:
diff changeset
1623 Set_Ekind (Standard_Op_Shift_Right, E_Operator);
kono
parents:
diff changeset
1624
kono
parents:
diff changeset
1625 Standard_Op_Shift_Right_Arithmetic := New_Standard_Entity;
kono
parents:
diff changeset
1626 Set_Chars (Standard_Op_Shift_Right_Arithmetic,
kono
parents:
diff changeset
1627 Name_Shift_Right_Arithmetic);
kono
parents:
diff changeset
1628 Set_Ekind (Standard_Op_Shift_Right_Arithmetic,
kono
parents:
diff changeset
1629 E_Operator);
kono
parents:
diff changeset
1630
kono
parents:
diff changeset
1631 -- Create standard operator declarations
kono
parents:
diff changeset
1632
kono
parents:
diff changeset
1633 Create_Operators;
kono
parents:
diff changeset
1634
kono
parents:
diff changeset
1635 -- Initialize visibility table with entities in Standard
kono
parents:
diff changeset
1636
kono
parents:
diff changeset
1637 for E in Standard_Entity_Type loop
kono
parents:
diff changeset
1638 if Ekind (Standard_Entity (E)) /= E_Operator then
kono
parents:
diff changeset
1639 Set_Name_Entity_Id
kono
parents:
diff changeset
1640 (Chars (Standard_Entity (E)), Standard_Entity (E));
kono
parents:
diff changeset
1641 Set_Homonym (Standard_Entity (E), Empty);
kono
parents:
diff changeset
1642 end if;
kono
parents:
diff changeset
1643
kono
parents:
diff changeset
1644 if E not in S_ASCII_Names then
kono
parents:
diff changeset
1645 Set_Scope (Standard_Entity (E), Standard_Standard);
kono
parents:
diff changeset
1646 Set_Is_Immediately_Visible (Standard_Entity (E));
kono
parents:
diff changeset
1647 end if;
kono
parents:
diff changeset
1648 end loop;
kono
parents:
diff changeset
1649
kono
parents:
diff changeset
1650 -- The predefined package Standard itself does not have a scope;
kono
parents:
diff changeset
1651 -- it is the only entity in the system not to have one, and this
kono
parents:
diff changeset
1652 -- is what identifies the package to Gigi.
kono
parents:
diff changeset
1653
kono
parents:
diff changeset
1654 Set_Scope (Standard_Standard, Empty);
kono
parents:
diff changeset
1655
kono
parents:
diff changeset
1656 -- Set global variables indicating last Id values and version
kono
parents:
diff changeset
1657
kono
parents:
diff changeset
1658 Last_Standard_Node_Id := Last_Node_Id;
kono
parents:
diff changeset
1659 Last_Standard_List_Id := Last_List_Id;
kono
parents:
diff changeset
1660
kono
parents:
diff changeset
1661 -- The Error node has an Etype of Any_Type to help error recovery
kono
parents:
diff changeset
1662
kono
parents:
diff changeset
1663 Set_Etype (Error, Any_Type);
kono
parents:
diff changeset
1664
kono
parents:
diff changeset
1665 -- Print representation of standard if switch set
kono
parents:
diff changeset
1666
kono
parents:
diff changeset
1667 if Opt.Print_Standard then
kono
parents:
diff changeset
1668 Print_Standard;
kono
parents:
diff changeset
1669 end if;
kono
parents:
diff changeset
1670 end Create_Standard;
kono
parents:
diff changeset
1671
kono
parents:
diff changeset
1672 ------------------------------------
kono
parents:
diff changeset
1673 -- Create_Unconstrained_Base_Type --
kono
parents:
diff changeset
1674 ------------------------------------
kono
parents:
diff changeset
1675
kono
parents:
diff changeset
1676 procedure Create_Unconstrained_Base_Type
kono
parents:
diff changeset
1677 (E : Entity_Id;
kono
parents:
diff changeset
1678 K : Entity_Kind)
kono
parents:
diff changeset
1679 is
kono
parents:
diff changeset
1680 New_Ent : constant Entity_Id := New_Copy (E);
kono
parents:
diff changeset
1681
kono
parents:
diff changeset
1682 begin
kono
parents:
diff changeset
1683 Set_Ekind (E, K);
kono
parents:
diff changeset
1684 Set_Is_Constrained (E, True);
kono
parents:
diff changeset
1685 Set_Is_First_Subtype (E, True);
kono
parents:
diff changeset
1686 Set_Etype (E, New_Ent);
kono
parents:
diff changeset
1687
kono
parents:
diff changeset
1688 Append_Entity (New_Ent, Standard_Standard);
kono
parents:
diff changeset
1689 Set_Is_Constrained (New_Ent, False);
kono
parents:
diff changeset
1690 Set_Etype (New_Ent, New_Ent);
kono
parents:
diff changeset
1691 Set_Is_Known_Valid (New_Ent, True);
kono
parents:
diff changeset
1692
kono
parents:
diff changeset
1693 if K = E_Signed_Integer_Subtype then
kono
parents:
diff changeset
1694 Set_Etype (Low_Bound (Scalar_Range (E)), New_Ent);
kono
parents:
diff changeset
1695 Set_Etype (High_Bound (Scalar_Range (E)), New_Ent);
kono
parents:
diff changeset
1696 end if;
kono
parents:
diff changeset
1697
kono
parents:
diff changeset
1698 end Create_Unconstrained_Base_Type;
kono
parents:
diff changeset
1699
kono
parents:
diff changeset
1700 --------------------
kono
parents:
diff changeset
1701 -- Identifier_For --
kono
parents:
diff changeset
1702 --------------------
kono
parents:
diff changeset
1703
kono
parents:
diff changeset
1704 function Identifier_For (S : Standard_Entity_Type) return Node_Id is
kono
parents:
diff changeset
1705 Ident_Node : Node_Id;
kono
parents:
diff changeset
1706 begin
kono
parents:
diff changeset
1707 Ident_Node := New_Node (N_Identifier, Stloc);
kono
parents:
diff changeset
1708 Set_Chars (Ident_Node, Chars (Standard_Entity (S)));
kono
parents:
diff changeset
1709 Set_Entity (Ident_Node, Standard_Entity (S));
kono
parents:
diff changeset
1710 return Ident_Node;
kono
parents:
diff changeset
1711 end Identifier_For;
kono
parents:
diff changeset
1712
kono
parents:
diff changeset
1713 --------------------
kono
parents:
diff changeset
1714 -- Make_Component --
kono
parents:
diff changeset
1715 --------------------
kono
parents:
diff changeset
1716
kono
parents:
diff changeset
1717 procedure Make_Component
kono
parents:
diff changeset
1718 (Rec : Entity_Id;
kono
parents:
diff changeset
1719 Typ : Entity_Id;
kono
parents:
diff changeset
1720 Nam : String)
kono
parents:
diff changeset
1721 is
kono
parents:
diff changeset
1722 Id : constant Entity_Id := New_Standard_Entity;
kono
parents:
diff changeset
1723
kono
parents:
diff changeset
1724 begin
kono
parents:
diff changeset
1725 Set_Ekind (Id, E_Component);
kono
parents:
diff changeset
1726 Set_Etype (Id, Typ);
kono
parents:
diff changeset
1727 Set_Scope (Id, Rec);
kono
parents:
diff changeset
1728 Init_Component_Location (Id);
kono
parents:
diff changeset
1729
kono
parents:
diff changeset
1730 Set_Original_Record_Component (Id, Id);
kono
parents:
diff changeset
1731 Make_Name (Id, Nam);
kono
parents:
diff changeset
1732 Append_Entity (Id, Rec);
kono
parents:
diff changeset
1733 end Make_Component;
kono
parents:
diff changeset
1734
kono
parents:
diff changeset
1735 -----------------
kono
parents:
diff changeset
1736 -- Make_Formal --
kono
parents:
diff changeset
1737 -----------------
kono
parents:
diff changeset
1738
kono
parents:
diff changeset
1739 function Make_Formal
kono
parents:
diff changeset
1740 (Typ : Entity_Id;
kono
parents:
diff changeset
1741 Formal_Name : String) return Entity_Id
kono
parents:
diff changeset
1742 is
kono
parents:
diff changeset
1743 Formal : Entity_Id;
kono
parents:
diff changeset
1744
kono
parents:
diff changeset
1745 begin
kono
parents:
diff changeset
1746 Formal := New_Standard_Entity;
kono
parents:
diff changeset
1747
kono
parents:
diff changeset
1748 Set_Ekind (Formal, E_In_Parameter);
kono
parents:
diff changeset
1749 Set_Mechanism (Formal, Default_Mechanism);
kono
parents:
diff changeset
1750 Set_Scope (Formal, Standard_Standard);
kono
parents:
diff changeset
1751 Set_Etype (Formal, Typ);
kono
parents:
diff changeset
1752 Make_Name (Formal, Formal_Name);
kono
parents:
diff changeset
1753
kono
parents:
diff changeset
1754 return Formal;
kono
parents:
diff changeset
1755 end Make_Formal;
kono
parents:
diff changeset
1756
kono
parents:
diff changeset
1757 ------------------
kono
parents:
diff changeset
1758 -- Make_Integer --
kono
parents:
diff changeset
1759 ------------------
kono
parents:
diff changeset
1760
kono
parents:
diff changeset
1761 function Make_Integer (V : Uint) return Node_Id is
kono
parents:
diff changeset
1762 N : constant Node_Id := Make_Integer_Literal (Stloc, V);
kono
parents:
diff changeset
1763 begin
kono
parents:
diff changeset
1764 Set_Is_Static_Expression (N);
kono
parents:
diff changeset
1765 return N;
kono
parents:
diff changeset
1766 end Make_Integer;
kono
parents:
diff changeset
1767
kono
parents:
diff changeset
1768 ---------------
kono
parents:
diff changeset
1769 -- Make_Name --
kono
parents:
diff changeset
1770 ---------------
kono
parents:
diff changeset
1771
kono
parents:
diff changeset
1772 procedure Make_Name (Id : Entity_Id; Nam : String) is
kono
parents:
diff changeset
1773 begin
kono
parents:
diff changeset
1774 for J in 1 .. Nam'Length loop
kono
parents:
diff changeset
1775 Name_Buffer (J) := Fold_Lower (Nam (Nam'First + (J - 1)));
kono
parents:
diff changeset
1776 end loop;
kono
parents:
diff changeset
1777
kono
parents:
diff changeset
1778 Name_Len := Nam'Length;
kono
parents:
diff changeset
1779 Set_Chars (Id, Name_Find);
kono
parents:
diff changeset
1780 end Make_Name;
kono
parents:
diff changeset
1781
kono
parents:
diff changeset
1782 ------------------
kono
parents:
diff changeset
1783 -- New_Operator --
kono
parents:
diff changeset
1784 ------------------
kono
parents:
diff changeset
1785
kono
parents:
diff changeset
1786 function New_Operator (Op : Name_Id; Typ : Entity_Id) return Entity_Id is
kono
parents:
diff changeset
1787 Ident_Node : Entity_Id;
kono
parents:
diff changeset
1788
kono
parents:
diff changeset
1789 begin
kono
parents:
diff changeset
1790 Ident_Node := Make_Defining_Identifier (Stloc, Op);
kono
parents:
diff changeset
1791
kono
parents:
diff changeset
1792 Set_Is_Pure (Ident_Node, True);
kono
parents:
diff changeset
1793 Set_Ekind (Ident_Node, E_Operator);
kono
parents:
diff changeset
1794 Set_Etype (Ident_Node, Typ);
kono
parents:
diff changeset
1795 Set_Scope (Ident_Node, Standard_Standard);
kono
parents:
diff changeset
1796 Set_Homonym (Ident_Node, Get_Name_Entity_Id (Op));
kono
parents:
diff changeset
1797 Set_Convention (Ident_Node, Convention_Intrinsic);
kono
parents:
diff changeset
1798
kono
parents:
diff changeset
1799 Set_Is_Immediately_Visible (Ident_Node, True);
kono
parents:
diff changeset
1800 Set_Is_Intrinsic_Subprogram (Ident_Node, True);
kono
parents:
diff changeset
1801
kono
parents:
diff changeset
1802 Set_Name_Entity_Id (Op, Ident_Node);
kono
parents:
diff changeset
1803 Append_Entity (Ident_Node, Standard_Standard);
kono
parents:
diff changeset
1804 return Ident_Node;
kono
parents:
diff changeset
1805 end New_Operator;
kono
parents:
diff changeset
1806
kono
parents:
diff changeset
1807 -------------------------
kono
parents:
diff changeset
1808 -- New_Standard_Entity --
kono
parents:
diff changeset
1809 -------------------------
kono
parents:
diff changeset
1810
kono
parents:
diff changeset
1811 function New_Standard_Entity
kono
parents:
diff changeset
1812 (New_Node_Kind : Node_Kind := N_Defining_Identifier) return Entity_Id
kono
parents:
diff changeset
1813 is
kono
parents:
diff changeset
1814 E : constant Entity_Id := New_Entity (New_Node_Kind, Stloc);
kono
parents:
diff changeset
1815
kono
parents:
diff changeset
1816 begin
kono
parents:
diff changeset
1817 -- All standard entities are Pure and Public
kono
parents:
diff changeset
1818
kono
parents:
diff changeset
1819 Set_Is_Pure (E);
kono
parents:
diff changeset
1820 Set_Is_Public (E);
kono
parents:
diff changeset
1821
kono
parents:
diff changeset
1822 -- All standard entity names are analyzed manually, and are thus
kono
parents:
diff changeset
1823 -- frozen as soon as they are created.
kono
parents:
diff changeset
1824
kono
parents:
diff changeset
1825 Set_Is_Frozen (E);
kono
parents:
diff changeset
1826
kono
parents:
diff changeset
1827 -- Set debug information required for all standard types
kono
parents:
diff changeset
1828
kono
parents:
diff changeset
1829 Set_Needs_Debug_Info (E);
kono
parents:
diff changeset
1830
kono
parents:
diff changeset
1831 -- All standard entities are built with fully qualified names, so
kono
parents:
diff changeset
1832 -- set the flag to prevent an abortive attempt at requalification.
kono
parents:
diff changeset
1833
kono
parents:
diff changeset
1834 Set_Has_Qualified_Name (E);
kono
parents:
diff changeset
1835
kono
parents:
diff changeset
1836 -- Return newly created entity to be completed by caller
kono
parents:
diff changeset
1837
kono
parents:
diff changeset
1838 return E;
kono
parents:
diff changeset
1839 end New_Standard_Entity;
kono
parents:
diff changeset
1840
kono
parents:
diff changeset
1841 function New_Standard_Entity (S : String) return Entity_Id is
kono
parents:
diff changeset
1842 Ent : constant Entity_Id := New_Standard_Entity;
kono
parents:
diff changeset
1843 begin
kono
parents:
diff changeset
1844 Make_Name (Ent, S);
kono
parents:
diff changeset
1845 return Ent;
kono
parents:
diff changeset
1846 end New_Standard_Entity;
kono
parents:
diff changeset
1847
kono
parents:
diff changeset
1848 --------------------
kono
parents:
diff changeset
1849 -- Print_Standard --
kono
parents:
diff changeset
1850 --------------------
kono
parents:
diff changeset
1851
kono
parents:
diff changeset
1852 procedure Print_Standard is
kono
parents:
diff changeset
1853
kono
parents:
diff changeset
1854 procedure P (Item : String) renames Output.Write_Line;
kono
parents:
diff changeset
1855 -- Short-hand, since we do a lot of line writes here
kono
parents:
diff changeset
1856
kono
parents:
diff changeset
1857 procedure P_Int_Range (Size : Pos);
kono
parents:
diff changeset
1858 -- Prints the range of an integer based on its Size
kono
parents:
diff changeset
1859
kono
parents:
diff changeset
1860 procedure P_Float_Range (Id : Entity_Id);
kono
parents:
diff changeset
1861 -- Prints the bounds range for the given float type entity
kono
parents:
diff changeset
1862
kono
parents:
diff changeset
1863 procedure P_Float_Type (Id : Entity_Id);
kono
parents:
diff changeset
1864 -- Prints the type declaration of the given float type entity
kono
parents:
diff changeset
1865
kono
parents:
diff changeset
1866 procedure P_Mixed_Name (Id : Name_Id);
kono
parents:
diff changeset
1867 -- Prints Id in mixed case
kono
parents:
diff changeset
1868
kono
parents:
diff changeset
1869 -------------------
kono
parents:
diff changeset
1870 -- P_Float_Range --
kono
parents:
diff changeset
1871 -------------------
kono
parents:
diff changeset
1872
kono
parents:
diff changeset
1873 procedure P_Float_Range (Id : Entity_Id) is
kono
parents:
diff changeset
1874 begin
kono
parents:
diff changeset
1875 Write_Str (" range ");
kono
parents:
diff changeset
1876 UR_Write (Realval (Type_Low_Bound (Id)));
kono
parents:
diff changeset
1877 Write_Str (" .. ");
kono
parents:
diff changeset
1878 UR_Write (Realval (Type_High_Bound (Id)));
kono
parents:
diff changeset
1879 Write_Str (";");
kono
parents:
diff changeset
1880 Write_Eol;
kono
parents:
diff changeset
1881 end P_Float_Range;
kono
parents:
diff changeset
1882
kono
parents:
diff changeset
1883 ------------------
kono
parents:
diff changeset
1884 -- P_Float_Type --
kono
parents:
diff changeset
1885 ------------------
kono
parents:
diff changeset
1886
kono
parents:
diff changeset
1887 procedure P_Float_Type (Id : Entity_Id) is
kono
parents:
diff changeset
1888 begin
kono
parents:
diff changeset
1889 Write_Str (" type ");
kono
parents:
diff changeset
1890 P_Mixed_Name (Chars (Id));
kono
parents:
diff changeset
1891 Write_Str (" is digits ");
kono
parents:
diff changeset
1892 Write_Int (UI_To_Int (Digits_Value (Id)));
kono
parents:
diff changeset
1893 Write_Eol;
kono
parents:
diff changeset
1894 P_Float_Range (Id);
kono
parents:
diff changeset
1895 Write_Str (" for ");
kono
parents:
diff changeset
1896 P_Mixed_Name (Chars (Id));
kono
parents:
diff changeset
1897 Write_Str ("'Size use ");
kono
parents:
diff changeset
1898 Write_Int (UI_To_Int (RM_Size (Id)));
kono
parents:
diff changeset
1899 Write_Line (";");
kono
parents:
diff changeset
1900 Write_Eol;
kono
parents:
diff changeset
1901 end P_Float_Type;
kono
parents:
diff changeset
1902
kono
parents:
diff changeset
1903 -----------------
kono
parents:
diff changeset
1904 -- P_Int_Range --
kono
parents:
diff changeset
1905 -----------------
kono
parents:
diff changeset
1906
kono
parents:
diff changeset
1907 procedure P_Int_Range (Size : Pos) is
kono
parents:
diff changeset
1908 begin
kono
parents:
diff changeset
1909 Write_Str (" is range -(2 **");
kono
parents:
diff changeset
1910 Write_Int (Size - 1);
kono
parents:
diff changeset
1911 Write_Str (")");
kono
parents:
diff changeset
1912 Write_Str (" .. +(2 **");
kono
parents:
diff changeset
1913 Write_Int (Size - 1);
kono
parents:
diff changeset
1914 Write_Str (" - 1);");
kono
parents:
diff changeset
1915 Write_Eol;
kono
parents:
diff changeset
1916 end P_Int_Range;
kono
parents:
diff changeset
1917
kono
parents:
diff changeset
1918 ------------------
kono
parents:
diff changeset
1919 -- P_Mixed_Name --
kono
parents:
diff changeset
1920 ------------------
kono
parents:
diff changeset
1921
kono
parents:
diff changeset
1922 procedure P_Mixed_Name (Id : Name_Id) is
kono
parents:
diff changeset
1923 begin
kono
parents:
diff changeset
1924 Get_Name_String (Id);
kono
parents:
diff changeset
1925
kono
parents:
diff changeset
1926 for J in 1 .. Name_Len loop
kono
parents:
diff changeset
1927 if J = 1 or else Name_Buffer (J - 1) = '_' then
kono
parents:
diff changeset
1928 Name_Buffer (J) := Fold_Upper (Name_Buffer (J));
kono
parents:
diff changeset
1929 end if;
kono
parents:
diff changeset
1930 end loop;
kono
parents:
diff changeset
1931
kono
parents:
diff changeset
1932 Write_Str (Name_Buffer (1 .. Name_Len));
kono
parents:
diff changeset
1933 end P_Mixed_Name;
kono
parents:
diff changeset
1934
kono
parents:
diff changeset
1935 -- Start of processing for Print_Standard
kono
parents:
diff changeset
1936
kono
parents:
diff changeset
1937 begin
kono
parents:
diff changeset
1938 P ("-- Representation of package Standard");
kono
parents:
diff changeset
1939 Write_Eol;
kono
parents:
diff changeset
1940 P ("-- This is not accurate Ada, since new base types cannot be ");
kono
parents:
diff changeset
1941 P ("-- created, but the listing shows the target dependent");
kono
parents:
diff changeset
1942 P ("-- characteristics of the Standard types for this compiler");
kono
parents:
diff changeset
1943 Write_Eol;
kono
parents:
diff changeset
1944
kono
parents:
diff changeset
1945 P ("package Standard is");
kono
parents:
diff changeset
1946 P ("pragma Pure (Standard);");
kono
parents:
diff changeset
1947 Write_Eol;
kono
parents:
diff changeset
1948
kono
parents:
diff changeset
1949 P (" type Boolean is (False, True);");
kono
parents:
diff changeset
1950 P (" for Boolean'Size use 1;");
kono
parents:
diff changeset
1951 P (" for Boolean use (False => 0, True => 1);");
kono
parents:
diff changeset
1952 Write_Eol;
kono
parents:
diff changeset
1953
kono
parents:
diff changeset
1954 -- Integer types
kono
parents:
diff changeset
1955
kono
parents:
diff changeset
1956 Write_Str (" type Integer");
kono
parents:
diff changeset
1957 P_Int_Range (Standard_Integer_Size);
kono
parents:
diff changeset
1958 Write_Str (" for Integer'Size use ");
kono
parents:
diff changeset
1959 Write_Int (Standard_Integer_Size);
kono
parents:
diff changeset
1960 P (";");
kono
parents:
diff changeset
1961 Write_Eol;
kono
parents:
diff changeset
1962
kono
parents:
diff changeset
1963 P (" subtype Natural is Integer range 0 .. Integer'Last;");
kono
parents:
diff changeset
1964 P (" subtype Positive is Integer range 1 .. Integer'Last;");
kono
parents:
diff changeset
1965 Write_Eol;
kono
parents:
diff changeset
1966
kono
parents:
diff changeset
1967 Write_Str (" type Short_Short_Integer");
kono
parents:
diff changeset
1968 P_Int_Range (Standard_Short_Short_Integer_Size);
kono
parents:
diff changeset
1969 Write_Str (" for Short_Short_Integer'Size use ");
kono
parents:
diff changeset
1970 Write_Int (Standard_Short_Short_Integer_Size);
kono
parents:
diff changeset
1971 P (";");
kono
parents:
diff changeset
1972 Write_Eol;
kono
parents:
diff changeset
1973
kono
parents:
diff changeset
1974 Write_Str (" type Short_Integer");
kono
parents:
diff changeset
1975 P_Int_Range (Standard_Short_Integer_Size);
kono
parents:
diff changeset
1976 Write_Str (" for Short_Integer'Size use ");
kono
parents:
diff changeset
1977 Write_Int (Standard_Short_Integer_Size);
kono
parents:
diff changeset
1978 P (";");
kono
parents:
diff changeset
1979 Write_Eol;
kono
parents:
diff changeset
1980
kono
parents:
diff changeset
1981 Write_Str (" type Long_Integer");
kono
parents:
diff changeset
1982 P_Int_Range (Standard_Long_Integer_Size);
kono
parents:
diff changeset
1983 Write_Str (" for Long_Integer'Size use ");
kono
parents:
diff changeset
1984 Write_Int (Standard_Long_Integer_Size);
kono
parents:
diff changeset
1985 P (";");
kono
parents:
diff changeset
1986 Write_Eol;
kono
parents:
diff changeset
1987
kono
parents:
diff changeset
1988 Write_Str (" type Long_Long_Integer");
kono
parents:
diff changeset
1989 P_Int_Range (Standard_Long_Long_Integer_Size);
kono
parents:
diff changeset
1990 Write_Str (" for Long_Long_Integer'Size use ");
kono
parents:
diff changeset
1991 Write_Int (Standard_Long_Long_Integer_Size);
kono
parents:
diff changeset
1992 P (";");
kono
parents:
diff changeset
1993 Write_Eol;
kono
parents:
diff changeset
1994
kono
parents:
diff changeset
1995 -- Floating point types
kono
parents:
diff changeset
1996
kono
parents:
diff changeset
1997 P_Float_Type (Standard_Short_Float);
kono
parents:
diff changeset
1998 P_Float_Type (Standard_Float);
kono
parents:
diff changeset
1999 P_Float_Type (Standard_Long_Float);
kono
parents:
diff changeset
2000 P_Float_Type (Standard_Long_Long_Float);
kono
parents:
diff changeset
2001
kono
parents:
diff changeset
2002 P (" type Character is (...)");
kono
parents:
diff changeset
2003 Write_Str (" for Character'Size use ");
kono
parents:
diff changeset
2004 Write_Int (Standard_Character_Size);
kono
parents:
diff changeset
2005 P (";");
kono
parents:
diff changeset
2006 P (" -- See RM A.1(35) for details of this type");
kono
parents:
diff changeset
2007 Write_Eol;
kono
parents:
diff changeset
2008
kono
parents:
diff changeset
2009 P (" type Wide_Character is (...)");
kono
parents:
diff changeset
2010 Write_Str (" for Wide_Character'Size use ");
kono
parents:
diff changeset
2011 Write_Int (Standard_Wide_Character_Size);
kono
parents:
diff changeset
2012 P (";");
kono
parents:
diff changeset
2013 P (" -- See RM A.1(36) for details of this type");
kono
parents:
diff changeset
2014 Write_Eol;
kono
parents:
diff changeset
2015
kono
parents:
diff changeset
2016 P (" type Wide_Wide_Character is (...)");
kono
parents:
diff changeset
2017 Write_Str (" for Wide_Wide_Character'Size use ");
kono
parents:
diff changeset
2018 Write_Int (Standard_Wide_Wide_Character_Size);
kono
parents:
diff changeset
2019 P (";");
kono
parents:
diff changeset
2020 P (" -- See RM A.1(36) for details of this type");
kono
parents:
diff changeset
2021
kono
parents:
diff changeset
2022 P (" type String is array (Positive range <>) of Character;");
kono
parents:
diff changeset
2023 P (" pragma Pack (String);");
kono
parents:
diff changeset
2024 Write_Eol;
kono
parents:
diff changeset
2025
kono
parents:
diff changeset
2026 P (" type Wide_String is array (Positive range <>)" &
kono
parents:
diff changeset
2027 " of Wide_Character;");
kono
parents:
diff changeset
2028 P (" pragma Pack (Wide_String);");
kono
parents:
diff changeset
2029 Write_Eol;
kono
parents:
diff changeset
2030
kono
parents:
diff changeset
2031 P (" type Wide_Wide_String is array (Positive range <>)" &
kono
parents:
diff changeset
2032 " of Wide_Wide_Character;");
kono
parents:
diff changeset
2033 P (" pragma Pack (Wide_Wide_String);");
kono
parents:
diff changeset
2034 Write_Eol;
kono
parents:
diff changeset
2035
kono
parents:
diff changeset
2036 -- We only have one representation each for 32-bit and 64-bit sizes,
kono
parents:
diff changeset
2037 -- so select the right one based on Duration_32_Bits_On_Target.
kono
parents:
diff changeset
2038
kono
parents:
diff changeset
2039 if Duration_32_Bits_On_Target then
kono
parents:
diff changeset
2040 P (" type Duration is delta 0.020");
kono
parents:
diff changeset
2041 P (" range -((2 ** 31) * 0.020) ..");
kono
parents:
diff changeset
2042 P (" +((2 ** 31 - 1) * 0.020);");
kono
parents:
diff changeset
2043 P (" for Duration'Small use 0.020;");
kono
parents:
diff changeset
2044
kono
parents:
diff changeset
2045 else
kono
parents:
diff changeset
2046 P (" type Duration is delta 0.000000001");
kono
parents:
diff changeset
2047 P (" range -((2 ** 63) * 0.000000001) ..");
kono
parents:
diff changeset
2048 P (" +((2 ** 63 - 1) * 0.000000001);");
kono
parents:
diff changeset
2049 P (" for Duration'Small use 0.000000001;");
kono
parents:
diff changeset
2050 end if;
kono
parents:
diff changeset
2051
kono
parents:
diff changeset
2052 Write_Eol;
kono
parents:
diff changeset
2053
kono
parents:
diff changeset
2054 P (" Constraint_Error : exception;");
kono
parents:
diff changeset
2055 P (" Program_Error : exception;");
kono
parents:
diff changeset
2056 P (" Storage_Error : exception;");
kono
parents:
diff changeset
2057 P (" Tasking_Error : exception;");
kono
parents:
diff changeset
2058 P (" Numeric_Error : exception renames Constraint_Error;");
kono
parents:
diff changeset
2059 Write_Eol;
kono
parents:
diff changeset
2060
kono
parents:
diff changeset
2061 P ("end Standard;");
kono
parents:
diff changeset
2062 end Print_Standard;
kono
parents:
diff changeset
2063
kono
parents:
diff changeset
2064 -------------------------
kono
parents:
diff changeset
2065 -- Register_Float_Type --
kono
parents:
diff changeset
2066 -------------------------
kono
parents:
diff changeset
2067
kono
parents:
diff changeset
2068 procedure Register_Float_Type
kono
parents:
diff changeset
2069 (Name : String;
kono
parents:
diff changeset
2070 Digs : Positive;
kono
parents:
diff changeset
2071 Float_Rep : Float_Rep_Kind;
kono
parents:
diff changeset
2072 Precision : Positive;
kono
parents:
diff changeset
2073 Size : Positive;
kono
parents:
diff changeset
2074 Alignment : Natural)
kono
parents:
diff changeset
2075 is
kono
parents:
diff changeset
2076 pragma Unreferenced (Precision);
kono
parents:
diff changeset
2077 -- See Build_Float_Type for the rationale
kono
parents:
diff changeset
2078
kono
parents:
diff changeset
2079 Ent : constant Entity_Id := New_Standard_Entity;
kono
parents:
diff changeset
2080
kono
parents:
diff changeset
2081 begin
kono
parents:
diff changeset
2082 Set_Defining_Identifier (New_Node (N_Full_Type_Declaration, Stloc), Ent);
kono
parents:
diff changeset
2083 Make_Name (Ent, Name);
kono
parents:
diff changeset
2084 Set_Scope (Ent, Standard_Standard);
kono
parents:
diff changeset
2085 Build_Float_Type
kono
parents:
diff changeset
2086 (Ent, Pos (Digs), Float_Rep, Int (Size), Int (Alignment / 8));
kono
parents:
diff changeset
2087
kono
parents:
diff changeset
2088 if No (Back_End_Float_Types) then
kono
parents:
diff changeset
2089 Back_End_Float_Types := New_Elmt_List;
kono
parents:
diff changeset
2090 end if;
kono
parents:
diff changeset
2091
kono
parents:
diff changeset
2092 Append_Elmt (Ent, Back_End_Float_Types);
kono
parents:
diff changeset
2093 end Register_Float_Type;
kono
parents:
diff changeset
2094
kono
parents:
diff changeset
2095 ----------------------
kono
parents:
diff changeset
2096 -- Set_Float_Bounds --
kono
parents:
diff changeset
2097 ----------------------
kono
parents:
diff changeset
2098
kono
parents:
diff changeset
2099 procedure Set_Float_Bounds (Id : Entity_Id) is
kono
parents:
diff changeset
2100 L : Node_Id;
kono
parents:
diff changeset
2101 H : Node_Id;
kono
parents:
diff changeset
2102 -- Low and high bounds of literal value
kono
parents:
diff changeset
2103
kono
parents:
diff changeset
2104 R : Node_Id;
kono
parents:
diff changeset
2105 -- Range specification
kono
parents:
diff changeset
2106
kono
parents:
diff changeset
2107 Radix : constant Uint := Machine_Radix_Value (Id);
kono
parents:
diff changeset
2108 Mantissa : constant Uint := Machine_Mantissa_Value (Id);
kono
parents:
diff changeset
2109 Emax : constant Uint := Machine_Emax_Value (Id);
kono
parents:
diff changeset
2110 Significand : constant Uint := Radix ** Mantissa - 1;
kono
parents:
diff changeset
2111 Exponent : constant Uint := Emax - Mantissa;
kono
parents:
diff changeset
2112
kono
parents:
diff changeset
2113 begin
kono
parents:
diff changeset
2114 H := Make_Float_Literal (Stloc, Radix, Significand, Exponent);
kono
parents:
diff changeset
2115 L := Make_Float_Literal (Stloc, Radix, -Significand, Exponent);
kono
parents:
diff changeset
2116
kono
parents:
diff changeset
2117 Set_Etype (L, Id);
kono
parents:
diff changeset
2118 Set_Is_Static_Expression (L);
kono
parents:
diff changeset
2119
kono
parents:
diff changeset
2120 Set_Etype (H, Id);
kono
parents:
diff changeset
2121 Set_Is_Static_Expression (H);
kono
parents:
diff changeset
2122
kono
parents:
diff changeset
2123 R := New_Node (N_Range, Stloc);
kono
parents:
diff changeset
2124 Set_Low_Bound (R, L);
kono
parents:
diff changeset
2125 Set_High_Bound (R, H);
kono
parents:
diff changeset
2126 Set_Includes_Infinities (R, True);
kono
parents:
diff changeset
2127 Set_Scalar_Range (Id, R);
kono
parents:
diff changeset
2128 Set_Etype (R, Id);
kono
parents:
diff changeset
2129 Set_Parent (R, Id);
kono
parents:
diff changeset
2130 end Set_Float_Bounds;
kono
parents:
diff changeset
2131
kono
parents:
diff changeset
2132 ------------------------
kono
parents:
diff changeset
2133 -- Set_Integer_Bounds --
kono
parents:
diff changeset
2134 ------------------------
kono
parents:
diff changeset
2135
kono
parents:
diff changeset
2136 procedure Set_Integer_Bounds
kono
parents:
diff changeset
2137 (Id : Entity_Id;
kono
parents:
diff changeset
2138 Typ : Entity_Id;
kono
parents:
diff changeset
2139 Lb : Uint;
kono
parents:
diff changeset
2140 Hb : Uint)
kono
parents:
diff changeset
2141 is
kono
parents:
diff changeset
2142 L : Node_Id;
kono
parents:
diff changeset
2143 H : Node_Id;
kono
parents:
diff changeset
2144 -- Low and high bounds of literal value
kono
parents:
diff changeset
2145
kono
parents:
diff changeset
2146 R : Node_Id;
kono
parents:
diff changeset
2147 -- Range specification
kono
parents:
diff changeset
2148
kono
parents:
diff changeset
2149 begin
kono
parents:
diff changeset
2150 L := Make_Integer (Lb);
kono
parents:
diff changeset
2151 H := Make_Integer (Hb);
kono
parents:
diff changeset
2152
kono
parents:
diff changeset
2153 Set_Etype (L, Typ);
kono
parents:
diff changeset
2154 Set_Etype (H, Typ);
kono
parents:
diff changeset
2155
kono
parents:
diff changeset
2156 R := New_Node (N_Range, Stloc);
kono
parents:
diff changeset
2157 Set_Low_Bound (R, L);
kono
parents:
diff changeset
2158 Set_High_Bound (R, H);
kono
parents:
diff changeset
2159 Set_Scalar_Range (Id, R);
kono
parents:
diff changeset
2160 Set_Etype (R, Typ);
kono
parents:
diff changeset
2161 Set_Parent (R, Id);
kono
parents:
diff changeset
2162 Set_Is_Unsigned_Type (Id, Lb >= 0);
kono
parents:
diff changeset
2163 end Set_Integer_Bounds;
kono
parents:
diff changeset
2164
kono
parents:
diff changeset
2165 end CStand;