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