/[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 26913 - (hide 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 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 grator 18 same_as,
17     c_type,
18 grator 930 instantiation_in,
19 manus 10818 complete_instantiation_in,
20     conforms_to_array,
21     generated_id,
22 manus 11298 generate_cid,
23 manus 14013 make_gen_type_byte_code,
24     generate_cid_array,
25     generate_cid_init
26 grator 18 end
27    
28 manus 26913 feature -- Access
29 grator 18
30 manus 26913 base_id: INTEGER
31 grator 18 -- 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 manus 9655 end
38 grator 18
39 manus 10890 cr_info : CREATE_INFO
40     -- Additional information for the creation
41     -- of generic types with anchored parameters
42    
43 manus 10818 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 grator 18 base_class: CLASS_C is
50     -- Base class associated to the class type
51     do
52 manus 9655 Result := System.class_of_id (base_id)
53     end
54 grator 18
55 manus 26913 type_a: CL_TYPE_A is
56 grator 236 do
57 manus 26913 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 manus 9655 end
62 grator 236
63 manus 26913 il_type_name: STRING is
64     -- Class name of current type.
65 grator 18 do
66 manus 26913 Result := clone (base_class.external_class_name)
67 manus 11218 end
68    
69 grator 18 instantiation_in (other: GEN_TYPE_I): CL_TYPE_I is
70     -- Instantiation of Current in context of `other'
71 grator 282 require else
72     True
73 grator 18 do
74 manus 9655 Result := Current
75     end
76 grator 18
77 manus 10818 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 grator 18 description: ATTR_DESC is
86     -- Type description for skeletons
87     local
88 michaels 7681 exp: EXPANDED_DESC
89     ref: REFERENCE_DESC
90 grator 485 do
91 manus 26913 if is_true_expanded then
92 manus 10140 !! exp
93 manus 26913 is_true_expanded := False
94 manus 10196 exp.set_class_type (base_class.types.conservative_search_item (Current))
95 manus 26913 is_true_expanded := True
96 manus 13232 exp.set_type_i (Current)
97 manus 9655 Result := exp
98 xavierl 4623 elseif is_separate then
99     -- FIXME
100     Result := c_type.description
101 grator 18 else
102 manus 9655 Result := c_type.description
103     end
104 michaels 7681
105     ref ?= Result
106     if ref /= Void then
107     ref.set_class_type_i (Current)
108     end
109 manus 9655 end
110 grator 18
111     c_type: TYPE_C is
112     -- Associated C type
113     do
114 manus 9655 Result := Reference_c_type
115     end
116 grator 18
117     associated_class_type: CLASS_TYPE is
118     -- Associated class type
119 michaels 7681 require
120 manus 16188 -- has: has_associated_class_type
121 grator 485 do
122 manus 26913 if is_true_expanded then
123     is_true_expanded := False
124 manus 11065 Result := base_class.types.conservative_search_item (Current)
125 manus 26913 is_true_expanded := True
126 xavierl 4623 elseif is_separate then
127 manus 11065 is_separate := False
128     Result := base_class.types.conservative_search_item (Current)
129     is_separate := True
130 grator 485 else
131 manus 10196 Result := base_class.types.conservative_search_item (Current)
132 manus 9655 end
133     end
134 grator 18
135     type_id: INTEGER is
136     -- Type id of the correponding class type
137     do
138 manus 9655 Result := associated_class_type.type_id
139     end
140 grator 18
141     expanded_type_id: INTEGER is
142     -- Type id of the corresponding expanded class type
143     do
144 manus 26913 is_true_expanded := False
145 manus 11065 Result := base_class.types.conservative_search_item (Current).type_id
146 manus 26913 is_true_expanded := True
147 manus 9655 end
148 grator 18
149 manus 26913 sk_value: INTEGER is
150     -- Generate SK value associated to the current type.
151 grator 18 do
152 xavierl 4623 -- FIXME????: separate
153 manus 26913 if not is_true_expanded then
154     Result := Sk_ref + (type_id - 1)
155 grator 18 else
156 manus 26913 is_true_expanded := False
157     Result := Sk_exp + (type_id - 1)
158     is_true_expanded := True
159 manus 9655 end
160     end
161 grator 18
162 manus 26913 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 grator 18 hash_code: INTEGER is
173     -- Hash code for current type
174     do
175 manus 26913 Result := Other_code + base_id
176 manus 9655 end
177 grator 18
178 manus 26913 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 grator 18 do
193 manus 26913 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 grator 18 else
226 manus 26913 Result := base_class.types.has_type (Current)
227 manus 9655 end
228     end
229 grator 18
230 manus 26913 same_as (other: TYPE_I): BOOLEAN is
231     -- Is `other' equal to Current ?
232     local
233     other_cl_type: CL_TYPE_I
234 grator 508 do
235 manus 26913 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 xavierl 4623 -- FIXME????: separate
304 manus 26913 if not is_true_expanded then
305     buffer.putstring ("SK_DTYPE")
306 grator 508 else
307 manus 26913 buffer.putstring ("SK_EXP + (uint32) ")
308     buffer.putint (base_id)
309 manus 9655 end
310     end
311 grator 508
312 grator 930 feature -- Array optimization
313    
314     conforms_to_array: BOOLEAN is
315     do
316     Result := base_class.conform_to (array_class_c)
317 manus 9655 end
318 grator 930
319     feature {NONE} -- Array optimization
320    
321     array_class_c: CLASS_C is
322     once
323     Result := System.array_class.compiled_class
324 manus 9655 end
325 grator 930
326 manus 10818 feature -- Generic conformance
327    
328     generated_id (final_mode : BOOLEAN) : INTEGER is
329 manus 11298
330 manus 10818 do
331 manus 11298 if final_mode then
332     Result := type_id - 1
333 manus 10818 else
334 manus 26913 Result := associated_class_type.static_type_id-1
335 manus 10818 end
336 manus 11298
337 manus 26913 if is_true_expanded then
338     Result := Expanded_level - Result
339 manus 11298 end
340 manus 10818 end
341    
342 manus 11599 generate_cid (buffer : GENERATION_BUFFER; final_mode, use_info : BOOLEAN) is
343 manus 11298
344 manus 10818 do
345 manus 11209 if
346     use_info and then (cr_info /= Void)
347 manus 26913 and then not is_expanded
348 manus 11209 then
349     -- It's an anchored type
350 manus 11599 cr_info.generate_cid (buffer, final_mode)
351 manus 10890 end
352 manus 11599 buffer.putint (generated_id (final_mode))
353     buffer.putstring (", ")
354 manus 10818 end
355    
356 manus 10890 make_gen_type_byte_code (ba : BYTE_ARRAY; use_info : BOOLEAN) is
357 manus 10818 do
358 manus 11209 if
359     use_info and then (cr_info /= Void)
360 manus 26913 and then not is_expanded
361 manus 11209 then
362     -- It's an anchored type
363 manus 10890 cr_info.make_gen_type_byte_code (ba)
364     end
365 manus 10818 ba.append_short_integer (generated_id (False))
366     end
367    
368 manus 14013 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 manus 26913 and then not is_expanded
376 manus 14013 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 manus 26913 and then not is_expanded
395 manus 14013 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 grator 18 end

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23