/[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 10140 - (show annotations)
Thu May 14 00:28:06 1998 UTC (21 years, 9 months ago) by manus
Original Path: trunk/Src/bench/Eiffel/eiffel/genericity/cl_type_i.e
File size: 5860 byte(s)
Changes to reflect the new TYPE_LIST class.

The previous implementation seems to believe that the old `search' feature
from TYPE_LIST always succeed. Now, I added a check for this assumption
and if we did not find anything I return a Void element. But I'm not sure about
it.

1 -- Type class
2
3 class CL_TYPE_I
4
5 inherit
6 TYPE_I
7 redefine
8 is_reference,
9 is_expanded,
10 is_separate,
11 is_valid,
12 same_as,
13 c_type,
14 instantiation_in,
15 conforms_to_array
16 end
17
18 feature
19
20 base_id: CLASS_ID
21 -- Base class id of the type class
22
23 is_expanded: BOOLEAN
24 -- Is the type expanded?
25
26 is_separate: BOOLEAN
27 -- Is the type separate?
28
29 set_base_id (c: CLASS_ID) is
30 -- Assign `c' to `base_id'.
31 do
32 base_id := c
33 end
34
35 set_is_expanded (b: BOOLEAN) is
36 -- Assign `b' to `is_expanded'.
37 do
38 is_expanded := b
39 end
40
41 set_is_separate (b: BOOLEAN) is
42 -- Assign `b' to `is_separate'.
43 do
44 is_separate := b
45 end
46
47 meta_generic: META_GENERIC is
48 -- Meta generic array describing the type class
49 do
50 -- No meta generic in non-generic type
51 end
52
53 base_class: CLASS_C is
54 -- Base class associated to the class type
55 do
56 Result := System.class_of_id (base_id)
57 end
58
59 is_valid: BOOLEAN is
60 -- Is the base class still in the system ?
61 do
62 Result := base_class /= Void
63 end
64
65 is_reference: BOOLEAN is
66 -- Is the type a reference type ?
67 do
68 Result := not is_expanded
69 end;
70
71 same_as (other: TYPE_I): BOOLEAN is
72 -- Is `other' equal to Current ?
73 local
74 other_cl_type: CL_TYPE_I
75 do
76 other_cl_type ?= other
77 Result := other_cl_type /= Void -- FIXME
78 and then equal (other_cl_type.base_id, base_id)
79 and then other_cl_type.is_expanded = is_expanded
80 and then other_cl_type.is_separate = is_separate
81 and then other_cl_type.meta_generic = Void
82 end
83
84 instantiation_in (other: GEN_TYPE_I): CL_TYPE_I is
85 -- Instantiation of Current in context of `other'
86 require else
87 True
88 do
89 Result := Current
90 end
91
92 description: ATTR_DESC is
93 -- Type description for skeletons
94 local
95 exp: EXPANDED_DESC
96 types: TYPE_LIST
97 ref: REFERENCE_DESC
98 do
99 if is_expanded then
100 !! exp
101 is_expanded := False
102
103 types := base_class.types
104
105 check
106 --| The type should be present
107 has_type: types.has_type (Current)
108 end
109
110 if types.has_type (Current) then
111 exp.set_class_type (types.found_item)
112 end
113
114 is_expanded := True
115 Result := exp
116 elseif is_separate then
117 -- FIXME
118 Result := c_type.description
119 else
120 Result := c_type.description
121 end
122
123 ref ?= Result
124 if ref /= Void then
125 ref.set_class_type_i (Current)
126 end
127 end
128
129 c_type: TYPE_C is
130 -- Associated C type
131 do
132 Result := Reference_c_type
133 end
134
135 append_signature (st: STRUCTURED_TEXT) is
136 do
137 if is_expanded then
138 st.add_string ("expanded ")
139 elseif is_separate then
140 st.add_string ("separate ")
141 end
142 base_class.append_signature (st)
143 end
144
145 dump (file: FILE) is
146 local
147 s: STRING
148 do
149 if is_expanded then
150 file.putstring ("expanded ")
151 elseif is_separate then
152 file.putstring ("separate ")
153 end
154 s := clone (base_class.name)
155 s.to_upper
156 file.putstring (s)
157 end
158
159 has_associated_class_type: BOOLEAN is
160 -- Has `Current' an associated class type?
161 local
162 types : TYPE_LIST
163 do
164 types := base_class.types
165
166 if is_expanded then
167 is_expanded := false
168 Result := types.has_type (Current)
169 is_expanded := true
170 elseif is_separate then
171 is_separate := false
172 Result := types.has_type (Current)
173 is_separate := true
174 else
175 Result := types.has_type (Current)
176 end
177 end
178
179 associated_class_type: CLASS_TYPE is
180 -- Associated class type
181 require
182 has: has_associated_class_type
183 local
184 types: TYPE_LIST
185 do
186 if is_expanded then
187 Result := associated_expanded_class_type
188 elseif is_separate then
189 Result := associated_separate_class_type
190 else
191 types := base_class.types
192
193 check
194 --| The type should be present
195 has_type: types.has_type (Current)
196 end
197
198 if types.has_type (Current) then
199 Result := types.found_item
200 end
201 end
202 end
203
204 associated_expanded_class_type: CLASS_TYPE is
205 -- Associated expanded class type
206 require
207 is_expanded: is_expanded
208 has: has_associated_class_type
209 do
210 is_expanded := false
211 Result := associated_class_type
212 is_expanded := true
213 end
214
215 associated_separate_class_type: CLASS_TYPE is
216 -- Associated separate class type
217 require
218 is_separate: is_separate
219 has: has_associated_class_type
220 do
221 is_separate := false
222 Result := associated_class_type
223 is_separate := true
224 end
225
226 type_id: INTEGER is
227 -- Type id of the correponding class type
228 do
229 Result := associated_class_type.type_id
230 end
231
232 expanded_type_id: INTEGER is
233 -- Type id of the corresponding expanded class type
234 do
235 Result := associated_expanded_class_type.type_id
236 end
237
238 generate_cecil_value (file: INDENT_FILE) is
239 -- Generate cecil value
240 do
241 -- FIXME????: separate
242 if not is_expanded then
243 file.putstring ("SK_DTYPE")
244 else
245 file.putstring ("SK_EXP + (uint32) ")
246 file.putint (base_id.id)
247 end
248 end
249
250 hash_code: INTEGER is
251 -- Hash code for current type
252 do
253 Result := Other_code + base_id.hash_code
254 end
255
256 sk_value: INTEGER is
257 -- Generate SK value associated to the current type.
258 do
259 -- FIXME????: separate
260 if not is_expanded then
261 Result := Sk_ref + (type_id - 1)
262 else
263 is_expanded := False
264 Result := Sk_exp + (type_id - 1)
265 is_expanded := True
266 end
267 end
268
269 cecil_value: INTEGER is
270 do
271 -- FIXME????: separate
272 if not is_expanded then
273 Result := Sk_dtype
274 else
275 Result := Sk_exp + base_id.id
276 end
277 end
278
279 feature -- Array optimization
280
281 conforms_to_array: BOOLEAN is
282 do
283 Result := base_class.conform_to (array_class_c)
284 end
285
286 feature {NONE} -- Array optimization
287
288 array_class_c: CLASS_C is
289 once
290 Result := System.array_class.compiled_class
291 end
292
293 feature
294
295 type_a: CL_TYPE_A is
296 do
297 !!Result
298 Result.set_is_expanded (is_expanded)
299 Result.set_is_separate (is_separate)
300 Result.set_base_class_id (base_id)
301 end
302
303 end

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23