/[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 4623 - (hide 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 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 ericb 3652 equal (other_cl_type.base_id, base_id)
81 grator 18 and then
82 grator 850 other_cl_type.is_expanded = is_expanded
83     and then
84 xavierl 4623 other_cl_type.is_separate = is_separate
85     and then
86 grator 850 other_cl_type.meta_generic = Void
87 grator 18 end;
88    
89     instantiation_in (other: GEN_TYPE_I): CL_TYPE_I is
90     -- Instantiation of Current in context of `other'
91 grator 282 require else
92     True
93 grator 18 do
94     Result := Current;
95     end;
96    
97     description: ATTR_DESC is
98     -- Type description for skeletons
99     local
100     exp: EXPANDED_DESC;
101 grator 485 types: TYPE_LIST;
102     pos: INTEGER;
103     do
104 grator 18 if is_expanded then
105     !!exp;
106     is_expanded := False;
107    
108 grator 485 types := base_class.types;
109 grator 541 pos := types.index;
110 grator 605 types.compare_references
111 grator 485 types.search (Current);
112 grator 18 exp.set_class_type (types.item);
113 grator 541 types.go_i_th (pos);
114 grator 18
115     is_expanded := True;
116     Result := exp;
117 xavierl 4623 elseif is_separate then
118     -- FIXME
119     Result := c_type.description
120 grator 18 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 guusl 3636 append_signature (st: STRUCTURED_TEXT) is
132 grator 552 do
133     if is_expanded then
134 guusl 3636 st.add_string ("expanded ");
135 xavierl 4623 elseif is_separate then
136     st.add_string ("separate ");
137 grator 552 end;
138 guusl 3636 base_class.e_class.append_signature (st)
139 grator 552 end;
140    
141 grator 605 dump (file: FILE) is
142 grator 1323 local
143     s: STRING
144 grator 18 do
145     if is_expanded then
146     file.putstring ("expanded ");
147 xavierl 4623 elseif is_separate then
148     file.putstring ("separate ");
149 grator 18 end;
150 grator 1323 s := clone (base_class.class_name);
151     s.to_upper;
152     file.putstring (s);
153 grator 18 end;
154    
155     associated_class_type: CLASS_TYPE is
156     -- Associated class type
157     local
158 grator 485 types: TYPE_LIST;
159     pos: INTEGER;
160     do
161     if is_expanded then
162     Result := associated_expanded_class_type
163 xavierl 4623 elseif is_separate then
164     Result := associated_separate_class_type
165 grator 485 else
166     types := base_class.types;
167 grator 541 pos := types.index;
168 grator 605 types.compare_references
169 grator 485 types.search (Current);
170     Result := types.item;
171 grator 541 types.go_i_th (pos);
172 grator 485 end;
173     end;
174 grator 18
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 grator 485 Result := associated_class_type;
182     is_expanded := true;
183 grator 18 end;
184    
185 xavierl 4623 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 grator 18 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 grator 621 generate_cecil_value (file: INDENT_FILE) is
208 grator 18 -- Generate cecil value
209     do
210 xavierl 4623 -- FIXME????: separate
211 grator 18 if not is_expanded then
212     file.putstring ("SK_DTYPE");
213     else
214     file.putstring ("SK_EXP + (uint32) ");
215 ericb 3652 file.putint (base_id.id);
216 grator 18 end;
217     end;
218    
219     hash_code: INTEGER is
220     -- Hash code for current type
221     do
222 ericb 3652 Result := Other_code + base_id.hash_code
223 grator 18 end;
224    
225     sk_value: INTEGER is
226     -- Generate SK value associated to the current type.
227     do
228 xavierl 4623 -- FIXME????: separate
229 grator 18 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 grator 508 cecil_value: INTEGER is
239     do
240 xavierl 4623 -- FIXME????: separate
241 grator 508 if not is_expanded then
242     Result := Sk_dtype
243     else
244 ericb 3652 Result := Sk_exp + base_id.id
245 grator 508 end;
246     end;
247    
248 grator 930 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 grator 1204 feature
263    
264     type_a: CL_TYPE_A is
265     do
266     !!Result
267     Result.set_is_expanded (is_expanded);
268 xavierl 4623 Result.set_is_separate (is_separate);
269 ericb 3652 Result.set_base_class_id (base_id)
270 grator 1204 end
271    
272 grator 18 end

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23