/[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 9971 - (show annotations)
Wed Apr 22 17:38:29 1998 UTC (21 years, 10 months ago) by manus
Original Path: trunk/Src/bench/Eiffel/eiffel/genericity/cl_type_i.e
File size: 5837 byte(s)
Changed the way to go within a list, now we are using `cursor' instead of `index'

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 old_cursor: CURSOR
98 ref: REFERENCE_DESC
99 do
100 if is_expanded then
101 !!exp
102 is_expanded := False
103
104 types := base_class.types
105 old_cursor := types.cursor
106 types.compare_references
107 types.search (Current)
108 exp.set_class_type (types.item)
109 types.go_to (old_cursor)
110
111 is_expanded := True
112 Result := exp
113 elseif is_separate then
114 -- FIXME
115 Result := c_type.description
116 else
117 Result := c_type.description
118 end
119
120 ref ?= Result
121 if ref /= Void then
122 ref.set_class_type_i (Current)
123 end
124 end
125
126 c_type: TYPE_C is
127 -- Associated C type
128 do
129 Result := Reference_c_type
130 end
131
132 append_signature (st: STRUCTURED_TEXT) is
133 do
134 if is_expanded then
135 st.add_string ("expanded ")
136 elseif is_separate then
137 st.add_string ("separate ")
138 end
139 base_class.append_signature (st)
140 end
141
142 dump (file: FILE) is
143 local
144 s: STRING
145 do
146 if is_expanded then
147 file.putstring ("expanded ")
148 elseif is_separate then
149 file.putstring ("separate ")
150 end
151 s := clone (base_class.name)
152 s.to_upper
153 file.putstring (s)
154 end
155
156 has_associated_class_type: BOOLEAN is
157 -- Has `Current' an associated class type?
158 local
159 types : TYPE_LIST
160 do
161 types := base_class.types
162
163 if is_expanded then
164 is_expanded := false
165 Result := types.has_type (Current)
166 is_expanded := true
167 elseif is_separate then
168 is_separate := false
169 Result := types.has_type (Current)
170 is_separate := true
171 else
172 Result := types.has_type (Current)
173 end
174 end
175
176 associated_class_type: CLASS_TYPE is
177 -- Associated class type
178 require
179 has: has_associated_class_type
180 local
181 types: TYPE_LIST
182 old_cursor: CURSOR
183 do
184 if is_expanded then
185 Result := associated_expanded_class_type
186 elseif is_separate then
187 Result := associated_separate_class_type
188 else
189 types := base_class.types
190 old_cursor := types.cursor
191 types.compare_references
192 types.search (Current)
193 Result := types.item
194 types.go_to (old_cursor)
195 end
196 end
197
198 associated_expanded_class_type: CLASS_TYPE is
199 -- Associated expanded class type
200 require
201 is_expanded: is_expanded
202 has: has_associated_class_type
203 do
204 is_expanded := false
205 Result := associated_class_type
206 is_expanded := true
207 end
208
209 associated_separate_class_type: CLASS_TYPE is
210 -- Associated separate class type
211 require
212 is_separate: is_separate
213 has: has_associated_class_type
214 do
215 is_separate := false
216 Result := associated_class_type
217 is_separate := true
218 end
219
220 type_id: INTEGER is
221 -- Type id of the correponding class type
222 do
223 Result := associated_class_type.type_id
224 end
225
226 expanded_type_id: INTEGER is
227 -- Type id of the corresponding expanded class type
228 do
229 Result := associated_expanded_class_type.type_id
230 end
231
232 generate_cecil_value (file: INDENT_FILE) is
233 -- Generate cecil value
234 do
235 -- FIXME????: separate
236 if not is_expanded then
237 file.putstring ("SK_DTYPE")
238 else
239 file.putstring ("SK_EXP + (uint32) ")
240 file.putint (base_id.id)
241 end
242 end
243
244 hash_code: INTEGER is
245 -- Hash code for current type
246 do
247 Result := Other_code + base_id.hash_code
248 end
249
250 sk_value: INTEGER is
251 -- Generate SK value associated to the current type.
252 do
253 -- FIXME????: separate
254 if not is_expanded then
255 Result := Sk_ref + (type_id - 1)
256 else
257 is_expanded := False
258 Result := Sk_exp + (type_id - 1)
259 is_expanded := True
260 end
261 end
262
263 cecil_value: INTEGER is
264 do
265 -- FIXME????: separate
266 if not is_expanded then
267 Result := Sk_dtype
268 else
269 Result := Sk_exp + base_id.id
270 end
271 end
272
273 feature -- Array optimization
274
275 conforms_to_array: BOOLEAN is
276 do
277 Result := base_class.conform_to (array_class_c)
278 end
279
280 feature {NONE} -- Array optimization
281
282 array_class_c: CLASS_C is
283 once
284 Result := System.array_class.compiled_class
285 end
286
287 feature
288
289 type_a: CL_TYPE_A is
290 do
291 !!Result
292 Result.set_is_expanded (is_expanded)
293 Result.set_is_separate (is_separate)
294 Result.set_base_class_id (base_id)
295 end
296
297 end

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23