/[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 11065 - (hide annotations)
Wed Aug 19 03:27:55 1998 UTC (21 years, 6 months ago) by manus
Original Path: trunk/Src/bench/Eiffel/eiffel/genericity/cl_type_i.e
File size: 6910 byte(s)
Removed `associated_expanded_class_type' and `associated_separate_class_type'
since we don't really need them, we always can do it through `associated_class_type'
which is more general.

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23