/[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 7681 - (hide 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 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 michaels 7681 exp: EXPANDED_DESC
102     types: TYPE_LIST
103     pos: INTEGER
104     ref: REFERENCE_DESC
105 grator 485 do
106 grator 18 if is_expanded then
107     !!exp;
108     is_expanded := False;
109    
110 grator 485 types := base_class.types;
111 grator 541 pos := types.index;
112 grator 605 types.compare_references
113 grator 485 types.search (Current);
114 grator 18 exp.set_class_type (types.item);
115 grator 541 types.go_i_th (pos);
116 grator 18
117     is_expanded := True;
118     Result := exp;
119 xavierl 4623 elseif is_separate then
120     -- FIXME
121     Result := c_type.description
122 grator 18 else
123     Result := c_type.description;
124     end;
125 michaels 7681
126     ref ?= Result
127     if ref /= Void then
128     ref.set_class_type_i (Current)
129     end
130 grator 18 end;
131    
132     c_type: TYPE_C is
133     -- Associated C type
134     do
135     Result := Reference_c_type;
136     end;
137    
138 guusl 3636 append_signature (st: STRUCTURED_TEXT) is
139 grator 552 do
140     if is_expanded then
141 guusl 3636 st.add_string ("expanded ");
142 xavierl 4623 elseif is_separate then
143     st.add_string ("separate ");
144 grator 552 end;
145 dinov 6562 base_class.append_signature (st)
146 grator 552 end;
147    
148 grator 605 dump (file: FILE) is
149 grator 1323 local
150     s: STRING
151 grator 18 do
152     if is_expanded then
153     file.putstring ("expanded ");
154 xavierl 4623 elseif is_separate then
155     file.putstring ("separate ");
156 grator 18 end;
157 dinov 6562 s := clone (base_class.name);
158 grator 1323 s.to_upper;
159     file.putstring (s);
160 grator 18 end;
161    
162 michaels 7681 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 grator 18 associated_class_type: CLASS_TYPE is
183     -- Associated class type
184 michaels 7681 require
185     has: has_associated_class_type
186 grator 18 local
187 grator 485 types: TYPE_LIST;
188     pos: INTEGER;
189     do
190     if is_expanded then
191     Result := associated_expanded_class_type
192 xavierl 4623 elseif is_separate then
193     Result := associated_separate_class_type
194 grator 485 else
195     types := base_class.types;
196 grator 541 pos := types.index;
197 grator 605 types.compare_references
198 grator 485 types.search (Current);
199     Result := types.item;
200 grator 541 types.go_i_th (pos);
201 grator 485 end;
202     end;
203 grator 18
204     associated_expanded_class_type: CLASS_TYPE is
205     -- Associated expanded class type
206     require
207     is_expanded: is_expanded
208 michaels 7681 has: has_associated_class_type
209 grator 18 do
210     is_expanded := false;
211 grator 485 Result := associated_class_type;
212     is_expanded := true;
213 grator 18 end;
214    
215 xavierl 4623 associated_separate_class_type: CLASS_TYPE is
216     -- Associated separate class type
217     require
218     is_separate: is_separate
219 michaels 7681 has: has_associated_class_type
220 xavierl 4623 do
221     is_separate := false;
222     Result := associated_class_type;
223     is_separate := true;
224     end;
225    
226 grator 18 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 grator 621 generate_cecil_value (file: INDENT_FILE) is
239 grator 18 -- Generate cecil value
240     do
241 xavierl 4623 -- FIXME????: separate
242 grator 18 if not is_expanded then
243     file.putstring ("SK_DTYPE");
244     else
245     file.putstring ("SK_EXP + (uint32) ");
246 ericb 3652 file.putint (base_id.id);
247 grator 18 end;
248     end;
249    
250     hash_code: INTEGER is
251     -- Hash code for current type
252     do
253 ericb 3652 Result := Other_code + base_id.hash_code
254 grator 18 end;
255    
256     sk_value: INTEGER is
257     -- Generate SK value associated to the current type.
258     do
259 xavierl 4623 -- FIXME????: separate
260 grator 18 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 grator 508 cecil_value: INTEGER is
270     do
271 xavierl 4623 -- FIXME????: separate
272 grator 508 if not is_expanded then
273     Result := Sk_dtype
274     else
275 ericb 3652 Result := Sk_exp + base_id.id
276 grator 508 end;
277     end;
278    
279 grator 930 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 grator 1204 feature
294    
295     type_a: CL_TYPE_A is
296     do
297     !!Result
298     Result.set_is_expanded (is_expanded);
299 xavierl 4623 Result.set_is_separate (is_separate);
300 ericb 3652 Result.set_base_class_id (base_id)
301 grator 1204 end
302    
303 grator 18 end

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23