/[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 8805 - (hide 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 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 manus 8805 -- Is the type expanded?
26 grator 18
27 xavierl 4623 is_separate: BOOLEAN;
28 manus 8805 -- Is the type separate?
29 xavierl 4623
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 manus 8805 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 grator 18 end;
84    
85     instantiation_in (other: GEN_TYPE_I): CL_TYPE_I is
86     -- Instantiation of Current in context of `other'
87 grator 282 require else
88     True
89 grator 18 do
90     Result := Current;
91     end;
92    
93     description: ATTR_DESC is
94     -- Type description for skeletons
95     local
96 michaels 7681 exp: EXPANDED_DESC
97     types: TYPE_LIST
98     pos: INTEGER
99     ref: REFERENCE_DESC
100 grator 485 do
101 grator 18 if is_expanded then
102     !!exp;
103     is_expanded := False;
104    
105 grator 485 types := base_class.types;
106 grator 541 pos := types.index;
107 grator 605 types.compare_references
108 grator 485 types.search (Current);
109 grator 18 exp.set_class_type (types.item);
110 grator 541 types.go_i_th (pos);
111 grator 18
112     is_expanded := True;
113     Result := exp;
114 xavierl 4623 elseif is_separate then
115     -- FIXME
116     Result := c_type.description
117 grator 18 else
118     Result := c_type.description;
119     end;
120 michaels 7681
121     ref ?= Result
122     if ref /= Void then
123     ref.set_class_type_i (Current)
124     end
125 grator 18 end;
126    
127     c_type: TYPE_C is
128     -- Associated C type
129     do
130     Result := Reference_c_type;
131     end;
132    
133 guusl 3636 append_signature (st: STRUCTURED_TEXT) is
134 grator 552 do
135     if is_expanded then
136 guusl 3636 st.add_string ("expanded ");
137 xavierl 4623 elseif is_separate then
138     st.add_string ("separate ");
139 grator 552 end;
140 dinov 6562 base_class.append_signature (st)
141 grator 552 end;
142    
143 grator 605 dump (file: FILE) is
144 grator 1323 local
145     s: STRING
146 grator 18 do
147     if is_expanded then
148     file.putstring ("expanded ");
149 xavierl 4623 elseif is_separate then
150     file.putstring ("separate ");
151 grator 18 end;
152 dinov 6562 s := clone (base_class.name);
153 grator 1323 s.to_upper;
154     file.putstring (s);
155 grator 18 end;
156    
157 michaels 7681 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 grator 18 associated_class_type: CLASS_TYPE is
178     -- Associated class type
179 michaels 7681 require
180     has: has_associated_class_type
181 grator 18 local
182 grator 485 types: TYPE_LIST;
183     pos: INTEGER;
184     do
185     if is_expanded then
186     Result := associated_expanded_class_type
187 xavierl 4623 elseif is_separate then
188     Result := associated_separate_class_type
189 grator 485 else
190     types := base_class.types;
191 grator 541 pos := types.index;
192 grator 605 types.compare_references
193 grator 485 types.search (Current);
194     Result := types.item;
195 grator 541 types.go_i_th (pos);
196 grator 485 end;
197     end;
198 grator 18
199     associated_expanded_class_type: CLASS_TYPE is
200     -- Associated expanded class type
201     require
202     is_expanded: is_expanded
203 michaels 7681 has: has_associated_class_type
204 grator 18 do
205     is_expanded := false;
206 grator 485 Result := associated_class_type;
207     is_expanded := true;
208 grator 18 end;
209    
210 xavierl 4623 associated_separate_class_type: CLASS_TYPE is
211     -- Associated separate class type
212     require
213     is_separate: is_separate
214 michaels 7681 has: has_associated_class_type
215 xavierl 4623 do
216     is_separate := false;
217     Result := associated_class_type;
218     is_separate := true;
219     end;
220    
221 grator 18 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 grator 621 generate_cecil_value (file: INDENT_FILE) is
234 grator 18 -- Generate cecil value
235     do
236 xavierl 4623 -- FIXME????: separate
237 grator 18 if not is_expanded then
238     file.putstring ("SK_DTYPE");
239     else
240     file.putstring ("SK_EXP + (uint32) ");
241 ericb 3652 file.putint (base_id.id);
242 grator 18 end;
243     end;
244    
245     hash_code: INTEGER is
246     -- Hash code for current type
247     do
248 ericb 3652 Result := Other_code + base_id.hash_code
249 grator 18 end;
250    
251     sk_value: INTEGER is
252     -- Generate SK value associated to the current type.
253     do
254 xavierl 4623 -- FIXME????: separate
255 grator 18 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 grator 508 cecil_value: INTEGER is
265     do
266 xavierl 4623 -- FIXME????: separate
267 grator 508 if not is_expanded then
268     Result := Sk_dtype
269     else
270 ericb 3652 Result := Sk_exp + base_id.id
271 grator 508 end;
272     end;
273    
274 grator 930 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 grator 1204 feature
289    
290     type_a: CL_TYPE_A is
291     do
292     !!Result
293     Result.set_is_expanded (is_expanded);
294 xavierl 4623 Result.set_is_separate (is_separate);
295 ericb 3652 Result.set_base_class_id (base_id)
296 grator 1204 end
297    
298 grator 18 end

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23