annotate gcc/ada/exp_strm.adb @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
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 -- E X P _ S T R M --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- B o d y --
kono
parents:
diff changeset
8 -- --
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
9 -- Copyright (C) 1992-2018, 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 Einfo; use Einfo;
kono
parents:
diff changeset
28 with Elists; use Elists;
kono
parents:
diff changeset
29 with Exp_Util; use Exp_Util;
kono
parents:
diff changeset
30 with Namet; use Namet;
kono
parents:
diff changeset
31 with Nlists; use Nlists;
kono
parents:
diff changeset
32 with Nmake; use Nmake;
kono
parents:
diff changeset
33 with Rtsfind; use Rtsfind;
kono
parents:
diff changeset
34 with Sem_Aux; use Sem_Aux;
kono
parents:
diff changeset
35 with Sem_Util; use Sem_Util;
kono
parents:
diff changeset
36 with Sinfo; use Sinfo;
kono
parents:
diff changeset
37 with Snames; use Snames;
kono
parents:
diff changeset
38 with Stand; use Stand;
kono
parents:
diff changeset
39 with Tbuild; use Tbuild;
kono
parents:
diff changeset
40 with Ttypes; use Ttypes;
kono
parents:
diff changeset
41 with Uintp; use Uintp;
kono
parents:
diff changeset
42
kono
parents:
diff changeset
43 package body Exp_Strm is
kono
parents:
diff changeset
44
kono
parents:
diff changeset
45 -----------------------
kono
parents:
diff changeset
46 -- Local Subprograms --
kono
parents:
diff changeset
47 -----------------------
kono
parents:
diff changeset
48
kono
parents:
diff changeset
49 procedure Build_Array_Read_Write_Procedure
kono
parents:
diff changeset
50 (Nod : Node_Id;
kono
parents:
diff changeset
51 Typ : Entity_Id;
kono
parents:
diff changeset
52 Decl : out Node_Id;
kono
parents:
diff changeset
53 Pnam : Entity_Id;
kono
parents:
diff changeset
54 Nam : Name_Id);
kono
parents:
diff changeset
55 -- Common routine shared to build either an array Read procedure or an
kono
parents:
diff changeset
56 -- array Write procedure, Nam is Name_Read or Name_Write to select which.
kono
parents:
diff changeset
57 -- Pnam is the defining identifier for the constructed procedure. The
kono
parents:
diff changeset
58 -- other parameters are as for Build_Array_Read_Procedure except that
kono
parents:
diff changeset
59 -- the first parameter Nod supplies the Sloc to be used to generate code.
kono
parents:
diff changeset
60
kono
parents:
diff changeset
61 procedure Build_Record_Read_Write_Procedure
kono
parents:
diff changeset
62 (Loc : Source_Ptr;
kono
parents:
diff changeset
63 Typ : Entity_Id;
kono
parents:
diff changeset
64 Decl : out Node_Id;
kono
parents:
diff changeset
65 Pnam : Entity_Id;
kono
parents:
diff changeset
66 Nam : Name_Id);
kono
parents:
diff changeset
67 -- Common routine shared to build a record Read Write procedure, Nam
kono
parents:
diff changeset
68 -- is Name_Read or Name_Write to select which. Pnam is the defining
kono
parents:
diff changeset
69 -- identifier for the constructed procedure. The other parameters are
kono
parents:
diff changeset
70 -- as for Build_Record_Read_Procedure.
kono
parents:
diff changeset
71
kono
parents:
diff changeset
72 procedure Build_Stream_Function
kono
parents:
diff changeset
73 (Loc : Source_Ptr;
kono
parents:
diff changeset
74 Typ : Entity_Id;
kono
parents:
diff changeset
75 Decl : out Node_Id;
kono
parents:
diff changeset
76 Fnam : Entity_Id;
kono
parents:
diff changeset
77 Decls : List_Id;
kono
parents:
diff changeset
78 Stms : List_Id);
kono
parents:
diff changeset
79 -- Called to build an array or record stream function. The first three
kono
parents:
diff changeset
80 -- arguments are the same as Build_Record_Or_Elementary_Input_Function.
kono
parents:
diff changeset
81 -- Decls and Stms are the declarations and statements for the body and
kono
parents:
diff changeset
82 -- The parameter Fnam is the name of the constructed function.
kono
parents:
diff changeset
83
kono
parents:
diff changeset
84 function Has_Stream_Standard_Rep (U_Type : Entity_Id) return Boolean;
kono
parents:
diff changeset
85 -- This function is used to test the type U_Type, to determine if it has
kono
parents:
diff changeset
86 -- a standard representation from a streaming point of view. Standard means
kono
parents:
diff changeset
87 -- that it has a standard representation (e.g. no enumeration rep clause),
kono
parents:
diff changeset
88 -- and the size of the root type is the same as the streaming size (which
kono
parents:
diff changeset
89 -- is defined as value specified by a Stream_Size clause if present, or
kono
parents:
diff changeset
90 -- the Esize of U_Type if not).
kono
parents:
diff changeset
91
kono
parents:
diff changeset
92 function Make_Stream_Subprogram_Name
kono
parents:
diff changeset
93 (Loc : Source_Ptr;
kono
parents:
diff changeset
94 Typ : Entity_Id;
kono
parents:
diff changeset
95 Nam : TSS_Name_Type) return Entity_Id;
kono
parents:
diff changeset
96 -- Return the entity that identifies the stream subprogram for type Typ
kono
parents:
diff changeset
97 -- that is identified by the given Nam. This procedure deals with the
kono
parents:
diff changeset
98 -- difference between tagged types (where a single subprogram associated
kono
parents:
diff changeset
99 -- with the type is generated) and all other cases (where a subprogram
kono
parents:
diff changeset
100 -- is generated at the point of the stream attribute reference). The
kono
parents:
diff changeset
101 -- Loc parameter is used as the Sloc of the created entity.
kono
parents:
diff changeset
102
kono
parents:
diff changeset
103 function Stream_Base_Type (E : Entity_Id) return Entity_Id;
kono
parents:
diff changeset
104 -- Stream attributes work on the basis of the base type except for the
kono
parents:
diff changeset
105 -- array case. For the array case, we do not go to the base type, but
kono
parents:
diff changeset
106 -- to the first subtype if it is constrained. This avoids problems with
kono
parents:
diff changeset
107 -- incorrect conversions in the packed array case. Stream_Base_Type is
kono
parents:
diff changeset
108 -- exactly this function (returns the base type, unless we have an array
kono
parents:
diff changeset
109 -- type whose first subtype is constrained, in which case it returns the
kono
parents:
diff changeset
110 -- first subtype).
kono
parents:
diff changeset
111
kono
parents:
diff changeset
112 --------------------------------
kono
parents:
diff changeset
113 -- Build_Array_Input_Function --
kono
parents:
diff changeset
114 --------------------------------
kono
parents:
diff changeset
115
kono
parents:
diff changeset
116 -- The function we build looks like
kono
parents:
diff changeset
117
kono
parents:
diff changeset
118 -- function typSI[_nnn] (S : access RST) return Typ is
kono
parents:
diff changeset
119 -- L1 : constant Index_Type_1 := Index_Type_1'Input (S);
kono
parents:
diff changeset
120 -- H1 : constant Index_Type_1 := Index_Type_1'Input (S);
kono
parents:
diff changeset
121 -- L2 : constant Index_Type_2 := Index_Type_2'Input (S);
kono
parents:
diff changeset
122 -- H2 : constant Index_Type_2 := Index_Type_2'Input (S);
kono
parents:
diff changeset
123 -- ..
kono
parents:
diff changeset
124 -- Ln : constant Index_Type_n := Index_Type_n'Input (S);
kono
parents:
diff changeset
125 -- Hn : constant Index_Type_n := Index_Type_n'Input (S);
kono
parents:
diff changeset
126 --
kono
parents:
diff changeset
127 -- V : Typ'Base (L1 .. H1, L2 .. H2, ... Ln .. Hn)
kono
parents:
diff changeset
128
kono
parents:
diff changeset
129 -- begin
kono
parents:
diff changeset
130 -- Typ'Read (S, V);
kono
parents:
diff changeset
131 -- return V;
kono
parents:
diff changeset
132 -- end typSI[_nnn]
kono
parents:
diff changeset
133
kono
parents:
diff changeset
134 -- Note: the suffix [_nnn] is present for untagged types, where we generate
kono
parents:
diff changeset
135 -- a local subprogram at the point of the occurrence of the attribute
kono
parents:
diff changeset
136 -- reference, so the name must be unique.
kono
parents:
diff changeset
137
kono
parents:
diff changeset
138 procedure Build_Array_Input_Function
kono
parents:
diff changeset
139 (Loc : Source_Ptr;
kono
parents:
diff changeset
140 Typ : Entity_Id;
kono
parents:
diff changeset
141 Decl : out Node_Id;
kono
parents:
diff changeset
142 Fnam : out Entity_Id)
kono
parents:
diff changeset
143 is
kono
parents:
diff changeset
144 Dim : constant Pos := Number_Dimensions (Typ);
kono
parents:
diff changeset
145 Lnam : Name_Id;
kono
parents:
diff changeset
146 Hnam : Name_Id;
kono
parents:
diff changeset
147 Decls : List_Id;
kono
parents:
diff changeset
148 Ranges : List_Id;
kono
parents:
diff changeset
149 Stms : List_Id;
kono
parents:
diff changeset
150 Rstmt : Node_Id;
kono
parents:
diff changeset
151 Indx : Node_Id;
kono
parents:
diff changeset
152 Odecl : Node_Id;
kono
parents:
diff changeset
153
kono
parents:
diff changeset
154 begin
kono
parents:
diff changeset
155 Decls := New_List;
kono
parents:
diff changeset
156 Ranges := New_List;
kono
parents:
diff changeset
157 Indx := First_Index (Typ);
kono
parents:
diff changeset
158 for J in 1 .. Dim loop
kono
parents:
diff changeset
159 Lnam := New_External_Name ('L', J);
kono
parents:
diff changeset
160 Hnam := New_External_Name ('H', J);
kono
parents:
diff changeset
161
kono
parents:
diff changeset
162 Append_To (Decls,
kono
parents:
diff changeset
163 Make_Object_Declaration (Loc,
kono
parents:
diff changeset
164 Defining_Identifier => Make_Defining_Identifier (Loc, Lnam),
kono
parents:
diff changeset
165 Constant_Present => True,
kono
parents:
diff changeset
166 Object_Definition => New_Occurrence_Of (Etype (Indx), Loc),
kono
parents:
diff changeset
167 Expression =>
kono
parents:
diff changeset
168 Make_Attribute_Reference (Loc,
kono
parents:
diff changeset
169 Prefix =>
kono
parents:
diff changeset
170 New_Occurrence_Of (Stream_Base_Type (Etype (Indx)), Loc),
kono
parents:
diff changeset
171 Attribute_Name => Name_Input,
kono
parents:
diff changeset
172 Expressions => New_List (Make_Identifier (Loc, Name_S)))));
kono
parents:
diff changeset
173
kono
parents:
diff changeset
174 Append_To (Decls,
kono
parents:
diff changeset
175 Make_Object_Declaration (Loc,
kono
parents:
diff changeset
176 Defining_Identifier => Make_Defining_Identifier (Loc, Hnam),
kono
parents:
diff changeset
177 Constant_Present => True,
kono
parents:
diff changeset
178 Object_Definition =>
kono
parents:
diff changeset
179 New_Occurrence_Of (Stream_Base_Type (Etype (Indx)), Loc),
kono
parents:
diff changeset
180 Expression =>
kono
parents:
diff changeset
181 Make_Attribute_Reference (Loc,
kono
parents:
diff changeset
182 Prefix =>
kono
parents:
diff changeset
183 New_Occurrence_Of (Stream_Base_Type (Etype (Indx)), Loc),
kono
parents:
diff changeset
184 Attribute_Name => Name_Input,
kono
parents:
diff changeset
185 Expressions => New_List (Make_Identifier (Loc, Name_S)))));
kono
parents:
diff changeset
186
kono
parents:
diff changeset
187 Append_To (Ranges,
kono
parents:
diff changeset
188 Make_Range (Loc,
kono
parents:
diff changeset
189 Low_Bound => Make_Identifier (Loc, Lnam),
kono
parents:
diff changeset
190 High_Bound => Make_Identifier (Loc, Hnam)));
kono
parents:
diff changeset
191
kono
parents:
diff changeset
192 Next_Index (Indx);
kono
parents:
diff changeset
193 end loop;
kono
parents:
diff changeset
194
kono
parents:
diff changeset
195 -- If the type is constrained, use it directly. Otherwise build a
kono
parents:
diff changeset
196 -- subtype indication with the proper bounds.
kono
parents:
diff changeset
197
kono
parents:
diff changeset
198 if Is_Constrained (Typ) then
kono
parents:
diff changeset
199 Odecl :=
kono
parents:
diff changeset
200 Make_Object_Declaration (Loc,
kono
parents:
diff changeset
201 Defining_Identifier => Make_Defining_Identifier (Loc, Name_V),
kono
parents:
diff changeset
202 Object_Definition => New_Occurrence_Of (Typ, Loc));
kono
parents:
diff changeset
203
kono
parents:
diff changeset
204 else
kono
parents:
diff changeset
205 Odecl :=
kono
parents:
diff changeset
206 Make_Object_Declaration (Loc,
kono
parents:
diff changeset
207 Defining_Identifier => Make_Defining_Identifier (Loc, Name_V),
kono
parents:
diff changeset
208 Object_Definition =>
kono
parents:
diff changeset
209 Make_Subtype_Indication (Loc,
kono
parents:
diff changeset
210 Subtype_Mark =>
kono
parents:
diff changeset
211 New_Occurrence_Of (Stream_Base_Type (Typ), Loc),
kono
parents:
diff changeset
212 Constraint =>
kono
parents:
diff changeset
213 Make_Index_Or_Discriminant_Constraint (Loc, Ranges)));
kono
parents:
diff changeset
214 end if;
kono
parents:
diff changeset
215
kono
parents:
diff changeset
216 Rstmt :=
kono
parents:
diff changeset
217 Make_Attribute_Reference (Loc,
kono
parents:
diff changeset
218 Prefix => New_Occurrence_Of (Typ, Loc),
kono
parents:
diff changeset
219 Attribute_Name => Name_Read,
kono
parents:
diff changeset
220 Expressions => New_List (
kono
parents:
diff changeset
221 Make_Identifier (Loc, Name_S),
kono
parents:
diff changeset
222 Make_Identifier (Loc, Name_V)));
kono
parents:
diff changeset
223
kono
parents:
diff changeset
224 Stms := New_List (
kono
parents:
diff changeset
225 Make_Extended_Return_Statement (Loc,
kono
parents:
diff changeset
226 Return_Object_Declarations => New_List (Odecl),
kono
parents:
diff changeset
227 Handled_Statement_Sequence =>
kono
parents:
diff changeset
228 Make_Handled_Sequence_Of_Statements (Loc, New_List (Rstmt))));
kono
parents:
diff changeset
229
kono
parents:
diff changeset
230 Fnam :=
kono
parents:
diff changeset
231 Make_Defining_Identifier (Loc,
kono
parents:
diff changeset
232 Chars => Make_TSS_Name_Local (Typ, TSS_Stream_Input));
kono
parents:
diff changeset
233
kono
parents:
diff changeset
234 Build_Stream_Function (Loc, Typ, Decl, Fnam, Decls, Stms);
kono
parents:
diff changeset
235 end Build_Array_Input_Function;
kono
parents:
diff changeset
236
kono
parents:
diff changeset
237 ----------------------------------
kono
parents:
diff changeset
238 -- Build_Array_Output_Procedure --
kono
parents:
diff changeset
239 ----------------------------------
kono
parents:
diff changeset
240
kono
parents:
diff changeset
241 procedure Build_Array_Output_Procedure
kono
parents:
diff changeset
242 (Loc : Source_Ptr;
kono
parents:
diff changeset
243 Typ : Entity_Id;
kono
parents:
diff changeset
244 Decl : out Node_Id;
kono
parents:
diff changeset
245 Pnam : out Entity_Id)
kono
parents:
diff changeset
246 is
kono
parents:
diff changeset
247 Stms : List_Id;
kono
parents:
diff changeset
248 Indx : Node_Id;
kono
parents:
diff changeset
249
kono
parents:
diff changeset
250 begin
kono
parents:
diff changeset
251 -- Build series of statements to output bounds
kono
parents:
diff changeset
252
kono
parents:
diff changeset
253 Indx := First_Index (Typ);
kono
parents:
diff changeset
254 Stms := New_List;
kono
parents:
diff changeset
255
kono
parents:
diff changeset
256 for J in 1 .. Number_Dimensions (Typ) loop
kono
parents:
diff changeset
257 Append_To (Stms,
kono
parents:
diff changeset
258 Make_Attribute_Reference (Loc,
kono
parents:
diff changeset
259 Prefix =>
kono
parents:
diff changeset
260 New_Occurrence_Of (Stream_Base_Type (Etype (Indx)), Loc),
kono
parents:
diff changeset
261 Attribute_Name => Name_Write,
kono
parents:
diff changeset
262 Expressions => New_List (
kono
parents:
diff changeset
263 Make_Identifier (Loc, Name_S),
kono
parents:
diff changeset
264 Make_Attribute_Reference (Loc,
kono
parents:
diff changeset
265 Prefix => Make_Identifier (Loc, Name_V),
kono
parents:
diff changeset
266 Attribute_Name => Name_First,
kono
parents:
diff changeset
267 Expressions => New_List (
kono
parents:
diff changeset
268 Make_Integer_Literal (Loc, J))))));
kono
parents:
diff changeset
269
kono
parents:
diff changeset
270 Append_To (Stms,
kono
parents:
diff changeset
271 Make_Attribute_Reference (Loc,
kono
parents:
diff changeset
272 Prefix =>
kono
parents:
diff changeset
273 New_Occurrence_Of (Stream_Base_Type (Etype (Indx)), Loc),
kono
parents:
diff changeset
274 Attribute_Name => Name_Write,
kono
parents:
diff changeset
275 Expressions => New_List (
kono
parents:
diff changeset
276 Make_Identifier (Loc, Name_S),
kono
parents:
diff changeset
277 Make_Attribute_Reference (Loc,
kono
parents:
diff changeset
278 Prefix => Make_Identifier (Loc, Name_V),
kono
parents:
diff changeset
279 Attribute_Name => Name_Last,
kono
parents:
diff changeset
280 Expressions => New_List (
kono
parents:
diff changeset
281 Make_Integer_Literal (Loc, J))))));
kono
parents:
diff changeset
282
kono
parents:
diff changeset
283 Next_Index (Indx);
kono
parents:
diff changeset
284 end loop;
kono
parents:
diff changeset
285
kono
parents:
diff changeset
286 -- Append Write attribute to write array elements
kono
parents:
diff changeset
287
kono
parents:
diff changeset
288 Append_To (Stms,
kono
parents:
diff changeset
289 Make_Attribute_Reference (Loc,
kono
parents:
diff changeset
290 Prefix => New_Occurrence_Of (Typ, Loc),
kono
parents:
diff changeset
291 Attribute_Name => Name_Write,
kono
parents:
diff changeset
292 Expressions => New_List (
kono
parents:
diff changeset
293 Make_Identifier (Loc, Name_S),
kono
parents:
diff changeset
294 Make_Identifier (Loc, Name_V))));
kono
parents:
diff changeset
295
kono
parents:
diff changeset
296 Pnam :=
kono
parents:
diff changeset
297 Make_Defining_Identifier (Loc,
kono
parents:
diff changeset
298 Chars => Make_TSS_Name_Local (Typ, TSS_Stream_Output));
kono
parents:
diff changeset
299
kono
parents:
diff changeset
300 Build_Stream_Procedure (Loc, Typ, Decl, Pnam, Stms, False);
kono
parents:
diff changeset
301 end Build_Array_Output_Procedure;
kono
parents:
diff changeset
302
kono
parents:
diff changeset
303 --------------------------------
kono
parents:
diff changeset
304 -- Build_Array_Read_Procedure --
kono
parents:
diff changeset
305 --------------------------------
kono
parents:
diff changeset
306
kono
parents:
diff changeset
307 procedure Build_Array_Read_Procedure
kono
parents:
diff changeset
308 (Nod : Node_Id;
kono
parents:
diff changeset
309 Typ : Entity_Id;
kono
parents:
diff changeset
310 Decl : out Node_Id;
kono
parents:
diff changeset
311 Pnam : out Entity_Id)
kono
parents:
diff changeset
312 is
kono
parents:
diff changeset
313 Loc : constant Source_Ptr := Sloc (Nod);
kono
parents:
diff changeset
314
kono
parents:
diff changeset
315 begin
kono
parents:
diff changeset
316 Pnam :=
kono
parents:
diff changeset
317 Make_Defining_Identifier (Loc,
kono
parents:
diff changeset
318 Chars => Make_TSS_Name_Local (Typ, TSS_Stream_Read));
kono
parents:
diff changeset
319 Build_Array_Read_Write_Procedure (Nod, Typ, Decl, Pnam, Name_Read);
kono
parents:
diff changeset
320 end Build_Array_Read_Procedure;
kono
parents:
diff changeset
321
kono
parents:
diff changeset
322 --------------------------------------
kono
parents:
diff changeset
323 -- Build_Array_Read_Write_Procedure --
kono
parents:
diff changeset
324 --------------------------------------
kono
parents:
diff changeset
325
kono
parents:
diff changeset
326 -- The form of the array read/write procedure is as follows:
kono
parents:
diff changeset
327
kono
parents:
diff changeset
328 -- procedure pnam (S : access RST, V : [out] Typ) is
kono
parents:
diff changeset
329 -- begin
kono
parents:
diff changeset
330 -- for L1 in V'Range (1) loop
kono
parents:
diff changeset
331 -- for L2 in V'Range (2) loop
kono
parents:
diff changeset
332 -- ...
kono
parents:
diff changeset
333 -- for Ln in V'Range (n) loop
kono
parents:
diff changeset
334 -- Component_Type'Read/Write (S, V (L1, L2, .. Ln));
kono
parents:
diff changeset
335 -- end loop;
kono
parents:
diff changeset
336 -- ..
kono
parents:
diff changeset
337 -- end loop;
kono
parents:
diff changeset
338 -- end loop
kono
parents:
diff changeset
339 -- end pnam;
kono
parents:
diff changeset
340
kono
parents:
diff changeset
341 -- The out keyword for V is supplied in the Read case
kono
parents:
diff changeset
342
kono
parents:
diff changeset
343 procedure Build_Array_Read_Write_Procedure
kono
parents:
diff changeset
344 (Nod : Node_Id;
kono
parents:
diff changeset
345 Typ : Entity_Id;
kono
parents:
diff changeset
346 Decl : out Node_Id;
kono
parents:
diff changeset
347 Pnam : Entity_Id;
kono
parents:
diff changeset
348 Nam : Name_Id)
kono
parents:
diff changeset
349 is
kono
parents:
diff changeset
350 Loc : constant Source_Ptr := Sloc (Nod);
kono
parents:
diff changeset
351 Ndim : constant Pos := Number_Dimensions (Typ);
kono
parents:
diff changeset
352 Ctyp : constant Entity_Id := Component_Type (Typ);
kono
parents:
diff changeset
353
kono
parents:
diff changeset
354 Stm : Node_Id;
kono
parents:
diff changeset
355 Exl : List_Id;
kono
parents:
diff changeset
356 RW : Entity_Id;
kono
parents:
diff changeset
357
kono
parents:
diff changeset
358 begin
kono
parents:
diff changeset
359 -- First build the inner attribute call
kono
parents:
diff changeset
360
kono
parents:
diff changeset
361 Exl := New_List;
kono
parents:
diff changeset
362
kono
parents:
diff changeset
363 for J in 1 .. Ndim loop
kono
parents:
diff changeset
364 Append_To (Exl, Make_Identifier (Loc, New_External_Name ('L', J)));
kono
parents:
diff changeset
365 end loop;
kono
parents:
diff changeset
366
kono
parents:
diff changeset
367 Stm :=
kono
parents:
diff changeset
368 Make_Attribute_Reference (Loc,
kono
parents:
diff changeset
369 Prefix => New_Occurrence_Of (Stream_Base_Type (Ctyp), Loc),
kono
parents:
diff changeset
370 Attribute_Name => Nam,
kono
parents:
diff changeset
371 Expressions => New_List (
kono
parents:
diff changeset
372 Make_Identifier (Loc, Name_S),
kono
parents:
diff changeset
373 Make_Indexed_Component (Loc,
kono
parents:
diff changeset
374 Prefix => Make_Identifier (Loc, Name_V),
kono
parents:
diff changeset
375 Expressions => Exl)));
kono
parents:
diff changeset
376
kono
parents:
diff changeset
377 -- The corresponding stream attribute for the component type of the
kono
parents:
diff changeset
378 -- array may be user-defined, and be frozen after the type for which
kono
parents:
diff changeset
379 -- we are generating the stream subprogram. In that case, freeze the
kono
parents:
diff changeset
380 -- stream attribute of the component type, whose declaration could not
kono
parents:
diff changeset
381 -- generate any additional freezing actions in any case.
kono
parents:
diff changeset
382
kono
parents:
diff changeset
383 if Nam = Name_Read then
kono
parents:
diff changeset
384 RW := TSS (Base_Type (Ctyp), TSS_Stream_Read);
kono
parents:
diff changeset
385 else
kono
parents:
diff changeset
386 RW := TSS (Base_Type (Ctyp), TSS_Stream_Write);
kono
parents:
diff changeset
387 end if;
kono
parents:
diff changeset
388
kono
parents:
diff changeset
389 if Present (RW)
kono
parents:
diff changeset
390 and then not Is_Frozen (RW)
kono
parents:
diff changeset
391 then
kono
parents:
diff changeset
392 Set_Is_Frozen (RW);
kono
parents:
diff changeset
393 end if;
kono
parents:
diff changeset
394
kono
parents:
diff changeset
395 -- Now this is the big loop to wrap that statement up in a sequence
kono
parents:
diff changeset
396 -- of loops. The first time around, Stm is the attribute call. The
kono
parents:
diff changeset
397 -- second and subsequent times, Stm is an inner loop.
kono
parents:
diff changeset
398
kono
parents:
diff changeset
399 for J in 1 .. Ndim loop
kono
parents:
diff changeset
400 Stm :=
kono
parents:
diff changeset
401 Make_Implicit_Loop_Statement (Nod,
kono
parents:
diff changeset
402 Iteration_Scheme =>
kono
parents:
diff changeset
403 Make_Iteration_Scheme (Loc,
kono
parents:
diff changeset
404 Loop_Parameter_Specification =>
kono
parents:
diff changeset
405 Make_Loop_Parameter_Specification (Loc,
kono
parents:
diff changeset
406 Defining_Identifier =>
kono
parents:
diff changeset
407 Make_Defining_Identifier (Loc,
kono
parents:
diff changeset
408 Chars => New_External_Name ('L', Ndim - J + 1)),
kono
parents:
diff changeset
409
kono
parents:
diff changeset
410 Discrete_Subtype_Definition =>
kono
parents:
diff changeset
411 Make_Attribute_Reference (Loc,
kono
parents:
diff changeset
412 Prefix => Make_Identifier (Loc, Name_V),
kono
parents:
diff changeset
413 Attribute_Name => Name_Range,
kono
parents:
diff changeset
414
kono
parents:
diff changeset
415 Expressions => New_List (
kono
parents:
diff changeset
416 Make_Integer_Literal (Loc, Ndim - J + 1))))),
kono
parents:
diff changeset
417
kono
parents:
diff changeset
418 Statements => New_List (Stm));
kono
parents:
diff changeset
419
kono
parents:
diff changeset
420 end loop;
kono
parents:
diff changeset
421
kono
parents:
diff changeset
422 Build_Stream_Procedure
kono
parents:
diff changeset
423 (Loc, Typ, Decl, Pnam, New_List (Stm), Nam = Name_Read);
kono
parents:
diff changeset
424 end Build_Array_Read_Write_Procedure;
kono
parents:
diff changeset
425
kono
parents:
diff changeset
426 ---------------------------------
kono
parents:
diff changeset
427 -- Build_Array_Write_Procedure --
kono
parents:
diff changeset
428 ---------------------------------
kono
parents:
diff changeset
429
kono
parents:
diff changeset
430 procedure Build_Array_Write_Procedure
kono
parents:
diff changeset
431 (Nod : Node_Id;
kono
parents:
diff changeset
432 Typ : Entity_Id;
kono
parents:
diff changeset
433 Decl : out Node_Id;
kono
parents:
diff changeset
434 Pnam : out Entity_Id)
kono
parents:
diff changeset
435 is
kono
parents:
diff changeset
436 Loc : constant Source_Ptr := Sloc (Nod);
kono
parents:
diff changeset
437 begin
kono
parents:
diff changeset
438 Pnam :=
kono
parents:
diff changeset
439 Make_Defining_Identifier (Loc,
kono
parents:
diff changeset
440 Chars => Make_TSS_Name_Local (Typ, TSS_Stream_Write));
kono
parents:
diff changeset
441 Build_Array_Read_Write_Procedure (Nod, Typ, Decl, Pnam, Name_Write);
kono
parents:
diff changeset
442 end Build_Array_Write_Procedure;
kono
parents:
diff changeset
443
kono
parents:
diff changeset
444 ---------------------------------
kono
parents:
diff changeset
445 -- Build_Elementary_Input_Call --
kono
parents:
diff changeset
446 ---------------------------------
kono
parents:
diff changeset
447
kono
parents:
diff changeset
448 function Build_Elementary_Input_Call (N : Node_Id) return Node_Id is
kono
parents:
diff changeset
449 Loc : constant Source_Ptr := Sloc (N);
kono
parents:
diff changeset
450 P_Type : constant Entity_Id := Entity (Prefix (N));
kono
parents:
diff changeset
451 U_Type : constant Entity_Id := Underlying_Type (P_Type);
kono
parents:
diff changeset
452 Rt_Type : constant Entity_Id := Root_Type (U_Type);
kono
parents:
diff changeset
453 FST : constant Entity_Id := First_Subtype (U_Type);
kono
parents:
diff changeset
454 Strm : constant Node_Id := First (Expressions (N));
kono
parents:
diff changeset
455 Targ : constant Node_Id := Next (Strm);
kono
parents:
diff changeset
456 P_Size : constant Uint := Get_Stream_Size (FST);
kono
parents:
diff changeset
457 Res : Node_Id;
kono
parents:
diff changeset
458 Lib_RE : RE_Id;
kono
parents:
diff changeset
459
kono
parents:
diff changeset
460 begin
kono
parents:
diff changeset
461
kono
parents:
diff changeset
462 -- Check first for Boolean and Character. These are enumeration types,
kono
parents:
diff changeset
463 -- but we treat them specially, since they may require special handling
kono
parents:
diff changeset
464 -- in the transfer protocol. However, this special handling only applies
kono
parents:
diff changeset
465 -- if they have standard representation, otherwise they are treated like
kono
parents:
diff changeset
466 -- any other enumeration type.
kono
parents:
diff changeset
467
kono
parents:
diff changeset
468 if Rt_Type = Standard_Boolean
kono
parents:
diff changeset
469 and then Has_Stream_Standard_Rep (U_Type)
kono
parents:
diff changeset
470 then
kono
parents:
diff changeset
471 Lib_RE := RE_I_B;
kono
parents:
diff changeset
472
kono
parents:
diff changeset
473 elsif Rt_Type = Standard_Character
kono
parents:
diff changeset
474 and then Has_Stream_Standard_Rep (U_Type)
kono
parents:
diff changeset
475 then
kono
parents:
diff changeset
476 Lib_RE := RE_I_C;
kono
parents:
diff changeset
477
kono
parents:
diff changeset
478 elsif Rt_Type = Standard_Wide_Character
kono
parents:
diff changeset
479 and then Has_Stream_Standard_Rep (U_Type)
kono
parents:
diff changeset
480 then
kono
parents:
diff changeset
481 Lib_RE := RE_I_WC;
kono
parents:
diff changeset
482
kono
parents:
diff changeset
483 elsif Rt_Type = Standard_Wide_Wide_Character
kono
parents:
diff changeset
484 and then Has_Stream_Standard_Rep (U_Type)
kono
parents:
diff changeset
485 then
kono
parents:
diff changeset
486 Lib_RE := RE_I_WWC;
kono
parents:
diff changeset
487
kono
parents:
diff changeset
488 -- Floating point types
kono
parents:
diff changeset
489
kono
parents:
diff changeset
490 elsif Is_Floating_Point_Type (U_Type) then
kono
parents:
diff changeset
491
kono
parents:
diff changeset
492 -- Question: should we use P_Size or Rt_Type to distinguish between
kono
parents:
diff changeset
493 -- possible floating point types? If a non-standard size or a stream
kono
parents:
diff changeset
494 -- size is specified, then we should certainly use the size. But if
kono
parents:
diff changeset
495 -- we have two types the same (notably Short_Float_Size = Float_Size
kono
parents:
diff changeset
496 -- which is close to universally true, and Long_Long_Float_Size =
kono
parents:
diff changeset
497 -- Long_Float_Size, true on most targets except the x86), then we
kono
parents:
diff changeset
498 -- would really rather use the root type, so that if people want to
kono
parents:
diff changeset
499 -- fiddle with System.Stream_Attributes to get inter-target portable
kono
parents:
diff changeset
500 -- streams, they get the size they expect. Consider in particular the
kono
parents:
diff changeset
501 -- case of a stream written on an x86, with 96-bit Long_Long_Float
kono
parents:
diff changeset
502 -- being read into a non-x86 target with 64 bit Long_Long_Float. A
kono
parents:
diff changeset
503 -- special version of System.Stream_Attributes can deal with this
kono
parents:
diff changeset
504 -- provided the proper type is always used.
kono
parents:
diff changeset
505
kono
parents:
diff changeset
506 -- To deal with these two requirements we add the special checks
kono
parents:
diff changeset
507 -- on equal sizes and use the root type to distinguish.
kono
parents:
diff changeset
508
kono
parents:
diff changeset
509 if P_Size <= Standard_Short_Float_Size
kono
parents:
diff changeset
510 and then (Standard_Short_Float_Size /= Standard_Float_Size
kono
parents:
diff changeset
511 or else Rt_Type = Standard_Short_Float)
kono
parents:
diff changeset
512 then
kono
parents:
diff changeset
513 Lib_RE := RE_I_SF;
kono
parents:
diff changeset
514
kono
parents:
diff changeset
515 elsif P_Size <= Standard_Float_Size then
kono
parents:
diff changeset
516 Lib_RE := RE_I_F;
kono
parents:
diff changeset
517
kono
parents:
diff changeset
518 elsif P_Size <= Standard_Long_Float_Size
kono
parents:
diff changeset
519 and then (Standard_Long_Float_Size /= Standard_Long_Long_Float_Size
kono
parents:
diff changeset
520 or else Rt_Type = Standard_Long_Float)
kono
parents:
diff changeset
521 then
kono
parents:
diff changeset
522 Lib_RE := RE_I_LF;
kono
parents:
diff changeset
523
kono
parents:
diff changeset
524 else
kono
parents:
diff changeset
525 Lib_RE := RE_I_LLF;
kono
parents:
diff changeset
526 end if;
kono
parents:
diff changeset
527
kono
parents:
diff changeset
528 -- Signed integer types. Also includes signed fixed-point types and
kono
parents:
diff changeset
529 -- enumeration types with a signed representation.
kono
parents:
diff changeset
530
kono
parents:
diff changeset
531 -- Note on signed integer types. We do not consider types as signed for
kono
parents:
diff changeset
532 -- this purpose if they have no negative numbers, or if they have biased
kono
parents:
diff changeset
533 -- representation. The reason is that the value in either case basically
kono
parents:
diff changeset
534 -- represents an unsigned value.
kono
parents:
diff changeset
535
kono
parents:
diff changeset
536 -- For example, consider:
kono
parents:
diff changeset
537
kono
parents:
diff changeset
538 -- type W is range 0 .. 2**32 - 1;
kono
parents:
diff changeset
539 -- for W'Size use 32;
kono
parents:
diff changeset
540
kono
parents:
diff changeset
541 -- This is a signed type, but the representation is unsigned, and may
kono
parents:
diff changeset
542 -- be outside the range of a 32-bit signed integer, so this must be
kono
parents:
diff changeset
543 -- treated as 32-bit unsigned.
kono
parents:
diff changeset
544
kono
parents:
diff changeset
545 -- Similarly, if we have
kono
parents:
diff changeset
546
kono
parents:
diff changeset
547 -- type W is range -1 .. +254;
kono
parents:
diff changeset
548 -- for W'Size use 8;
kono
parents:
diff changeset
549
kono
parents:
diff changeset
550 -- then the representation is unsigned
kono
parents:
diff changeset
551
kono
parents:
diff changeset
552 elsif not Is_Unsigned_Type (FST)
kono
parents:
diff changeset
553
kono
parents:
diff changeset
554 -- The following set of tests gets repeated many times, we should
kono
parents:
diff changeset
555 -- have an abstraction defined ???
kono
parents:
diff changeset
556
kono
parents:
diff changeset
557 and then
kono
parents:
diff changeset
558 (Is_Fixed_Point_Type (U_Type)
kono
parents:
diff changeset
559 or else
kono
parents:
diff changeset
560 Is_Enumeration_Type (U_Type)
kono
parents:
diff changeset
561 or else
kono
parents:
diff changeset
562 (Is_Signed_Integer_Type (U_Type)
kono
parents:
diff changeset
563 and then not Has_Biased_Representation (FST)))
kono
parents:
diff changeset
564
kono
parents:
diff changeset
565 then
kono
parents:
diff changeset
566 if P_Size <= Standard_Short_Short_Integer_Size then
kono
parents:
diff changeset
567 Lib_RE := RE_I_SSI;
kono
parents:
diff changeset
568
kono
parents:
diff changeset
569 elsif P_Size <= Standard_Short_Integer_Size then
kono
parents:
diff changeset
570 Lib_RE := RE_I_SI;
kono
parents:
diff changeset
571
kono
parents:
diff changeset
572 elsif P_Size <= Standard_Integer_Size then
kono
parents:
diff changeset
573 Lib_RE := RE_I_I;
kono
parents:
diff changeset
574
kono
parents:
diff changeset
575 elsif P_Size <= Standard_Long_Integer_Size then
kono
parents:
diff changeset
576 Lib_RE := RE_I_LI;
kono
parents:
diff changeset
577
kono
parents:
diff changeset
578 else
kono
parents:
diff changeset
579 Lib_RE := RE_I_LLI;
kono
parents:
diff changeset
580 end if;
kono
parents:
diff changeset
581
kono
parents:
diff changeset
582 -- Unsigned integer types, also includes unsigned fixed-point types
kono
parents:
diff changeset
583 -- and enumeration types with an unsigned representation (note that
kono
parents:
diff changeset
584 -- we know they are unsigned because we already tested for signed).
kono
parents:
diff changeset
585
kono
parents:
diff changeset
586 -- Also includes signed integer types that are unsigned in the sense
kono
parents:
diff changeset
587 -- that they do not include negative numbers. See above for details.
kono
parents:
diff changeset
588
kono
parents:
diff changeset
589 elsif Is_Modular_Integer_Type (U_Type)
kono
parents:
diff changeset
590 or else Is_Fixed_Point_Type (U_Type)
kono
parents:
diff changeset
591 or else Is_Enumeration_Type (U_Type)
kono
parents:
diff changeset
592 or else Is_Signed_Integer_Type (U_Type)
kono
parents:
diff changeset
593 then
kono
parents:
diff changeset
594 if P_Size <= Standard_Short_Short_Integer_Size then
kono
parents:
diff changeset
595 Lib_RE := RE_I_SSU;
kono
parents:
diff changeset
596
kono
parents:
diff changeset
597 elsif P_Size <= Standard_Short_Integer_Size then
kono
parents:
diff changeset
598 Lib_RE := RE_I_SU;
kono
parents:
diff changeset
599
kono
parents:
diff changeset
600 elsif P_Size <= Standard_Integer_Size then
kono
parents:
diff changeset
601 Lib_RE := RE_I_U;
kono
parents:
diff changeset
602
kono
parents:
diff changeset
603 elsif P_Size <= Standard_Long_Integer_Size then
kono
parents:
diff changeset
604 Lib_RE := RE_I_LU;
kono
parents:
diff changeset
605
kono
parents:
diff changeset
606 else
kono
parents:
diff changeset
607 Lib_RE := RE_I_LLU;
kono
parents:
diff changeset
608 end if;
kono
parents:
diff changeset
609
kono
parents:
diff changeset
610 else pragma Assert (Is_Access_Type (U_Type));
kono
parents:
diff changeset
611 if P_Size > System_Address_Size then
kono
parents:
diff changeset
612 Lib_RE := RE_I_AD;
kono
parents:
diff changeset
613 else
kono
parents:
diff changeset
614 Lib_RE := RE_I_AS;
kono
parents:
diff changeset
615 end if;
kono
parents:
diff changeset
616 end if;
kono
parents:
diff changeset
617
kono
parents:
diff changeset
618 -- Call the function, and do an unchecked conversion of the result
kono
parents:
diff changeset
619 -- to the actual type of the prefix. If the target is a discriminant,
kono
parents:
diff changeset
620 -- and we are in the body of the default implementation of a 'Read
kono
parents:
diff changeset
621 -- attribute, set target type to force a constraint check (13.13.2(35)).
kono
parents:
diff changeset
622 -- If the type of the discriminant is currently private, add another
kono
parents:
diff changeset
623 -- unchecked conversion from the full view.
kono
parents:
diff changeset
624
kono
parents:
diff changeset
625 if Nkind (Targ) = N_Identifier
kono
parents:
diff changeset
626 and then Is_Internal_Name (Chars (Targ))
kono
parents:
diff changeset
627 and then Is_TSS (Scope (Entity (Targ)), TSS_Stream_Read)
kono
parents:
diff changeset
628 then
kono
parents:
diff changeset
629 Res :=
kono
parents:
diff changeset
630 Unchecked_Convert_To (Base_Type (U_Type),
kono
parents:
diff changeset
631 Make_Function_Call (Loc,
kono
parents:
diff changeset
632 Name => New_Occurrence_Of (RTE (Lib_RE), Loc),
kono
parents:
diff changeset
633 Parameter_Associations => New_List (
kono
parents:
diff changeset
634 Relocate_Node (Strm))));
kono
parents:
diff changeset
635
kono
parents:
diff changeset
636 Set_Do_Range_Check (Res);
kono
parents:
diff changeset
637
kono
parents:
diff changeset
638 if Base_Type (P_Type) /= Base_Type (U_Type) then
kono
parents:
diff changeset
639 Res := Unchecked_Convert_To (Base_Type (P_Type), Res);
kono
parents:
diff changeset
640 end if;
kono
parents:
diff changeset
641
kono
parents:
diff changeset
642 return Res;
kono
parents:
diff changeset
643
kono
parents:
diff changeset
644 else
kono
parents:
diff changeset
645 Res :=
kono
parents:
diff changeset
646 Make_Function_Call (Loc,
kono
parents:
diff changeset
647 Name => New_Occurrence_Of (RTE (Lib_RE), Loc),
kono
parents:
diff changeset
648 Parameter_Associations => New_List (
kono
parents:
diff changeset
649 Relocate_Node (Strm)));
kono
parents:
diff changeset
650
kono
parents:
diff changeset
651 -- Now convert to the base type if we do not have a biased type. Note
kono
parents:
diff changeset
652 -- that we did not do this in some older versions, and the result was
kono
parents:
diff changeset
653 -- losing a required range check in the case where 'Input is being
kono
parents:
diff changeset
654 -- called from 'Read.
kono
parents:
diff changeset
655
kono
parents:
diff changeset
656 if not Has_Biased_Representation (P_Type) then
kono
parents:
diff changeset
657 return Unchecked_Convert_To (Base_Type (P_Type), Res);
kono
parents:
diff changeset
658
kono
parents:
diff changeset
659 -- For the biased case, the conversion to the base type loses the
kono
parents:
diff changeset
660 -- biasing, so just convert to Ptype. This is not quite right, and
kono
parents:
diff changeset
661 -- for example may lose a corner case CE test, but it is such a
kono
parents:
diff changeset
662 -- rare case that for now we ignore it ???
kono
parents:
diff changeset
663
kono
parents:
diff changeset
664 else
kono
parents:
diff changeset
665 return Unchecked_Convert_To (P_Type, Res);
kono
parents:
diff changeset
666 end if;
kono
parents:
diff changeset
667 end if;
kono
parents:
diff changeset
668 end Build_Elementary_Input_Call;
kono
parents:
diff changeset
669
kono
parents:
diff changeset
670 ---------------------------------
kono
parents:
diff changeset
671 -- Build_Elementary_Write_Call --
kono
parents:
diff changeset
672 ---------------------------------
kono
parents:
diff changeset
673
kono
parents:
diff changeset
674 function Build_Elementary_Write_Call (N : Node_Id) return Node_Id is
kono
parents:
diff changeset
675 Loc : constant Source_Ptr := Sloc (N);
kono
parents:
diff changeset
676 P_Type : constant Entity_Id := Entity (Prefix (N));
kono
parents:
diff changeset
677 U_Type : constant Entity_Id := Underlying_Type (P_Type);
kono
parents:
diff changeset
678 Rt_Type : constant Entity_Id := Root_Type (U_Type);
kono
parents:
diff changeset
679 FST : constant Entity_Id := First_Subtype (U_Type);
kono
parents:
diff changeset
680 Strm : constant Node_Id := First (Expressions (N));
kono
parents:
diff changeset
681 Item : constant Node_Id := Next (Strm);
kono
parents:
diff changeset
682 P_Size : Uint;
kono
parents:
diff changeset
683 Lib_RE : RE_Id;
kono
parents:
diff changeset
684 Libent : Entity_Id;
kono
parents:
diff changeset
685
kono
parents:
diff changeset
686 begin
kono
parents:
diff changeset
687 -- Compute the size of the stream element. This is either the size of
kono
parents:
diff changeset
688 -- the first subtype or if given the size of the Stream_Size attribute.
kono
parents:
diff changeset
689
kono
parents:
diff changeset
690 if Has_Stream_Size_Clause (FST) then
kono
parents:
diff changeset
691 P_Size := Static_Integer (Expression (Stream_Size_Clause (FST)));
kono
parents:
diff changeset
692 else
kono
parents:
diff changeset
693 P_Size := Esize (FST);
kono
parents:
diff changeset
694 end if;
kono
parents:
diff changeset
695
kono
parents:
diff changeset
696 -- Find the routine to be called
kono
parents:
diff changeset
697
kono
parents:
diff changeset
698 -- Check for First Boolean and Character. These are enumeration types,
kono
parents:
diff changeset
699 -- but we treat them specially, since they may require special handling
kono
parents:
diff changeset
700 -- in the transfer protocol. However, this special handling only applies
kono
parents:
diff changeset
701 -- if they have standard representation, otherwise they are treated like
kono
parents:
diff changeset
702 -- any other enumeration type.
kono
parents:
diff changeset
703
kono
parents:
diff changeset
704 if Rt_Type = Standard_Boolean
kono
parents:
diff changeset
705 and then Has_Stream_Standard_Rep (U_Type)
kono
parents:
diff changeset
706 then
kono
parents:
diff changeset
707 Lib_RE := RE_W_B;
kono
parents:
diff changeset
708
kono
parents:
diff changeset
709 elsif Rt_Type = Standard_Character
kono
parents:
diff changeset
710 and then Has_Stream_Standard_Rep (U_Type)
kono
parents:
diff changeset
711 then
kono
parents:
diff changeset
712 Lib_RE := RE_W_C;
kono
parents:
diff changeset
713
kono
parents:
diff changeset
714 elsif Rt_Type = Standard_Wide_Character
kono
parents:
diff changeset
715 and then Has_Stream_Standard_Rep (U_Type)
kono
parents:
diff changeset
716 then
kono
parents:
diff changeset
717 Lib_RE := RE_W_WC;
kono
parents:
diff changeset
718
kono
parents:
diff changeset
719 elsif Rt_Type = Standard_Wide_Wide_Character
kono
parents:
diff changeset
720 and then Has_Stream_Standard_Rep (U_Type)
kono
parents:
diff changeset
721 then
kono
parents:
diff changeset
722 Lib_RE := RE_W_WWC;
kono
parents:
diff changeset
723
kono
parents:
diff changeset
724 -- Floating point types
kono
parents:
diff changeset
725
kono
parents:
diff changeset
726 elsif Is_Floating_Point_Type (U_Type) then
kono
parents:
diff changeset
727
kono
parents:
diff changeset
728 -- Question: should we use P_Size or Rt_Type to distinguish between
kono
parents:
diff changeset
729 -- possible floating point types? If a non-standard size or a stream
kono
parents:
diff changeset
730 -- size is specified, then we should certainly use the size. But if
kono
parents:
diff changeset
731 -- we have two types the same (notably Short_Float_Size = Float_Size
kono
parents:
diff changeset
732 -- which is close to universally true, and Long_Long_Float_Size =
kono
parents:
diff changeset
733 -- Long_Float_Size, true on most targets except the x86), then we
kono
parents:
diff changeset
734 -- would really rather use the root type, so that if people want to
kono
parents:
diff changeset
735 -- fiddle with System.Stream_Attributes to get inter-target portable
kono
parents:
diff changeset
736 -- streams, they get the size they expect. Consider in particular the
kono
parents:
diff changeset
737 -- case of a stream written on an x86, with 96-bit Long_Long_Float
kono
parents:
diff changeset
738 -- being read into a non-x86 target with 64 bit Long_Long_Float. A
kono
parents:
diff changeset
739 -- special version of System.Stream_Attributes can deal with this
kono
parents:
diff changeset
740 -- provided the proper type is always used.
kono
parents:
diff changeset
741
kono
parents:
diff changeset
742 -- To deal with these two requirements we add the special checks
kono
parents:
diff changeset
743 -- on equal sizes and use the root type to distinguish.
kono
parents:
diff changeset
744
kono
parents:
diff changeset
745 if P_Size <= Standard_Short_Float_Size
kono
parents:
diff changeset
746 and then (Standard_Short_Float_Size /= Standard_Float_Size
kono
parents:
diff changeset
747 or else Rt_Type = Standard_Short_Float)
kono
parents:
diff changeset
748 then
kono
parents:
diff changeset
749 Lib_RE := RE_W_SF;
kono
parents:
diff changeset
750
kono
parents:
diff changeset
751 elsif P_Size <= Standard_Float_Size then
kono
parents:
diff changeset
752 Lib_RE := RE_W_F;
kono
parents:
diff changeset
753
kono
parents:
diff changeset
754 elsif P_Size <= Standard_Long_Float_Size
kono
parents:
diff changeset
755 and then (Standard_Long_Float_Size /= Standard_Long_Long_Float_Size
kono
parents:
diff changeset
756 or else Rt_Type = Standard_Long_Float)
kono
parents:
diff changeset
757 then
kono
parents:
diff changeset
758 Lib_RE := RE_W_LF;
kono
parents:
diff changeset
759
kono
parents:
diff changeset
760 else
kono
parents:
diff changeset
761 Lib_RE := RE_W_LLF;
kono
parents:
diff changeset
762 end if;
kono
parents:
diff changeset
763
kono
parents:
diff changeset
764 -- Signed integer types. Also includes signed fixed-point types and
kono
parents:
diff changeset
765 -- signed enumeration types share this circuitry.
kono
parents:
diff changeset
766
kono
parents:
diff changeset
767 -- Note on signed integer types. We do not consider types as signed for
kono
parents:
diff changeset
768 -- this purpose if they have no negative numbers, or if they have biased
kono
parents:
diff changeset
769 -- representation. The reason is that the value in either case basically
kono
parents:
diff changeset
770 -- represents an unsigned value.
kono
parents:
diff changeset
771
kono
parents:
diff changeset
772 -- For example, consider:
kono
parents:
diff changeset
773
kono
parents:
diff changeset
774 -- type W is range 0 .. 2**32 - 1;
kono
parents:
diff changeset
775 -- for W'Size use 32;
kono
parents:
diff changeset
776
kono
parents:
diff changeset
777 -- This is a signed type, but the representation is unsigned, and may
kono
parents:
diff changeset
778 -- be outside the range of a 32-bit signed integer, so this must be
kono
parents:
diff changeset
779 -- treated as 32-bit unsigned.
kono
parents:
diff changeset
780
kono
parents:
diff changeset
781 -- Similarly, the representation is also unsigned if we have:
kono
parents:
diff changeset
782
kono
parents:
diff changeset
783 -- type W is range -1 .. +254;
kono
parents:
diff changeset
784 -- for W'Size use 8;
kono
parents:
diff changeset
785
kono
parents:
diff changeset
786 -- forcing a biased and unsigned representation
kono
parents:
diff changeset
787
kono
parents:
diff changeset
788 elsif not Is_Unsigned_Type (FST)
kono
parents:
diff changeset
789 and then
kono
parents:
diff changeset
790 (Is_Fixed_Point_Type (U_Type)
kono
parents:
diff changeset
791 or else
kono
parents:
diff changeset
792 Is_Enumeration_Type (U_Type)
kono
parents:
diff changeset
793 or else
kono
parents:
diff changeset
794 (Is_Signed_Integer_Type (U_Type)
kono
parents:
diff changeset
795 and then not Has_Biased_Representation (FST)))
kono
parents:
diff changeset
796 then
kono
parents:
diff changeset
797 if P_Size <= Standard_Short_Short_Integer_Size then
kono
parents:
diff changeset
798 Lib_RE := RE_W_SSI;
kono
parents:
diff changeset
799 elsif P_Size <= Standard_Short_Integer_Size then
kono
parents:
diff changeset
800 Lib_RE := RE_W_SI;
kono
parents:
diff changeset
801 elsif P_Size <= Standard_Integer_Size then
kono
parents:
diff changeset
802 Lib_RE := RE_W_I;
kono
parents:
diff changeset
803 elsif P_Size <= Standard_Long_Integer_Size then
kono
parents:
diff changeset
804 Lib_RE := RE_W_LI;
kono
parents:
diff changeset
805 else
kono
parents:
diff changeset
806 Lib_RE := RE_W_LLI;
kono
parents:
diff changeset
807 end if;
kono
parents:
diff changeset
808
kono
parents:
diff changeset
809 -- Unsigned integer types, also includes unsigned fixed-point types
kono
parents:
diff changeset
810 -- and unsigned enumeration types (note we know they are unsigned
kono
parents:
diff changeset
811 -- because we already tested for signed above).
kono
parents:
diff changeset
812
kono
parents:
diff changeset
813 -- Also includes signed integer types that are unsigned in the sense
kono
parents:
diff changeset
814 -- that they do not include negative numbers. See above for details.
kono
parents:
diff changeset
815
kono
parents:
diff changeset
816 elsif Is_Modular_Integer_Type (U_Type)
kono
parents:
diff changeset
817 or else Is_Fixed_Point_Type (U_Type)
kono
parents:
diff changeset
818 or else Is_Enumeration_Type (U_Type)
kono
parents:
diff changeset
819 or else Is_Signed_Integer_Type (U_Type)
kono
parents:
diff changeset
820 then
kono
parents:
diff changeset
821 if P_Size <= Standard_Short_Short_Integer_Size then
kono
parents:
diff changeset
822 Lib_RE := RE_W_SSU;
kono
parents:
diff changeset
823 elsif P_Size <= Standard_Short_Integer_Size then
kono
parents:
diff changeset
824 Lib_RE := RE_W_SU;
kono
parents:
diff changeset
825 elsif P_Size <= Standard_Integer_Size then
kono
parents:
diff changeset
826 Lib_RE := RE_W_U;
kono
parents:
diff changeset
827 elsif P_Size <= Standard_Long_Integer_Size then
kono
parents:
diff changeset
828 Lib_RE := RE_W_LU;
kono
parents:
diff changeset
829 else
kono
parents:
diff changeset
830 Lib_RE := RE_W_LLU;
kono
parents:
diff changeset
831 end if;
kono
parents:
diff changeset
832
kono
parents:
diff changeset
833 else pragma Assert (Is_Access_Type (U_Type));
kono
parents:
diff changeset
834
kono
parents:
diff changeset
835 if P_Size > System_Address_Size then
kono
parents:
diff changeset
836 Lib_RE := RE_W_AD;
kono
parents:
diff changeset
837 else
kono
parents:
diff changeset
838 Lib_RE := RE_W_AS;
kono
parents:
diff changeset
839 end if;
kono
parents:
diff changeset
840 end if;
kono
parents:
diff changeset
841
kono
parents:
diff changeset
842 -- Unchecked-convert parameter to the required type (i.e. the type of
kono
parents:
diff changeset
843 -- the corresponding parameter, and call the appropriate routine.
kono
parents:
diff changeset
844
kono
parents:
diff changeset
845 Libent := RTE (Lib_RE);
kono
parents:
diff changeset
846
kono
parents:
diff changeset
847 return
kono
parents:
diff changeset
848 Make_Procedure_Call_Statement (Loc,
kono
parents:
diff changeset
849 Name => New_Occurrence_Of (Libent, Loc),
kono
parents:
diff changeset
850 Parameter_Associations => New_List (
kono
parents:
diff changeset
851 Relocate_Node (Strm),
kono
parents:
diff changeset
852 Unchecked_Convert_To (Etype (Next_Formal (First_Formal (Libent))),
kono
parents:
diff changeset
853 Relocate_Node (Item))));
kono
parents:
diff changeset
854 end Build_Elementary_Write_Call;
kono
parents:
diff changeset
855
kono
parents:
diff changeset
856 -----------------------------------------
kono
parents:
diff changeset
857 -- Build_Mutable_Record_Read_Procedure --
kono
parents:
diff changeset
858 -----------------------------------------
kono
parents:
diff changeset
859
kono
parents:
diff changeset
860 procedure Build_Mutable_Record_Read_Procedure
kono
parents:
diff changeset
861 (Loc : Source_Ptr;
kono
parents:
diff changeset
862 Typ : Entity_Id;
kono
parents:
diff changeset
863 Decl : out Node_Id;
kono
parents:
diff changeset
864 Pnam : out Entity_Id)
kono
parents:
diff changeset
865 is
kono
parents:
diff changeset
866 Out_Formal : Node_Id;
kono
parents:
diff changeset
867 -- Expression denoting the out formal parameter
kono
parents:
diff changeset
868
kono
parents:
diff changeset
869 Dcls : constant List_Id := New_List;
kono
parents:
diff changeset
870 -- Declarations for the 'Read body
kono
parents:
diff changeset
871
kono
parents:
diff changeset
872 Stms : constant List_Id := New_List;
kono
parents:
diff changeset
873 -- Statements for the 'Read body
kono
parents:
diff changeset
874
kono
parents:
diff changeset
875 Disc : Entity_Id;
kono
parents:
diff changeset
876 -- Entity of the discriminant being processed
kono
parents:
diff changeset
877
kono
parents:
diff changeset
878 Tmp_For_Disc : Entity_Id;
kono
parents:
diff changeset
879 -- Temporary object used to read the value of Disc
kono
parents:
diff changeset
880
kono
parents:
diff changeset
881 Tmps_For_Discs : constant List_Id := New_List;
kono
parents:
diff changeset
882 -- List of object declarations for temporaries holding the read values
kono
parents:
diff changeset
883 -- for the discriminants.
kono
parents:
diff changeset
884
kono
parents:
diff changeset
885 Cstr : constant List_Id := New_List;
kono
parents:
diff changeset
886 -- List of constraints to be applied on temporary record
kono
parents:
diff changeset
887
kono
parents:
diff changeset
888 Discriminant_Checks : constant List_Id := New_List;
kono
parents:
diff changeset
889 -- List of discriminant checks to be performed if the actual object
kono
parents:
diff changeset
890 -- is constrained.
kono
parents:
diff changeset
891
kono
parents:
diff changeset
892 Tmp : constant Entity_Id := Make_Defining_Identifier (Loc, Name_V);
kono
parents:
diff changeset
893 -- Temporary record must hide formal (assignments to components of the
kono
parents:
diff changeset
894 -- record are always generated with V as the identifier for the record).
kono
parents:
diff changeset
895
kono
parents:
diff changeset
896 Constrained_Stms : List_Id := New_List;
kono
parents:
diff changeset
897 -- Statements within the block where we have the constrained temporary
kono
parents:
diff changeset
898
kono
parents:
diff changeset
899 begin
kono
parents:
diff changeset
900 -- A mutable type cannot be a tagged type, so we generate a new name
kono
parents:
diff changeset
901 -- for the stream procedure.
kono
parents:
diff changeset
902
kono
parents:
diff changeset
903 Pnam :=
kono
parents:
diff changeset
904 Make_Defining_Identifier (Loc,
kono
parents:
diff changeset
905 Chars => Make_TSS_Name_Local (Typ, TSS_Stream_Read));
kono
parents:
diff changeset
906
kono
parents:
diff changeset
907 if Is_Unchecked_Union (Typ) then
kono
parents:
diff changeset
908
kono
parents:
diff changeset
909 -- If this is an unchecked union, the stream procedure is erroneous,
kono
parents:
diff changeset
910 -- because there are no discriminants to read.
kono
parents:
diff changeset
911
kono
parents:
diff changeset
912 -- This should generate a warning ???
kono
parents:
diff changeset
913
kono
parents:
diff changeset
914 Append_To (Stms,
kono
parents:
diff changeset
915 Make_Raise_Program_Error (Loc,
kono
parents:
diff changeset
916 Reason => PE_Unchecked_Union_Restriction));
kono
parents:
diff changeset
917
kono
parents:
diff changeset
918 Build_Stream_Procedure (Loc, Typ, Decl, Pnam, Stms, Outp => True);
kono
parents:
diff changeset
919 return;
kono
parents:
diff changeset
920 end if;
kono
parents:
diff changeset
921
kono
parents:
diff changeset
922 Disc := First_Discriminant (Typ);
kono
parents:
diff changeset
923
kono
parents:
diff changeset
924 Out_Formal :=
kono
parents:
diff changeset
925 Make_Selected_Component (Loc,
kono
parents:
diff changeset
926 Prefix => New_Occurrence_Of (Pnam, Loc),
kono
parents:
diff changeset
927 Selector_Name => Make_Identifier (Loc, Name_V));
kono
parents:
diff changeset
928
kono
parents:
diff changeset
929 -- Generate Reads for the discriminants of the type. The discriminants
kono
parents:
diff changeset
930 -- need to be read before the rest of the components, so that variants
kono
parents:
diff changeset
931 -- are initialized correctly. The discriminants must be read into temp
kono
parents:
diff changeset
932 -- variables so an incomplete Read (interrupted by an exception, for
kono
parents:
diff changeset
933 -- example) does not alter the passed object.
kono
parents:
diff changeset
934
kono
parents:
diff changeset
935 while Present (Disc) loop
kono
parents:
diff changeset
936 Tmp_For_Disc := Make_Defining_Identifier (Loc,
kono
parents:
diff changeset
937 New_External_Name (Chars (Disc), "D"));
kono
parents:
diff changeset
938
kono
parents:
diff changeset
939 Append_To (Tmps_For_Discs,
kono
parents:
diff changeset
940 Make_Object_Declaration (Loc,
kono
parents:
diff changeset
941 Defining_Identifier => Tmp_For_Disc,
kono
parents:
diff changeset
942 Object_Definition => New_Occurrence_Of (Etype (Disc), Loc)));
kono
parents:
diff changeset
943 Set_No_Initialization (Last (Tmps_For_Discs));
kono
parents:
diff changeset
944
kono
parents:
diff changeset
945 Append_To (Stms,
kono
parents:
diff changeset
946 Make_Attribute_Reference (Loc,
kono
parents:
diff changeset
947 Prefix => New_Occurrence_Of (Etype (Disc), Loc),
kono
parents:
diff changeset
948 Attribute_Name => Name_Read,
kono
parents:
diff changeset
949 Expressions => New_List (
kono
parents:
diff changeset
950 Make_Identifier (Loc, Name_S),
kono
parents:
diff changeset
951 New_Occurrence_Of (Tmp_For_Disc, Loc))));
kono
parents:
diff changeset
952
kono
parents:
diff changeset
953 Append_To (Cstr,
kono
parents:
diff changeset
954 Make_Discriminant_Association (Loc,
kono
parents:
diff changeset
955 Selector_Names => New_List (New_Occurrence_Of (Disc, Loc)),
kono
parents:
diff changeset
956 Expression => New_Occurrence_Of (Tmp_For_Disc, Loc)));
kono
parents:
diff changeset
957
kono
parents:
diff changeset
958 Append_To (Discriminant_Checks,
kono
parents:
diff changeset
959 Make_Raise_Constraint_Error (Loc,
kono
parents:
diff changeset
960 Condition =>
kono
parents:
diff changeset
961 Make_Op_Ne (Loc,
kono
parents:
diff changeset
962 Left_Opnd => New_Occurrence_Of (Tmp_For_Disc, Loc),
kono
parents:
diff changeset
963 Right_Opnd =>
kono
parents:
diff changeset
964 Make_Selected_Component (Loc,
kono
parents:
diff changeset
965 Prefix => New_Copy_Tree (Out_Formal),
kono
parents:
diff changeset
966 Selector_Name => New_Occurrence_Of (Disc, Loc))),
kono
parents:
diff changeset
967 Reason => CE_Discriminant_Check_Failed));
kono
parents:
diff changeset
968 Next_Discriminant (Disc);
kono
parents:
diff changeset
969 end loop;
kono
parents:
diff changeset
970
kono
parents:
diff changeset
971 -- Generate reads for the components of the record (including those
kono
parents:
diff changeset
972 -- that depend on discriminants).
kono
parents:
diff changeset
973
kono
parents:
diff changeset
974 Build_Record_Read_Write_Procedure (Loc, Typ, Decl, Pnam, Name_Read);
kono
parents:
diff changeset
975
kono
parents:
diff changeset
976 -- Save original statement sequence for component assignments, and
kono
parents:
diff changeset
977 -- replace it with Stms.
kono
parents:
diff changeset
978
kono
parents:
diff changeset
979 Constrained_Stms := Statements (Handled_Statement_Sequence (Decl));
kono
parents:
diff changeset
980 Set_Handled_Statement_Sequence (Decl,
kono
parents:
diff changeset
981 Make_Handled_Sequence_Of_Statements (Loc,
kono
parents:
diff changeset
982 Statements => Stms));
kono
parents:
diff changeset
983
kono
parents:
diff changeset
984 -- If Typ has controlled components (i.e. if it is classwide or
kono
parents:
diff changeset
985 -- Has_Controlled), or components constrained using the discriminants
kono
parents:
diff changeset
986 -- of Typ, then we need to ensure that all component assignments are
kono
parents:
diff changeset
987 -- performed on an object that has been appropriately constrained
kono
parents:
diff changeset
988 -- prior to being initialized. To this effect, we wrap the component
kono
parents:
diff changeset
989 -- assignments in a block where V is a constrained temporary.
kono
parents:
diff changeset
990
kono
parents:
diff changeset
991 Append_To (Dcls,
kono
parents:
diff changeset
992 Make_Object_Declaration (Loc,
kono
parents:
diff changeset
993 Defining_Identifier => Tmp,
kono
parents:
diff changeset
994 Object_Definition =>
kono
parents:
diff changeset
995 Make_Subtype_Indication (Loc,
kono
parents:
diff changeset
996 Subtype_Mark => New_Occurrence_Of (Base_Type (Typ), Loc),
kono
parents:
diff changeset
997 Constraint =>
kono
parents:
diff changeset
998 Make_Index_Or_Discriminant_Constraint (Loc,
kono
parents:
diff changeset
999 Constraints => Cstr))));
kono
parents:
diff changeset
1000
kono
parents:
diff changeset
1001 -- AI05-023-1: Insert discriminant check prior to initialization of the
kono
parents:
diff changeset
1002 -- constrained temporary.
kono
parents:
diff changeset
1003
kono
parents:
diff changeset
1004 Append_To (Stms,
kono
parents:
diff changeset
1005 Make_Implicit_If_Statement (Pnam,
kono
parents:
diff changeset
1006 Condition =>
kono
parents:
diff changeset
1007 Make_Attribute_Reference (Loc,
kono
parents:
diff changeset
1008 Prefix => New_Copy_Tree (Out_Formal),
kono
parents:
diff changeset
1009 Attribute_Name => Name_Constrained),
kono
parents:
diff changeset
1010 Then_Statements => Discriminant_Checks));
kono
parents:
diff changeset
1011
kono
parents:
diff changeset
1012 -- Now insert back original component assignments, wrapped in a block
kono
parents:
diff changeset
1013 -- in which V is the constrained temporary.
kono
parents:
diff changeset
1014
kono
parents:
diff changeset
1015 Append_To (Stms,
kono
parents:
diff changeset
1016 Make_Block_Statement (Loc,
kono
parents:
diff changeset
1017 Declarations => Dcls,
kono
parents:
diff changeset
1018 Handled_Statement_Sequence => Parent (Constrained_Stms)));
kono
parents:
diff changeset
1019
kono
parents:
diff changeset
1020 Append_To (Constrained_Stms,
kono
parents:
diff changeset
1021 Make_Assignment_Statement (Loc,
kono
parents:
diff changeset
1022 Name => Out_Formal,
kono
parents:
diff changeset
1023 Expression => Make_Identifier (Loc, Name_V)));
kono
parents:
diff changeset
1024
kono
parents:
diff changeset
1025 Set_Declarations (Decl, Tmps_For_Discs);
kono
parents:
diff changeset
1026 end Build_Mutable_Record_Read_Procedure;
kono
parents:
diff changeset
1027
kono
parents:
diff changeset
1028 ------------------------------------------
kono
parents:
diff changeset
1029 -- Build_Mutable_Record_Write_Procedure --
kono
parents:
diff changeset
1030 ------------------------------------------
kono
parents:
diff changeset
1031
kono
parents:
diff changeset
1032 procedure Build_Mutable_Record_Write_Procedure
kono
parents:
diff changeset
1033 (Loc : Source_Ptr;
kono
parents:
diff changeset
1034 Typ : Entity_Id;
kono
parents:
diff changeset
1035 Decl : out Node_Id;
kono
parents:
diff changeset
1036 Pnam : out Entity_Id)
kono
parents:
diff changeset
1037 is
kono
parents:
diff changeset
1038 Stms : List_Id;
kono
parents:
diff changeset
1039 Disc : Entity_Id;
kono
parents:
diff changeset
1040 D_Ref : Node_Id;
kono
parents:
diff changeset
1041
kono
parents:
diff changeset
1042 begin
kono
parents:
diff changeset
1043 Stms := New_List;
kono
parents:
diff changeset
1044 Disc := First_Discriminant (Typ);
kono
parents:
diff changeset
1045
kono
parents:
diff changeset
1046 -- Generate Writes for the discriminants of the type
kono
parents:
diff changeset
1047 -- If the type is an unchecked union, use the default values of
kono
parents:
diff changeset
1048 -- the discriminants, because they are not stored.
kono
parents:
diff changeset
1049
kono
parents:
diff changeset
1050 while Present (Disc) loop
kono
parents:
diff changeset
1051 if Is_Unchecked_Union (Typ) then
kono
parents:
diff changeset
1052 D_Ref :=
kono
parents:
diff changeset
1053 New_Copy_Tree (Discriminant_Default_Value (Disc));
kono
parents:
diff changeset
1054 else
kono
parents:
diff changeset
1055 D_Ref :=
kono
parents:
diff changeset
1056 Make_Selected_Component (Loc,
kono
parents:
diff changeset
1057 Prefix => Make_Identifier (Loc, Name_V),
kono
parents:
diff changeset
1058 Selector_Name => New_Occurrence_Of (Disc, Loc));
kono
parents:
diff changeset
1059 end if;
kono
parents:
diff changeset
1060
kono
parents:
diff changeset
1061 Append_To (Stms,
kono
parents:
diff changeset
1062 Make_Attribute_Reference (Loc,
kono
parents:
diff changeset
1063 Prefix => New_Occurrence_Of (Etype (Disc), Loc),
kono
parents:
diff changeset
1064 Attribute_Name => Name_Write,
kono
parents:
diff changeset
1065 Expressions => New_List (
kono
parents:
diff changeset
1066 Make_Identifier (Loc, Name_S),
kono
parents:
diff changeset
1067 D_Ref)));
kono
parents:
diff changeset
1068
kono
parents:
diff changeset
1069 Next_Discriminant (Disc);
kono
parents:
diff changeset
1070 end loop;
kono
parents:
diff changeset
1071
kono
parents:
diff changeset
1072 -- A mutable type cannot be a tagged type, so we generate a new name
kono
parents:
diff changeset
1073 -- for the stream procedure.
kono
parents:
diff changeset
1074
kono
parents:
diff changeset
1075 Pnam :=
kono
parents:
diff changeset
1076 Make_Defining_Identifier (Loc,
kono
parents:
diff changeset
1077 Chars => Make_TSS_Name_Local (Typ, TSS_Stream_Write));
kono
parents:
diff changeset
1078 Build_Record_Read_Write_Procedure (Loc, Typ, Decl, Pnam, Name_Write);
kono
parents:
diff changeset
1079
kono
parents:
diff changeset
1080 -- Write the discriminants before the rest of the components, so
kono
parents:
diff changeset
1081 -- that discriminant values are properly set of variants, etc.
kono
parents:
diff changeset
1082
kono
parents:
diff changeset
1083 if Is_Non_Empty_List (
kono
parents:
diff changeset
1084 Statements (Handled_Statement_Sequence (Decl)))
kono
parents:
diff changeset
1085 then
kono
parents:
diff changeset
1086 Insert_List_Before
kono
parents:
diff changeset
1087 (First (Statements (Handled_Statement_Sequence (Decl))), Stms);
kono
parents:
diff changeset
1088 else
kono
parents:
diff changeset
1089 Set_Statements (Handled_Statement_Sequence (Decl), Stms);
kono
parents:
diff changeset
1090 end if;
kono
parents:
diff changeset
1091 end Build_Mutable_Record_Write_Procedure;
kono
parents:
diff changeset
1092
kono
parents:
diff changeset
1093 -----------------------------------------------
kono
parents:
diff changeset
1094 -- Build_Record_Or_Elementary_Input_Function --
kono
parents:
diff changeset
1095 -----------------------------------------------
kono
parents:
diff changeset
1096
kono
parents:
diff changeset
1097 -- The function we build looks like
kono
parents:
diff changeset
1098
kono
parents:
diff changeset
1099 -- function InputN (S : access RST) return Typ is
kono
parents:
diff changeset
1100 -- C1 : constant Disc_Type_1;
kono
parents:
diff changeset
1101 -- Discr_Type_1'Read (S, C1);
kono
parents:
diff changeset
1102 -- C2 : constant Disc_Type_2;
kono
parents:
diff changeset
1103 -- Discr_Type_2'Read (S, C2);
kono
parents:
diff changeset
1104 -- ...
kono
parents:
diff changeset
1105 -- Cn : constant Disc_Type_n;
kono
parents:
diff changeset
1106 -- Discr_Type_n'Read (S, Cn);
kono
parents:
diff changeset
1107 -- V : Typ (C1, C2, .. Cn)
kono
parents:
diff changeset
1108
kono
parents:
diff changeset
1109 -- begin
kono
parents:
diff changeset
1110 -- Typ'Read (S, V);
kono
parents:
diff changeset
1111 -- return V;
kono
parents:
diff changeset
1112 -- end InputN
kono
parents:
diff changeset
1113
kono
parents:
diff changeset
1114 -- The discriminants are of course only present in the case of a record
kono
parents:
diff changeset
1115 -- with discriminants. In the case of a record with no discriminants, or
kono
parents:
diff changeset
1116 -- an elementary type, then no Cn constants are defined.
kono
parents:
diff changeset
1117
kono
parents:
diff changeset
1118 procedure Build_Record_Or_Elementary_Input_Function
kono
parents:
diff changeset
1119 (Loc : Source_Ptr;
kono
parents:
diff changeset
1120 Typ : Entity_Id;
kono
parents:
diff changeset
1121 Decl : out Node_Id;
kono
parents:
diff changeset
1122 Fnam : out Entity_Id;
kono
parents:
diff changeset
1123 Use_Underlying : Boolean := True)
kono
parents:
diff changeset
1124 is
kono
parents:
diff changeset
1125 B_Typ : Entity_Id := Base_Type (Typ);
kono
parents:
diff changeset
1126 Cn : Name_Id;
kono
parents:
diff changeset
1127 Constr : List_Id;
kono
parents:
diff changeset
1128 Decls : List_Id;
kono
parents:
diff changeset
1129 Discr : Entity_Id;
kono
parents:
diff changeset
1130 Discr_Elmt : Elmt_Id := No_Elmt;
kono
parents:
diff changeset
1131 J : Pos;
kono
parents:
diff changeset
1132 Obj_Decl : Node_Id;
kono
parents:
diff changeset
1133 Odef : Node_Id;
kono
parents:
diff changeset
1134 Stms : List_Id;
kono
parents:
diff changeset
1135
kono
parents:
diff changeset
1136 begin
kono
parents:
diff changeset
1137 if Use_Underlying then
kono
parents:
diff changeset
1138 B_Typ := Underlying_Type (B_Typ);
kono
parents:
diff changeset
1139 end if;
kono
parents:
diff changeset
1140
kono
parents:
diff changeset
1141 Decls := New_List;
kono
parents:
diff changeset
1142 Constr := New_List;
kono
parents:
diff changeset
1143
kono
parents:
diff changeset
1144 J := 1;
kono
parents:
diff changeset
1145
kono
parents:
diff changeset
1146 -- In the presence of multiple instantiations (as in uses of the Booch
kono
parents:
diff changeset
1147 -- components) the base type may be private, and the underlying type
kono
parents:
diff changeset
1148 -- already constrained, in which case there's no discriminant constraint
kono
parents:
diff changeset
1149 -- to construct.
kono
parents:
diff changeset
1150
kono
parents:
diff changeset
1151 if Has_Discriminants (Typ)
kono
parents:
diff changeset
1152 and then No (Discriminant_Default_Value (First_Discriminant (Typ)))
kono
parents:
diff changeset
1153 and then not Is_Constrained (Underlying_Type (B_Typ))
kono
parents:
diff changeset
1154 then
kono
parents:
diff changeset
1155 Discr := First_Discriminant (B_Typ);
kono
parents:
diff changeset
1156
kono
parents:
diff changeset
1157 -- If the prefix subtype is constrained, then retrieve the first
kono
parents:
diff changeset
1158 -- element of its constraint.
kono
parents:
diff changeset
1159
kono
parents:
diff changeset
1160 if Is_Constrained (Typ) then
kono
parents:
diff changeset
1161 Discr_Elmt := First_Elmt (Discriminant_Constraint (Typ));
kono
parents:
diff changeset
1162 end if;
kono
parents:
diff changeset
1163
kono
parents:
diff changeset
1164 while Present (Discr) loop
kono
parents:
diff changeset
1165 Cn := New_External_Name ('C', J);
kono
parents:
diff changeset
1166
kono
parents:
diff changeset
1167 Decl :=
kono
parents:
diff changeset
1168 Make_Object_Declaration (Loc,
kono
parents:
diff changeset
1169 Defining_Identifier => Make_Defining_Identifier (Loc, Cn),
kono
parents:
diff changeset
1170 Object_Definition =>
kono
parents:
diff changeset
1171 New_Occurrence_Of (Etype (Discr), Loc));
kono
parents:
diff changeset
1172
kono
parents:
diff changeset
1173 -- If this is an access discriminant, do not perform default
kono
parents:
diff changeset
1174 -- initialization. The discriminant is about to get its value
kono
parents:
diff changeset
1175 -- from Read, and if the type is null excluding we do not want
kono
parents:
diff changeset
1176 -- spurious warnings on an initial null value.
kono
parents:
diff changeset
1177
kono
parents:
diff changeset
1178 if Is_Access_Type (Etype (Discr)) then
kono
parents:
diff changeset
1179 Set_No_Initialization (Decl);
kono
parents:
diff changeset
1180 end if;
kono
parents:
diff changeset
1181
kono
parents:
diff changeset
1182 Append_To (Decls, Decl);
kono
parents:
diff changeset
1183 Append_To (Decls,
kono
parents:
diff changeset
1184 Make_Attribute_Reference (Loc,
kono
parents:
diff changeset
1185 Prefix => New_Occurrence_Of (Etype (Discr), Loc),
kono
parents:
diff changeset
1186 Attribute_Name => Name_Read,
kono
parents:
diff changeset
1187 Expressions => New_List (
kono
parents:
diff changeset
1188 Make_Identifier (Loc, Name_S),
kono
parents:
diff changeset
1189 Make_Identifier (Loc, Cn))));
kono
parents:
diff changeset
1190
kono
parents:
diff changeset
1191 Append_To (Constr, Make_Identifier (Loc, Cn));
kono
parents:
diff changeset
1192
kono
parents:
diff changeset
1193 -- If the prefix subtype imposes a discriminant constraint, then
kono
parents:
diff changeset
1194 -- check that each discriminant value equals the value read.
kono
parents:
diff changeset
1195
kono
parents:
diff changeset
1196 if Present (Discr_Elmt) then
kono
parents:
diff changeset
1197 Append_To (Decls,
kono
parents:
diff changeset
1198 Make_Raise_Constraint_Error (Loc,
kono
parents:
diff changeset
1199 Condition => Make_Op_Ne (Loc,
kono
parents:
diff changeset
1200 Left_Opnd =>
kono
parents:
diff changeset
1201 New_Occurrence_Of
kono
parents:
diff changeset
1202 (Defining_Identifier (Decl), Loc),
kono
parents:
diff changeset
1203 Right_Opnd =>
kono
parents:
diff changeset
1204 New_Copy_Tree (Node (Discr_Elmt))),
kono
parents:
diff changeset
1205 Reason => CE_Discriminant_Check_Failed));
kono
parents:
diff changeset
1206
kono
parents:
diff changeset
1207 Next_Elmt (Discr_Elmt);
kono
parents:
diff changeset
1208 end if;
kono
parents:
diff changeset
1209
kono
parents:
diff changeset
1210 Next_Discriminant (Discr);
kono
parents:
diff changeset
1211 J := J + 1;
kono
parents:
diff changeset
1212 end loop;
kono
parents:
diff changeset
1213
kono
parents:
diff changeset
1214 Odef :=
kono
parents:
diff changeset
1215 Make_Subtype_Indication (Loc,
kono
parents:
diff changeset
1216 Subtype_Mark => New_Occurrence_Of (B_Typ, Loc),
kono
parents:
diff changeset
1217 Constraint =>
kono
parents:
diff changeset
1218 Make_Index_Or_Discriminant_Constraint (Loc,
kono
parents:
diff changeset
1219 Constraints => Constr));
kono
parents:
diff changeset
1220
kono
parents:
diff changeset
1221 -- If no discriminants, then just use the type with no constraint
kono
parents:
diff changeset
1222
kono
parents:
diff changeset
1223 else
kono
parents:
diff changeset
1224 Odef := New_Occurrence_Of (B_Typ, Loc);
kono
parents:
diff changeset
1225 end if;
kono
parents:
diff changeset
1226
kono
parents:
diff changeset
1227 -- Create an extended return statement encapsulating the result object
kono
parents:
diff changeset
1228 -- and 'Read call, which is needed in general for proper handling of
kono
parents:
diff changeset
1229 -- build-in-place results (such as when the result type is inherently
kono
parents:
diff changeset
1230 -- limited).
kono
parents:
diff changeset
1231
kono
parents:
diff changeset
1232 Obj_Decl :=
kono
parents:
diff changeset
1233 Make_Object_Declaration (Loc,
kono
parents:
diff changeset
1234 Defining_Identifier => Make_Defining_Identifier (Loc, Name_V),
kono
parents:
diff changeset
1235 Object_Definition => Odef);
kono
parents:
diff changeset
1236
kono
parents:
diff changeset
1237 -- If the type is an access type, do not perform default initialization.
kono
parents:
diff changeset
1238 -- The object is about to get its value from Read, and if the type is
kono
parents:
diff changeset
1239 -- null excluding we do not want spurious warnings on an initial null.
kono
parents:
diff changeset
1240
kono
parents:
diff changeset
1241 if Is_Access_Type (B_Typ) then
kono
parents:
diff changeset
1242 Set_No_Initialization (Obj_Decl);
kono
parents:
diff changeset
1243 end if;
kono
parents:
diff changeset
1244
kono
parents:
diff changeset
1245 Stms := New_List (
kono
parents:
diff changeset
1246 Make_Extended_Return_Statement (Loc,
kono
parents:
diff changeset
1247 Return_Object_Declarations => New_List (Obj_Decl),
kono
parents:
diff changeset
1248 Handled_Statement_Sequence =>
kono
parents:
diff changeset
1249 Make_Handled_Sequence_Of_Statements (Loc,
kono
parents:
diff changeset
1250 Statements => New_List (
kono
parents:
diff changeset
1251 Make_Attribute_Reference (Loc,
kono
parents:
diff changeset
1252 Prefix => New_Occurrence_Of (B_Typ, Loc),
kono
parents:
diff changeset
1253 Attribute_Name => Name_Read,
kono
parents:
diff changeset
1254 Expressions => New_List (
kono
parents:
diff changeset
1255 Make_Identifier (Loc, Name_S),
kono
parents:
diff changeset
1256 Make_Identifier (Loc, Name_V)))))));
kono
parents:
diff changeset
1257
kono
parents:
diff changeset
1258 Fnam := Make_Stream_Subprogram_Name (Loc, B_Typ, TSS_Stream_Input);
kono
parents:
diff changeset
1259
kono
parents:
diff changeset
1260 Build_Stream_Function (Loc, B_Typ, Decl, Fnam, Decls, Stms);
kono
parents:
diff changeset
1261 end Build_Record_Or_Elementary_Input_Function;
kono
parents:
diff changeset
1262
kono
parents:
diff changeset
1263 -------------------------------------------------
kono
parents:
diff changeset
1264 -- Build_Record_Or_Elementary_Output_Procedure --
kono
parents:
diff changeset
1265 -------------------------------------------------
kono
parents:
diff changeset
1266
kono
parents:
diff changeset
1267 procedure Build_Record_Or_Elementary_Output_Procedure
kono
parents:
diff changeset
1268 (Loc : Source_Ptr;
kono
parents:
diff changeset
1269 Typ : Entity_Id;
kono
parents:
diff changeset
1270 Decl : out Node_Id;
kono
parents:
diff changeset
1271 Pnam : out Entity_Id)
kono
parents:
diff changeset
1272 is
kono
parents:
diff changeset
1273 Stms : List_Id;
kono
parents:
diff changeset
1274 Disc : Entity_Id;
kono
parents:
diff changeset
1275 Disc_Ref : Node_Id;
kono
parents:
diff changeset
1276
kono
parents:
diff changeset
1277 begin
kono
parents:
diff changeset
1278 Stms := New_List;
kono
parents:
diff changeset
1279
kono
parents:
diff changeset
1280 -- Note that of course there will be no discriminants for the elementary
kono
parents:
diff changeset
1281 -- type case, so Has_Discriminants will be False. Note that the language
kono
parents:
diff changeset
1282 -- rules do not allow writing the discriminants in the defaulted case,
kono
parents:
diff changeset
1283 -- because those are written by 'Write.
kono
parents:
diff changeset
1284
kono
parents:
diff changeset
1285 if Has_Discriminants (Typ)
kono
parents:
diff changeset
1286 and then No (Discriminant_Default_Value (First_Discriminant (Typ)))
kono
parents:
diff changeset
1287 then
kono
parents:
diff changeset
1288 Disc := First_Discriminant (Typ);
kono
parents:
diff changeset
1289 while Present (Disc) loop
kono
parents:
diff changeset
1290
kono
parents:
diff changeset
1291 -- If the type is an unchecked union, it must have default
kono
parents:
diff changeset
1292 -- discriminants (this is checked earlier), and those defaults
kono
parents:
diff changeset
1293 -- are written out to the stream.
kono
parents:
diff changeset
1294
kono
parents:
diff changeset
1295 if Is_Unchecked_Union (Typ) then
kono
parents:
diff changeset
1296 Disc_Ref := New_Copy_Tree (Discriminant_Default_Value (Disc));
kono
parents:
diff changeset
1297
kono
parents:
diff changeset
1298 else
kono
parents:
diff changeset
1299 Disc_Ref :=
kono
parents:
diff changeset
1300 Make_Selected_Component (Loc,
kono
parents:
diff changeset
1301 Prefix => Make_Identifier (Loc, Name_V),
kono
parents:
diff changeset
1302 Selector_Name => New_Occurrence_Of (Disc, Loc));
kono
parents:
diff changeset
1303 end if;
kono
parents:
diff changeset
1304
kono
parents:
diff changeset
1305 Append_To (Stms,
kono
parents:
diff changeset
1306 Make_Attribute_Reference (Loc,
kono
parents:
diff changeset
1307 Prefix =>
kono
parents:
diff changeset
1308 New_Occurrence_Of (Stream_Base_Type (Etype (Disc)), Loc),
kono
parents:
diff changeset
1309 Attribute_Name => Name_Write,
kono
parents:
diff changeset
1310 Expressions => New_List (
kono
parents:
diff changeset
1311 Make_Identifier (Loc, Name_S),
kono
parents:
diff changeset
1312 Disc_Ref)));
kono
parents:
diff changeset
1313
kono
parents:
diff changeset
1314 Next_Discriminant (Disc);
kono
parents:
diff changeset
1315 end loop;
kono
parents:
diff changeset
1316 end if;
kono
parents:
diff changeset
1317
kono
parents:
diff changeset
1318 Append_To (Stms,
kono
parents:
diff changeset
1319 Make_Attribute_Reference (Loc,
kono
parents:
diff changeset
1320 Prefix => New_Occurrence_Of (Typ, Loc),
kono
parents:
diff changeset
1321 Attribute_Name => Name_Write,
kono
parents:
diff changeset
1322 Expressions => New_List (
kono
parents:
diff changeset
1323 Make_Identifier (Loc, Name_S),
kono
parents:
diff changeset
1324 Make_Identifier (Loc, Name_V))));
kono
parents:
diff changeset
1325
kono
parents:
diff changeset
1326 Pnam := Make_Stream_Subprogram_Name (Loc, Typ, TSS_Stream_Output);
kono
parents:
diff changeset
1327
kono
parents:
diff changeset
1328 Build_Stream_Procedure (Loc, Typ, Decl, Pnam, Stms, False);
kono
parents:
diff changeset
1329 end Build_Record_Or_Elementary_Output_Procedure;
kono
parents:
diff changeset
1330
kono
parents:
diff changeset
1331 ---------------------------------
kono
parents:
diff changeset
1332 -- Build_Record_Read_Procedure --
kono
parents:
diff changeset
1333 ---------------------------------
kono
parents:
diff changeset
1334
kono
parents:
diff changeset
1335 procedure Build_Record_Read_Procedure
kono
parents:
diff changeset
1336 (Loc : Source_Ptr;
kono
parents:
diff changeset
1337 Typ : Entity_Id;
kono
parents:
diff changeset
1338 Decl : out Node_Id;
kono
parents:
diff changeset
1339 Pnam : out Entity_Id)
kono
parents:
diff changeset
1340 is
kono
parents:
diff changeset
1341 begin
kono
parents:
diff changeset
1342 Pnam := Make_Stream_Subprogram_Name (Loc, Typ, TSS_Stream_Read);
kono
parents:
diff changeset
1343 Build_Record_Read_Write_Procedure (Loc, Typ, Decl, Pnam, Name_Read);
kono
parents:
diff changeset
1344 end Build_Record_Read_Procedure;
kono
parents:
diff changeset
1345
kono
parents:
diff changeset
1346 ---------------------------------------
kono
parents:
diff changeset
1347 -- Build_Record_Read_Write_Procedure --
kono
parents:
diff changeset
1348 ---------------------------------------
kono
parents:
diff changeset
1349
kono
parents:
diff changeset
1350 -- The form of the record read/write procedure is as shown by the
kono
parents:
diff changeset
1351 -- following example for a case with one discriminant case variant:
kono
parents:
diff changeset
1352
kono
parents:
diff changeset
1353 -- procedure pnam (S : access RST, V : [out] Typ) is
kono
parents:
diff changeset
1354 -- begin
kono
parents:
diff changeset
1355 -- Component_Type'Read/Write (S, V.component);
kono
parents:
diff changeset
1356 -- Component_Type'Read/Write (S, V.component);
kono
parents:
diff changeset
1357 -- ...
kono
parents:
diff changeset
1358 -- Component_Type'Read/Write (S, V.component);
kono
parents:
diff changeset
1359 --
kono
parents:
diff changeset
1360 -- case V.discriminant is
kono
parents:
diff changeset
1361 -- when choices =>
kono
parents:
diff changeset
1362 -- Component_Type'Read/Write (S, V.component);
kono
parents:
diff changeset
1363 -- Component_Type'Read/Write (S, V.component);
kono
parents:
diff changeset
1364 -- ...
kono
parents:
diff changeset
1365 -- Component_Type'Read/Write (S, V.component);
kono
parents:
diff changeset
1366 --
kono
parents:
diff changeset
1367 -- when choices =>
kono
parents:
diff changeset
1368 -- Component_Type'Read/Write (S, V.component);
kono
parents:
diff changeset
1369 -- Component_Type'Read/Write (S, V.component);
kono
parents:
diff changeset
1370 -- ...
kono
parents:
diff changeset
1371 -- Component_Type'Read/Write (S, V.component);
kono
parents:
diff changeset
1372 -- ...
kono
parents:
diff changeset
1373 -- end case;
kono
parents:
diff changeset
1374 -- end pnam;
kono
parents:
diff changeset
1375
kono
parents:
diff changeset
1376 -- The out keyword for V is supplied in the Read case
kono
parents:
diff changeset
1377
kono
parents:
diff changeset
1378 procedure Build_Record_Read_Write_Procedure
kono
parents:
diff changeset
1379 (Loc : Source_Ptr;
kono
parents:
diff changeset
1380 Typ : Entity_Id;
kono
parents:
diff changeset
1381 Decl : out Node_Id;
kono
parents:
diff changeset
1382 Pnam : Entity_Id;
kono
parents:
diff changeset
1383 Nam : Name_Id)
kono
parents:
diff changeset
1384 is
kono
parents:
diff changeset
1385 Rdef : Node_Id;
kono
parents:
diff changeset
1386 Stms : List_Id;
kono
parents:
diff changeset
1387 Typt : Entity_Id;
kono
parents:
diff changeset
1388
kono
parents:
diff changeset
1389 In_Limited_Extension : Boolean := False;
kono
parents:
diff changeset
1390 -- Set to True while processing the record extension definition
kono
parents:
diff changeset
1391 -- for an extension of a limited type (for which an ancestor type
kono
parents:
diff changeset
1392 -- has an explicit Nam attribute definition).
kono
parents:
diff changeset
1393
kono
parents:
diff changeset
1394 function Make_Component_List_Attributes (CL : Node_Id) return List_Id;
kono
parents:
diff changeset
1395 -- Returns a sequence of attributes to process the components that
kono
parents:
diff changeset
1396 -- are referenced in the given component list.
kono
parents:
diff changeset
1397
kono
parents:
diff changeset
1398 function Make_Field_Attribute (C : Entity_Id) return Node_Id;
kono
parents:
diff changeset
1399 -- Given C, the entity for a discriminant or component, build
kono
parents:
diff changeset
1400 -- an attribute for the corresponding field values.
kono
parents:
diff changeset
1401
kono
parents:
diff changeset
1402 function Make_Field_Attributes (Clist : List_Id) return List_Id;
kono
parents:
diff changeset
1403 -- Given Clist, a component items list, construct series of attributes
kono
parents:
diff changeset
1404 -- for fieldwise processing of the corresponding components.
kono
parents:
diff changeset
1405
kono
parents:
diff changeset
1406 ------------------------------------
kono
parents:
diff changeset
1407 -- Make_Component_List_Attributes --
kono
parents:
diff changeset
1408 ------------------------------------
kono
parents:
diff changeset
1409
kono
parents:
diff changeset
1410 function Make_Component_List_Attributes (CL : Node_Id) return List_Id is
kono
parents:
diff changeset
1411 CI : constant List_Id := Component_Items (CL);
kono
parents:
diff changeset
1412 VP : constant Node_Id := Variant_Part (CL);
kono
parents:
diff changeset
1413
kono
parents:
diff changeset
1414 Result : List_Id;
kono
parents:
diff changeset
1415 Alts : List_Id;
kono
parents:
diff changeset
1416 V : Node_Id;
kono
parents:
diff changeset
1417 DC : Node_Id;
kono
parents:
diff changeset
1418 DCH : List_Id;
kono
parents:
diff changeset
1419 D_Ref : Node_Id;
kono
parents:
diff changeset
1420
kono
parents:
diff changeset
1421 begin
kono
parents:
diff changeset
1422 Result := Make_Field_Attributes (CI);
kono
parents:
diff changeset
1423
kono
parents:
diff changeset
1424 if Present (VP) then
kono
parents:
diff changeset
1425 Alts := New_List;
kono
parents:
diff changeset
1426
kono
parents:
diff changeset
1427 V := First_Non_Pragma (Variants (VP));
kono
parents:
diff changeset
1428 while Present (V) loop
kono
parents:
diff changeset
1429 DCH := New_List;
kono
parents:
diff changeset
1430
kono
parents:
diff changeset
1431 DC := First (Discrete_Choices (V));
kono
parents:
diff changeset
1432 while Present (DC) loop
kono
parents:
diff changeset
1433 Append_To (DCH, New_Copy_Tree (DC));
kono
parents:
diff changeset
1434 Next (DC);
kono
parents:
diff changeset
1435 end loop;
kono
parents:
diff changeset
1436
kono
parents:
diff changeset
1437 Append_To (Alts,
kono
parents:
diff changeset
1438 Make_Case_Statement_Alternative (Loc,
kono
parents:
diff changeset
1439 Discrete_Choices => DCH,
kono
parents:
diff changeset
1440 Statements =>
kono
parents:
diff changeset
1441 Make_Component_List_Attributes (Component_List (V))));
kono
parents:
diff changeset
1442 Next_Non_Pragma (V);
kono
parents:
diff changeset
1443 end loop;
kono
parents:
diff changeset
1444
kono
parents:
diff changeset
1445 -- Note: in the following, we make sure that we use new occurrence
kono
parents:
diff changeset
1446 -- of for the selector, since there are cases in which we make a
kono
parents:
diff changeset
1447 -- reference to a hidden discriminant that is not visible.
kono
parents:
diff changeset
1448
kono
parents:
diff changeset
1449 -- If the enclosing record is an unchecked_union, we use the
kono
parents:
diff changeset
1450 -- default expressions for the discriminant (it must exist)
kono
parents:
diff changeset
1451 -- because we cannot generate a reference to it, given that
kono
parents:
diff changeset
1452 -- it is not stored.
kono
parents:
diff changeset
1453
kono
parents:
diff changeset
1454 if Is_Unchecked_Union (Scope (Entity (Name (VP)))) then
kono
parents:
diff changeset
1455 D_Ref :=
kono
parents:
diff changeset
1456 New_Copy_Tree
kono
parents:
diff changeset
1457 (Discriminant_Default_Value (Entity (Name (VP))));
kono
parents:
diff changeset
1458 else
kono
parents:
diff changeset
1459 D_Ref :=
kono
parents:
diff changeset
1460 Make_Selected_Component (Loc,
kono
parents:
diff changeset
1461 Prefix => Make_Identifier (Loc, Name_V),
kono
parents:
diff changeset
1462 Selector_Name =>
kono
parents:
diff changeset
1463 New_Occurrence_Of (Entity (Name (VP)), Loc));
kono
parents:
diff changeset
1464 end if;
kono
parents:
diff changeset
1465
kono
parents:
diff changeset
1466 Append_To (Result,
kono
parents:
diff changeset
1467 Make_Case_Statement (Loc,
kono
parents:
diff changeset
1468 Expression => D_Ref,
kono
parents:
diff changeset
1469 Alternatives => Alts));
kono
parents:
diff changeset
1470 end if;
kono
parents:
diff changeset
1471
kono
parents:
diff changeset
1472 return Result;
kono
parents:
diff changeset
1473 end Make_Component_List_Attributes;
kono
parents:
diff changeset
1474
kono
parents:
diff changeset
1475 --------------------------
kono
parents:
diff changeset
1476 -- Make_Field_Attribute --
kono
parents:
diff changeset
1477 --------------------------
kono
parents:
diff changeset
1478
kono
parents:
diff changeset
1479 function Make_Field_Attribute (C : Entity_Id) return Node_Id is
kono
parents:
diff changeset
1480 Field_Typ : constant Entity_Id := Stream_Base_Type (Etype (C));
kono
parents:
diff changeset
1481
kono
parents:
diff changeset
1482 TSS_Names : constant array (Name_Input .. Name_Write) of
kono
parents:
diff changeset
1483 TSS_Name_Type :=
kono
parents:
diff changeset
1484 (Name_Read => TSS_Stream_Read,
kono
parents:
diff changeset
1485 Name_Write => TSS_Stream_Write,
kono
parents:
diff changeset
1486 Name_Input => TSS_Stream_Input,
kono
parents:
diff changeset
1487 Name_Output => TSS_Stream_Output,
kono
parents:
diff changeset
1488 others => TSS_Null);
kono
parents:
diff changeset
1489 pragma Assert (TSS_Names (Nam) /= TSS_Null);
kono
parents:
diff changeset
1490
kono
parents:
diff changeset
1491 begin
kono
parents:
diff changeset
1492 if In_Limited_Extension
kono
parents:
diff changeset
1493 and then Is_Limited_Type (Field_Typ)
kono
parents:
diff changeset
1494 and then No (Find_Inherited_TSS (Field_Typ, TSS_Names (Nam)))
kono
parents:
diff changeset
1495 then
kono
parents:
diff changeset
1496 -- The declaration is illegal per 13.13.2(9/1), and this is
kono
parents:
diff changeset
1497 -- enforced in Exp_Ch3.Check_Stream_Attributes. Keep the caller
kono
parents:
diff changeset
1498 -- happy by returning a null statement.
kono
parents:
diff changeset
1499
kono
parents:
diff changeset
1500 return Make_Null_Statement (Loc);
kono
parents:
diff changeset
1501 end if;
kono
parents:
diff changeset
1502
kono
parents:
diff changeset
1503 return
kono
parents:
diff changeset
1504 Make_Attribute_Reference (Loc,
kono
parents:
diff changeset
1505 Prefix => New_Occurrence_Of (Field_Typ, Loc),
kono
parents:
diff changeset
1506 Attribute_Name => Nam,
kono
parents:
diff changeset
1507 Expressions => New_List (
kono
parents:
diff changeset
1508 Make_Identifier (Loc, Name_S),
kono
parents:
diff changeset
1509 Make_Selected_Component (Loc,
kono
parents:
diff changeset
1510 Prefix => Make_Identifier (Loc, Name_V),
kono
parents:
diff changeset
1511 Selector_Name => New_Occurrence_Of (C, Loc))));
kono
parents:
diff changeset
1512 end Make_Field_Attribute;
kono
parents:
diff changeset
1513
kono
parents:
diff changeset
1514 ---------------------------
kono
parents:
diff changeset
1515 -- Make_Field_Attributes --
kono
parents:
diff changeset
1516 ---------------------------
kono
parents:
diff changeset
1517
kono
parents:
diff changeset
1518 function Make_Field_Attributes (Clist : List_Id) return List_Id is
kono
parents:
diff changeset
1519 Item : Node_Id;
kono
parents:
diff changeset
1520 Result : List_Id;
kono
parents:
diff changeset
1521
kono
parents:
diff changeset
1522 begin
kono
parents:
diff changeset
1523 Result := New_List;
kono
parents:
diff changeset
1524
kono
parents:
diff changeset
1525 if Present (Clist) then
kono
parents:
diff changeset
1526 Item := First (Clist);
kono
parents:
diff changeset
1527
kono
parents:
diff changeset
1528 -- Loop through components, skipping all internal components,
kono
parents:
diff changeset
1529 -- which are not part of the value (e.g. _Tag), except that we
kono
parents:
diff changeset
1530 -- don't skip the _Parent, since we do want to process that
kono
parents:
diff changeset
1531 -- recursively. If _Parent is an interface type, being abstract
kono
parents:
diff changeset
1532 -- with no components there is no need to handle it.
kono
parents:
diff changeset
1533
kono
parents:
diff changeset
1534 while Present (Item) loop
kono
parents:
diff changeset
1535 if Nkind (Item) = N_Component_Declaration
kono
parents:
diff changeset
1536 and then
kono
parents:
diff changeset
1537 ((Chars (Defining_Identifier (Item)) = Name_uParent
kono
parents:
diff changeset
1538 and then not Is_Interface
kono
parents:
diff changeset
1539 (Etype (Defining_Identifier (Item))))
kono
parents:
diff changeset
1540 or else
kono
parents:
diff changeset
1541 not Is_Internal_Name (Chars (Defining_Identifier (Item))))
kono
parents:
diff changeset
1542 then
kono
parents:
diff changeset
1543 Append_To
kono
parents:
diff changeset
1544 (Result,
kono
parents:
diff changeset
1545 Make_Field_Attribute (Defining_Identifier (Item)));
kono
parents:
diff changeset
1546 end if;
kono
parents:
diff changeset
1547
kono
parents:
diff changeset
1548 Next (Item);
kono
parents:
diff changeset
1549 end loop;
kono
parents:
diff changeset
1550 end if;
kono
parents:
diff changeset
1551
kono
parents:
diff changeset
1552 return Result;
kono
parents:
diff changeset
1553 end Make_Field_Attributes;
kono
parents:
diff changeset
1554
kono
parents:
diff changeset
1555 -- Start of processing for Build_Record_Read_Write_Procedure
kono
parents:
diff changeset
1556
kono
parents:
diff changeset
1557 begin
kono
parents:
diff changeset
1558 -- For the protected type case, use corresponding record
kono
parents:
diff changeset
1559
kono
parents:
diff changeset
1560 if Is_Protected_Type (Typ) then
kono
parents:
diff changeset
1561 Typt := Corresponding_Record_Type (Typ);
kono
parents:
diff changeset
1562 else
kono
parents:
diff changeset
1563 Typt := Typ;
kono
parents:
diff changeset
1564 end if;
kono
parents:
diff changeset
1565
kono
parents:
diff changeset
1566 -- Note that we do nothing with the discriminants, since Read and
kono
parents:
diff changeset
1567 -- Write do not read or write the discriminant values. All handling
kono
parents:
diff changeset
1568 -- of discriminants occurs in the Input and Output subprograms.
kono
parents:
diff changeset
1569
kono
parents:
diff changeset
1570 Rdef := Type_Definition
kono
parents:
diff changeset
1571 (Declaration_Node (Base_Type (Underlying_Type (Typt))));
kono
parents:
diff changeset
1572 Stms := Empty_List;
kono
parents:
diff changeset
1573
kono
parents:
diff changeset
1574 -- In record extension case, the fields we want, including the _Parent
kono
parents:
diff changeset
1575 -- field representing the parent type, are to be found in the extension.
kono
parents:
diff changeset
1576 -- Note that we will naturally process the _Parent field using the type
kono
parents:
diff changeset
1577 -- of the parent, and hence its stream attributes, which is appropriate.
kono
parents:
diff changeset
1578
kono
parents:
diff changeset
1579 if Nkind (Rdef) = N_Derived_Type_Definition then
kono
parents:
diff changeset
1580 Rdef := Record_Extension_Part (Rdef);
kono
parents:
diff changeset
1581
kono
parents:
diff changeset
1582 if Is_Limited_Type (Typt) then
kono
parents:
diff changeset
1583 In_Limited_Extension := True;
kono
parents:
diff changeset
1584 end if;
kono
parents:
diff changeset
1585 end if;
kono
parents:
diff changeset
1586
kono
parents:
diff changeset
1587 if Present (Component_List (Rdef)) then
kono
parents:
diff changeset
1588 Append_List_To (Stms,
kono
parents:
diff changeset
1589 Make_Component_List_Attributes (Component_List (Rdef)));
kono
parents:
diff changeset
1590 end if;
kono
parents:
diff changeset
1591
kono
parents:
diff changeset
1592 Build_Stream_Procedure
kono
parents:
diff changeset
1593 (Loc, Typ, Decl, Pnam, Stms, Nam = Name_Read);
kono
parents:
diff changeset
1594 end Build_Record_Read_Write_Procedure;
kono
parents:
diff changeset
1595
kono
parents:
diff changeset
1596 ----------------------------------
kono
parents:
diff changeset
1597 -- Build_Record_Write_Procedure --
kono
parents:
diff changeset
1598 ----------------------------------
kono
parents:
diff changeset
1599
kono
parents:
diff changeset
1600 procedure Build_Record_Write_Procedure
kono
parents:
diff changeset
1601 (Loc : Source_Ptr;
kono
parents:
diff changeset
1602 Typ : Entity_Id;
kono
parents:
diff changeset
1603 Decl : out Node_Id;
kono
parents:
diff changeset
1604 Pnam : out Entity_Id)
kono
parents:
diff changeset
1605 is
kono
parents:
diff changeset
1606 begin
kono
parents:
diff changeset
1607 Pnam := Make_Stream_Subprogram_Name (Loc, Typ, TSS_Stream_Write);
kono
parents:
diff changeset
1608 Build_Record_Read_Write_Procedure (Loc, Typ, Decl, Pnam, Name_Write);
kono
parents:
diff changeset
1609 end Build_Record_Write_Procedure;
kono
parents:
diff changeset
1610
kono
parents:
diff changeset
1611 -------------------------------
kono
parents:
diff changeset
1612 -- Build_Stream_Attr_Profile --
kono
parents:
diff changeset
1613 -------------------------------
kono
parents:
diff changeset
1614
kono
parents:
diff changeset
1615 function Build_Stream_Attr_Profile
kono
parents:
diff changeset
1616 (Loc : Source_Ptr;
kono
parents:
diff changeset
1617 Typ : Entity_Id;
kono
parents:
diff changeset
1618 Nam : TSS_Name_Type) return List_Id
kono
parents:
diff changeset
1619 is
kono
parents:
diff changeset
1620 Profile : List_Id;
kono
parents:
diff changeset
1621
kono
parents:
diff changeset
1622 begin
kono
parents:
diff changeset
1623 -- (Ada 2005: AI-441): Set the null-excluding attribute because it has
kono
parents:
diff changeset
1624 -- no semantic meaning in Ada 95 but it is a requirement in Ada 2005.
kono
parents:
diff changeset
1625
kono
parents:
diff changeset
1626 Profile := New_List (
kono
parents:
diff changeset
1627 Make_Parameter_Specification (Loc,
kono
parents:
diff changeset
1628 Defining_Identifier => Make_Defining_Identifier (Loc, Name_S),
kono
parents:
diff changeset
1629 Parameter_Type =>
kono
parents:
diff changeset
1630 Make_Access_Definition (Loc,
kono
parents:
diff changeset
1631 Null_Exclusion_Present => True,
kono
parents:
diff changeset
1632 Subtype_Mark => New_Occurrence_Of (
kono
parents:
diff changeset
1633 Class_Wide_Type (RTE (RE_Root_Stream_Type)), Loc))));
kono
parents:
diff changeset
1634
kono
parents:
diff changeset
1635 if Nam /= TSS_Stream_Input then
kono
parents:
diff changeset
1636 Append_To (Profile,
kono
parents:
diff changeset
1637 Make_Parameter_Specification (Loc,
kono
parents:
diff changeset
1638 Defining_Identifier => Make_Defining_Identifier (Loc, Name_V),
kono
parents:
diff changeset
1639 Out_Present => (Nam = TSS_Stream_Read),
kono
parents:
diff changeset
1640 Parameter_Type => New_Occurrence_Of (Typ, Loc)));
kono
parents:
diff changeset
1641 end if;
kono
parents:
diff changeset
1642
kono
parents:
diff changeset
1643 return Profile;
kono
parents:
diff changeset
1644 end Build_Stream_Attr_Profile;
kono
parents:
diff changeset
1645
kono
parents:
diff changeset
1646 ---------------------------
kono
parents:
diff changeset
1647 -- Build_Stream_Function --
kono
parents:
diff changeset
1648 ---------------------------
kono
parents:
diff changeset
1649
kono
parents:
diff changeset
1650 procedure Build_Stream_Function
kono
parents:
diff changeset
1651 (Loc : Source_Ptr;
kono
parents:
diff changeset
1652 Typ : Entity_Id;
kono
parents:
diff changeset
1653 Decl : out Node_Id;
kono
parents:
diff changeset
1654 Fnam : Entity_Id;
kono
parents:
diff changeset
1655 Decls : List_Id;
kono
parents:
diff changeset
1656 Stms : List_Id)
kono
parents:
diff changeset
1657 is
kono
parents:
diff changeset
1658 Spec : Node_Id;
kono
parents:
diff changeset
1659
kono
parents:
diff changeset
1660 begin
kono
parents:
diff changeset
1661 -- Construct function specification
kono
parents:
diff changeset
1662
kono
parents:
diff changeset
1663 -- (Ada 2005: AI-441): Set the null-excluding attribute because it has
kono
parents:
diff changeset
1664 -- no semantic meaning in Ada 95 but it is a requirement in Ada 2005.
kono
parents:
diff changeset
1665
kono
parents:
diff changeset
1666 Spec :=
kono
parents:
diff changeset
1667 Make_Function_Specification (Loc,
kono
parents:
diff changeset
1668 Defining_Unit_Name => Fnam,
kono
parents:
diff changeset
1669
kono
parents:
diff changeset
1670 Parameter_Specifications => New_List (
kono
parents:
diff changeset
1671 Make_Parameter_Specification (Loc,
kono
parents:
diff changeset
1672 Defining_Identifier => Make_Defining_Identifier (Loc, Name_S),
kono
parents:
diff changeset
1673 Parameter_Type =>
kono
parents:
diff changeset
1674 Make_Access_Definition (Loc,
kono
parents:
diff changeset
1675 Null_Exclusion_Present => True,
kono
parents:
diff changeset
1676 Subtype_Mark =>
kono
parents:
diff changeset
1677 New_Occurrence_Of
kono
parents:
diff changeset
1678 (Class_Wide_Type (RTE (RE_Root_Stream_Type)), Loc)))),
kono
parents:
diff changeset
1679
kono
parents:
diff changeset
1680 Result_Definition => New_Occurrence_Of (Typ, Loc));
kono
parents:
diff changeset
1681
kono
parents:
diff changeset
1682 Decl :=
kono
parents:
diff changeset
1683 Make_Subprogram_Body (Loc,
kono
parents:
diff changeset
1684 Specification => Spec,
kono
parents:
diff changeset
1685 Declarations => Decls,
kono
parents:
diff changeset
1686 Handled_Statement_Sequence =>
kono
parents:
diff changeset
1687 Make_Handled_Sequence_Of_Statements (Loc,
kono
parents:
diff changeset
1688 Statements => Stms));
kono
parents:
diff changeset
1689 end Build_Stream_Function;
kono
parents:
diff changeset
1690
kono
parents:
diff changeset
1691 ----------------------------
kono
parents:
diff changeset
1692 -- Build_Stream_Procedure --
kono
parents:
diff changeset
1693 ----------------------------
kono
parents:
diff changeset
1694
kono
parents:
diff changeset
1695 procedure Build_Stream_Procedure
kono
parents:
diff changeset
1696 (Loc : Source_Ptr;
kono
parents:
diff changeset
1697 Typ : Entity_Id;
kono
parents:
diff changeset
1698 Decl : out Node_Id;
kono
parents:
diff changeset
1699 Pnam : Entity_Id;
kono
parents:
diff changeset
1700 Stms : List_Id;
kono
parents:
diff changeset
1701 Outp : Boolean)
kono
parents:
diff changeset
1702 is
kono
parents:
diff changeset
1703 Spec : Node_Id;
kono
parents:
diff changeset
1704
kono
parents:
diff changeset
1705 begin
kono
parents:
diff changeset
1706 -- Construct procedure specification
kono
parents:
diff changeset
1707
kono
parents:
diff changeset
1708 -- (Ada 2005: AI-441): Set the null-excluding attribute because it has
kono
parents:
diff changeset
1709 -- no semantic meaning in Ada 95 but it is a requirement in Ada 2005.
kono
parents:
diff changeset
1710
kono
parents:
diff changeset
1711 Spec :=
kono
parents:
diff changeset
1712 Make_Procedure_Specification (Loc,
kono
parents:
diff changeset
1713 Defining_Unit_Name => Pnam,
kono
parents:
diff changeset
1714
kono
parents:
diff changeset
1715 Parameter_Specifications => New_List (
kono
parents:
diff changeset
1716 Make_Parameter_Specification (Loc,
kono
parents:
diff changeset
1717 Defining_Identifier => Make_Defining_Identifier (Loc, Name_S),
kono
parents:
diff changeset
1718 Parameter_Type =>
kono
parents:
diff changeset
1719 Make_Access_Definition (Loc,
kono
parents:
diff changeset
1720 Null_Exclusion_Present => True,
kono
parents:
diff changeset
1721 Subtype_Mark =>
kono
parents:
diff changeset
1722 New_Occurrence_Of
kono
parents:
diff changeset
1723 (Class_Wide_Type (RTE (RE_Root_Stream_Type)), Loc))),
kono
parents:
diff changeset
1724
kono
parents:
diff changeset
1725 Make_Parameter_Specification (Loc,
kono
parents:
diff changeset
1726 Defining_Identifier => Make_Defining_Identifier (Loc, Name_V),
kono
parents:
diff changeset
1727 Out_Present => Outp,
kono
parents:
diff changeset
1728 Parameter_Type => New_Occurrence_Of (Typ, Loc))));
kono
parents:
diff changeset
1729
kono
parents:
diff changeset
1730 Decl :=
kono
parents:
diff changeset
1731 Make_Subprogram_Body (Loc,
kono
parents:
diff changeset
1732 Specification => Spec,
kono
parents:
diff changeset
1733 Declarations => Empty_List,
kono
parents:
diff changeset
1734 Handled_Statement_Sequence =>
kono
parents:
diff changeset
1735 Make_Handled_Sequence_Of_Statements (Loc,
kono
parents:
diff changeset
1736 Statements => Stms));
kono
parents:
diff changeset
1737 end Build_Stream_Procedure;
kono
parents:
diff changeset
1738
kono
parents:
diff changeset
1739 -----------------------------
kono
parents:
diff changeset
1740 -- Has_Stream_Standard_Rep --
kono
parents:
diff changeset
1741 -----------------------------
kono
parents:
diff changeset
1742
kono
parents:
diff changeset
1743 function Has_Stream_Standard_Rep (U_Type : Entity_Id) return Boolean is
kono
parents:
diff changeset
1744 Siz : Uint;
kono
parents:
diff changeset
1745
kono
parents:
diff changeset
1746 begin
kono
parents:
diff changeset
1747 if Has_Non_Standard_Rep (U_Type) then
kono
parents:
diff changeset
1748 return False;
kono
parents:
diff changeset
1749 end if;
kono
parents:
diff changeset
1750
kono
parents:
diff changeset
1751 if Has_Stream_Size_Clause (U_Type) then
kono
parents:
diff changeset
1752 Siz := Static_Integer (Expression (Stream_Size_Clause (U_Type)));
kono
parents:
diff changeset
1753 else
kono
parents:
diff changeset
1754 Siz := Esize (First_Subtype (U_Type));
kono
parents:
diff changeset
1755 end if;
kono
parents:
diff changeset
1756
kono
parents:
diff changeset
1757 return Siz = Esize (Root_Type (U_Type));
kono
parents:
diff changeset
1758 end Has_Stream_Standard_Rep;
kono
parents:
diff changeset
1759
kono
parents:
diff changeset
1760 ---------------------------------
kono
parents:
diff changeset
1761 -- Make_Stream_Subprogram_Name --
kono
parents:
diff changeset
1762 ---------------------------------
kono
parents:
diff changeset
1763
kono
parents:
diff changeset
1764 function Make_Stream_Subprogram_Name
kono
parents:
diff changeset
1765 (Loc : Source_Ptr;
kono
parents:
diff changeset
1766 Typ : Entity_Id;
kono
parents:
diff changeset
1767 Nam : TSS_Name_Type) return Entity_Id
kono
parents:
diff changeset
1768 is
kono
parents:
diff changeset
1769 Sname : Name_Id;
kono
parents:
diff changeset
1770
kono
parents:
diff changeset
1771 begin
kono
parents:
diff changeset
1772 -- For tagged types, we are dealing with a TSS associated with the
kono
parents:
diff changeset
1773 -- declaration, so we use the standard primitive function name. For
kono
parents:
diff changeset
1774 -- other types, generate a local TSS name since we are generating
kono
parents:
diff changeset
1775 -- the subprogram at the point of use.
kono
parents:
diff changeset
1776
kono
parents:
diff changeset
1777 if Is_Tagged_Type (Typ) then
kono
parents:
diff changeset
1778 Sname := Make_TSS_Name (Typ, Nam);
kono
parents:
diff changeset
1779 else
kono
parents:
diff changeset
1780 Sname := Make_TSS_Name_Local (Typ, Nam);
kono
parents:
diff changeset
1781 end if;
kono
parents:
diff changeset
1782
kono
parents:
diff changeset
1783 return Make_Defining_Identifier (Loc, Sname);
kono
parents:
diff changeset
1784 end Make_Stream_Subprogram_Name;
kono
parents:
diff changeset
1785
kono
parents:
diff changeset
1786 ----------------------
kono
parents:
diff changeset
1787 -- Stream_Base_Type --
kono
parents:
diff changeset
1788 ----------------------
kono
parents:
diff changeset
1789
kono
parents:
diff changeset
1790 function Stream_Base_Type (E : Entity_Id) return Entity_Id is
kono
parents:
diff changeset
1791 begin
kono
parents:
diff changeset
1792 if Is_Array_Type (E)
kono
parents:
diff changeset
1793 and then Is_First_Subtype (E)
kono
parents:
diff changeset
1794 then
kono
parents:
diff changeset
1795 return E;
kono
parents:
diff changeset
1796 else
kono
parents:
diff changeset
1797 return Base_Type (E);
kono
parents:
diff changeset
1798 end if;
kono
parents:
diff changeset
1799 end Stream_Base_Type;
kono
parents:
diff changeset
1800
kono
parents:
diff changeset
1801 end Exp_Strm;