/[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 8805 - (show annotations)
Wed Dec 10 17:30:55 1997 UTC (22 years, 2 months ago) by manus
Original Path: trunk/Src/bench/Eiffel/eiffel/genericity/cl_type_i.e
File size: 5883 byte(s)
Cosmetics
Fixed a problem with same_as and is_equal in GEN_TYPE_I

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23