/[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 7681 - (show annotations)
Wed Feb 12 09:23:09 1997 UTC (23 years ago) by michaels
Original Path: trunk/Src/bench/Eiffel/eiffel/genericity/cl_type_i.e
File size: 5922 byte(s)
*** empty log message ***

1 -- Type class
2
3 class CL_TYPE_I
4
5 inherit
6
7 TYPE_I
8 redefine
9 is_reference,
10 is_expanded,
11 is_separate,
12 is_valid,
13 same_as,
14 c_type,
15 instantiation_in,
16 conforms_to_array
17 end
18
19 feature
20
21 base_id: CLASS_ID;
22 -- Base class id of the type class
23
24 is_expanded: BOOLEAN;
25 -- Is the type expanded ?
26
27 is_separate: BOOLEAN;
28 -- Is the type separate ?
29
30 set_base_id (c: CLASS_ID) is
31 -- Assign `c' to `base_id'.
32 do
33 base_id := c;
34 end;
35
36 set_is_expanded (b: BOOLEAN) is
37 -- Assign `b' to `is_expanded'.
38 do
39 is_expanded := b;
40 end;
41
42 set_is_separate (b: BOOLEAN) is
43 -- Assign `b' to `is_separate'.
44 do
45 is_separate := b;
46 end;
47
48 meta_generic: META_GENERIC is
49 -- Meta generic array describing the type class
50 do
51 -- No meta generic in non-generic type
52 end;
53
54 base_class: CLASS_C is
55 -- Base class associated to the class type
56 do
57 Result := System.class_of_id (base_id);
58 end;
59
60 is_valid: BOOLEAN is
61 -- Is the base class still in the system ?
62 do
63 Result := base_class /= Void;
64 end;
65
66 is_reference: BOOLEAN is
67 -- Is the type a reference type ?
68 do
69 Result := not is_expanded;
70 end;
71
72 same_as (other: TYPE_I): BOOLEAN is
73 -- Is `other' equal to Current ?
74 local
75 other_cl_type: CL_TYPE_I;
76 do
77 other_cl_type ?= other;
78 Result := other_cl_type /= Void
79 and then
80 -- FIXME
81 equal (other_cl_type.base_id, base_id)
82 and then
83 other_cl_type.is_expanded = is_expanded
84 and then
85 other_cl_type.is_separate = is_separate
86 and then
87 other_cl_type.meta_generic = Void
88 end;
89
90 instantiation_in (other: GEN_TYPE_I): CL_TYPE_I is
91 -- Instantiation of Current in context of `other'
92 require else
93 True
94 do
95 Result := Current;
96 end;
97
98 description: ATTR_DESC is
99 -- Type description for skeletons
100 local
101 exp: EXPANDED_DESC
102 types: TYPE_LIST
103 pos: INTEGER
104 ref: REFERENCE_DESC
105 do
106 if is_expanded then
107 !!exp;
108 is_expanded := False;
109
110 types := base_class.types;
111 pos := types.index;
112 types.compare_references
113 types.search (Current);
114 exp.set_class_type (types.item);
115 types.go_i_th (pos);
116
117 is_expanded := True;
118 Result := exp;
119 elseif is_separate then
120 -- FIXME
121 Result := c_type.description
122 else
123 Result := c_type.description;
124 end;
125
126 ref ?= Result
127 if ref /= Void then
128 ref.set_class_type_i (Current)
129 end
130 end;
131
132 c_type: TYPE_C is
133 -- Associated C type
134 do
135 Result := Reference_c_type;
136 end;
137
138 append_signature (st: STRUCTURED_TEXT) is
139 do
140 if is_expanded then
141 st.add_string ("expanded ");
142 elseif is_separate then
143 st.add_string ("separate ");
144 end;
145 base_class.append_signature (st)
146 end;
147
148 dump (file: FILE) is
149 local
150 s: STRING
151 do
152 if is_expanded then
153 file.putstring ("expanded ");
154 elseif is_separate then
155 file.putstring ("separate ");
156 end;
157 s := clone (base_class.name);
158 s.to_upper;
159 file.putstring (s);
160 end;
161
162 has_associated_class_type: BOOLEAN is
163 -- Has `Current' an associated class type?
164 local
165 types : TYPE_LIST
166 do
167 types := base_class.types
168
169 if is_expanded then
170 is_expanded := false
171 Result := types.has_type (Current)
172 is_expanded := true
173 elseif is_separate then
174 is_separate := false
175 Result := types.has_type (Current)
176 is_separate := true
177 else
178 Result := types.has_type (Current)
179 end
180 end
181
182 associated_class_type: CLASS_TYPE is
183 -- Associated class type
184 require
185 has: has_associated_class_type
186 local
187 types: TYPE_LIST;
188 pos: INTEGER;
189 do
190 if is_expanded then
191 Result := associated_expanded_class_type
192 elseif is_separate then
193 Result := associated_separate_class_type
194 else
195 types := base_class.types;
196 pos := types.index;
197 types.compare_references
198 types.search (Current);
199 Result := types.item;
200 types.go_i_th (pos);
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