/[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 29681 - (hide annotations)
Thu Dec 13 21:21:06 2001 UTC (18 years, 2 months ago) by manus
Original Path: trunk/Src/bench/Eiffel/eiffel/genericity/cl_type_i.e
File size: 9005 byte(s)
We do not use the external name anymore for an Eiffel class. Only for pure
external .NET classes.

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23