/[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 5770 - (show annotations)
Fri Jun 28 18:53:00 1996 UTC (23 years, 8 months ago) by xavierl
Original Path: trunk/Src/bench/Eiffel/eiffel/genericity/cl_type_i.e
File size: 5285 byte(s)
incorrect optimization removed

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 do
105 if is_expanded then
106 !!exp;
107 is_expanded := False;
108
109 types := base_class.types;
110 pos := types.index;
111 types.compare_references
112 types.search (Current);
113 exp.set_class_type (types.item);
114 types.go_i_th (pos);
115
116 is_expanded := True;
117 Result := exp;
118 elseif is_separate then
119 -- FIXME
120 Result := c_type.description
121 else
122 Result := c_type.description;
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.e_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.class_name);
152 s.to_upper;
153 file.putstring (s);
154 end;
155
156 associated_class_type: CLASS_TYPE is
157 -- Associated class type
158 local
159 types: TYPE_LIST;
160 pos: INTEGER;
161 do
162 if is_expanded then
163 Result := associated_expanded_class_type
164 elseif is_separate then
165 Result := associated_separate_class_type
166 else
167 types := base_class.types;
168 pos := types.index;
169 types.compare_references
170 types.search (Current);
171 Result := types.item;
172 types.go_i_th (pos);
173 end;
174 end;
175
176 associated_expanded_class_type: CLASS_TYPE is
177 -- Associated expanded class type
178 require
179 is_expanded: is_expanded
180 do
181 is_expanded := false;
182 Result := associated_class_type;
183 is_expanded := true;
184 end;
185
186 associated_separate_class_type: CLASS_TYPE is
187 -- Associated separate class type
188 require
189 is_separate: is_separate
190 do
191 is_separate := false;
192 Result := associated_class_type;
193 is_separate := true;
194 end;
195
196 type_id: INTEGER is
197 -- Type id of the correponding class type
198 do
199 Result := associated_class_type.type_id;
200 end;
201
202 expanded_type_id: INTEGER is
203 -- Type id of the corresponding expanded class type
204 do
205 Result := associated_expanded_class_type.type_id
206 end;
207
208 generate_cecil_value (file: INDENT_FILE) is
209 -- Generate cecil value
210 do
211 -- FIXME????: separate
212 if not is_expanded then
213 file.putstring ("SK_DTYPE");
214 else
215 file.putstring ("SK_EXP + (uint32) ");
216 file.putint (base_id.id);
217 end;
218 end;
219
220 hash_code: INTEGER is
221 -- Hash code for current type
222 do
223 Result := Other_code + base_id.hash_code
224 end;
225
226 sk_value: INTEGER is
227 -- Generate SK value associated to the current type.
228 do
229 -- FIXME????: separate
230 if not is_expanded then
231 Result := Sk_ref + (type_id - 1);
232 else
233 is_expanded := False;
234 Result := Sk_exp + (type_id - 1);
235 is_expanded := True;
236 end;
237 end;
238
239 cecil_value: INTEGER is
240 do
241 -- FIXME????: separate
242 if not is_expanded then
243 Result := Sk_dtype
244 else
245 Result := Sk_exp + base_id.id
246 end;
247 end;
248
249 feature -- Array optimization
250
251 conforms_to_array: BOOLEAN is
252 do
253 Result := base_class.conform_to (array_class_c)
254 end;
255
256 feature {NONE} -- Array optimization
257
258 array_class_c: CLASS_C is
259 once
260 Result := System.array_class.compiled_class
261 end;
262
263 feature
264
265 type_a: CL_TYPE_A is
266 do
267 !!Result
268 Result.set_is_expanded (is_expanded);
269 Result.set_is_separate (is_separate);
270 Result.set_base_class_id (base_id)
271 end
272
273 end

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23