/[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 69629 - (show annotations)
Mon Jul 23 21:36:18 2007 UTC (12 years, 5 months ago) by manus
File size: 8397 byte(s)
Creation of CAT_mono branch to implement variant/invariant proposal
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, 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: BOOLEAN; is_sep: 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_expanded then
178 Result.set_expanded_class_mark
179 end
180 end
181
182 feature -- Status report
183
184 is_native_array: BOOLEAN is True
185 -- Is the class special ?
186
187 feature {NONE}
188
189 make_signature: DYN_PROC_I is
190 -- Required signature for feature `make' of class NATIVE_ARRAY.
191 local
192 args: FEAT_ARG
193 do
194 create args.make (1)
195 args.put_i_th (Integer_type, 1)
196 create Result
197 Result.set_arguments (args)
198 Result.set_feature_name_id ({PREDEFINED_NAMES}.make_name_id, 0)
199 end
200
201 count_signature: DYN_FUNC_I is
202 -- Required signature for feature `count' of class NATIVE_ARRAY.
203 local
204 args: FEAT_ARG
205 do
206 create args.make (0)
207 create Result
208 Result.set_arguments (args)
209 Result.set_type (Integer_type, 0)
210 Result.set_feature_name_id ({PREDEFINED_NAMES}.count_name_id, 0)
211 ensure
212 item_signature_not_void: Result /= Void
213 end
214
215 item_signature: DYN_FUNC_I is
216 -- Required signature for feature `item' of class NATIVE_ARRAY.
217 local
218 args: FEAT_ARG
219 f: FORMAL_A
220 do
221 create args.make (1)
222 args.put_i_th (Integer_type, 1)
223 create Result
224 Result.set_arguments (args)
225 create f.make (False, False, 1)
226 Result.set_type (f, 0)
227 Result.set_feature_name_id ({PREDEFINED_NAMES}.item_name_id, 0)
228 ensure
229 item_signature_not_void: Result /= Void
230 end
231
232 infix_at_signature: DYN_FUNC_I is
233 -- Required signature for feature `infix "@"' of class NATIVE_ARRAY.
234 local
235 args: FEAT_ARG
236 f: FORMAL_A
237 do
238 create args.make (1)
239 args.put_i_th (Integer_type, 1)
240 create Result
241 Result.set_arguments (args)
242 create f.make (False, False, 1)
243 Result.set_type (f, 0)
244 Result.set_feature_name_id ({PREDEFINED_NAMES}.infix_at_name_id, 0)
245 ensure
246 item_signature_not_void: Result /= Void
247 end
248
249 put_signature: DYN_PROC_I is
250 -- Required signature for feature `put' of class NATIVE_ARRAY.
251 local
252 args: FEAT_ARG
253 f: FORMAL_A
254 do
255 create f.make (False, False, 1)
256 create args.make (2)
257 args.put_i_th (Integer_type, 1)
258 args.put_i_th (f, 2)
259 create Result
260 Result.set_arguments (args)
261 Result.set_feature_name_id ({PREDEFINED_NAMES}.put_name_id, 0)
262 ensure
263 put_signature_not_void: Result /= Void
264 end
265
266 indexing
267 copyright: "Copyright (c) 1984-2006, Eiffel Software"
268 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
269 licensing_options: "http://www.eiffel.com/licensing"
270 copying: "[
271 This file is part of Eiffel Software's Eiffel Development Environment.
272
273 Eiffel Software's Eiffel Development Environment is free
274 software; you can redistribute it and/or modify it under
275 the terms of the GNU General Public License as published
276 by the Free Software Foundation, version 2 of the License
277 (available at the URL listed under "license" above).
278
279 Eiffel Software's Eiffel Development Environment is
280 distributed in the hope that it will be useful, but
281 WITHOUT ANY WARRANTY; without even the implied warranty
282 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
283 See the GNU General Public License for more details.
284
285 You should have received a copy of the GNU General Public
286 License along with Eiffel Software's Eiffel Development
287 Environment; if not, write to the Free Software Foundation,
288 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
289 ]"
290 source: "[
291 Eiffel Software
292 356 Storke Road, Goleta, CA 93117 USA
293 Telephone 805-685-1006, Fax 805-685-6869
294 Website http://www.eiffel.com
295 Customer support http://support.eiffel.com
296 ]"
297
298 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