1 |
indexing |
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) is |
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) is |
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_int (a_type.bit_count) |
76 |
end |
77 |
|
78 |
process_bits_symbol_a (a_type: BITS_SYMBOL_A) is |
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, l_feat, False) |
90 |
end |
91 |
|
92 |
process_boolean_a (a_type: BOOLEAN_A) is |
93 |
-- Process `a_type'. |
94 |
do |
95 |
process_cl_type_a (a_type) |
96 |
end |
97 |
|
98 |
process_character_a (a_type: CHARACTER_A) is |
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) is |
105 |
-- Process `a_type'. |
106 |
local |
107 |
l_class: CLASS_C |
108 |
do |
109 |
if a_type.has_expanded_mark then |
110 |
text_formatter.process_keyword_text (ti_expanded_keyword, Void) |
111 |
text_formatter.add_space |
112 |
elseif a_type.has_reference_mark then |
113 |
text_formatter.process_keyword_text (ti_reference_keyword, Void) |
114 |
text_formatter.add_space |
115 |
elseif a_type.has_separate_mark then |
116 |
text_formatter.process_keyword_text (ti_separate_keyword, Void) |
117 |
text_formatter.add_space |
118 |
elseif a_type.has_monomorph_mark then |
119 |
text_formatter.process_keyword_text (ti_frozen_keyword, Void) |
120 |
end |
121 |
l_class := a_type.associated_class |
122 |
if l_class /= Void then |
123 |
l_class.append_name (text_formatter) |
124 |
else |
125 |
-- Very rare case when a type refers to a class that has been removed |
126 |
-- from the universe. |
127 |
text_formatter.add ("Class_" + a_type.class_id.out + "_does_not_exist") |
128 |
end |
129 |
end |
130 |
|
131 |
process_formal_a (a_type: FORMAL_A) is |
132 |
-- Process `a_type'. |
133 |
do |
134 |
text_formatter.process_generic_text (current_class.generics.i_th (a_type.position).name.name.as_upper) |
135 |
end |
136 |
|
137 |
process_gen_type_a (a_type: GEN_TYPE_A) is |
138 |
-- Process `a_type'. |
139 |
local |
140 |
i, count: INTEGER |
141 |
do |
142 |
if a_type.is_separate then |
143 |
text_formatter.process_symbol_text (ti_separate_keyword) |
144 |
text_formatter.add_space |
145 |
end |
146 |
process_cl_type_a (a_type) |
147 |
-- TUPLE may have zero generic parameters |
148 |
count := a_type.generics.count |
149 |
if count > 0 then |
150 |
text_formatter.add_space |
151 |
text_formatter.process_symbol_text (ti_l_bracket) |
152 |
from |
153 |
i := 1 |
154 |
until |
155 |
i > count |
156 |
loop |
157 |
a_type.generics.item (i).process (Current) |
158 |
if i /= count then |
159 |
text_formatter.process_symbol_text (ti_comma) |
160 |
text_formatter.add_space |
161 |
end |
162 |
i := i + 1 |
163 |
end |
164 |
text_formatter.process_symbol_text (ti_r_bracket) |
165 |
end |
166 |
end |
167 |
|
168 |
process_integer_a (a_type: INTEGER_A) is |
169 |
-- Process `a_type'. |
170 |
do |
171 |
process_cl_type_a (a_type) |
172 |
end |
173 |
|
174 |
process_like_argument (a_type: LIKE_ARGUMENT) is |
175 |
-- Process `a_type'. |
176 |
do |
177 |
text_formatter.process_keyword_text (ti_like_keyword, Void) |
178 |
text_formatter.add_space |
179 |
if current_feature /= Void and then current_feature.argument_count <= a_type.position then |
180 |
text_formatter.process_local_text (current_feature.arguments.item_name (a_type.position)) |
181 |
else |
182 |
text_formatter.add (ti_argument_index) |
183 |
text_formatter.add_int (a_type.position) |
184 |
end |
185 |
end |
186 |
|
187 |
process_like_current (a_type: LIKE_CURRENT) is |
188 |
-- Process `a_type'. |
189 |
do |
190 |
text_formatter.process_keyword_text (ti_like_keyword, Void) |
191 |
text_formatter.add_space |
192 |
text_formatter.process_keyword_text (ti_current, Void) |
193 |
end |
194 |
|
195 |
process_like_feature (a_type: LIKE_FEATURE) is |
196 |
-- Process `a_type'. |
197 |
local |
198 |
l_feat: E_FEATURE |
199 |
do |
200 |
text_formatter.process_keyword_text (ti_like_keyword, Void) |
201 |
text_formatter.add_space |
202 |
l_feat := current_class.feature_with_rout_id (a_type.routine_id) |
203 |
check |
204 |
l_feat_not_void: l_feat /= Void |
205 |
end |
206 |
text_formatter.add_feature (l_feat, l_feat.name) |
207 |
end |
208 |
|
209 |
process_manifest_integer_a (a_type: MANIFEST_INTEGER_A) is |
210 |
-- Process `a_type'. |
211 |
do |
212 |
process_cl_type_a (a_type) |
213 |
end |
214 |
|
215 |
process_manifest_natural_64_a (a_type: MANIFEST_NATURAL_64_A) is |
216 |
-- Process `a_type'. |
217 |
do |
218 |
process_cl_type_a (a_type) |
219 |
end |
220 |
|
221 |
process_named_tuple_type_a (a_type: NAMED_TUPLE_TYPE_A) is |
222 |
-- Process `a_type'. |
223 |
local |
224 |
i, count: INTEGER |
225 |
do |
226 |
if a_type.is_separate then |
227 |
text_formatter.process_symbol_text (ti_separate_keyword) |
228 |
text_formatter.add_space |
229 |
end |
230 |
process_cl_type_a (a_type) |
231 |
-- TUPLE may have zero generic parameters |
232 |
count := a_type.generics.count |
233 |
if count > 0 then |
234 |
text_formatter.add_space |
235 |
text_formatter.process_symbol_text (ti_l_bracket) |
236 |
from |
237 |
i := 1 |
238 |
until |
239 |
i > count |
240 |
loop |
241 |
text_formatter.process_local_text (a_type.label_name (i)) |
242 |
text_formatter.process_symbol_text (ti_colon) |
243 |
text_formatter.add_space |
244 |
a_type.generics.item (i).process (Current) |
245 |
if i /= count then |
246 |
text_formatter.process_symbol_text (ti_semi_colon) |
247 |
text_formatter.add_space |
248 |
end |
249 |
i := i + 1 |
250 |
end |
251 |
text_formatter.process_symbol_text (ti_r_bracket) |
252 |
end |
253 |
end |
254 |
|
255 |
process_native_array_type_a (a_type: NATIVE_ARRAY_TYPE_A) is |
256 |
-- Process `a_type'. |
257 |
do |
258 |
process_gen_type_a (a_type) |
259 |
end |
260 |
|
261 |
process_natural_a (a_type: NATURAL_A) is |
262 |
-- Process `a_type'. |
263 |
do |
264 |
process_cl_type_a (a_type) |
265 |
end |
266 |
|
267 |
process_none_a (a_type: NONE_A) is |
268 |
-- Process `a_type'. |
269 |
do |
270 |
text_formatter.add (ti_none_class) |
271 |
end |
272 |
|
273 |
process_open_type_a (a_type: OPEN_TYPE_A) is |
274 |
-- Process `a_type'. |
275 |
do |
276 |
text_formatter.add (ti_open_arg) |
277 |
end |
278 |
|
279 |
process_pointer_a (a_type: POINTER_A) is |
280 |
-- Process `a_type'. |
281 |
do |
282 |
process_cl_type_a (a_type) |
283 |
end |
284 |
|
285 |
process_real_32_A (a_type: REAL_32_A) is |
286 |
-- Process `a_type'. |
287 |
do |
288 |
process_cl_type_a (a_type) |
289 |
end |
290 |
|
291 |
process_real_64_a (a_type: REAL_64_A) is |
292 |
-- Process `a_type'. |
293 |
do |
294 |
process_cl_type_a (a_type) |
295 |
end |
296 |
|
297 |
process_renamed_type_a (a_type: RENAMED_TYPE_A [TYPE_A]) is |
298 |
-- Process `a_type'. |
299 |
do |
300 |
a_type.type.append_to (text_formatter) |
301 |
if a_type.has_renaming then |
302 |
if a_type.has_associated_class then |
303 |
a_type.renaming.append_to_with_pebbles (text_formatter, a_type.associated_class) |
304 |
else |
305 |
a_type.renaming.append_to (text_formatter) |
306 |
end |
307 |
end |
308 |
end |
309 |
|
310 |
process_tuple_type_a (a_type: TUPLE_TYPE_A) is |
311 |
-- Process `a_type'. |
312 |
do |
313 |
process_gen_type_a (a_type) |
314 |
end |
315 |
|
316 |
process_typed_pointer_a (a_type: TYPED_POINTER_A) is |
317 |
-- Process `a_type'. |
318 |
do |
319 |
process_gen_type_a (a_type) |
320 |
end |
321 |
|
322 |
process_unevaluated_bits_symbol_a (a_type: UNEVALUATED_BITS_SYMBOL_A) is |
323 |
-- Process `a_type'. |
324 |
do |
325 |
text_formatter.process_keyword_text (ti_bit_class, Void) |
326 |
text_formatter.add_space |
327 |
text_formatter.add (a_type.symbol) |
328 |
end |
329 |
|
330 |
process_unevaluated_like_type (a_type: UNEVALUATED_LIKE_TYPE) is |
331 |
-- Process `a_type'. |
332 |
do |
333 |
text_formatter.process_keyword_text (ti_like_keyword, Void) |
334 |
text_formatter.add_space |
335 |
text_formatter.process_local_text (a_type.anchor) |
336 |
end |
337 |
|
338 |
process_void_a (a_type: VOID_A) is |
339 |
-- Process `a_type'. |
340 |
do |
341 |
text_formatter.process_keyword_text (ti_void, Void) |
342 |
end |
343 |
|
344 |
indexing |
345 |
copyright: "Copyright (c) 1984-2006, Eiffel Software" |
346 |
license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)" |
347 |
licensing_options: "http://www.eiffel.com/licensing" |
348 |
copying: "[ |
349 |
This file is part of Eiffel Software's Eiffel Development Environment. |
350 |
|
351 |
Eiffel Software's Eiffel Development Environment is free |
352 |
software; you can redistribute it and/or modify it under |
353 |
the terms of the GNU General Public License as published |
354 |
by the Free Software Foundation, version 2 of the License |
355 |
(available at the URL listed under "license" above). |
356 |
|
357 |
Eiffel Software's Eiffel Development Environment is |
358 |
distributed in the hope that it will be useful, but |
359 |
WITHOUT ANY WARRANTY; without even the implied warranty |
360 |
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
361 |
See the GNU General Public License for more details. |
362 |
|
363 |
You should have received a copy of the GNU General Public |
364 |
License along with Eiffel Software's Eiffel Development |
365 |
Environment; if not, write to the Free Software Foundation, |
366 |
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
367 |
]" |
368 |
source: "[ |
369 |
Eiffel Software |
370 |
356 Storke Road, Goleta, CA 93117 USA |
371 |
Telephone 805-685-1006, Fax 805-685-6869 |
372 |
Website http://www.eiffel.com |
373 |
Customer support http://support.eiffel.com |
374 |
]" |
375 |
end |