/[eiffelstudio]/branches/CAT_mono/Src/Eiffel/eiffel/genericity/cl_type_i.e
ViewVC logotype

Annotation of /branches/CAT_mono/Src/Eiffel/eiffel/genericity/cl_type_i.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5770 - (hide 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 grator 18 -- Type class
2    
3     class CL_TYPE_I
4    
5     inherit
6    
7     TYPE_I
8     redefine
9     is_reference,
10     is_expanded,
11 xavierl 4623 is_separate,
12 grator 236 is_valid,
13 grator 18 same_as,
14     c_type,
15 grator 930 instantiation_in,
16     conforms_to_array
17 grator 18 end
18    
19     feature
20    
21 ericb 3652 base_id: CLASS_ID;
22 grator 18 -- Base class id of the type class
23    
24     is_expanded: BOOLEAN;
25     -- Is the type expanded ?
26    
27 xavierl 4623 is_separate: BOOLEAN;
28     -- Is the type separate ?
29    
30 ericb 3652 set_base_id (c: CLASS_ID) is
31 grator 18 -- 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 xavierl 4623 set_is_separate (b: BOOLEAN) is
43     -- Assign `b' to `is_separate'.
44     do
45     is_separate := b;
46     end;
47    
48 grator 18 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 grator 236 is_valid: BOOLEAN is
61     -- Is the base class still in the system ?
62     do
63     Result := base_class /= Void;
64     end;
65    
66 grator 18 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 xavierl 5770 -- FIXME
81     equal (other_cl_type.base_id, base_id)
82 grator 18 and then
83 grator 850 other_cl_type.is_expanded = is_expanded
84     and then
85 xavierl 4623 other_cl_type.is_separate = is_separate
86     and then
87 grator 850 other_cl_type.meta_generic = Void
88 grator 18 end;
89    
90     instantiation_in (other: GEN_TYPE_I): CL_TYPE_I is
91     -- Instantiation of Current in context of `other'
92 grator 282 require else
93     True
94 grator 18 do
95     Result := Current;
96     end;
97    
98     description: ATTR_DESC is
99     -- Type description for skeletons
100     local
101     exp: EXPANDED_DESC;
102 grator 485 types: TYPE_LIST;
103     pos: INTEGER;
104     do
105 grator 18 if is_expanded then
106     !!exp;
107     is_expanded := False;
108    
109 grator 485 types := base_class.types;
110 grator 541 pos := types.index;
111 grator 605 types.compare_references
112 grator 485 types.search (Current);
113 grator 18 exp.set_class_type (types.item);
114 grator 541 types.go_i_th (pos);
115 grator 18
116     is_expanded := True;
117     Result := exp;
118 xavierl 4623 elseif is_separate then
119     -- FIXME
120     Result := c_type.description
121 grator 18 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 guusl 3636 append_signature (st: STRUCTURED_TEXT) is
133 grator 552 do
134     if is_expanded then
135 guusl 3636 st.add_string ("expanded ");
136 xavierl 4623 elseif is_separate then
137     st.add_string ("separate ");
138 grator 552 end;
139 guusl 3636 base_class.e_class.append_signature (st)
140 grator 552 end;
141    
142 grator 605 dump (file: FILE) is
143 grator 1323 local
144     s: STRING
145 grator 18 do
146     if is_expanded then
147     file.putstring ("expanded ");
148 xavierl 4623 elseif is_separate then
149     file.putstring ("separate ");
150 grator 18 end;
151 grator 1323 s := clone (base_class.class_name);
152     s.to_upper;
153     file.putstring (s);
154 grator 18 end;
155    
156     associated_class_type: CLASS_TYPE is
157     -- Associated class type
158     local
159 grator 485 types: TYPE_LIST;
160     pos: INTEGER;
161     do
162     if is_expanded then
163     Result := associated_expanded_class_type
164 xavierl 4623 elseif is_separate then
165     Result := associated_separate_class_type
166 grator 485 else
167     types := base_class.types;
168 grator 541 pos := types.index;
169 grator 605 types.compare_references
170 grator 485 types.search (Current);
171     Result := types.item;
172 grator 541 types.go_i_th (pos);
173 grator 485 end;
174     end;
175 grator 18
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 grator 485 Result := associated_class_type;
183     is_expanded := true;
184 grator 18 end;
185    
186 xavierl 4623 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 grator 18 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 grator 621 generate_cecil_value (file: INDENT_FILE) is
209 grator 18 -- Generate cecil value
210     do
211 xavierl 4623 -- FIXME????: separate
212 grator 18 if not is_expanded then
213     file.putstring ("SK_DTYPE");
214     else
215     file.putstring ("SK_EXP + (uint32) ");
216 ericb 3652 file.putint (base_id.id);
217 grator 18 end;
218     end;
219    
220     hash_code: INTEGER is
221     -- Hash code for current type
222     do
223 ericb 3652 Result := Other_code + base_id.hash_code
224 grator 18 end;
225    
226     sk_value: INTEGER is
227     -- Generate SK value associated to the current type.
228     do
229 xavierl 4623 -- FIXME????: separate
230 grator 18 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 grator 508 cecil_value: INTEGER is
240     do
241 xavierl 4623 -- FIXME????: separate
242 grator 508 if not is_expanded then
243     Result := Sk_dtype
244     else
245 ericb 3652 Result := Sk_exp + base_id.id
246 grator 508 end;
247     end;
248    
249 grator 930 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 grator 1204 feature
264    
265     type_a: CL_TYPE_A is
266     do
267     !!Result
268     Result.set_is_expanded (is_expanded);
269 xavierl 4623 Result.set_is_separate (is_separate);
270 ericb 3652 Result.set_base_class_id (base_id)
271 grator 1204 end
272    
273 grator 18 end

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23