/[eiffelstudio]/branches/eth/eve/Src/Eiffel/API/evaluated_type/tuple_type_a.e
ViewVC logotype

Contents of /branches/eth/eve/Src/Eiffel/API/evaluated_type/tuple_type_a.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 92723 - (show annotations)
Fri Jun 21 07:47:04 2013 UTC (6 years, 6 months ago) by jasonw
File size: 7825 byte(s)
<<Merged from trunk#92722.>>
1 note
2 description: "Description of a TUPLE type."
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 TUPLE_TYPE_A
9
10 inherit
11 GEN_TYPE_A
12 redefine
13 good_generics, error_generics, check_constraints,
14 is_tuple, internal_conform_to, process, valid_generic,
15 il_type_name, generate_gen_type_instance, same_generic_derivation_as,
16 generic_derivation, generate_cid_prefix, make_type_prefix_byte_code
17 end
18
19 create
20 make
21
22 feature -- Visitor
23
24 process (v: TYPE_A_VISITOR)
25 -- Process current element.
26 do
27 v.process_tuple_type_a (Current)
28 end
29
30 feature -- Properties
31
32 is_tuple: BOOLEAN = True
33
34 is_basic_uniform: BOOLEAN
35 -- Are all types in Current basic?
36 local
37 i, nb: INTEGER
38 l_generics: like generics
39 do
40 from
41 l_generics := generics
42 i := l_generics.lower
43 nb := l_generics.upper
44 Result := True
45 until
46 i > nb
47 loop
48 if not l_generics.i_th (i).is_basic then
49 Result := False
50 i := nb + 1
51 else
52 i := i + 1
53 end
54 end
55 end
56
57 feature -- Access
58
59 generic_derivation: TUPLE_TYPE_A
60 do
61 -- Since the generic derivation for a TUPLE does not has actual generic parameter
62 -- we simply create a copy of current without actuals.
63 create Result.make (class_id, create {ARRAYED_LIST [TYPE_A]}.make (0))
64 Result.set_mark (declaration_mark)
65 end
66
67 feature -- Comparison
68
69 same_generic_derivation_as (current_type, other: TYPE_A): BOOLEAN
70 do
71 -- For TUPLE, it is just enough that they are
72 -- either both reference or both expanded.
73 if attached {TUPLE_TYPE_A} other as t then
74 Result := is_expanded = t.is_expanded
75 end
76 end
77
78 feature -- Generic conformance
79
80 generate_gen_type_instance (il_generator: IL_CODE_GENERATOR; n: INTEGER)
81 -- Generic runtime instance for Current
82 do
83 il_generator.generate_tuple_type_instance (n)
84 end
85
86 feature {NONE} -- Generic conformance
87
88 generate_cid_prefix (buffer: GENERATION_BUFFER; idx_cnt: COUNTER)
89 -- <Precursor>
90 local
91 l_dummy: INTEGER
92 do
93 Precursor (buffer, idx_cnt)
94 -- If `buffer' was provided, outputs tuple specification.
95 if buffer /= Void then
96 buffer.put_hex_natural_16 ({SHARED_GEN_CONF_LEVEL}.tuple_type)
97 buffer.put_character (',')
98 buffer.put_integer (generics.count)
99 buffer.put_character (',')
100 end
101 -- If counter was provided, increments it.
102 if idx_cnt /= Void then
103 l_dummy := idx_cnt.next
104 l_dummy := idx_cnt.next
105 end
106 end
107
108 make_type_prefix_byte_code (ba: BYTE_ARRAY)
109 -- <Precursor>
110 do
111 Precursor (ba)
112 ba.append_natural_16 ({SHARED_GEN_CONF_LEVEL}.tuple_type)
113 ba.append_short_integer (generics.count)
114 end
115
116 feature -- IL code generation
117
118 il_type_name (a_prefix: STRING; a_context_type: TYPE_A): STRING
119 -- Class name of current type.
120 local
121 l_class_c: like base_class
122 l_is_precompiled: BOOLEAN
123 l_cl_type: like associated_class_type
124 do
125 l_class_c := base_class
126 l_is_precompiled := l_class_c.is_precompiled
127 if l_is_precompiled then
128 l_cl_type := associated_class_type (a_context_type)
129 l_is_precompiled := l_cl_type.is_precompiled
130 if l_is_precompiled then
131 Result := l_cl_type.il_type_name (a_prefix)
132 end
133 end
134 if not l_is_precompiled then
135 Result := internal_il_type_name (l_class_c.name.twin, a_prefix)
136 end
137 end
138
139 feature {COMPILER_EXPORTER} -- Primitives
140
141 good_generics: BOOLEAN
142
143 local
144 i, count: INTEGER
145 do
146 -- Any number of generic parameters is allowed.
147 -- Therefore we only check the gen. parameters.
148 from
149 Result := True
150 count := generics.count
151 i := 1
152 until
153 i > count or else not Result
154 loop
155 Result := generics.i_th (i).good_generics
156 i := i + 1
157 end
158 end
159
160 error_generics: VTUG
161
162 local
163 i, count: INTEGER
164 do
165 -- Any number of generic parameters is allowed.
166 -- Therefore we only check the gen. parameters.
167 from
168 count := generics.count
169 i := 1
170 until
171 i > count or else (Result /= Void)
172 loop
173 if not generics.i_th (i).good_generics then
174 Result := generics.i_th (i).error_generics
175 end
176 i := i + 1
177 end
178 end
179
180 check_constraints (context_class: CLASS_C; a_context_feature: FEATURE_I; a_check_creation_readiness: BOOLEAN)
181 -- Check the constrained genericity validity rule
182 local
183 i, count: INTEGER
184 gen_param: TYPE_A
185 do
186 -- There are no constraints in a TUPLE type.
187 -- Therefore we only check the gen. parameters.
188 from
189 i := 1
190 count := generics.count
191 until
192 i > count
193 loop
194 gen_param := generics.i_th (i)
195 -- Creation readiness check is set to false because:
196 -- * one cannot inherit from TUPLE
197 -- * there is no expanded entity
198 gen_param.check_constraints (context_class, a_context_feature, False)
199 i := i + 1
200 end
201 end
202
203 feature {TYPE_A} -- Helpers
204
205 internal_conform_to (a_context_class: CLASS_C; other: TYPE_A; a_in_generic: BOOLEAN): BOOLEAN
206 -- <Precursor>
207 local
208 tuple_type: TUPLE_TYPE_A
209 i, count, other_count: INTEGER
210 other_generics: like generics
211 do
212 tuple_type ?= other
213
214 if tuple_type /= Void then
215 -- Conformance TUPLE -> TUPLE
216 other_generics := tuple_type.generics
217 from
218 i := 1
219 count := generics.count
220 other_count := other_generics.count
221 Result := count >= other_count and then
222 (a_context_class.lace_class.is_void_safe_conformance implies is_attachable_to (tuple_type)) and then
223 is_processor_attachable_to (tuple_type)
224 until
225 (i > other_count) or else (not Result)
226 loop
227 Result := generics.i_th (i).internal_conform_to (a_context_class, other_generics.i_th (i), True)
228 i := i + 1
229 end
230 else
231 -- Conformance TUPLE -> other classtypes
232 Result := Precursor {GEN_TYPE_A} (a_context_class, other, a_in_generic)
233 end
234 end
235
236 valid_generic (a_context_class: CLASS_C; type: CL_TYPE_A; a_in_generic: BOOLEAN): BOOLEAN
237 -- Check generic parameters
238 local
239 i, nb: INTEGER
240 l_tuple: TUPLE_TYPE_A
241 l_tuple_generics: like generics
242 do
243 l_tuple ?= type
244 if l_tuple /= Void then
245 from
246 i := 1
247 l_tuple_generics := l_tuple.generics
248 nb := generics.count
249 Result := nb <= l_tuple_generics.count
250 until
251 i > nb or else not Result
252 loop
253 Result := l_tuple_generics.i_th (i).internal_conform_to (a_context_class, generics.i_th (i), True)
254 i := i + 1
255 end
256 else
257 Result := Precursor {GEN_TYPE_A} (a_context_class, type, a_in_generic)
258 end
259 end
260
261 note
262 copyright: "Copyright (c) 1984-2013, Eiffel Software"
263 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
264 licensing_options: "http://www.eiffel.com/licensing"
265 copying: "[
266 This file is part of Eiffel Software's Eiffel Development Environment.
267
268 Eiffel Software's Eiffel Development Environment is free
269 software; you can redistribute it and/or modify it under
270 the terms of the GNU General Public License as published
271 by the Free Software Foundation, version 2 of the License
272 (available at the URL listed under "license" above).
273
274 Eiffel Software's Eiffel Development Environment is
275 distributed in the hope that it will be useful, but
276 WITHOUT ANY WARRANTY; without even the implied warranty
277 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
278 See the GNU General Public License for more details.
279
280 You should have received a copy of the GNU General Public
281 License along with Eiffel Software's Eiffel Development
282 Environment; if not, write to the Free Software Foundation,
283 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
284 ]"
285 source: "[
286 Eiffel Software
287 5949 Hollister Ave., Goleta, CA 93117 USA
288 Telephone 805-685-1006, Fax 805-685-6869
289 Website http://www.eiffel.com
290 Customer support http://support.eiffel.com
291 ]"
292
293 end -- class TUPLE_TYPE_A

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23