/[eiffelstudio]/branches/CAT_mono/Src/Eiffel/eiffel/AST/visitor/ast_type_a_generator.e
ViewVC logotype

Annotation of /branches/CAT_mono/Src/Eiffel/eiffel/AST/visitor/ast_type_a_generator.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 69868 - (hide annotations)
Fri Aug 3 22:28:26 2007 UTC (12 years, 5 months ago) by martins
File size: 7988 byte(s)
enabled more types to store monomorph information
1 manus 57371 indexing
2     description: "Perform resolution of TYPE_AS into TYPE_A without validity checking."
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
9     AST_TYPE_A_GENERATOR
10    
11     inherit
12     AST_NULL_VISITOR
13     redefine
14     process_like_id_as, process_like_cur_as,
15     process_formal_as, process_class_type_as, process_none_type_as,
16     process_bits_as, process_bits_symbol_as,
17     process_named_tuple_type_as, process_type_dec_as
18     end
19    
20     COMPILER_EXPORTER
21     export
22     {NONE} all
23     end
24    
25     SHARED_WORKBENCH
26     export
27     {NONE} all
28     end
29    
30     SHARED_TYPES
31     export
32     {NONE} all
33     end
34    
35     REFACTORING_HELPER
36     export
37     {NONE} all
38     end
39    
40     feature -- Status report
41    
42 manus 57773 evaluate_type_if_possible (a_type: TYPE_AS; a_context_class: CLASS_C): TYPE_A is
43 manus 57371 -- Given a TYPE_AS node, try to find its equivalent CL_TYPE_A node.
44     require
45     a_type_not_void: a_type /= Void
46     a_context_class_not_void: a_context_class /= Void
47     do
48     is_failure_enabled := True
49     current_class := a_context_class
50     a_type.process (Current)
51 manus 57773 Result := last_type
52 manus 57371 current_class := Void
53     last_type := Void
54     end
55    
56     evaluate_type (a_type: TYPE_AS; a_context_class: CLASS_C): TYPE_A is
57     -- Given a TYPE_AS node, find its equivalent TYPE_A node.
58     require
59     a_type_not_void: a_type /= Void
60     a_context_class_not_void: a_context_class /= Void
61     a_type_is_in_universe: True -- All class identifiers of `a_type' are in the universe.
62     do
63     is_failure_enabled := False
64     current_class := a_context_class
65     a_type.process (Current)
66     Result := last_type
67     current_class := Void
68     last_type := Void
69     ensure
70     evaluate_type_not_void: Result /= Void
71     end
72    
73     evaluate_class_type (a_class_type: CLASS_TYPE_AS; a_context_class: CLASS_C): CL_TYPE_A is
74     -- Given a CLASS_TYPE_AS node, find its equivalent CL_TYPE_A node.
75     require
76     a_class_type_not_void: a_class_type /= Void
77     a_context_class_not_void: a_context_class /= Void
78     a_type_is_in_universe: True -- All class identifiers of `a_class_type' are in the universe.
79     do
80     is_failure_enabled := False
81     current_class := a_context_class
82     a_class_type.process (Current)
83     Result ?= last_type
84     current_class := Void
85     last_type := Void
86     ensure
87     evaluate_type_not_void: Result /= Void
88     end
89    
90     feature {NONE} -- Implementation: Access
91    
92     last_type: TYPE_A
93     -- Last resolved type of checker
94    
95     current_class: CLASS_C
96     -- Current class where current type is resolved
97    
98     is_failure_enabled: BOOLEAN
99     -- Is failure authorized?
100    
101     feature {NONE} -- Visitor implementation
102    
103     process_like_id_as (l_as: LIKE_ID_AS) is
104     do
105 patrickr 65165 create {UNEVALUATED_LIKE_TYPE} last_type.make (l_as.anchor.name)
106 manus 57371 end
107    
108     process_like_cur_as (l_as: LIKE_CUR_AS) is
109     local
110     l_cur: LIKE_CURRENT
111     do
112 manus 64704 create l_cur
113     l_cur.set_actual_type (current_class.actual_type)
114     last_type := l_cur
115 manus 57371 end
116    
117     process_formal_as (l_as: FORMAL_AS) is
118     do
119 martins 69868 create {FORMAL_A} last_type.make (l_as.is_reference, l_as.is_expanded, l_as.is_monomorph, l_as.position)
120 manus 57371 end
121    
122     process_class_type_as (l_as: CLASS_TYPE_AS) is
123     local
124     l_class_i: CLASS_I
125     l_class_c: CLASS_C
126     l_actual_generic: ARRAY [TYPE_A]
127     i, count: INTEGER
128     l_has_error: BOOLEAN
129     l_type: TYPE_A
130 martins 69687 l_covariant_flags: PACKED_BOOLEANS
131     l_type_as: TYPE_AS
132     l_gen_type: GEN_TYPE_A
133 manus 57371 do
134     -- Lookup class in universe, it should be present.
135 patrickr 65165 l_class_i := universe.class_named (l_as.class_name.name, current_class.group)
136 manus 57371 if l_class_i /= Void and then l_class_i.is_compiled then
137     l_class_c := l_class_i.compiled_class
138     if l_as.generics /= Void then
139     from
140     i := 1
141     count := l_as.generics.count
142     create l_actual_generic.make (1, count)
143     l_type := l_class_c.partial_actual_type (l_actual_generic, l_as.is_expanded,
144 juliant 69650 l_as.is_separate, l_as.is_monomorph)
145 manus 57371 until
146     i > count or l_has_error
147     loop
148 martins 69687
149     l_type_as := l_as.generics.i_th (i)
150     l_type_as.process (Current)
151     if l_type_as.has_covariant_keyword then
152     if l_covariant_flags = Void then
153     create l_covariant_flags.make (count)
154     end
155     l_covariant_flags.put (True, i)
156     end
157 manus 57371 l_has_error := last_type = Void
158     l_actual_generic.put (last_type, i)
159     i := i + 1
160     end
161 martins 69687 if l_covariant_flags /= Void then
162     l_gen_type ?= l_type
163     check is_gen_type_a: l_gen_type /= Void end
164     l_gen_type.set_covariance_flags (l_covariant_flags)
165     end
166 manus 57371 if l_has_error then
167     check failure_enabled: is_failure_enabled end
168     last_type := Void
169     else
170     last_type := l_type
171     end
172     else
173 juliant 69650 l_type := l_class_c.partial_actual_type (Void, l_as.is_expanded, l_as.is_separate, l_as.is_monomorph)
174 manus 57371 last_type := l_type
175     end
176     else
177     check failure_enabled: is_failure_enabled end
178     last_type := Void
179     end
180     end
181    
182     process_named_tuple_type_as (l_as: NAMED_TUPLE_TYPE_AS) is
183     local
184     l_class_i: CLASS_I
185     l_class_c: CLASS_C
186     l_actual_generic: ARRAY [TYPE_A]
187 konradm 60594 i, g, count: INTEGER
188 manus 57371 l_type: NAMED_TUPLE_TYPE_A
189     l_generics: EIFFEL_LIST [TYPE_DEC_AS]
190     l_names: SPECIAL [INTEGER]
191     l_id_list: CONSTRUCT_LIST [INTEGER]
192     l_has_error: BOOLEAN
193     do
194     -- Lookup class in universe, it should be present.
195     l_class_i := System.tuple_class
196     if l_class_i /= Void and then l_class_i.is_compiled then
197     l_class_c := l_class_i.compiled_class
198     l_generics := l_as.generics
199     from
200     i := 1
201 konradm 60594 g := 1
202 manus 57371 count := l_as.generic_count
203     create l_actual_generic.make (1, count)
204     create l_names.make (count)
205     create l_type.make (l_class_c.class_id, l_actual_generic, l_names)
206     until
207     i > count or l_has_error
208     loop
209 konradm 60594 l_generics.i_th (g).process (Current)
210 manus 57371 l_has_error := last_type = Void
211 konradm 60594 l_id_list := l_generics.i_th (g).id_list
212 manus 57371 from
213     l_id_list.start
214     until
215     l_id_list.after
216     loop
217     l_actual_generic.put (last_type, i)
218     l_names.put (l_id_list.item, i - 1)
219     i := i + 1
220     l_id_list.forth
221     end
222 konradm 60594 g := g + 1
223 manus 57371 end
224     if l_has_error then
225     check failure_enabled: is_failure_enabled end
226     last_type := Void
227     else
228     last_type := l_type
229     end
230     else
231     check failure_enabled: is_failure_enabled end
232     last_type := Void
233     end
234     end
235    
236     process_type_dec_as (l_as: TYPE_DEC_AS) is
237     do
238     l_as.type.process (Current)
239     end
240    
241     process_none_type_as (l_as: NONE_TYPE_AS) is
242     do
243     last_type := none_type
244     end
245    
246     process_bits_as (l_as: BITS_AS) is
247     do
248     create {BITS_A} last_type.make (l_as.bits_value.integer_32_value)
249     end
250    
251     process_bits_symbol_as (l_as: BITS_SYMBOL_AS) is
252     do
253 patrickr 65165 create {UNEVALUATED_BITS_SYMBOL_A} last_type.make (l_as.bits_symbol.name)
254 manus 57371 end
255    
256     indexing
257     copyright: "Copyright (c) 1984-2006, Eiffel Software"
258 manus 58027 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
259 manus 57371 licensing_options: "http://www.eiffel.com/licensing"
260     copying: "[
261     This file is part of Eiffel Software's Eiffel Development Environment.
262 manus 58027
263 manus 57371 Eiffel Software's Eiffel Development Environment is free
264     software; you can redistribute it and/or modify it under
265     the terms of the GNU General Public License as published
266     by the Free Software Foundation, version 2 of the License
267     (available at the URL listed under "license" above).
268 manus 58027
269 manus 57371 Eiffel Software's Eiffel Development Environment is
270     distributed in the hope that it will be useful, but
271     WITHOUT ANY WARRANTY; without even the implied warranty
272     of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
273     See the GNU General Public License for more details.
274 manus 58027
275 manus 57371 You should have received a copy of the GNU General Public
276     License along with Eiffel Software's Eiffel Development
277     Environment; if not, write to the Free Software Foundation,
278     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
279     ]"
280     source: "[
281     Eiffel Software
282     356 Storke Road, Goleta, CA 93117 USA
283     Telephone 805-685-1006, Fax 805-685-6869
284     Website http://www.eiffel.com
285     Customer support http://support.eiffel.com
286     ]"
287    
288     end

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23