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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 83445 - (show annotations)
Sat Jun 5 15:29:40 2010 UTC (9 years, 8 months ago) by jasonw
File size: 13438 byte(s)
<<Merged from trunk@83442.>>
1 note
2 description: "Formats TYPE_A instances using TEXT_FORMATTER"
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_OUTPUT_STRATEGY
10
11 inherit
12 TYPE_A_VISITOR
13
14 COMPILER_EXPORTER
15 export
16 {NONE} all
17 end
18
19 SHARED_WORKBENCH
20 export
21 {NONE} all
22 end
23
24 SHARED_TEXT_ITEMS
25 export
26 {NONE} all
27 end
28
29 SHARED_NAMES_HEAP
30 export
31 {NONE} all
32 end
33
34 create
35 default_create
36
37 feature -- Initialization
38
39 process (a_type: TYPE_A; a_text_formatter: TEXT_FORMATTER; a_class: CLASS_C; a_feature: FEATURE_I)
40 -- Output `a_type' into `a_text_formatter' using context of `a_class' and `a_feature'.
41 -- `a_feature' is only used when resolving anchors to argument.
42 require
43 a_text_formatter_not_void: a_text_formatter /= Void
44 a_class_not_void: a_class /= Void
45 do
46 text_formatter := a_text_formatter
47 current_class := a_class
48 current_feature := a_feature
49 a_type.process (Current)
50 text_formatter := Void
51 current_class := Void
52 current_feature := Void
53 ensure
54 no_state: text_formatter = Void and current_class = Void and current_feature = Void
55 end
56
57 feature -- Access
58
59 text_formatter: TEXT_FORMATTER
60 -- Output formatter.
61
62 current_class: CLASS_C
63 -- Type is being viewed in this class.
64
65 current_feature: FEATURE_I
66 -- Current feature where type appears.
67
68 feature {TYPE_A} -- Visitors
69
70 process_bits_a (a_type: BITS_A)
71 -- Process `a_type'.
72 do
73 text_formatter.process_keyword_text (ti_bit_class, Void)
74 text_formatter.add_space
75 text_formatter.add_natural_32 (a_type.bit_count)
76 end
77
78 process_bits_symbol_a (a_type: BITS_SYMBOL_A)
79 -- Process `a_type'.
80 local
81 l_feat : E_FEATURE
82 do
83 text_formatter.process_keyword_text (ti_bit_class, Void)
84 text_formatter.add_space
85 l_feat := current_class.feature_with_rout_id (a_type.rout_id)
86 check
87 l_feat_not_void: l_feat /= Void
88 end
89 text_formatter.process_feature_text (l_feat.name_32, l_feat, False)
90 end
91
92 process_boolean_a (a_type: BOOLEAN_A)
93 -- Process `a_type'.
94 do
95 process_cl_type_a (a_type)
96 end
97
98 process_character_a (a_type: CHARACTER_A)
99 -- Process `a_type'.
100 do
101 process_cl_type_a (a_type)
102 end
103
104 process_cl_type_a (a_type: CL_TYPE_A)
105 -- Process `a_type'.
106 local
107 l_class: CLASS_C
108 do
109 if a_type.has_attached_mark then
110 text_formatter.process_keyword_text (ti_attached_keyword, Void)
111 text_formatter.add_space
112 elseif a_type.has_detachable_mark then
113 text_formatter.process_keyword_text (ti_detachable_keyword, Void)
114 text_formatter.add_space
115 end
116 if a_type.has_expanded_mark then
117 text_formatter.process_keyword_text (ti_expanded_keyword, Void)
118 text_formatter.add_space
119 elseif a_type.has_reference_mark then
120 text_formatter.process_keyword_text (ti_reference_keyword, Void)
121 text_formatter.add_space
122 elseif a_type.has_separate_mark then
123 text_formatter.process_keyword_text (ti_separate_keyword, Void)
124 text_formatter.add_space
125 end
126 l_class := a_type.associated_class
127 if l_class /= Void then
128 l_class.append_name (text_formatter)
129 else
130 -- Very rare case when a type refers to a class that has been removed
131 -- from the universe.
132 text_formatter.add ("Class_" + a_type.class_id.out + "_does_not_exist")
133 end
134 end
135
136 process_formal_a (a_type: FORMAL_A)
137 -- Process `a_type'.
138 do
139 if a_type.has_attached_mark then
140 text_formatter.process_keyword_text (ti_attached_keyword, Void)
141 text_formatter.add_space
142 elseif a_type.has_detachable_mark then
143 text_formatter.process_keyword_text (ti_detachable_keyword, Void)
144 text_formatter.add_space
145 end
146 if current_feature /= Void and then current_feature.has_replicated_ast then
147 -- Current feature may be Void.
148 -- If not we check if the feature has a replicated AST, in which case
149 -- we query the written class for type information.
150 text_formatter.process_generic_text (current_feature.written_class.generics.i_th (a_type.position).name.name_8.as_upper)
151 else
152 text_formatter.process_generic_text (current_class.generics.i_th (a_type.position).name.name_8.as_upper)
153 end
154 end
155
156 process_gen_type_a (a_type: GEN_TYPE_A)
157 -- Process `a_type'.
158 local
159 i, count: INTEGER
160 do
161 process_cl_type_a (a_type)
162 -- TUPLE may have zero generic parameters
163 count := a_type.generics.count
164 if count > 0 then
165 text_formatter.add_space
166 text_formatter.process_symbol_text (ti_l_bracket)
167 from
168 i := 1
169 until
170 i > count
171 loop
172 a_type.generics.item (i).process (Current)
173 if i /= count then
174 text_formatter.process_symbol_text (ti_comma)
175 text_formatter.add_space
176 end
177 i := i + 1
178 end
179 text_formatter.process_symbol_text (ti_r_bracket)
180 end
181 end
182
183 process_integer_a (a_type: INTEGER_A)
184 -- Process `a_type'.
185 do
186 process_cl_type_a (a_type)
187 end
188
189 process_like_argument (a_type: LIKE_ARGUMENT)
190 -- Process `a_type'.
191 do
192 if a_type.has_attached_mark then
193 text_formatter.process_keyword_text (ti_attached_keyword, Void)
194 text_formatter.add_space
195 elseif a_type.has_detachable_mark then
196 text_formatter.process_keyword_text (ti_detachable_keyword, Void)
197 text_formatter.add_space
198 end
199 text_formatter.process_keyword_text (ti_like_keyword, Void)
200 text_formatter.add_space
201 if current_feature /= Void and then current_feature.argument_count <= a_type.position then
202 text_formatter.process_local_text (current_feature.arguments.item_name (a_type.position))
203 else
204 text_formatter.add (ti_argument_index)
205 text_formatter.add_int (a_type.position)
206 end
207 end
208
209 process_like_current (a_type: LIKE_CURRENT)
210 -- Process `a_type'.
211 do
212 if a_type.has_attached_mark then
213 text_formatter.process_keyword_text (ti_attached_keyword, Void)
214 text_formatter.add_space
215 elseif a_type.has_detachable_mark then
216 text_formatter.process_keyword_text (ti_detachable_keyword, Void)
217 text_formatter.add_space
218 end
219 text_formatter.process_keyword_text (ti_like_keyword, Void)
220 text_formatter.add_space
221 text_formatter.process_keyword_text (ti_current, Void)
222 end
223
224 process_like_feature (a_type: LIKE_FEATURE)
225 -- Process `a_type'.
226 local
227 l_feat: E_FEATURE
228 do
229 if a_type.has_attached_mark then
230 text_formatter.process_keyword_text (ti_attached_keyword, Void)
231 text_formatter.add_space
232 elseif a_type.has_detachable_mark then
233 text_formatter.process_keyword_text (ti_detachable_keyword, Void)
234 text_formatter.add_space
235 end
236 text_formatter.process_keyword_text (ti_like_keyword, Void)
237 text_formatter.add_space
238 l_feat := current_class.feature_with_rout_id (a_type.routine_id)
239 check
240 l_feat_not_void: l_feat /= Void
241 end
242 l_feat.append_name (text_formatter)
243 end
244
245 process_manifest_integer_a (a_type: MANIFEST_INTEGER_A)
246 -- Process `a_type'.
247 do
248 process_cl_type_a (a_type)
249 end
250
251 process_manifest_natural_64_a (a_type: MANIFEST_NATURAL_64_A)
252 -- Process `a_type'.
253 do
254 process_cl_type_a (a_type)
255 end
256
257 process_manifest_real_a (a_type: MANIFEST_REAL_A)
258 -- Process `a_type'.
259 do
260 process_cl_type_a (a_type)
261 end
262
263 process_named_tuple_type_a (a_type: NAMED_TUPLE_TYPE_A)
264 -- Process `a_type'.
265 local
266 i, count: INTEGER
267 do
268 if a_type.is_separate then
269 text_formatter.process_symbol_text (ti_separate_keyword)
270 text_formatter.add_space
271 end
272 process_cl_type_a (a_type)
273 -- TUPLE may have zero generic parameters
274 count := a_type.generics.count
275 if count > 0 then
276 text_formatter.add_space
277 text_formatter.process_symbol_text (ti_l_bracket)
278 from
279 i := 1
280 until
281 i > count
282 loop
283 text_formatter.process_local_text (a_type.label_name (i))
284 text_formatter.process_symbol_text (ti_colon)
285 text_formatter.add_space
286 a_type.generics.item (i).process (Current)
287 if i /= count then
288 text_formatter.process_symbol_text (ti_semi_colon)
289 text_formatter.add_space
290 end
291 i := i + 1
292 end
293 text_formatter.process_symbol_text (ti_r_bracket)
294 end
295 end
296
297 process_native_array_type_a (a_type: NATIVE_ARRAY_TYPE_A)
298 -- Process `a_type'.
299 do
300 process_gen_type_a (a_type)
301 end
302
303 process_natural_a (a_type: NATURAL_A)
304 -- Process `a_type'.
305 do
306 process_cl_type_a (a_type)
307 end
308
309 process_none_a (a_type: NONE_A)
310 -- Process `a_type'.
311 do
312 text_formatter.add (ti_none_class)
313 end
314
315 process_open_type_a (a_type: OPEN_TYPE_A)
316 -- Process `a_type'.
317 do
318 text_formatter.add (ti_open_arg)
319 end
320
321 process_pointer_a (a_type: POINTER_A)
322 -- Process `a_type'.
323 do
324 process_cl_type_a (a_type)
325 end
326
327 process_qualified_anchored_type_a (a_type: QUALIFIED_ANCHORED_TYPE_A)
328 -- Process `a_type'.
329 local
330 c: CLASS_C
331 n: INTEGER_32
332 i: INTEGER
333 do
334 if a_type.has_attached_mark then
335 text_formatter.process_keyword_text (ti_attached_keyword, Void)
336 text_formatter.add_space
337 elseif a_type.has_detachable_mark then
338 text_formatter.process_keyword_text (ti_detachable_keyword, Void)
339 text_formatter.add_space
340 end
341 if a_type.qualifier.is_like then
342 a_type.qualifier.process (Current)
343 else
344 text_formatter.process_keyword_text (ti_like_keyword, Void)
345 text_formatter.add_space
346 text_formatter.process_symbol_text (ti_l_curly)
347 a_type.qualifier.process (Current)
348 text_formatter.process_symbol_text (ti_r_curly)
349 end
350 from
351 c := a_type.qualifier.associated_class
352 until
353 i >= a_type.chain.count
354 loop
355 text_formatter.process_symbol_text (ti_dot)
356 n := a_type.chain [i]
357 if c /= Void and then attached c.feature_with_name_id (n) as f then
358 f.append_name (text_formatter)
359 c := f.type.associated_class
360 else
361 text_formatter.process_feature_name_text (names_heap.item_32 (n), c)
362 end
363 i := i + 1
364 end
365 end
366
367 process_real_a (a_type: REAL_A)
368 -- Process `a_type'.
369 do
370 process_cl_type_a (a_type)
371 end
372
373 process_renamed_type_a (a_type: RENAMED_TYPE_A [TYPE_A])
374 -- Process `a_type'.
375 do
376 a_type.type.append_to (text_formatter)
377 if a_type.has_renaming then
378 if a_type.has_associated_class then
379 a_type.renaming.append_to_with_pebbles (text_formatter, a_type.associated_class)
380 else
381 a_type.renaming.append_to (text_formatter)
382 end
383 end
384 end
385
386 process_tuple_type_a (a_type: TUPLE_TYPE_A)
387 -- Process `a_type'.
388 do
389 process_gen_type_a (a_type)
390 end
391
392 process_typed_pointer_a (a_type: TYPED_POINTER_A)
393 -- Process `a_type'.
394 do
395 process_gen_type_a (a_type)
396 end
397
398 process_unevaluated_bits_symbol_a (a_type: UNEVALUATED_BITS_SYMBOL_A)
399 -- Process `a_type'.
400 do
401 text_formatter.process_keyword_text (ti_bit_class, Void)
402 text_formatter.add_space
403 text_formatter.add (a_type.symbol)
404 end
405
406 process_unevaluated_like_type (a_type: UNEVALUATED_LIKE_TYPE)
407 -- Process `a_type'.
408 do
409 text_formatter.process_keyword_text (ti_like_keyword, Void)
410 text_formatter.add_space
411 text_formatter.process_local_text (a_type.anchor)
412 end
413
414 process_unevaluated_qualified_anchored_type (a_type: UNEVALUATED_QUALIFIED_ANCHORED_TYPE)
415 -- Process `a_type'.
416 local
417 i, nb: INTEGER
418 do
419 if a_type.has_attached_mark then
420 text_formatter.process_keyword_text (ti_attached_keyword, Void)
421 text_formatter.add_space
422 elseif a_type.has_detachable_mark then
423 text_formatter.process_keyword_text (ti_detachable_keyword, Void)
424 text_formatter.add_space
425 end
426 if a_type.qualifier.is_like then
427 a_type.qualifier.process (Current)
428 else
429 text_formatter.process_keyword_text (ti_like_keyword, Void)
430 text_formatter.add_space
431 text_formatter.process_symbol_text (ti_l_curly)
432 a_type.qualifier.process (Current)
433 text_formatter.process_symbol_text (ti_r_curly)
434 end
435 from
436 i := 0
437 nb := a_type.chain.count
438 until
439 i = nb
440 loop
441 text_formatter.process_symbol_text (ti_dot)
442 text_formatter.process_local_text (names_heap.item_32 (a_type.chain.item (i)))
443 i := i + 1
444 end
445 end
446
447 process_void_a (a_type: VOID_A)
448 -- Process `a_type'.
449 do
450 text_formatter.process_keyword_text (ti_void, Void)
451 end
452
453 note
454 copyright: "Copyright (c) 1984-2010, Eiffel Software"
455 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
456 licensing_options: "http://www.eiffel.com/licensing"
457 copying: "[
458 This file is part of Eiffel Software's Eiffel Development Environment.
459
460 Eiffel Software's Eiffel Development Environment is free
461 software; you can redistribute it and/or modify it under
462 the terms of the GNU General Public License as published
463 by the Free Software Foundation, version 2 of the License
464 (available at the URL listed under "license" above).
465
466 Eiffel Software's Eiffel Development Environment is
467 distributed in the hope that it will be useful, but
468 WITHOUT ANY WARRANTY; without even the implied warranty
469 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
470 See the GNU General Public License for more details.
471
472 You should have received a copy of the GNU General Public
473 License along with Eiffel Software's Eiffel Development
474 Environment; if not, write to the Free Software Foundation,
475 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
476 ]"
477 source: "[
478 Eiffel Software
479 5949 Hollister Ave., Goleta, CA 93117 USA
480 Telephone 805-685-1006, Fax 805-685-6869
481 Website http://www.eiffel.com
482 Customer support http://support.eiffel.com
483 ]"
484 end

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23