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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 26913 - (show annotations)
Sun Aug 12 23:50:20 2001 UTC (18 years, 6 months ago) by manus
Original Path: trunk/Src/bench/Eiffel/eiffel/genericity/cl_type_i.e
File size: 8518 byte(s)
Merged branch `dev46_manu' to the trunc.

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23