/[eiffelstudio]/branches/CAT_mono/Src/Eiffel/eiffel/interface/native_array_b.e
ViewVC logotype

Contents of /branches/CAT_mono/Src/Eiffel/eiffel/interface/native_array_b.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 69868 - (show annotations)
Fri Aug 3 22:28:26 2007 UTC (12 years, 4 months ago) by martins
File size: 8617 byte(s)
enabled more types to store monomorph information
1 indexing
2 description: "Compiled class NATIVE_ARRAY"
3 legal: "See notice at end of class."
4 status: "See notice at end of class."
5 date: "$Date$"
6 revision: "$Revision$"
7
8 class NATIVE_ARRAY_B
9
10 inherit
11 EIFFEL_CLASS_C
12 redefine
13 check_validity, new_type, is_native_array, partial_actual_type, actual_type
14 end
15
16 SPECIAL_CONST
17
18 create
19 make
20
21 feature -- Validity
22
23 check_validity is
24 -- Check validity of class ARRAY
25 local
26 error: BOOLEAN
27 special_error: SPECIAL_ERROR
28 l_feat_tbl: like feature_table
29 l_feat: FEATURE_I
30 done: BOOLEAN
31 do
32 l_feat_tbl := feature_table
33 -- First check if current class has one formal generic parameter
34 if (generics = Void) or else generics.count /= 1 then
35 create special_error.make (native_array_case_1, Current)
36 Error_handler.insert_error (special_error)
37 end
38
39 -- Second, check if there is only one creation procedure
40 -- having only one integer argument
41 error := creators = Void
42 if not error then
43 from
44 creators.start
45 until
46 done or else creators.after
47 loop
48 l_feat := l_feat_tbl.item (creators.key_for_iteration)
49 if
50 l_feat.feature_name_id = names_heap.make_name_id and then
51 l_feat.same_signature (make_signature)
52 then
53 done := True
54 else
55 creators.forth
56 end
57 end
58 error := not done
59 end
60 if error then
61 create special_error.make (native_array_case_2, Current)
62 Error_handler.insert_error (special_error)
63 end
64
65 -- Third, check if class has a feature item and infix "@" (INTEGER): G#1
66 l_feat := l_feat_tbl.item_id ({PREDEFINED_NAMES}.item_name_id)
67 if
68 l_feat = Void
69 or else not (l_feat.written_in = class_id)
70 or else not l_feat.same_signature (item_signature)
71 then
72 create special_error.make (native_array_case_3, Current)
73 Error_handler.insert_error (special_error)
74 end
75
76 l_feat := l_feat_tbl.item_id ({PREDEFINED_NAMES}.infix_at_name_id)
77 if
78 l_feat = Void
79 or else not (l_feat.written_in = class_id)
80 or else not l_feat.same_signature (infix_at_signature)
81 then
82 create special_error.make (native_array_case_4, Current)
83 Error_handler.insert_error (special_error)
84 end
85
86 -- Fourth, check if class has a feature put (G#1, INTEGER)
87 l_feat := l_feat_tbl.item_id ({PREDEFINED_NAMES}.put_name_id)
88 if
89 l_feat = Void
90 or else not (l_feat.written_in = class_id)
91 or else not l_feat.same_signature (put_signature)
92 then
93 create special_error.make (native_array_case_5, Current)
94 Error_handler.insert_error (special_error)
95 end
96
97 -- Fourth, check if class has a feature count, INTEGER)
98 l_feat := l_feat_tbl.item_id ({PREDEFINED_NAMES}.count_name_id)
99 if
100 l_feat = Void
101 or else not (l_feat.written_in = class_id)
102 or else not l_feat.same_signature (count_signature)
103 then
104 create special_error.make (native_array_case_6, Current)
105 Error_handler.insert_error (special_error)
106 end
107 end
108
109 feature -- Generic derivation
110
111 new_type (data: CL_TYPE_I): NATIVE_ARRAY_CLASS_TYPE is
112 -- New class type for class NATIVE_ARRAY.
113 local
114 l_data: NATIVE_ARRAY_TYPE_I
115 do
116 l_data ?= data
117 check
118 l_data_not_void: l_data /= Void
119 end
120 create Result.make (l_data)
121 if already_compiled then
122 -- Melt all the code written in the associated class of the new class type
123 melt_all
124 end
125 end
126
127 feature -- Actual class type
128
129 actual_type: CL_TYPE_A is
130 -- Actual type of the class
131 local
132 i, nb: INTEGER
133 actual_generic: ARRAY [FORMAL_A]
134 formal: FORMAL_A
135 l_formal_dec: FORMAL_DEC_AS
136 do
137 if generics = Void then
138 create Result.make (class_id)
139 else
140 from
141 i := 1
142 nb := generics.count
143 create actual_generic.make (1, nb)
144 create {NATIVE_ARRAY_TYPE_A} Result.make (class_id, actual_generic)
145 until
146 i > nb
147 loop
148 l_formal_dec := generics.i_th (i)
149 create formal.make (l_formal_dec.is_reference, l_formal_dec.is_expanded, l_formal_dec.is_monomorph, i)
150 actual_generic.put (formal, i)
151 i := i + 1
152 end
153 end
154 -- Note that NATIVE_ARRAY is not expanded by default
155 end
156
157 feature {CLASS_TYPE_AS} -- Actual class type
158
159 partial_actual_type (gen: ARRAY [TYPE_A]; is_exp, is_sep, is_mono: BOOLEAN): CL_TYPE_A is
160 -- Actual type of `current depending on the context in which it is declared
161 -- in CLASS_TYPE_AS. That is to say, it could have generics `gen' but not
162 -- be a generic class. It simplifies creation of `CL_TYPE_A' instances in
163 -- CLASS_TYPE_AS when trying to resolve types, by using dynamic binding
164 -- rather than if statements.
165 do
166 if gen /= Void then
167 create {NATIVE_ARRAY_TYPE_A} Result.make (class_id, gen)
168 else
169 create Result.make (class_id)
170 end
171 -- Note that NATIVE_ARRAY is not expanded by default
172 if is_exp then
173 Result.set_expanded_mark
174 elseif is_sep then
175 Result.set_separate_mark
176 end
177 if is_mono then
178 Result.set_monomorph_mark
179 end
180 if is_expanded then
181 Result.set_expanded_class_mark
182 end
183 end
184
185 feature -- Status report
186
187 is_native_array: BOOLEAN is True
188 -- Is the class special ?
189
190 feature {NONE}
191
192 make_signature: DYN_PROC_I is
193 -- Required signature for feature `make' of class NATIVE_ARRAY.
194 local
195 args: FEAT_ARG
196 do
197 create args.make (1)
198 args.put_i_th (Integer_type, 1)
199 create Result
200 Result.set_arguments (args)
201 Result.set_feature_name_id ({PREDEFINED_NAMES}.make_name_id, 0)
202 end
203
204 count_signature: DYN_FUNC_I is
205 -- Required signature for feature `count' of class NATIVE_ARRAY.
206 local
207 args: FEAT_ARG
208 do
209 create args.make (0)
210 create Result
211 Result.set_arguments (args)
212 Result.set_type (Integer_type, 0)
213 Result.set_feature_name_id ({PREDEFINED_NAMES}.count_name_id, 0)
214 ensure
215 item_signature_not_void: Result /= Void
216 end
217
218 item_signature: DYN_FUNC_I is
219 -- Required signature for feature `item' of class NATIVE_ARRAY.
220 local
221 args: FEAT_ARG
222 f: FORMAL_A
223 do
224 create args.make (1)
225 args.put_i_th (Integer_type, 1)
226 create Result
227 Result.set_arguments (args)
228 -- TODO: is polymorph ok?
229 create f.make (False, False, False, 1)
230 Result.set_type (f, 0)
231 Result.set_feature_name_id ({PREDEFINED_NAMES}.item_name_id, 0)
232 ensure
233 item_signature_not_void: Result /= Void
234 end
235
236 infix_at_signature: DYN_FUNC_I is
237 -- Required signature for feature `infix "@"' of class NATIVE_ARRAY.
238 local
239 args: FEAT_ARG
240 f: FORMAL_A
241 do
242 create args.make (1)
243 args.put_i_th (Integer_type, 1)
244 create Result
245 Result.set_arguments (args)
246 -- TODO: is polymorph ok? (3rd False)
247 create f.make (False, False, False, 1)
248 Result.set_type (f, 0)
249 Result.set_feature_name_id ({PREDEFINED_NAMES}.infix_at_name_id, 0)
250 ensure
251 item_signature_not_void: Result /= Void
252 end
253
254 put_signature: DYN_PROC_I is
255 -- Required signature for feature `put' of class NATIVE_ARRAY.
256 local
257 args: FEAT_ARG
258 f: FORMAL_A
259 do
260 -- TODO: should it be monomorph or not?
261 create f.make (False, False, False, 1)
262 create args.make (2)
263 args.put_i_th (Integer_type, 1)
264 args.put_i_th (f, 2)
265 create Result
266 Result.set_arguments (args)
267 Result.set_feature_name_id ({PREDEFINED_NAMES}.put_name_id, 0)
268 ensure
269 put_signature_not_void: Result /= Void
270 end
271
272 indexing
273 copyright: "Copyright (c) 1984-2006, Eiffel Software"
274 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
275 licensing_options: "http://www.eiffel.com/licensing"
276 copying: "[
277 This file is part of Eiffel Software's Eiffel Development Environment.
278
279 Eiffel Software's Eiffel Development Environment is free
280 software; you can redistribute it and/or modify it under
281 the terms of the GNU General Public License as published
282 by the Free Software Foundation, version 2 of the License
283 (available at the URL listed under "license" above).
284
285 Eiffel Software's Eiffel Development Environment is
286 distributed in the hope that it will be useful, but
287 WITHOUT ANY WARRANTY; without even the implied warranty
288 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
289 See the GNU General Public License for more details.
290
291 You should have received a copy of the GNU General Public
292 License along with Eiffel Software's Eiffel Development
293 Environment; if not, write to the Free Software Foundation,
294 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
295 ]"
296 source: "[
297 Eiffel Software
298 356 Storke Road, Goleta, CA 93117 USA
299 Telephone 805-685-1006, Fax 805-685-6869
300 Website http://www.eiffel.com
301 Customer support http://support.eiffel.com
302 ]"
303
304 end -- end of NATIVE_ARRAY_B

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23