/[eiffelstudio]/branches/CAT_mono/Src/Eiffel/eiffel/genericity/cl_type_i.e
ViewVC logotype

Contents of /branches/CAT_mono/Src/Eiffel/eiffel/genericity/cl_type_i.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 10183 - (show annotations)
Thu May 21 23:39:12 1998 UTC (21 years, 9 months ago) by manus
Original Path: trunk/Src/bench/Eiffel/eiffel/genericity/cl_type_i.e
File size: 5510 byte(s)
Fixed one bug concerning the search algorithm used in `description' and in
`associated_class_type', now we are using the `search_item' function from
TYPE_LIST to get back to the old behavior. The problem is that some times
a search is not successful and in this case, we should always return a non-
void element (This has been taking care by `search_item'.

1 -- Type class
2
3 class CL_TYPE_I
4
5 inherit
6 TYPE_I
7 redefine
8 is_reference,
9 is_expanded,
10 is_separate,
11 is_valid,
12 same_as,
13 c_type,
14 instantiation_in,
15 conforms_to_array
16 end
17
18 feature
19
20 base_id: CLASS_ID
21 -- Base class id of the type class
22
23 is_expanded: BOOLEAN
24 -- Is the type expanded?
25
26 is_separate: BOOLEAN
27 -- Is the type separate?
28
29 set_base_id (c: CLASS_ID) is
30 -- Assign `c' to `base_id'.
31 do
32 base_id := c
33 end
34
35 set_is_expanded (b: BOOLEAN) is
36 -- Assign `b' to `is_expanded'.
37 do
38 is_expanded := b
39 end
40
41 set_is_separate (b: BOOLEAN) is
42 -- Assign `b' to `is_separate'.
43 do
44 is_separate := b
45 end
46
47 meta_generic: META_GENERIC is
48 -- Meta generic array describing the type class
49 do
50 -- No meta generic in non-generic type
51 end
52
53 base_class: CLASS_C is
54 -- Base class associated to the class type
55 do
56 Result := System.class_of_id (base_id)
57 end
58
59 is_valid: BOOLEAN is
60 -- Is the base class still in the system ?
61 do
62 Result := base_class /= Void
63 end
64
65 is_reference: BOOLEAN is
66 -- Is the type a reference type ?
67 do
68 Result := not is_expanded
69 end;
70
71 same_as (other: TYPE_I): BOOLEAN is
72 -- Is `other' equal to Current ?
73 local
74 other_cl_type: CL_TYPE_I
75 do
76 other_cl_type ?= other
77 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 end
83
84 instantiation_in (other: GEN_TYPE_I): CL_TYPE_I is
85 -- Instantiation of Current in context of `other'
86 require else
87 True
88 do
89 Result := Current
90 end
91
92 description: ATTR_DESC is
93 -- Type description for skeletons
94 local
95 exp: EXPANDED_DESC
96 ref: REFERENCE_DESC
97 do
98 if is_expanded then
99 !! exp
100 is_expanded := False
101 exp.set_class_type (base_class.types.search_item (Current))
102 is_expanded := True
103 Result := exp
104 elseif is_separate then
105 -- FIXME
106 Result := c_type.description
107 else
108 Result := c_type.description
109 end
110
111 ref ?= Result
112 if ref /= Void then
113 ref.set_class_type_i (Current)
114 end
115 end
116
117 c_type: TYPE_C is
118 -- Associated C type
119 do
120 Result := Reference_c_type
121 end
122
123 append_signature (st: STRUCTURED_TEXT) is
124 do
125 if is_expanded then
126 st.add_string ("expanded ")
127 elseif is_separate then
128 st.add_string ("separate ")
129 end
130 base_class.append_signature (st)
131 end
132
133 dump (file: FILE) is
134 local
135 s: STRING
136 do
137 if is_expanded then
138 file.putstring ("expanded ")
139 elseif is_separate then
140 file.putstring ("separate ")
141 end
142 s := clone (base_class.name)
143 s.to_upper
144 file.putstring (s)
145 end
146
147 has_associated_class_type: BOOLEAN is
148 -- Has `Current' an associated class type?
149 do
150 if is_expanded then
151 is_expanded := false
152 Result := base_class.types.has_type (Current)
153 is_expanded := true
154 elseif is_separate then
155 is_separate := false
156 Result := base_class.types.has_type (Current)
157 is_separate := true
158 else
159 Result := base_class.types.has_type (Current)
160 end
161 end
162
163 associated_class_type: CLASS_TYPE is
164 -- Associated class type
165 require
166 has: has_associated_class_type
167 local
168 types: TYPE_LIST
169 do
170 if is_expanded then
171 Result := associated_expanded_class_type
172 elseif is_separate then
173 Result := associated_separate_class_type
174 else
175 Result := base_class.types.search_item (Current)
176 end
177 end
178
179 associated_expanded_class_type: CLASS_TYPE is
180 -- Associated expanded class type
181 require
182 is_expanded: is_expanded
183 has: has_associated_class_type
184 do
185 is_expanded := false
186 Result := associated_class_type
187 is_expanded := true
188 end
189
190 associated_separate_class_type: CLASS_TYPE is
191 -- Associated separate class type
192 require
193 is_separate: is_separate
194 has: has_associated_class_type
195 do
196 is_separate := false
197 Result := associated_class_type
198 is_separate := true
199 end
200
201 type_id: INTEGER is
202 -- Type id of the correponding class type
203 do
204 Result := associated_class_type.type_id
205 end
206
207 expanded_type_id: INTEGER is
208 -- Type id of the corresponding expanded class type
209 do
210 Result := associated_expanded_class_type.type_id
211 end
212
213 generate_cecil_value (file: INDENT_FILE) is
214 -- Generate cecil value
215 do
216 -- FIXME????: separate
217 if not is_expanded then
218 file.putstring ("SK_DTYPE")
219 else
220 file.putstring ("SK_EXP + (uint32) ")
221 file.putint (base_id.id)
222 end
223 end
224
225 hash_code: INTEGER is
226 -- Hash code for current type
227 do
228 Result := Other_code + base_id.hash_code
229 end
230
231 sk_value: INTEGER is
232 -- Generate SK value associated to the current type.
233 do
234 -- FIXME????: separate
235 if not is_expanded then
236 Result := Sk_ref + (type_id - 1)
237 else
238 is_expanded := False
239 Result := Sk_exp + (type_id - 1)
240 is_expanded := True
241 end
242 end
243
244 cecil_value: INTEGER is
245 do
246 -- FIXME????: separate
247 if not is_expanded then
248 Result := Sk_dtype
249 else
250 Result := Sk_exp + base_id.id
251 end
252 end
253
254 feature -- Array optimization
255
256 conforms_to_array: BOOLEAN is
257 do
258 Result := base_class.conform_to (array_class_c)
259 end
260
261 feature {NONE} -- Array optimization
262
263 array_class_c: CLASS_C is
264 once
265 Result := System.array_class.compiled_class
266 end
267
268 feature
269
270 type_a: CL_TYPE_A is
271 do
272 !!Result
273 Result.set_is_expanded (is_expanded)
274 Result.set_is_separate (is_separate)
275 Result.set_base_class_id (base_id)
276 end
277
278 end

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23