/[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 9655 - (hide annotations)
Sun Mar 15 02:15:49 1998 UTC (21 years, 11 months ago) by manus
Original Path: trunk/Src/bench/Eiffel/eiffel/genericity/cl_type_i.e
File size: 5799 byte(s)
Cosmetics
Changed somehow the interface of basic types *_I

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     pos: INTEGER
98     ref: REFERENCE_DESC
99 grator 485 do
100 grator 18 if is_expanded then
101 manus 9655 !!exp
102     is_expanded := False
103 grator 18
104 manus 9655 types := base_class.types
105     pos := types.index
106 grator 605 types.compare_references
107 manus 9655 types.search (Current)
108     exp.set_class_type (types.item)
109     types.go_i_th (pos)
110 grator 18
111 manus 9655 is_expanded := True
112     Result := exp
113 xavierl 4623 elseif is_separate then
114     -- FIXME
115     Result := c_type.description
116 grator 18 else
117 manus 9655 Result := c_type.description
118     end
119 michaels 7681
120     ref ?= Result
121     if ref /= Void then
122     ref.set_class_type_i (Current)
123     end
124 manus 9655 end
125 grator 18
126     c_type: TYPE_C is
127     -- Associated C type
128     do
129 manus 9655 Result := Reference_c_type
130     end
131 grator 18
132 guusl 3636 append_signature (st: STRUCTURED_TEXT) is
133 grator 552 do
134     if is_expanded then
135 manus 9655 st.add_string ("expanded ")
136 xavierl 4623 elseif is_separate then
137 manus 9655 st.add_string ("separate ")
138     end
139 dinov 6562 base_class.append_signature (st)
140 manus 9655 end
141 grator 552
142 grator 605 dump (file: FILE) is
143 grator 1323 local
144     s: STRING
145 grator 18 do
146     if is_expanded then
147 manus 9655 file.putstring ("expanded ")
148 xavierl 4623 elseif is_separate then
149 manus 9655 file.putstring ("separate ")
150     end
151     s := clone (base_class.name)
152     s.to_upper
153     file.putstring (s)
154     end
155 grator 18
156 michaels 7681 has_associated_class_type: BOOLEAN is
157     -- Has `Current' an associated class type?
158     local
159     types : TYPE_LIST
160     do
161     types := base_class.types
162    
163     if is_expanded then
164     is_expanded := false
165     Result := types.has_type (Current)
166     is_expanded := true
167     elseif is_separate then
168     is_separate := false
169     Result := types.has_type (Current)
170     is_separate := true
171     else
172     Result := types.has_type (Current)
173     end
174     end
175    
176 grator 18 associated_class_type: CLASS_TYPE is
177     -- Associated class type
178 michaels 7681 require
179     has: has_associated_class_type
180 grator 18 local
181 manus 9655 types: TYPE_LIST
182     pos: INTEGER
183 grator 485 do
184     if is_expanded then
185     Result := associated_expanded_class_type
186 xavierl 4623 elseif is_separate then
187     Result := associated_separate_class_type
188 grator 485 else
189 manus 9655 types := base_class.types
190     pos := types.index
191 grator 605 types.compare_references
192 manus 9655 types.search (Current)
193     Result := types.item
194     types.go_i_th (pos)
195     end
196     end
197 grator 18
198     associated_expanded_class_type: CLASS_TYPE is
199     -- Associated expanded class type
200     require
201     is_expanded: is_expanded
202 michaels 7681 has: has_associated_class_type
203 grator 18 do
204 manus 9655 is_expanded := false
205     Result := associated_class_type
206     is_expanded := true
207     end
208 grator 18
209 xavierl 4623 associated_separate_class_type: CLASS_TYPE is
210     -- Associated separate class type
211     require
212     is_separate: is_separate
213 michaels 7681 has: has_associated_class_type
214 xavierl 4623 do
215 manus 9655 is_separate := false
216     Result := associated_class_type
217     is_separate := true
218     end
219 xavierl 4623
220 grator 18 type_id: INTEGER is
221     -- Type id of the correponding class type
222     do
223 manus 9655 Result := associated_class_type.type_id
224     end
225 grator 18
226     expanded_type_id: INTEGER is
227     -- Type id of the corresponding expanded class type
228     do
229     Result := associated_expanded_class_type.type_id
230 manus 9655 end
231 grator 18
232 grator 621 generate_cecil_value (file: INDENT_FILE) is
233 grator 18 -- Generate cecil value
234     do
235 xavierl 4623 -- FIXME????: separate
236 grator 18 if not is_expanded then
237 manus 9655 file.putstring ("SK_DTYPE")
238 grator 18 else
239 manus 9655 file.putstring ("SK_EXP + (uint32) ")
240     file.putint (base_id.id)
241     end
242     end
243 grator 18
244     hash_code: INTEGER is
245     -- Hash code for current type
246     do
247 ericb 3652 Result := Other_code + base_id.hash_code
248 manus 9655 end
249 grator 18
250     sk_value: INTEGER is
251     -- Generate SK value associated to the current type.
252     do
253 xavierl 4623 -- FIXME????: separate
254 grator 18 if not is_expanded then
255 manus 9655 Result := Sk_ref + (type_id - 1)
256 grator 18 else
257 manus 9655 is_expanded := False
258     Result := Sk_exp + (type_id - 1)
259     is_expanded := True
260     end
261     end
262 grator 18
263 grator 508 cecil_value: INTEGER is
264     do
265 xavierl 4623 -- FIXME????: separate
266 grator 508 if not is_expanded then
267     Result := Sk_dtype
268     else
269 ericb 3652 Result := Sk_exp + base_id.id
270 manus 9655 end
271     end
272 grator 508
273 grator 930 feature -- Array optimization
274    
275     conforms_to_array: BOOLEAN is
276     do
277     Result := base_class.conform_to (array_class_c)
278 manus 9655 end
279 grator 930
280     feature {NONE} -- Array optimization
281    
282     array_class_c: CLASS_C is
283     once
284     Result := System.array_class.compiled_class
285 manus 9655 end
286 grator 930
287 grator 1204 feature
288    
289     type_a: CL_TYPE_A is
290     do
291     !!Result
292 manus 9655 Result.set_is_expanded (is_expanded)
293     Result.set_is_separate (is_separate)
294 ericb 3652 Result.set_base_class_id (base_id)
295 grator 1204 end
296    
297 grator 18 end

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23