/[eiffelstudio]/branches/CAT_mono/Src/Eiffel/eiffel/genericity/cl_type_i.e
ViewVC logotype

Annotation of /branches/CAT_mono/Src/Eiffel/eiffel/genericity/cl_type_i.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 13232 - (hide annotations)
Fri Feb 5 03:57:18 1999 UTC (21 years ago) by manus
Original Path: trunk/Src/bench/Eiffel/eiffel/genericity/cl_type_i.e
File size: 7054 byte(s)
Fixed some problems related to the use of expanded types in generic parameter or with
simple expanded types:
- Fixed the byte code generation
- Changed the skeleton to handle correctly expanded type as a generic parameter
- Changed the attribute description to match the new skeleton
- Propagation of the expanded information (which was not done before, especially
  with inheritance)
- Changed the make routine of the TO_SPECIAL class so that it handles correctly
  an expanded type.

1 grator 18 -- Type class
2    
3     class CL_TYPE_I
4    
5     inherit
6     TYPE_I
7     redefine
8     is_reference,
9     is_expanded,
10 xavierl 4623 is_separate,
11 grator 236 is_valid,
12 manus 11218 is_explicit,
13 grator 18 same_as,
14     c_type,
15 grator 930 instantiation_in,
16 manus 10818 complete_instantiation_in,
17     conforms_to_array,
18     generated_id,
19 manus 11298 generate_cid,
20 manus 10818 make_gen_type_byte_code
21 grator 18 end
22    
23     feature
24    
25 manus 9655 base_id: CLASS_ID
26 grator 18 -- Base class id of the type class
27    
28 manus 9655 is_expanded: BOOLEAN
29 manus 8805 -- Is the type expanded?
30 grator 18
31 manus 9655 is_separate: BOOLEAN
32 manus 8805 -- Is the type separate?
33 xavierl 4623
34 ericb 3652 set_base_id (c: CLASS_ID) is
35 grator 18 -- Assign `c' to `base_id'.
36     do
37 manus 9655 base_id := c
38     end
39 grator 18
40     set_is_expanded (b: BOOLEAN) is
41     -- Assign `b' to `is_expanded'.
42     do
43 manus 9655 is_expanded := b
44     end
45 grator 18
46 xavierl 4623 set_is_separate (b: BOOLEAN) is
47     -- Assign `b' to `is_separate'.
48     do
49 manus 9655 is_separate := b
50     end
51 xavierl 4623
52 grator 18 meta_generic: META_GENERIC is
53     -- Meta generic array describing the type class
54     do
55     -- No meta generic in non-generic type
56 manus 9655 end
57 grator 18
58 manus 10890 cr_info : CREATE_INFO
59     -- Additional information for the creation
60     -- of generic types with anchored parameters
61    
62     set_cr_info (cinfo : CREATE_INFO) is
63 manus 11734 -- Set `cr_info' to `cinfo'.
64 manus 10890 do
65     cr_info := cinfo
66     ensure
67     cr_info_set : cr_info = cinfo
68     end
69    
70 manus 10818 true_generics : ARRAY [TYPE_I] is
71     -- Array of generics: no mapping reference -> REFERENCE_I
72     do
73     -- Non generic types don't have them
74     end
75    
76 grator 18 base_class: CLASS_C is
77     -- Base class associated to the class type
78     do
79 manus 9655 Result := System.class_of_id (base_id)
80     end
81 grator 18
82 grator 236 is_valid: BOOLEAN is
83     -- Is the base class still in the system ?
84     do
85 manus 9655 Result := base_class /= Void
86     end
87 grator 236
88 grator 18 is_reference: BOOLEAN is
89     -- Is the type a reference type ?
90     do
91 manus 9655 Result := not is_expanded
92 grator 18 end;
93    
94 manus 11218 is_explicit: BOOLEAN is
95    
96     do
97     Result := (cr_info = Void) or else (is_expanded or is_basic)
98     end
99    
100 grator 18 same_as (other: TYPE_I): BOOLEAN is
101     -- Is `other' equal to Current ?
102     local
103 manus 9655 other_cl_type: CL_TYPE_I
104 grator 18 do
105 manus 9655 other_cl_type ?= other
106 manus 8805 Result := other_cl_type /= Void -- FIXME
107     and then equal (other_cl_type.base_id, base_id)
108     and then other_cl_type.is_expanded = is_expanded
109     and then other_cl_type.is_separate = is_separate
110     and then other_cl_type.meta_generic = Void
111 manus 10818 and then other_cl_type.true_generics = Void
112 manus 9655 end
113 grator 18
114     instantiation_in (other: GEN_TYPE_I): CL_TYPE_I is
115     -- Instantiation of Current in context of `other'
116 grator 282 require else
117     True
118 grator 18 do
119 manus 9655 Result := Current
120     end
121 grator 18
122 manus 10818 complete_instantiation_in (other: GEN_TYPE_I): CL_TYPE_I is
123     -- Instantiation of Current in context of `other'
124     require else
125     True
126     do
127     Result := Current
128     end
129    
130 grator 18 description: ATTR_DESC is
131     -- Type description for skeletons
132     local
133 michaels 7681 exp: EXPANDED_DESC
134     ref: REFERENCE_DESC
135 grator 485 do
136 grator 18 if is_expanded then
137 manus 10140 !! exp
138 manus 9655 is_expanded := False
139 manus 10196 exp.set_class_type (base_class.types.conservative_search_item (Current))
140 manus 9655 is_expanded := True
141 manus 13232 exp.set_type_i (Current)
142 manus 9655 Result := exp
143 xavierl 4623 elseif is_separate then
144     -- FIXME
145     Result := c_type.description
146 grator 18 else
147 manus 9655 Result := c_type.description
148     end
149 michaels 7681
150     ref ?= Result
151     if ref /= Void then
152     ref.set_class_type_i (Current)
153     end
154 manus 9655 end
155 grator 18
156     c_type: TYPE_C is
157     -- Associated C type
158     do
159 manus 9655 Result := Reference_c_type
160     end
161 grator 18
162 guusl 3636 append_signature (st: STRUCTURED_TEXT) is
163 grator 552 do
164     if is_expanded then
165 manus 9655 st.add_string ("expanded ")
166 xavierl 4623 elseif is_separate then
167 manus 9655 st.add_string ("separate ")
168     end
169 dinov 6562 base_class.append_signature (st)
170 manus 9655 end
171 grator 552
172 manus 11599 dump (buffer: GENERATION_BUFFER) is
173 grator 1323 local
174     s: STRING
175 grator 18 do
176     if is_expanded then
177 manus 11599 buffer.putstring ("expanded ")
178 xavierl 4623 elseif is_separate then
179 manus 11599 buffer.putstring ("separate ")
180 manus 9655 end
181     s := clone (base_class.name)
182     s.to_upper
183 manus 11599 buffer.putstring (s)
184 manus 9655 end
185 grator 18
186 michaels 7681 has_associated_class_type: BOOLEAN is
187     -- Has `Current' an associated class type?
188     do
189     if is_expanded then
190 manus 11065 is_expanded := False
191 manus 10183 Result := base_class.types.has_type (Current)
192 manus 11065 is_expanded := True
193 michaels 7681 elseif is_separate then
194 manus 11065 is_separate := False
195 manus 10183 Result := base_class.types.has_type (Current)
196 manus 11065 is_separate := True
197 michaels 7681 else
198 manus 10183 Result := base_class.types.has_type (Current)
199 michaels 7681 end
200     end
201    
202 grator 18 associated_class_type: CLASS_TYPE is
203     -- Associated class type
204 michaels 7681 require
205     has: has_associated_class_type
206 grator 18 local
207 manus 9655 types: TYPE_LIST
208 grator 485 do
209     if is_expanded then
210 manus 11065 is_expanded := False
211     Result := base_class.types.conservative_search_item (Current)
212     is_expanded := True
213 xavierl 4623 elseif is_separate then
214 manus 11065 is_separate := False
215     Result := base_class.types.conservative_search_item (Current)
216     is_separate := True
217 grator 485 else
218 manus 10196 Result := base_class.types.conservative_search_item (Current)
219 manus 9655 end
220     end
221 grator 18
222     type_id: INTEGER is
223     -- Type id of the correponding class type
224     do
225 manus 9655 Result := associated_class_type.type_id
226     end
227 grator 18
228     expanded_type_id: INTEGER is
229     -- Type id of the corresponding expanded class type
230     do
231 manus 11065 is_expanded := False
232     Result := base_class.types.conservative_search_item (Current).type_id
233     is_expanded := True
234 manus 9655 end
235 grator 18
236 manus 11599 generate_cecil_value (buffer: GENERATION_BUFFER) is
237 grator 18 -- Generate cecil value
238     do
239 xavierl 4623 -- FIXME????: separate
240 grator 18 if not is_expanded then
241 manus 11599 buffer.putstring ("SK_DTYPE")
242 grator 18 else
243 manus 11599 buffer.putstring ("SK_EXP + (uint32) ")
244     buffer.putint (base_id.id)
245 manus 9655 end
246     end
247 grator 18
248     hash_code: INTEGER is
249     -- Hash code for current type
250     do
251 ericb 3652 Result := Other_code + base_id.hash_code
252 manus 9655 end
253 grator 18
254     sk_value: INTEGER is
255     -- Generate SK value associated to the current type.
256     do
257 xavierl 4623 -- FIXME????: separate
258 grator 18 if not is_expanded then
259 manus 9655 Result := Sk_ref + (type_id - 1)
260 grator 18 else
261 manus 9655 is_expanded := False
262     Result := Sk_exp + (type_id - 1)
263     is_expanded := True
264     end
265     end
266 grator 18
267 grator 508 cecil_value: INTEGER is
268     do
269 xavierl 4623 -- FIXME????: separate
270 grator 508 if not is_expanded then
271     Result := Sk_dtype
272     else
273 ericb 3652 Result := Sk_exp + base_id.id
274 manus 9655 end
275     end
276 grator 508
277 grator 930 feature -- Array optimization
278    
279     conforms_to_array: BOOLEAN is
280     do
281     Result := base_class.conform_to (array_class_c)
282 manus 9655 end
283 grator 930
284     feature {NONE} -- Array optimization
285    
286     array_class_c: CLASS_C is
287     once
288     Result := System.array_class.compiled_class
289 manus 9655 end
290 grator 930
291 grator 1204 feature
292    
293     type_a: CL_TYPE_A is
294     do
295     !!Result
296 manus 9655 Result.set_is_expanded (is_expanded)
297     Result.set_is_separate (is_separate)
298 ericb 3652 Result.set_base_class_id (base_id)
299 grator 1204 end
300    
301 manus 10818 feature -- Generic conformance
302    
303     generated_id (final_mode : BOOLEAN) : INTEGER is
304 manus 11298
305 manus 10818 do
306 manus 11298 if final_mode then
307     Result := type_id - 1
308 manus 10818 else
309 manus 11298 Result := associated_class_type.id.id-1
310 manus 10818 end
311 manus 11298
312     if is_expanded then
313     Result := -256 - Result
314     end
315 manus 10818 end
316    
317 manus 11599 generate_cid (buffer : GENERATION_BUFFER; final_mode, use_info : BOOLEAN) is
318 manus 11298
319 manus 10818 do
320 manus 11209 if
321     use_info and then (cr_info /= Void)
322     and then not (is_expanded or is_basic)
323     then
324     -- It's an anchored type
325 manus 11599 cr_info.generate_cid (buffer, final_mode)
326 manus 10890 end
327 manus 11599 buffer.putint (generated_id (final_mode))
328     buffer.putstring (", ")
329 manus 10818 end
330    
331 manus 10890 make_gen_type_byte_code (ba : BYTE_ARRAY; use_info : BOOLEAN) is
332 manus 10818 do
333 manus 11209 if
334     use_info and then (cr_info /= Void)
335     and then not (is_expanded or is_basic)
336     then
337     -- It's an anchored type
338 manus 10890 cr_info.make_gen_type_byte_code (ba)
339     end
340 manus 10818 ba.append_short_integer (generated_id (False))
341     end
342    
343 grator 18 end

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.23