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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 69650 - (hide annotations)
Tue Jul 24 17:18:14 2007 UTC (12 years, 6 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 manus 28393 indexing
2     description: "Compiled class NATIVE_ARRAY"
3 manus 56535 legal: "See notice at end of class."
4     status: "See notice at end of class."
5 manus 28393 date: "$Date$"
6     revision: "$Revision$"
7    
8     class NATIVE_ARRAY_B
9    
10     inherit
11 patrickr 57781 EIFFEL_CLASS_C
12 manus 28393 redefine
13 manus 43304 check_validity, new_type, is_native_array, partial_actual_type, actual_type
14 manus 28393 end
15 manus 33851
16     SPECIAL_CONST
17 alexk 56011
18 julieng 37693 create
19 manus 28393 make
20 alexk 56011
21 manus 33851 feature -- Validity
22 manus 28393
23     check_validity is
24 manus 33851 -- Check validity of class ARRAY
25     local
26 manus 33880 error: BOOLEAN
27 manus 33851 special_error: SPECIAL_ERROR
28     l_feat_tbl: like feature_table
29     l_feat: FEATURE_I
30     done: BOOLEAN
31 manus 28393 do
32 manus 33851 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 manus 43164 create special_error.make (native_array_case_1, Current)
36 manus 33851 Error_handler.insert_error (special_error)
37     end
38    
39 alexk 56011 -- Second, check if there is only one creation procedure
40 manus 33851 -- 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 manus 43164 l_feat.feature_name_id = names_heap.make_name_id and then
51     l_feat.same_signature (make_signature)
52 manus 33851 then
53     done := True
54     else
55     creators.forth
56     end
57     end
58     error := not done
59     end
60     if error then
61 manus 43164 create special_error.make (native_array_case_2, Current)
62 manus 33851 Error_handler.insert_error (special_error)
63     end
64    
65 manus 57371 -- Third, check if class has a feature item and infix "@" (INTEGER): G#1
66 manus 49446 l_feat := l_feat_tbl.item_id ({PREDEFINED_NAMES}.item_name_id)
67 manus 33851 if
68     l_feat = Void
69     or else not (l_feat.written_in = class_id)
70 manus 43164 or else not l_feat.same_signature (item_signature)
71 manus 33851 then
72 manus 43164 create special_error.make (native_array_case_3, Current)
73 manus 33851 Error_handler.insert_error (special_error)
74     end
75 alexk 56011
76 manus 49446 l_feat := l_feat_tbl.item_id ({PREDEFINED_NAMES}.infix_at_name_id)
77 manus 33851 if
78     l_feat = Void
79     or else not (l_feat.written_in = class_id)
80 manus 43164 or else not l_feat.same_signature (infix_at_signature)
81 manus 33851 then
82 manus 43164 create special_error.make (native_array_case_4, Current)
83 manus 33851 Error_handler.insert_error (special_error)
84     end
85 alexk 56011
86 manus 57371 -- Fourth, check if class has a feature put (G#1, INTEGER)
87 manus 49446 l_feat := l_feat_tbl.item_id ({PREDEFINED_NAMES}.put_name_id)
88 manus 33851 if
89     l_feat = Void
90     or else not (l_feat.written_in = class_id)
91 manus 43164 or else not l_feat.same_signature (put_signature)
92 manus 33851 then
93 manus 43164 create special_error.make (native_array_case_5, Current)
94 manus 33851 Error_handler.insert_error (special_error)
95     end
96    
97     -- Fourth, check if class has a feature count, INTEGER)
98 manus 49446 l_feat := l_feat_tbl.item_id ({PREDEFINED_NAMES}.count_name_id)
99 manus 33851 if
100     l_feat = Void
101     or else not (l_feat.written_in = class_id)
102 manus 43164 or else not l_feat.same_signature (count_signature)
103 manus 33851 then
104 manus 43164 create special_error.make (native_array_case_6, Current)
105 manus 33851 Error_handler.insert_error (special_error)
106     end
107 manus 28393 end
108 manus 33851
109     feature -- Generic derivation
110    
111 manus 28393 new_type (data: CL_TYPE_I): NATIVE_ARRAY_CLASS_TYPE is
112 manus 33851 -- New class type for class NATIVE_ARRAY.
113 manus 45562 local
114     l_data: NATIVE_ARRAY_TYPE_I
115 manus 28393 do
116 manus 45562 l_data ?= data
117     check
118     l_data_not_void: l_data /= Void
119     end
120     create Result.make (l_data)
121 manus 40533 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 manus 28393 end
126    
127 manus 43304 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 manus 41845 feature {CLASS_TYPE_AS} -- Actual class type
158    
159 juliant 69650 partial_actual_type (gen: ARRAY [TYPE_A]; is_exp, is_sep, is_mono: BOOLEAN): CL_TYPE_A is
160 manus 41845 -- 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 manus 44449 -- be a generic class. It simplifies creation of `CL_TYPE_A' instances in
163 manus 41845 -- 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 alexk 56011 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 juliant 69650 elseif is_mono then
180     Result.set_monomorph_mark
181 alexk 56011 end
182 manus 41845 end
183 alexk 56011
184 manus 33851 feature -- Status report
185    
186 manus 28393 is_native_array: BOOLEAN is True
187     -- Is the class special ?
188 manus 33851
189     feature {NONE}
190    
191 manus 43164 make_signature: DYN_PROC_I is
192 manus 33851 -- Required signature for feature `make' of class NATIVE_ARRAY.
193     local
194     args: FEAT_ARG
195 manus 43164 do
196 manus 33851 create args.make (1)
197     args.put_i_th (Integer_type, 1)
198     create Result
199     Result.set_arguments (args)
200 alexk 51140 Result.set_feature_name_id ({PREDEFINED_NAMES}.make_name_id, 0)
201 manus 33851 end
202    
203 manus 43164 count_signature: DYN_FUNC_I is
204 manus 33851 -- Required signature for feature `count' of class NATIVE_ARRAY.
205     local
206     args: FEAT_ARG
207 manus 43164 do
208 manus 33851 create args.make (0)
209     create Result
210     Result.set_arguments (args)
211 alexk 51821 Result.set_type (Integer_type, 0)
212 alexk 51140 Result.set_feature_name_id ({PREDEFINED_NAMES}.count_name_id, 0)
213 manus 33851 ensure
214     item_signature_not_void: Result /= Void
215     end
216    
217 manus 43164 item_signature: DYN_FUNC_I is
218 manus 33851 -- Required signature for feature `item' of class NATIVE_ARRAY.
219     local
220     args: FEAT_ARG
221     f: FORMAL_A
222 manus 43164 do
223 manus 33851 create args.make (1)
224     args.put_i_th (Integer_type, 1)
225     create Result
226     Result.set_arguments (args)
227 manus 42641 create f.make (False, False, 1)
228 alexk 51821 Result.set_type (f, 0)
229 alexk 51140 Result.set_feature_name_id ({PREDEFINED_NAMES}.item_name_id, 0)
230 manus 33851 ensure
231     item_signature_not_void: Result /= Void
232     end
233    
234 manus 43164 infix_at_signature: DYN_FUNC_I is
235 manus 33851 -- Required signature for feature `infix "@"' of class NATIVE_ARRAY.
236     local
237     args: FEAT_ARG
238     f: FORMAL_A
239 manus 43164 do
240 manus 33851 create args.make (1)
241     args.put_i_th (Integer_type, 1)
242     create Result
243     Result.set_arguments (args)
244 manus 42641 create f.make (False, False, 1)
245 alexk 51821 Result.set_type (f, 0)
246 alexk 51140 Result.set_feature_name_id ({PREDEFINED_NAMES}.infix_at_name_id, 0)
247 manus 33851 ensure
248     item_signature_not_void: Result /= Void
249     end
250    
251 manus 43164 put_signature: DYN_PROC_I is
252 manus 33851 -- Required signature for feature `put' of class NATIVE_ARRAY.
253     local
254     args: FEAT_ARG
255     f: FORMAL_A
256 manus 43164 do
257 manus 42641 create f.make (False, False, 1)
258 manus 33851 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 alexk 51140 Result.set_feature_name_id ({PREDEFINED_NAMES}.put_name_id, 0)
264 manus 33851 ensure
265     put_signature_not_void: Result /= Void
266     end
267    
268 manus 56535 indexing
269     copyright: "Copyright (c) 1984-2006, Eiffel Software"
270 manus 58027 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
271 manus 56535 licensing_options: "http://www.eiffel.com/licensing"
272     copying: "[
273     This file is part of Eiffel Software's Eiffel Development Environment.
274 manus 58027
275 manus 56535 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 manus 58027
281 manus 56535 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 manus 58027
287 manus 56535 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 manus 28393 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