/[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 10140 - (hide annotations)
Thu May 14 00:28:06 1998 UTC (21 years, 9 months ago) by manus
Original Path: trunk/Src/bench/Eiffel/eiffel/genericity/cl_type_i.e
File size: 5860 byte(s)
Changes to reflect the new TYPE_LIST class.

The previous implementation seems to believe that the old `search' feature
from TYPE_LIST always succeed. Now, I added a check for this assumption
and if we did not find anything I return a Void element. But I'm not sure about
it.

1 grator 18 -- Type class
2    
3     class CL_TYPE_I
4    
5     inherit
6     TYPE_I
7     redefine
8     is_reference,
9     is_expanded,
10 xavierl 4623 is_separate,
11 grator 236 is_valid,
12 grator 18 same_as,
13     c_type,
14 grator 930 instantiation_in,
15     conforms_to_array
16 grator 18 end
17    
18     feature
19    
20 manus 9655 base_id: CLASS_ID
21 grator 18 -- Base class id of the type class
22    
23 manus 9655 is_expanded: BOOLEAN
24 manus 8805 -- Is the type expanded?
25 grator 18
26 manus 9655 is_separate: BOOLEAN
27 manus 8805 -- Is the type separate?
28 xavierl 4623
29 ericb 3652 set_base_id (c: CLASS_ID) is
30 grator 18 -- Assign `c' to `base_id'.
31     do
32 manus 9655 base_id := c
33     end
34 grator 18
35     set_is_expanded (b: BOOLEAN) is
36     -- Assign `b' to `is_expanded'.
37     do
38 manus 9655 is_expanded := b
39     end
40 grator 18
41 xavierl 4623 set_is_separate (b: BOOLEAN) is
42     -- Assign `b' to `is_separate'.
43     do
44 manus 9655 is_separate := b
45     end
46 xavierl 4623
47 grator 18 meta_generic: META_GENERIC is
48     -- Meta generic array describing the type class
49     do
50     -- No meta generic in non-generic type
51 manus 9655 end
52 grator 18
53     base_class: CLASS_C is
54     -- Base class associated to the class type
55     do
56 manus 9655 Result := System.class_of_id (base_id)
57     end
58 grator 18
59 grator 236 is_valid: BOOLEAN is
60     -- Is the base class still in the system ?
61     do
62 manus 9655 Result := base_class /= Void
63     end
64 grator 236
65 grator 18 is_reference: BOOLEAN is
66     -- Is the type a reference type ?
67     do
68 manus 9655 Result := not is_expanded
69 grator 18 end;
70    
71     same_as (other: TYPE_I): BOOLEAN is
72     -- Is `other' equal to Current ?
73     local
74 manus 9655 other_cl_type: CL_TYPE_I
75 grator 18 do
76 manus 9655 other_cl_type ?= other
77 manus 8805 Result := other_cl_type /= Void -- FIXME
78     and then equal (other_cl_type.base_id, base_id)
79     and then other_cl_type.is_expanded = is_expanded
80     and then other_cl_type.is_separate = is_separate
81     and then other_cl_type.meta_generic = Void
82 manus 9655 end
83 grator 18
84     instantiation_in (other: GEN_TYPE_I): CL_TYPE_I is
85     -- Instantiation of Current in context of `other'
86 grator 282 require else
87     True
88 grator 18 do
89 manus 9655 Result := Current
90     end
91 grator 18
92     description: ATTR_DESC is
93     -- Type description for skeletons
94     local
95 michaels 7681 exp: EXPANDED_DESC
96     types: TYPE_LIST
97     ref: REFERENCE_DESC
98 grator 485 do
99 grator 18 if is_expanded then
100 manus 10140 !! exp
101 manus 9655 is_expanded := False
102 grator 18
103 manus 9655 types := base_class.types
104 grator 18
105 manus 10140 check
106     --| The type should be present
107     has_type: types.has_type (Current)
108     end
109    
110     if types.has_type (Current) then
111     exp.set_class_type (types.found_item)
112     end
113    
114 manus 9655 is_expanded := True
115     Result := exp
116 xavierl 4623 elseif is_separate then
117     -- FIXME
118     Result := c_type.description
119 grator 18 else
120 manus 9655 Result := c_type.description
121     end
122 michaels 7681
123     ref ?= Result
124     if ref /= Void then
125     ref.set_class_type_i (Current)
126     end
127 manus 9655 end
128 grator 18
129     c_type: TYPE_C is
130     -- Associated C type
131     do
132 manus 9655 Result := Reference_c_type
133     end
134 grator 18
135 guusl 3636 append_signature (st: STRUCTURED_TEXT) is
136 grator 552 do
137     if is_expanded then
138 manus 9655 st.add_string ("expanded ")
139 xavierl 4623 elseif is_separate then
140 manus 9655 st.add_string ("separate ")
141     end
142 dinov 6562 base_class.append_signature (st)
143 manus 9655 end
144 grator 552
145 grator 605 dump (file: FILE) is
146 grator 1323 local
147     s: STRING
148 grator 18 do
149     if is_expanded then
150 manus 9655 file.putstring ("expanded ")
151 xavierl 4623 elseif is_separate then
152 manus 9655 file.putstring ("separate ")
153     end
154     s := clone (base_class.name)
155     s.to_upper
156     file.putstring (s)
157     end
158 grator 18
159 michaels 7681 has_associated_class_type: BOOLEAN is
160     -- Has `Current' an associated class type?
161     local
162     types : TYPE_LIST
163     do
164     types := base_class.types
165    
166     if is_expanded then
167     is_expanded := false
168     Result := types.has_type (Current)
169     is_expanded := true
170     elseif is_separate then
171     is_separate := false
172     Result := types.has_type (Current)
173     is_separate := true
174     else
175     Result := types.has_type (Current)
176     end
177     end
178    
179 grator 18 associated_class_type: CLASS_TYPE is
180     -- Associated class type
181 michaels 7681 require
182     has: has_associated_class_type
183 grator 18 local
184 manus 9655 types: TYPE_LIST
185 grator 485 do
186     if is_expanded then
187     Result := associated_expanded_class_type
188 xavierl 4623 elseif is_separate then
189     Result := associated_separate_class_type
190 grator 485 else
191 manus 9655 types := base_class.types
192 manus 10140
193     check
194     --| The type should be present
195     has_type: types.has_type (Current)
196     end
197    
198     if types.has_type (Current) then
199     Result := types.found_item
200     end
201 manus 9655 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 manus 9655 is_expanded := false
211     Result := associated_class_type
212     is_expanded := true
213     end
214 grator 18
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 manus 9655 is_separate := false
222     Result := associated_class_type
223     is_separate := true
224     end
225 xavierl 4623
226 grator 18 type_id: INTEGER is
227     -- Type id of the correponding class type
228     do
229 manus 9655 Result := associated_class_type.type_id
230     end
231 grator 18
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 manus 9655 end
237 grator 18
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 manus 9655 file.putstring ("SK_DTYPE")
244 grator 18 else
245 manus 9655 file.putstring ("SK_EXP + (uint32) ")
246     file.putint (base_id.id)
247     end
248     end
249 grator 18
250     hash_code: INTEGER is
251     -- Hash code for current type
252     do
253 ericb 3652 Result := Other_code + base_id.hash_code
254 manus 9655 end
255 grator 18
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 manus 9655 Result := Sk_ref + (type_id - 1)
262 grator 18 else
263 manus 9655 is_expanded := False
264     Result := Sk_exp + (type_id - 1)
265     is_expanded := True
266     end
267     end
268 grator 18
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 manus 9655 end
277     end
278 grator 508
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 manus 9655 end
285 grator 930
286     feature {NONE} -- Array optimization
287    
288     array_class_c: CLASS_C is
289     once
290     Result := System.array_class.compiled_class
291 manus 9655 end
292 grator 930
293 grator 1204 feature
294    
295     type_a: CL_TYPE_A is
296     do
297     !!Result
298 manus 9655 Result.set_is_expanded (is_expanded)
299     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