/[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 4623 - (show annotations)
Thu Apr 11 10:44:28 1996 UTC (23 years, 10 months ago) by xavierl
Original Path: trunk/Src/bench/Eiffel/eiffel/genericity/cl_type_i.e
File size: 5269 byte(s)
implementation of `is_separate'

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23