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

Contents of /branches/CAT_mono/Src/Eiffel/eiffel/AST/visitor/ast_type_a_generator.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: 7477 byte(s)
Added monomorph mark for class types, either "frozen" or "invariant".
First (simple) conformance check for monomorphic types.
1 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 evaluate_type_if_possible (a_type: TYPE_AS; a_context_class: CLASS_C): TYPE_A is
43 -- 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 Result := last_type
52 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 create {UNEVALUATED_LIKE_TYPE} last_type.make (l_as.anchor.name)
106 end
107
108 process_like_cur_as (l_as: LIKE_CUR_AS) is
109 local
110 l_cur: LIKE_CURRENT
111 do
112 create l_cur
113 l_cur.set_actual_type (current_class.actual_type)
114 last_type := l_cur
115 end
116
117 process_formal_as (l_as: FORMAL_AS) is
118 do
119 create {FORMAL_A} last_type.make (l_as.is_reference, l_as.is_expanded, l_as.position)
120 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 do
131 -- Lookup class in universe, it should be present.
132 l_class_i := universe.class_named (l_as.class_name.name, current_class.group)
133 if l_class_i /= Void and then l_class_i.is_compiled then
134 l_class_c := l_class_i.compiled_class
135 if l_as.generics /= Void then
136 from
137 i := 1
138 count := l_as.generics.count
139 create l_actual_generic.make (1, count)
140 l_type := l_class_c.partial_actual_type (l_actual_generic, l_as.is_expanded,
141 l_as.is_separate, l_as.is_monomorph)
142 until
143 i > count or l_has_error
144 loop
145 l_as.generics.i_th (i).process (Current)
146 l_has_error := last_type = Void
147 l_actual_generic.put (last_type, i)
148 i := i + 1
149 end
150 if l_has_error then
151 check failure_enabled: is_failure_enabled end
152 last_type := Void
153 else
154 last_type := l_type
155 end
156 else
157 l_type := l_class_c.partial_actual_type (Void, l_as.is_expanded, l_as.is_separate, l_as.is_monomorph)
158 last_type := l_type
159 end
160 else
161 check failure_enabled: is_failure_enabled end
162 last_type := Void
163 end
164 end
165
166 process_named_tuple_type_as (l_as: NAMED_TUPLE_TYPE_AS) is
167 local
168 l_class_i: CLASS_I
169 l_class_c: CLASS_C
170 l_actual_generic: ARRAY [TYPE_A]
171 i, g, count: INTEGER
172 l_type: NAMED_TUPLE_TYPE_A
173 l_generics: EIFFEL_LIST [TYPE_DEC_AS]
174 l_names: SPECIAL [INTEGER]
175 l_id_list: CONSTRUCT_LIST [INTEGER]
176 l_has_error: BOOLEAN
177 do
178 -- Lookup class in universe, it should be present.
179 l_class_i := System.tuple_class
180 if l_class_i /= Void and then l_class_i.is_compiled then
181 l_class_c := l_class_i.compiled_class
182 l_generics := l_as.generics
183 from
184 i := 1
185 g := 1
186 count := l_as.generic_count
187 create l_actual_generic.make (1, count)
188 create l_names.make (count)
189 create l_type.make (l_class_c.class_id, l_actual_generic, l_names)
190 until
191 i > count or l_has_error
192 loop
193 l_generics.i_th (g).process (Current)
194 l_has_error := last_type = Void
195 l_id_list := l_generics.i_th (g).id_list
196 from
197 l_id_list.start
198 until
199 l_id_list.after
200 loop
201 l_actual_generic.put (last_type, i)
202 l_names.put (l_id_list.item, i - 1)
203 i := i + 1
204 l_id_list.forth
205 end
206 g := g + 1
207 end
208 if l_has_error then
209 check failure_enabled: is_failure_enabled end
210 last_type := Void
211 else
212 last_type := l_type
213 end
214 else
215 check failure_enabled: is_failure_enabled end
216 last_type := Void
217 end
218 end
219
220 process_type_dec_as (l_as: TYPE_DEC_AS) is
221 do
222 l_as.type.process (Current)
223 end
224
225 process_none_type_as (l_as: NONE_TYPE_AS) is
226 do
227 last_type := none_type
228 end
229
230 process_bits_as (l_as: BITS_AS) is
231 do
232 create {BITS_A} last_type.make (l_as.bits_value.integer_32_value)
233 end
234
235 process_bits_symbol_as (l_as: BITS_SYMBOL_AS) is
236 do
237 create {UNEVALUATED_BITS_SYMBOL_A} last_type.make (l_as.bits_symbol.name)
238 end
239
240 indexing
241 copyright: "Copyright (c) 1984-2006, Eiffel Software"
242 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
243 licensing_options: "http://www.eiffel.com/licensing"
244 copying: "[
245 This file is part of Eiffel Software's Eiffel Development Environment.
246
247 Eiffel Software's Eiffel Development Environment is free
248 software; you can redistribute it and/or modify it under
249 the terms of the GNU General Public License as published
250 by the Free Software Foundation, version 2 of the License
251 (available at the URL listed under "license" above).
252
253 Eiffel Software's Eiffel Development Environment is
254 distributed in the hope that it will be useful, but
255 WITHOUT ANY WARRANTY; without even the implied warranty
256 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
257 See the GNU General Public License for more details.
258
259 You should have received a copy of the GNU General Public
260 License along with Eiffel Software's Eiffel Development
261 Environment; if not, write to the Free Software Foundation,
262 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
263 ]"
264 source: "[
265 Eiffel Software
266 356 Storke Road, Goleta, CA 93117 USA
267 Telephone 805-685-1006, Fax 805-685-6869
268 Website http://www.eiffel.com
269 Customer support http://support.eiffel.com
270 ]"
271
272 end

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23