/[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 10196 - (hide annotations)
Fri May 22 01:22:10 1998 UTC (21 years, 9 months ago) by manus
Original Path: trunk/Src/bench/Eiffel/eiffel/genericity/cl_type_i.e
File size: 5536 byte(s)
Changed former `search_item' into `conservative_search_item' which preserves
cursor's position and add `search_item' which does the same thing as
conservative_search_item' without saving cursor's position

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23