/[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 28380 - (show annotations)
Wed Oct 24 22:04:53 2001 UTC (18 years, 4 months ago) by manus
Original Path: trunk/Src/bench/Eiffel/eiffel/genericity/cl_type_i.e
File size: 8729 byte(s)
Added `is_external' to find out if `base_class' is an external class or not.

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23