1 // $Id: ast.cpp,v 1.60 2004/03/31 13:56:32 ericb Exp $
2 //
3 // This software is subject to the terms of the IBM Jikes Compiler
4 // License Agreement available at the following URL:
5 // http://ibm.com/developerworks/opensource/jikes.
6 // Copyright (C) 1996, 2004 IBM Corporation and others. All Rights Reserved.
7 // You must accept the terms of that agreement to use this software.
8 //
9
10 #include "ast.h"
11 #include "symbol.h"
12 #ifdef JIKES_DEBUG
13 # include "stream.h"
14 #endif // JIKES_DEBUG
15
16 #ifdef HAVE_JIKES_NAMESPACE
17 namespace Jikes { // Open namespace Jikes block
18 #endif
19
20 #ifdef JIKES_DEBUG
21 unsigned Ast::count = 0;
22 #endif
23
24 //
25 // Allocate another block of storage for the VariableSymbol array.
26 //
AllocateMoreSpace()27 void VariableSymbolArray::AllocateMoreSpace()
28 {
29 //
30 //
31 // The variable size always indicates the maximum number of
32 // elements that has been allocated for the array.
33 // Initially, it is set to 0 to indicate that the array is empty.
34 // The pool of available elements is divided into segments of size
35 // 2**log_blksize each. Each segment is pointed to by a slot in
36 // the array base.
37 //
38 // By dividing size by the size of the segment we obtain the
39 // index for the next segment in base. If base is full, it is
40 // reallocated.
41 //
42 //
43 size_t k = size >> log_blksize; /* which segment? */
44
45 //
46 // If the base is overflowed, reallocate it and initialize the new
47 // elements to NULL.
48 //
49 if (k == base_size)
50 {
51 int old_base_size = base_size;
52 T** old_base = base;
53
54 base_size += base_increment;
55
56 // There must be enough room to allocate base
57 assert(base_size <= pool -> Blksize());
58
59 base = (T**) pool -> Alloc(sizeof(T*) * base_size);
60
61 if (old_base)
62 {
63 memcpy(base, old_base, old_base_size * sizeof(T*));
64 }
65 memset(&base[old_base_size], 0,
66 (base_size - old_base_size) * sizeof(T*));
67 }
68
69 //
70 // We allocate a new segment and place its adjusted address in
71 // base[k]. The adjustment allows us to index the segment directly,
72 // instead of having to perform a subtraction for each reference.
73 // See operator[] below. There must be enough room to allocate block.
74 //
75 assert(Blksize() <= pool -> Blksize());
76
77 base[k] = (T*) pool -> Alloc(sizeof(T) * Blksize());
78 base[k] -= size;
79
80 //
81 // Finally, we update size.
82 //
83 size += Blksize();
84 }
85
86
VariableSymbolArray(StoragePool * p,unsigned estimate=0)87 VariableSymbolArray::VariableSymbolArray(StoragePool* p,
88 unsigned estimate = 0)
89 : pool(p)
90 {
91 // There must be enough space in the storage pool to move !!!
92 assert(pool -> Blksize() >= 256);
93
94 if (estimate == 0)
95 log_blksize = 6; // take a guess
96 else
97 {
98 for (log_blksize = 1;
99 ((1U << log_blksize) < estimate) && (log_blksize < 31);
100 log_blksize++)
101 ;
102 }
103
104 //
105 // Increment a base_increment size that is big enough not to have to
106 // be reallocated. Find a block size that is smaller that the block
107 // size of the pool.
108 //
109 base_increment = (Blksize() > pool -> Blksize()
110 ? Blksize() / pool -> Blksize() : 1) * 2;
111 while (Blksize() >= pool -> Blksize())
112 log_blksize--;
113
114 base_size = 0;
115 size = 0;
116 top = 0;
117 base = NULL;
118 }
119
120
FreeAst()121 void AstCompilationUnit::FreeAst()
122 {
123 delete ast_pool;
124 }
125
126 //
127 // This procedure uses a quick sort algorithm to sort the cases in a switch
128 // statement. Element 0 is not sorted, because it is the default case (and
129 // may be NULL).
130 //
SortCases()131 void AstSwitchStatement::SortCases()
132 {
133 int lower;
134 int upper;
135 int lostack[32];
136 int histack[32];
137 int top = 0;
138 int i;
139 int j;
140 CaseElement pivot;
141 CaseElement temp;
142
143 lostack[top] = 1;
144 histack[top] = num_cases;
145
146 while (top >= 0)
147 {
148 lower = lostack[top];
149 upper = histack[top];
150 top--;
151
152 while (upper > lower)
153 {
154 //
155 // The array is most-likely almost sorted. Therefore,
156 // we use the middle element as the pivot element.
157 //
158 i = (lower + upper) >> 1;
159 pivot = *cases[i];
160 *cases[i] = *cases[lower];
161
162 //
163 // Split the array section indicated by LOWER and UPPER
164 // using ARRAY(LOWER) as the pivot.
165 //
166 i = lower;
167 for (j = lower + 1; j <= upper; j++)
168 if (*cases[j] < pivot)
169 {
170 temp = *cases[++i];
171 *cases[i] = *cases[j];
172 *cases[j] = temp;
173 }
174 *cases[lower] = *cases[i];
175 *cases[i] = pivot;
176
177 top++;
178 if ((i - lower) < (upper - i))
179 {
180 lostack[top] = i + 1;
181 histack[top] = upper;
182 upper = i - 1;
183 }
184 else
185 {
186 histack[top] = i - 1;
187 lostack[top] = lower;
188 lower = i + 1;
189 }
190 }
191 }
192 }
193
194 //
195 // Performs a binary search to locate the correct case (including the
196 // default case) for a constant expression value. Returns NULL if the switch
197 // is a no-op for this constant.
198 //
CaseForValue(i4 value)199 CaseElement* AstSwitchStatement::CaseForValue(i4 value)
200 {
201 unsigned lower = 1;
202 unsigned upper = num_cases;
203 while (lower <= upper)
204 {
205 unsigned mid = (lower + upper) >> 1;
206 CaseElement* elt = cases[mid];
207 if (elt -> value == value)
208 return elt;
209 if (elt -> value > value)
210 upper = mid - 1;
211 else
212 lower = mid + 1;
213 }
214 return cases[0];
215 }
216
217
Type()218 TypeSymbol* AstMemberValue::Type()
219 {
220 return ! symbol ? (TypeSymbol*) NULL
221 : symbol -> Kind() == Symbol::TYPE
222 ? (TypeSymbol*) symbol
223 : symbol -> Kind() == Symbol::VARIABLE
224 ? ((VariableSymbol*) symbol) -> Type()
225 : symbol -> Kind() == Symbol::METHOD
226 ? ((MethodSymbol*) symbol) -> Type()
227 : (TypeSymbol*) NULL;
228 }
229
230
Clone(StoragePool * ast_pool)231 Ast* AstBlock::Clone(StoragePool* ast_pool)
232 {
233 AstBlock* clone = ast_pool -> GenBlock();
234 clone -> CloneBlock(ast_pool, this);
235 return clone;
236 }
237
CloneBlock(StoragePool * ast_pool,AstBlock * orig)238 void AstBlock::CloneBlock(StoragePool* ast_pool, AstBlock* orig)
239 {
240 other_tag = orig -> other_tag;
241 label_opt = orig -> label_opt;
242 nesting_level = orig -> nesting_level;
243 left_brace_token = orig -> left_brace_token;
244 unsigned count = orig -> NumStatements();
245 AllocateStatements(count);
246 for (unsigned i = 0; i < count; i++)
247 AddStatement((AstStatement*) orig -> Statement(i) -> Clone(ast_pool));
248 right_brace_token = orig -> right_brace_token;
249 no_braces = orig -> no_braces;
250 }
251
Clone(StoragePool * ast_pool)252 Ast* AstName::Clone(StoragePool* ast_pool)
253 {
254 AstName* clone = ast_pool -> GenName(identifier_token);
255 if (base_opt)
256 clone -> base_opt = (AstName*) base_opt -> Clone(ast_pool);
257 if (resolution_opt)
258 clone -> resolution_opt =
259 (AstExpression*) resolution_opt -> Clone(ast_pool);
260 return clone;
261 }
262
Clone(StoragePool * ast_pool)263 Ast* AstPrimitiveType::Clone(StoragePool* ast_pool)
264 {
265 return ast_pool -> GenPrimitiveType(kind, primitive_kind_token);
266 }
267
Clone(StoragePool * ast_pool)268 Ast* AstBrackets::Clone(StoragePool* ast_pool)
269 {
270 AstBrackets* clone =
271 ast_pool -> GenBrackets(left_bracket_token, right_bracket_token);
272 clone -> dims = dims;
273 return clone;
274 }
275
Clone(StoragePool * ast_pool)276 Ast* AstArrayType::Clone(StoragePool* ast_pool)
277 {
278 return ast_pool -> GenArrayType((AstType*) type -> Clone(ast_pool),
279 ((AstBrackets*) brackets ->
280 Clone(ast_pool)));
281 }
282
Clone(StoragePool * ast_pool)283 Ast* AstWildcard::Clone(StoragePool* ast_pool)
284 {
285 AstWildcard* clone = ast_pool -> GenWildcard(question_token);
286 clone -> extends_token_opt = extends_token_opt;
287 clone -> super_token_opt = super_token_opt;
288 if (bounds_opt)
289 clone -> bounds_opt = (AstType*) bounds_opt -> Clone(ast_pool);
290 return clone;
291 }
292
Clone(StoragePool * ast_pool)293 Ast* AstTypeArguments::Clone(StoragePool* ast_pool)
294 {
295 AstTypeArguments* clone = ast_pool -> GenTypeArguments(left_angle_token,
296 right_angle_token);
297 clone -> AllocateTypeArguments(NumTypeArguments());
298 for (unsigned i = 0; i < NumTypeArguments(); i++)
299 clone -> AddTypeArgument((AstType*) TypeArgument(i) ->
300 Clone(ast_pool));
301 return clone;
302 }
303
Clone(StoragePool * ast_pool)304 Ast* AstTypeName::Clone(StoragePool* ast_pool)
305 {
306 AstTypeName* clone =
307 ast_pool -> GenTypeName((AstName*) name -> Clone(ast_pool));
308 if (base_opt)
309 clone -> base_opt = (AstTypeName*) base_opt -> Clone(ast_pool);
310 if (type_arguments_opt)
311 clone -> type_arguments_opt =
312 (AstTypeArguments*) type_arguments_opt -> Clone(ast_pool);
313 return clone;
314 }
315
Clone(StoragePool * ast_pool)316 Ast* AstMemberValuePair::Clone(StoragePool* ast_pool)
317 {
318 AstMemberValuePair* clone = ast_pool -> GenMemberValuePair();
319 clone -> identifier_token_opt = identifier_token_opt;
320 clone -> member_value = (AstMemberValue*) member_value -> Clone(ast_pool);
321 return clone;
322 }
323
Clone(StoragePool * ast_pool)324 Ast* AstAnnotation::Clone(StoragePool* ast_pool)
325 {
326 AstAnnotation* clone = ast_pool -> GenAnnotation();
327 clone -> at_token = at_token;
328 clone -> name = (AstName*) name -> Clone(ast_pool);
329 clone -> AllocateMemberValuePairs(NumMemberValuePairs());
330 for (unsigned i = 0; i < NumMemberValuePairs(); i++)
331 clone -> AddMemberValuePair((AstMemberValuePair*)
332 MemberValuePair(i) -> Clone(ast_pool));
333 clone -> right_paren_token_opt = right_paren_token_opt;
334 return clone;
335 }
336
Clone(StoragePool * ast_pool)337 Ast* AstModifierKeyword::Clone(StoragePool* ast_pool)
338 {
339 return ast_pool -> GenModifierKeyword(modifier_token);
340 }
341
Clone(StoragePool * ast_pool)342 Ast* AstModifiers::Clone(StoragePool* ast_pool)
343 {
344 AstModifiers* clone = ast_pool -> GenModifiers();
345 clone -> AllocateModifiers(NumModifiers());
346 for (unsigned i = 0; i < NumModifiers(); i++)
347 {
348 if (Modifier(i) -> ModifierKeywordCast())
349 clone -> AddModifier((AstModifierKeyword*)
350 Modifier(i) -> Clone(ast_pool));
351 else clone -> AddModifier((AstAnnotation*)
352 Modifier(i) -> Clone(ast_pool));
353 }
354 clone -> static_token_opt = static_token_opt;
355 return clone;
356 }
357
Clone(StoragePool * ast_pool)358 Ast* AstPackageDeclaration::Clone(StoragePool* ast_pool)
359 {
360 AstPackageDeclaration* clone = ast_pool -> GenPackageDeclaration();
361 if (modifiers_opt)
362 clone -> modifiers_opt =
363 (AstModifiers*) modifiers_opt -> Clone(ast_pool);
364 clone -> package_token = package_token;
365 clone -> name = (AstName*) name -> Clone(ast_pool);
366 clone -> semicolon_token = semicolon_token;
367 return clone;
368 }
369
Clone(StoragePool * ast_pool)370 Ast* AstImportDeclaration::Clone(StoragePool* ast_pool)
371 {
372 AstImportDeclaration* clone = ast_pool -> GenImportDeclaration();
373 clone -> import_token = import_token;
374 clone -> static_token_opt = static_token_opt;
375 clone -> name = (AstName*) name -> Clone(ast_pool);
376 clone -> star_token_opt = star_token_opt;
377 clone -> semicolon_token = semicolon_token;
378 return clone;
379 }
380
Clone(StoragePool * ast_pool)381 Ast* AstCompilationUnit::Clone(StoragePool* ast_pool)
382 {
383 unsigned i;
384 AstCompilationUnit* clone = ast_pool -> GenCompilationUnit();
385 clone -> other_tag = other_tag;
386 if (package_declaration_opt)
387 clone -> package_declaration_opt = (AstPackageDeclaration*)
388 package_declaration_opt -> Clone(ast_pool);
389 clone -> AllocateImportDeclarations(NumImportDeclarations());
390 for (i = 0; i < NumImportDeclarations(); i++)
391 clone -> AddImportDeclaration((AstImportDeclaration*)
392 ImportDeclaration(i) -> Clone(ast_pool));
393 clone -> AllocateTypeDeclarations(NumTypeDeclarations());
394 for (i = 0; i < NumTypeDeclarations(); i++)
395 clone -> AddTypeDeclaration((AstDeclaredType*) TypeDeclaration(i) ->
396 Clone(ast_pool));
397 return clone;
398 }
399
Clone(StoragePool * ast_pool)400 Ast* AstEmptyDeclaration::Clone(StoragePool* ast_pool)
401 {
402 return ast_pool -> GenEmptyDeclaration(semicolon_token);
403 }
404
Clone(StoragePool * ast_pool)405 Ast* AstClassBody::Clone(StoragePool* ast_pool)
406 {
407 AstClassBody* clone = ast_pool -> GenClassBody();
408 clone -> identifier_token = identifier_token;
409 clone -> left_brace_token = left_brace_token;
410 clone -> AllocateClassBodyDeclarations(NumClassBodyDeclarations());
411 clone -> AllocateInstanceVariables(NumInstanceVariables());
412 clone -> AllocateClassVariables(NumClassVariables());
413 clone -> AllocateMethods(NumMethods());
414 clone -> AllocateConstructors(NumConstructors());
415 clone -> AllocateStaticInitializers(NumStaticInitializers());
416 clone -> AllocateInstanceInitializers(NumInstanceInitializers());
417 clone -> AllocateNestedClasses(NumNestedClasses());
418 clone -> AllocateNestedEnums(NumNestedEnums());
419 clone -> AllocateNestedInterfaces(NumNestedInterfaces());
420 clone -> AllocateNestedAnnotations(NumNestedAnnotations());
421 clone -> AllocateEmptyDeclarations(NumEmptyDeclarations());
422 for (unsigned i = 0; i < NumClassBodyDeclarations(); i++)
423 clone -> AddClassBodyDeclaration((AstDeclaredType*)
424 ClassBodyDeclaration(i) ->
425 Clone(ast_pool));
426 clone -> right_brace_token = right_brace_token;
427 return clone;
428 }
429
AddClassBodyDeclaration(AstDeclared * member)430 void AstClassBody::AddClassBodyDeclaration(AstDeclared* member)
431 {
432 assert(class_body_declarations);
433 AstFieldDeclaration* field_declaration = member -> FieldDeclarationCast();
434 AstMethodDeclaration* method_declaration =
435 member -> MethodDeclarationCast();
436 AstConstructorDeclaration* constructor_declaration =
437 member -> ConstructorDeclarationCast();
438 AstInitializerDeclaration* initializer =
439 member -> InitializerDeclarationCast();
440 AstClassDeclaration* class_declaration = member -> ClassDeclarationCast();
441 AstEnumDeclaration* enum_declaration = member -> EnumDeclarationCast();
442 AstInterfaceDeclaration* interface_declaration =
443 member -> InterfaceDeclarationCast();
444 AstAnnotationDeclaration* annotation_declaration =
445 member -> AnnotationDeclarationCast();
446
447 class_body_declarations -> Next() = member;
448 if (field_declaration)
449 {
450 if (field_declaration -> StaticFieldCast())
451 AddClassVariable(field_declaration);
452 else AddInstanceVariable(field_declaration);
453 }
454 else if (method_declaration)
455 AddMethod(method_declaration);
456 else if (constructor_declaration)
457 AddConstructor(constructor_declaration);
458 else if (initializer)
459 {
460 if (initializer -> StaticInitializerCast())
461 AddStaticInitializer(initializer);
462 else AddInstanceInitializer(initializer);
463 }
464 else if (class_declaration)
465 AddNestedClass(class_declaration);
466 else if (enum_declaration)
467 AddNestedEnum(enum_declaration);
468 else if (interface_declaration)
469 AddNestedInterface(interface_declaration);
470 else if (annotation_declaration)
471 AddNestedAnnotation(annotation_declaration);
472 else AddEmptyDeclaration((AstEmptyDeclaration*) member);
473 }
474
Clone(StoragePool * ast_pool)475 Ast* AstTypeParameter::Clone(StoragePool* ast_pool)
476 {
477 AstTypeParameter* clone = ast_pool -> GenTypeParameter(identifier_token);
478 clone -> AllocateBounds(NumBounds());
479 for (unsigned i = 0; i < NumBounds(); i++)
480 clone -> AddBound((AstTypeName*) Bound(i) -> Clone(ast_pool));
481 return clone;
482 }
483
Clone(StoragePool * ast_pool)484 Ast* AstTypeParameters::Clone(StoragePool* ast_pool)
485 {
486 AstTypeParameters* clone = ast_pool -> GenTypeParameters();
487 clone -> left_angle_token = left_angle_token;
488 clone -> AllocateTypeParameters(NumTypeParameters());
489 for (unsigned i = 0; i < NumTypeParameters(); i++)
490 clone -> AddTypeParameter((AstTypeParameter*) TypeParameter(i) ->
491 Clone(ast_pool));
492 clone -> right_angle_token = right_angle_token;
493 return clone;
494 }
495
Clone(StoragePool * ast_pool)496 Ast* AstClassDeclaration::Clone(StoragePool* ast_pool)
497 {
498 AstClassDeclaration* clone = ast_pool -> GenClassDeclaration();
499 if (modifiers_opt)
500 clone -> modifiers_opt =
501 (AstModifiers*) modifiers_opt -> Clone(ast_pool);
502 clone -> class_token = class_token;
503 if (type_parameters_opt)
504 clone -> type_parameters_opt =
505 (AstTypeParameters*) type_parameters_opt -> Clone(ast_pool);
506 if (super_opt)
507 clone -> super_opt = (AstTypeName*) super_opt -> Clone(ast_pool);
508 clone -> AllocateInterfaces(NumInterfaces());
509 for (unsigned i = 0; i < NumInterfaces(); i++)
510 clone -> AddInterface((AstTypeName*) Interface(i) -> Clone(ast_pool));
511 clone -> class_body = (AstClassBody*) class_body -> Clone(ast_pool);
512 clone -> class_body -> owner = clone;
513 return clone;
514 }
515
Clone(StoragePool * ast_pool)516 Ast* AstArrayInitializer::Clone(StoragePool* ast_pool)
517 {
518 AstArrayInitializer* clone = ast_pool -> GenArrayInitializer();
519 clone -> left_brace_token = left_brace_token;
520 clone -> AllocateVariableInitializers(NumVariableInitializers());
521 for (unsigned i = 0; i < NumVariableInitializers(); i++)
522 clone -> AddVariableInitializer((AstMemberValue*)
523 VariableInitializer(i) ->
524 Clone(ast_pool));
525 clone -> right_brace_token = right_brace_token;
526 return clone;
527 }
528
Clone(StoragePool * ast_pool)529 Ast* AstVariableDeclaratorId::Clone(StoragePool* ast_pool)
530 {
531 AstVariableDeclaratorId* clone = ast_pool -> GenVariableDeclaratorId();
532 clone -> identifier_token = identifier_token;
533 if (brackets_opt)
534 clone -> brackets_opt = (AstBrackets*) brackets_opt -> Clone(ast_pool);
535 return clone;
536 }
537
Clone(StoragePool * ast_pool)538 Ast* AstVariableDeclarator::Clone(StoragePool* ast_pool)
539 {
540 AstVariableDeclarator* clone = ast_pool -> GenVariableDeclarator();
541 clone -> variable_declarator_name = (AstVariableDeclaratorId*)
542 variable_declarator_name -> Clone(ast_pool);
543 if (variable_initializer_opt)
544 clone -> variable_initializer_opt =
545 variable_initializer_opt -> Clone(ast_pool);
546 return clone;
547 }
548
Clone(StoragePool * ast_pool)549 Ast* AstFieldDeclaration::Clone(StoragePool* ast_pool)
550 {
551 AstFieldDeclaration* clone = ast_pool -> GenFieldDeclaration();
552 clone -> other_tag = other_tag;
553 if (modifiers_opt)
554 clone -> modifiers_opt =
555 (AstModifiers*) modifiers_opt -> Clone(ast_pool);
556 clone -> type = (AstType*) type -> Clone(ast_pool);
557 clone -> AllocateVariableDeclarators(NumVariableDeclarators());
558 for (unsigned i = 0; i < NumVariableDeclarators(); i++)
559 clone -> AddVariableDeclarator((AstVariableDeclarator*)
560 VariableDeclarator(i) ->
561 Clone(ast_pool));
562 clone -> semicolon_token = semicolon_token;
563 return clone;
564 }
565
Clone(StoragePool * ast_pool)566 Ast* AstFormalParameter::Clone(StoragePool* ast_pool)
567 {
568 AstFormalParameter* clone = ast_pool -> GenFormalParameter();
569 if (modifiers_opt)
570 clone -> modifiers_opt =
571 (AstModifiers*) modifiers_opt -> Clone(ast_pool);
572 clone -> type = (AstType*) type -> Clone(ast_pool);
573 clone -> ellipsis_token_opt = ellipsis_token_opt;
574 clone -> formal_declarator =
575 (AstVariableDeclarator*) formal_declarator -> Clone(ast_pool);
576 return clone;
577 }
578
Clone(StoragePool * ast_pool)579 Ast* AstMethodDeclarator::Clone(StoragePool* ast_pool)
580 {
581 AstMethodDeclarator* clone = ast_pool -> GenMethodDeclarator();
582 clone -> identifier_token = identifier_token;
583 clone -> left_parenthesis_token = left_parenthesis_token;
584 clone -> AllocateFormalParameters(NumFormalParameters());
585 for (unsigned i = 0; i < NumFormalParameters(); i++)
586 clone -> AddFormalParameter((AstFormalParameter*)
587 FormalParameter(i) -> Clone(ast_pool));
588 clone -> right_parenthesis_token = right_parenthesis_token;
589 if (brackets_opt)
590 clone -> brackets_opt = (AstBrackets*) brackets_opt -> Clone(ast_pool);
591 return clone;
592 }
593
Clone(StoragePool * ast_pool)594 Ast* AstMethodBody::Clone(StoragePool* ast_pool)
595 {
596 AstMethodBody* clone = ast_pool -> GenMethodBody();
597 clone -> CloneBlock(ast_pool, this);
598 if (explicit_constructor_opt)
599 clone -> explicit_constructor_opt =
600 (AstStatement*) explicit_constructor_opt -> Clone(ast_pool);
601 return clone;
602 }
603
Clone(StoragePool * ast_pool)604 Ast* AstMethodDeclaration::Clone(StoragePool* ast_pool)
605 {
606 AstMethodDeclaration* clone = ast_pool -> GenMethodDeclaration();
607 if (modifiers_opt)
608 clone -> modifiers_opt =
609 (AstModifiers*) modifiers_opt -> Clone(ast_pool);
610 if (type_parameters_opt)
611 clone -> type_parameters_opt =
612 (AstTypeParameters*) type_parameters_opt -> Clone(ast_pool);
613 clone -> type = (AstType*) type -> Clone(ast_pool);
614 clone -> method_declarator =
615 (AstMethodDeclarator*) method_declarator -> Clone(ast_pool);
616 clone -> AllocateThrows(NumThrows());
617 for (unsigned i = 0; i < NumThrows(); i++)
618 clone -> AddThrow((AstTypeName*) Throw(i) -> Clone(ast_pool));
619 if (default_value_opt)
620 clone -> default_value_opt =
621 (AstMemberValue*) default_value_opt -> Clone(ast_pool);
622 if (method_body_opt)
623 clone -> method_body_opt =
624 (AstMethodBody*) method_body_opt -> Clone(ast_pool);
625 clone -> semicolon_token_opt = semicolon_token_opt;
626 return clone;
627 }
628
Clone(StoragePool * ast_pool)629 Ast* AstInitializerDeclaration::Clone(StoragePool* ast_pool)
630 {
631 AstInitializerDeclaration* clone = ast_pool -> GenInitializerDeclaration();
632 clone -> other_tag = other_tag;
633 if (modifiers_opt)
634 clone -> modifiers_opt =
635 (AstModifiers*) modifiers_opt -> Clone(ast_pool);
636 clone -> block = (AstMethodBody*) block -> Clone(ast_pool);
637 return clone;
638 }
639
Clone(StoragePool * ast_pool)640 Ast* AstArguments::Clone(StoragePool* ast_pool)
641 {
642 unsigned i;
643 AstArguments* clone = ast_pool -> GenArguments(left_parenthesis_token,
644 right_parenthesis_token);
645 clone -> AllocateArguments(NumArguments());
646 for (i = 0; i < NumArguments(); i++)
647 clone -> AddArgument((AstExpression*) Argument(i) -> Clone(ast_pool));
648 clone -> AllocateLocalArguments(NumLocalArguments());
649 for (i = 0; i < NumLocalArguments(); i++)
650 clone -> AddLocalArgument((AstName*) LocalArgument(i) ->
651 Clone(ast_pool));
652 clone -> other_tag = other_tag;
653 return clone;
654 }
655
Clone(StoragePool * ast_pool)656 Ast* AstThisCall::Clone(StoragePool* ast_pool)
657 {
658 AstThisCall* clone = ast_pool -> GenThisCall();
659 if (type_arguments_opt)
660 clone -> type_arguments_opt =
661 (AstTypeArguments*) type_arguments_opt -> Clone(ast_pool);
662 clone -> this_token = this_token;
663 clone -> arguments = (AstArguments*) arguments -> Clone(ast_pool);
664 clone -> semicolon_token = semicolon_token;
665 return clone;
666 }
667
Clone(StoragePool * ast_pool)668 Ast* AstSuperCall::Clone(StoragePool* ast_pool)
669 {
670 AstSuperCall* clone = ast_pool -> GenSuperCall();
671 if (base_opt)
672 clone -> base_opt = (AstExpression*) base_opt -> Clone(ast_pool);
673 if (type_arguments_opt)
674 clone -> type_arguments_opt =
675 (AstTypeArguments*) type_arguments_opt -> Clone(ast_pool);
676 clone -> super_token = super_token;
677 clone -> arguments = (AstArguments*) arguments -> Clone(ast_pool);
678 clone -> semicolon_token = semicolon_token;
679 return clone;
680 }
681
Clone(StoragePool * ast_pool)682 Ast* AstConstructorDeclaration::Clone(StoragePool* ast_pool)
683 {
684 AstConstructorDeclaration* clone = ast_pool -> GenConstructorDeclaration();
685 if (modifiers_opt)
686 clone -> modifiers_opt =
687 (AstModifiers*) modifiers_opt -> Clone(ast_pool);
688 if (type_parameters_opt)
689 clone -> type_parameters_opt =
690 (AstTypeParameters*) type_parameters_opt -> Clone(ast_pool);
691 clone -> constructor_declarator =
692 (AstMethodDeclarator*) constructor_declarator -> Clone(ast_pool);
693 clone -> AllocateThrows(NumThrows());
694 for (unsigned i = 0; i < NumThrows(); i++)
695 clone -> AddThrow((AstTypeName*) Throw(i) -> Clone(ast_pool));
696 clone -> constructor_body =
697 (AstMethodBody*) constructor_body -> Clone(ast_pool);
698 return clone;
699 }
700
Clone(StoragePool * ast_pool)701 Ast* AstEnumDeclaration::Clone(StoragePool* ast_pool)
702 {
703 unsigned i;
704 AstEnumDeclaration* clone = ast_pool -> GenEnumDeclaration();
705 if (modifiers_opt)
706 clone -> modifiers_opt =
707 (AstModifiers*) modifiers_opt -> Clone(ast_pool);
708 clone -> AllocateInterfaces(NumInterfaces());
709 for (i = 0; i < NumInterfaces(); i++)
710 clone -> AddInterface((AstTypeName*) Interface(i) -> Clone(ast_pool));
711 clone -> AllocateEnumConstants(NumEnumConstants());
712 for (i = 0; i < NumEnumConstants(); i++)
713 clone -> AddEnumConstant((AstEnumConstant*) EnumConstant(i) ->
714 Clone(ast_pool));
715 clone -> class_body = (AstClassBody*) class_body -> Clone(ast_pool);
716 clone -> class_body -> owner = clone;
717 return clone;
718 }
719
Clone(StoragePool * ast_pool)720 Ast* AstEnumConstant::Clone(StoragePool* ast_pool)
721 {
722 AstEnumConstant* clone = ast_pool -> GenEnumConstant(identifier_token);
723 if (modifiers_opt)
724 clone -> modifiers_opt =
725 (AstModifiers*) modifiers_opt -> Clone(ast_pool);
726 if (arguments_opt)
727 clone -> arguments_opt =
728 (AstArguments*) arguments_opt -> Clone(ast_pool);
729 if (class_body_opt)
730 clone -> class_body_opt =
731 (AstClassBody*) class_body_opt -> Clone(ast_pool);
732 return clone;
733 }
734
Clone(StoragePool * ast_pool)735 Ast* AstInterfaceDeclaration::Clone(StoragePool* ast_pool)
736 {
737 AstInterfaceDeclaration* clone = ast_pool -> GenInterfaceDeclaration();
738 if (modifiers_opt)
739 clone -> modifiers_opt =
740 (AstModifiers*) modifiers_opt -> Clone(ast_pool);
741 clone -> interface_token = interface_token;
742 if (type_parameters_opt)
743 clone -> type_parameters_opt =
744 (AstTypeParameters*) type_parameters_opt -> Clone(ast_pool);
745 clone -> AllocateInterfaces(NumInterfaces());
746 for (unsigned i = 0; i < NumInterfaces(); i++)
747 clone -> AddInterface((AstTypeName*) Interface(i) -> Clone(ast_pool));
748 clone -> class_body = (AstClassBody*) class_body -> Clone(ast_pool);
749 clone -> class_body -> owner = clone;
750 return clone;
751 }
752
Clone(StoragePool * ast_pool)753 Ast* AstAnnotationDeclaration::Clone(StoragePool* ast_pool)
754 {
755 AstAnnotationDeclaration* clone =
756 ast_pool -> GenAnnotationDeclaration(interface_token);
757 if (modifiers_opt)
758 clone -> modifiers_opt =
759 (AstModifiers*) modifiers_opt -> Clone(ast_pool);
760 clone -> class_body = (AstClassBody*) class_body -> Clone(ast_pool);
761 clone -> class_body -> owner = clone;
762 return clone;
763 }
764
Clone(StoragePool * ast_pool)765 Ast* AstLocalVariableStatement::Clone(StoragePool* ast_pool)
766 {
767 AstLocalVariableStatement* clone = ast_pool -> GenLocalVariableStatement();
768 if (modifiers_opt)
769 clone -> modifiers_opt =
770 (AstModifiers*) modifiers_opt -> Clone(ast_pool);
771 clone -> type = (AstType*) type -> Clone(ast_pool);
772 clone -> AllocateVariableDeclarators(NumVariableDeclarators());
773 for (unsigned i = 0; i < NumVariableDeclarators(); i++)
774 clone -> AddVariableDeclarator((AstVariableDeclarator*)
775 VariableDeclarator(i) ->
776 Clone(ast_pool));
777 clone -> semicolon_token_opt = semicolon_token_opt;
778 return clone;
779 }
780
Clone(StoragePool * ast_pool)781 Ast* AstLocalClassStatement::Clone(StoragePool* ast_pool)
782 {
783 Ast* p = declaration -> Clone(ast_pool);
784 if (p -> ClassDeclarationCast())
785 return ast_pool -> GenLocalClassStatement((AstClassDeclaration*) p);
786 else return ast_pool -> GenLocalClassStatement((AstEnumDeclaration*) p);
787 }
788
Clone(StoragePool * ast_pool)789 Ast* AstIfStatement::Clone(StoragePool* ast_pool)
790 {
791 AstIfStatement* clone = ast_pool -> GenIfStatement();
792 clone -> if_token = if_token;
793 clone -> expression = (AstExpression*) expression -> Clone(ast_pool);
794 clone -> true_statement = (AstBlock*) true_statement -> Clone(ast_pool);
795 if (false_statement_opt)
796 clone -> false_statement_opt =
797 (AstBlock*) false_statement_opt -> Clone(ast_pool);
798 return clone;
799 }
800
Clone(StoragePool * ast_pool)801 Ast* AstEmptyStatement::Clone(StoragePool* ast_pool)
802 {
803 return ast_pool -> GenEmptyStatement(semicolon_token);
804 }
805
Clone(StoragePool * ast_pool)806 Ast* AstExpressionStatement::Clone(StoragePool* ast_pool)
807 {
808 AstExpressionStatement* clone = ast_pool -> GenExpressionStatement();
809 clone -> expression = (AstExpression*) expression -> Clone(ast_pool);
810 clone -> semicolon_token_opt = semicolon_token_opt;
811 return clone;
812 }
813
Clone(StoragePool * ast_pool)814 Ast* AstSwitchLabel::Clone(StoragePool* ast_pool)
815 {
816 AstSwitchLabel* clone = ast_pool -> GenSwitchLabel();
817 clone -> case_token = case_token;
818 if (expression_opt)
819 clone -> expression_opt =
820 (AstExpression*) expression_opt -> Clone(ast_pool);
821 clone -> colon_token = colon_token;
822 clone -> map_index = map_index;
823 return clone;
824 }
825
Clone(StoragePool * ast_pool)826 Ast* AstSwitchBlockStatement::Clone(StoragePool* ast_pool)
827 {
828 AstSwitchBlockStatement* clone = ast_pool -> GenSwitchBlockStatement();
829 clone -> CloneBlock(ast_pool, this);
830 clone -> AllocateSwitchLabels(NumSwitchLabels());
831 for (unsigned i = 0; i < NumSwitchLabels(); i++)
832 clone -> AddSwitchLabel((AstSwitchLabel*) SwitchLabel(i) ->
833 Clone(ast_pool));
834 return clone;
835 }
836
Clone(StoragePool * ast_pool)837 Ast* AstSwitchStatement::Clone(StoragePool* ast_pool)
838 {
839 AstSwitchStatement* clone = ast_pool -> GenSwitchStatement();
840 clone -> switch_token = switch_token;
841 clone -> expression = (AstExpression*) expression -> Clone(ast_pool);
842 clone -> switch_block = (AstBlock*) switch_block -> Clone(ast_pool);
843 clone -> AllocateCases(NumCases());
844 if (DefaultCase())
845 {
846 clone -> DefaultCase() = ast_pool -> GenCaseElement(0, 0);
847 *clone -> DefaultCase() = *DefaultCase();
848 }
849 for (unsigned i = 0; i < NumCases(); i++)
850 {
851 CaseElement* elt = ast_pool -> GenCaseElement(0, 0);
852 *elt = *Case(i);
853 clone -> AddCase(elt);
854 }
855 return clone;
856 }
857
Clone(StoragePool * ast_pool)858 Ast* AstWhileStatement::Clone(StoragePool* ast_pool)
859 {
860 AstWhileStatement* clone = ast_pool -> GenWhileStatement();
861 clone -> while_token = while_token;
862 clone -> expression = (AstExpression*) expression -> Clone(ast_pool);
863 clone -> statement = (AstBlock*) statement -> Clone(ast_pool);
864 return clone;
865 }
866
Clone(StoragePool * ast_pool)867 Ast* AstDoStatement::Clone(StoragePool* ast_pool)
868 {
869 AstDoStatement* clone = ast_pool -> GenDoStatement();
870 clone -> do_token = do_token;
871 clone -> statement = (AstBlock*) statement -> Clone(ast_pool);
872 clone -> while_token = while_token;
873 clone -> expression = (AstExpression*) expression -> Clone(ast_pool);
874 clone -> semicolon_token = semicolon_token;
875 return clone;
876 }
877
Clone(StoragePool * ast_pool)878 Ast* AstForStatement::Clone(StoragePool* ast_pool)
879 {
880 unsigned i;
881 AstForStatement* clone = ast_pool -> GenForStatement();
882 clone -> for_token = for_token;
883 clone -> AllocateForInitStatements(NumForInitStatements());
884 for (i = 0; i < NumForInitStatements(); i++)
885 clone -> AddForInitStatement((AstStatement*)
886 ForInitStatement(i) -> Clone(ast_pool));
887 if (end_expression_opt)
888 clone -> end_expression_opt =
889 (AstExpression*) end_expression_opt -> Clone(ast_pool);
890 clone -> AllocateForUpdateStatements(NumForUpdateStatements());
891 for (i = 0; i < NumForUpdateStatements(); i++)
892 clone -> AddForUpdateStatement((AstExpressionStatement*)
893 ForUpdateStatement(i) ->
894 Clone(ast_pool));
895 clone -> statement = (AstBlock*) statement -> Clone(ast_pool);
896 return clone;
897 }
898
Clone(StoragePool * ast_pool)899 Ast* AstForeachStatement::Clone(StoragePool* ast_pool)
900 {
901 AstForeachStatement* clone = ast_pool -> GenForeachStatement();
902 clone -> for_token = for_token;
903 clone -> formal_parameter =
904 (AstFormalParameter*) formal_parameter -> Clone(ast_pool);
905 clone -> expression = (AstExpression*) expression -> Clone(ast_pool);
906 clone -> statement = (AstBlock*) statement -> Clone(ast_pool);
907 return clone;
908 }
909
Clone(StoragePool * ast_pool)910 Ast* AstBreakStatement::Clone(StoragePool* ast_pool)
911 {
912 AstBreakStatement* clone = ast_pool -> GenBreakStatement();
913 clone -> break_token = break_token;
914 clone -> identifier_token_opt = identifier_token_opt;
915 clone -> semicolon_token = semicolon_token;
916 clone -> nesting_level = nesting_level;
917 return clone;
918 }
919
Clone(StoragePool * ast_pool)920 Ast* AstContinueStatement::Clone(StoragePool* ast_pool)
921 {
922 AstContinueStatement* clone = ast_pool -> GenContinueStatement();
923 clone -> continue_token = continue_token;
924 clone -> identifier_token_opt = identifier_token_opt;
925 clone -> semicolon_token = semicolon_token;
926 clone -> nesting_level = nesting_level;
927 return clone;
928 }
929
Clone(StoragePool * ast_pool)930 Ast* AstReturnStatement::Clone(StoragePool* ast_pool)
931 {
932 AstReturnStatement* clone = ast_pool -> GenReturnStatement();
933 clone -> return_token = return_token;
934 if (expression_opt)
935 clone -> expression_opt =
936 (AstExpression*) expression_opt -> Clone(ast_pool);
937 clone -> semicolon_token = semicolon_token;
938 return clone;
939 }
940
Clone(StoragePool * ast_pool)941 Ast* AstThrowStatement::Clone(StoragePool* ast_pool)
942 {
943 AstThrowStatement* clone = ast_pool -> GenThrowStatement();
944 clone -> throw_token = throw_token;
945 clone -> expression = (AstExpression*) expression -> Clone(ast_pool);
946 clone -> semicolon_token = semicolon_token;
947 return clone;
948 }
949
Clone(StoragePool * ast_pool)950 Ast* AstSynchronizedStatement::Clone(StoragePool* ast_pool)
951 {
952 AstSynchronizedStatement* clone = ast_pool -> GenSynchronizedStatement();
953 clone -> synchronized_token = synchronized_token;
954 clone -> expression = (AstExpression*) expression -> Clone(ast_pool);
955 clone -> block = (AstBlock*) block -> Clone(ast_pool);
956 return clone;
957 }
958
Clone(StoragePool * ast_pool)959 Ast* AstAssertStatement::Clone(StoragePool* ast_pool)
960 {
961 AstAssertStatement* clone = ast_pool -> GenAssertStatement();
962 clone -> assert_token = assert_token;
963 clone -> condition = (AstExpression*) condition -> Clone(ast_pool);
964 if (message_opt)
965 clone -> message_opt = (AstExpression*) message_opt -> Clone(ast_pool);
966 clone -> semicolon_token = semicolon_token;
967 return clone;
968 }
969
Clone(StoragePool * ast_pool)970 Ast* AstCatchClause::Clone(StoragePool* ast_pool)
971 {
972 AstCatchClause* clone = ast_pool -> GenCatchClause();
973 clone -> catch_token = catch_token;
974 clone -> formal_parameter =
975 (AstFormalParameter*) formal_parameter -> Clone(ast_pool);
976 clone -> block = (AstBlock*) block -> Clone(ast_pool);
977 return clone;
978 }
979
Clone(StoragePool * ast_pool)980 Ast* AstFinallyClause::Clone(StoragePool* ast_pool)
981 {
982 AstFinallyClause* clone = ast_pool -> GenFinallyClause();
983 clone -> finally_token = finally_token;
984 clone -> block = (AstBlock*) block -> Clone(ast_pool);
985 return clone;
986 }
987
Clone(StoragePool * ast_pool)988 Ast* AstTryStatement::Clone(StoragePool* ast_pool)
989 {
990 AstTryStatement* clone = ast_pool -> GenTryStatement();
991 clone -> try_token = try_token;
992 clone -> block = (AstBlock*) block -> Clone(ast_pool);
993 clone -> AllocateCatchClauses(NumCatchClauses());
994 for (unsigned i = 0; i < NumCatchClauses(); i++)
995 clone -> AddCatchClause((AstCatchClause*) CatchClause(i) ->
996 Clone(ast_pool));
997 if (finally_clause_opt)
998 clone -> finally_clause_opt =
999 (AstFinallyClause*) finally_clause_opt -> Clone(ast_pool);
1000 return clone;
1001 }
1002
Clone(StoragePool * ast_pool)1003 Ast* AstIntegerLiteral::Clone(StoragePool* ast_pool)
1004 {
1005 return ast_pool -> GenIntegerLiteral(integer_literal_token);
1006 }
1007
Clone(StoragePool * ast_pool)1008 Ast* AstLongLiteral::Clone(StoragePool* ast_pool)
1009 {
1010 return ast_pool -> GenLongLiteral(long_literal_token);
1011 }
1012
Clone(StoragePool * ast_pool)1013 Ast* AstFloatLiteral::Clone(StoragePool* ast_pool)
1014 {
1015 return ast_pool -> GenFloatLiteral(float_literal_token);
1016 }
1017
Clone(StoragePool * ast_pool)1018 Ast* AstDoubleLiteral::Clone(StoragePool* ast_pool)
1019 {
1020 return ast_pool -> GenDoubleLiteral(double_literal_token);
1021 }
1022
Clone(StoragePool * ast_pool)1023 Ast* AstTrueLiteral::Clone(StoragePool* ast_pool)
1024 {
1025 return ast_pool -> GenTrueLiteral(true_literal_token);
1026 }
1027
Clone(StoragePool * ast_pool)1028 Ast* AstFalseLiteral::Clone(StoragePool* ast_pool)
1029 {
1030 return ast_pool -> GenFalseLiteral(false_literal_token);
1031 }
1032
Clone(StoragePool * ast_pool)1033 Ast* AstStringLiteral::Clone(StoragePool* ast_pool)
1034 {
1035 return ast_pool -> GenStringLiteral(string_literal_token);
1036 }
1037
Clone(StoragePool * ast_pool)1038 Ast* AstCharacterLiteral::Clone(StoragePool* ast_pool)
1039 {
1040 return ast_pool -> GenCharacterLiteral(character_literal_token);
1041 }
1042
Clone(StoragePool * ast_pool)1043 Ast* AstNullLiteral::Clone(StoragePool* ast_pool)
1044 {
1045 return ast_pool -> GenNullLiteral(null_token);
1046 }
1047
Clone(StoragePool * ast_pool)1048 Ast* AstClassLiteral::Clone(StoragePool* ast_pool)
1049 {
1050 AstClassLiteral* clone = ast_pool -> GenClassLiteral(class_token);
1051 clone -> type = (AstTypeName*) type -> Clone(ast_pool);
1052 if (resolution_opt)
1053 clone -> resolution_opt =
1054 (AstExpression*) resolution_opt -> Clone(ast_pool);
1055 return clone;
1056 }
1057
Clone(StoragePool * ast_pool)1058 Ast* AstThisExpression::Clone(StoragePool* ast_pool)
1059 {
1060 AstThisExpression* clone = ast_pool -> GenThisExpression(this_token);
1061 if (base_opt)
1062 clone -> base_opt = (AstTypeName*) base_opt -> Clone(ast_pool);
1063 if (resolution_opt)
1064 clone -> resolution_opt =
1065 (AstExpression*) resolution_opt -> Clone(ast_pool);
1066 return clone;
1067 }
1068
Clone(StoragePool * ast_pool)1069 Ast* AstSuperExpression::Clone(StoragePool* ast_pool)
1070 {
1071 AstSuperExpression* clone = ast_pool -> GenSuperExpression(super_token);
1072 if (base_opt)
1073 clone -> base_opt = (AstTypeName*) base_opt -> Clone(ast_pool);
1074 if (resolution_opt)
1075 clone -> resolution_opt =
1076 (AstExpression*) resolution_opt -> Clone(ast_pool);
1077 return clone;
1078 }
1079
Clone(StoragePool * ast_pool)1080 Ast* AstParenthesizedExpression::Clone(StoragePool* ast_pool)
1081 {
1082 AstParenthesizedExpression* clone =
1083 ast_pool -> GenParenthesizedExpression();
1084 clone -> left_parenthesis_token = left_parenthesis_token;
1085 clone -> expression = (AstExpression*) expression -> Clone(ast_pool);
1086 clone -> right_parenthesis_token = right_parenthesis_token;
1087 return clone;
1088 }
1089
Clone(StoragePool * ast_pool)1090 Ast* AstClassCreationExpression::Clone(StoragePool* ast_pool)
1091 {
1092 AstClassCreationExpression* clone =
1093 ast_pool -> GenClassCreationExpression();
1094 if (base_opt)
1095 clone -> base_opt = (AstExpression*) base_opt -> Clone(ast_pool);
1096 clone -> new_token = new_token;
1097 if (type_arguments_opt)
1098 clone -> type_arguments_opt =
1099 (AstTypeArguments*) type_arguments_opt -> Clone(ast_pool);
1100 clone -> class_type = (AstTypeName*) class_type -> Clone(ast_pool);
1101 clone -> arguments = (AstArguments*) arguments -> Clone(ast_pool);
1102 if (class_body_opt)
1103 clone -> class_body_opt =
1104 (AstClassBody*) class_body_opt -> Clone(ast_pool);
1105 if (resolution_opt)
1106 clone -> resolution_opt =
1107 (AstClassCreationExpression*) resolution_opt -> Clone(ast_pool);
1108 return clone;
1109 }
1110
Clone(StoragePool * ast_pool)1111 Ast* AstDimExpr::Clone(StoragePool* ast_pool)
1112 {
1113 AstDimExpr* clone = ast_pool -> GenDimExpr();
1114 clone -> left_bracket_token = left_bracket_token;
1115 clone -> expression = (AstExpression*) expression -> Clone(ast_pool);
1116 clone -> right_bracket_token = right_bracket_token;
1117 return clone;
1118 }
1119
Clone(StoragePool * ast_pool)1120 Ast* AstArrayCreationExpression::Clone(StoragePool* ast_pool)
1121 {
1122 AstArrayCreationExpression* clone =
1123 ast_pool -> GenArrayCreationExpression();
1124 clone -> new_token = new_token;
1125 clone -> array_type = (AstType*) array_type -> Clone(ast_pool);
1126 clone -> AllocateDimExprs(NumDimExprs());
1127 for (unsigned i = 0; i < NumDimExprs(); i++)
1128 clone -> AddDimExpr((AstDimExpr*) DimExpr(i) -> Clone(ast_pool));
1129 if (brackets_opt)
1130 clone -> brackets_opt = (AstBrackets*) brackets_opt -> Clone(ast_pool);
1131 if (array_initializer_opt)
1132 clone -> array_initializer_opt =
1133 (AstArrayInitializer*) array_initializer_opt -> Clone(ast_pool);
1134 return clone;
1135 }
1136
Clone(StoragePool * ast_pool)1137 Ast* AstFieldAccess::Clone(StoragePool* ast_pool)
1138 {
1139 AstFieldAccess* clone = ast_pool -> GenFieldAccess();
1140 clone -> base = (AstExpression*) base -> Clone(ast_pool);
1141 clone -> identifier_token = identifier_token;
1142 if (resolution_opt)
1143 clone -> resolution_opt =
1144 (AstExpression*) resolution_opt -> Clone(ast_pool);
1145 return clone;
1146 }
1147
Clone(StoragePool * ast_pool)1148 Ast* AstMethodInvocation::Clone(StoragePool* ast_pool)
1149 {
1150 AstMethodInvocation* clone =
1151 ast_pool -> GenMethodInvocation(identifier_token);
1152 if (base_opt)
1153 clone -> base_opt = (AstExpression*) base_opt -> Clone(ast_pool);
1154 if (type_arguments_opt)
1155 clone -> type_arguments_opt =
1156 (AstTypeArguments*) type_arguments_opt -> Clone(ast_pool);
1157 clone -> identifier_token = identifier_token;
1158 clone -> arguments = (AstArguments*) arguments -> Clone(ast_pool);
1159 if (resolution_opt)
1160 clone -> resolution_opt =
1161 (AstExpression*) resolution_opt -> Clone(ast_pool);
1162 return clone;
1163 }
1164
Clone(StoragePool * ast_pool)1165 Ast* AstArrayAccess::Clone(StoragePool* ast_pool)
1166 {
1167 AstArrayAccess* clone = ast_pool -> GenArrayAccess();
1168 clone -> base = (AstExpression*) base -> Clone(ast_pool);
1169 clone -> left_bracket_token = left_bracket_token;
1170 clone -> expression = (AstExpression*) expression -> Clone(ast_pool);
1171 clone -> right_bracket_token = right_bracket_token;
1172 return clone;
1173 }
1174
Clone(StoragePool * ast_pool)1175 Ast* AstPostUnaryExpression::Clone(StoragePool* ast_pool)
1176 {
1177 AstPostUnaryExpression* clone =
1178 ast_pool -> GenPostUnaryExpression((PostUnaryExpressionTag) other_tag);
1179 clone -> expression = (AstExpression*) expression -> Clone(ast_pool);
1180 clone -> post_operator_token = post_operator_token;
1181 return clone;
1182 }
1183
Clone(StoragePool * ast_pool)1184 Ast* AstPreUnaryExpression::Clone(StoragePool* ast_pool)
1185 {
1186 AstPreUnaryExpression* clone =
1187 ast_pool -> GenPreUnaryExpression((PreUnaryExpressionTag) other_tag);
1188 clone -> pre_operator_token = pre_operator_token;
1189 clone -> expression = (AstExpression*) expression -> Clone(ast_pool);
1190 return clone;
1191 }
1192
Clone(StoragePool * ast_pool)1193 Ast* AstCastExpression::Clone(StoragePool* ast_pool)
1194 {
1195 AstCastExpression* clone = ast_pool -> GenCastExpression();
1196 clone -> left_parenthesis_token = left_parenthesis_token;
1197 if (type)
1198 clone -> type = (AstType*) type -> Clone(ast_pool);
1199 clone -> right_parenthesis_token = right_parenthesis_token;
1200 clone -> expression = (AstExpression*) expression -> Clone(ast_pool);
1201 return clone;
1202 }
1203
Clone(StoragePool * ast_pool)1204 Ast* AstBinaryExpression::Clone(StoragePool* ast_pool)
1205 {
1206 AstBinaryExpression* clone =
1207 ast_pool -> GenBinaryExpression((BinaryExpressionTag) other_tag);
1208 clone -> left_expression =
1209 (AstExpression*) left_expression -> Clone(ast_pool);
1210 clone -> binary_operator_token = binary_operator_token;
1211 clone -> right_expression =
1212 (AstExpression*) right_expression -> Clone(ast_pool);
1213 return clone;
1214 }
1215
Clone(StoragePool * ast_pool)1216 Ast* AstInstanceofExpression::Clone(StoragePool* ast_pool)
1217 {
1218 AstInstanceofExpression* clone = ast_pool -> GenInstanceofExpression();
1219 clone -> expression = (AstExpression*) expression -> Clone(ast_pool);
1220 clone -> instanceof_token = instanceof_token;
1221 clone -> type = (AstType*) type -> Clone(ast_pool);
1222 return clone;
1223 }
1224
Clone(StoragePool * ast_pool)1225 Ast* AstConditionalExpression::Clone(StoragePool* ast_pool)
1226 {
1227 AstConditionalExpression* clone = ast_pool -> GenConditionalExpression();
1228 clone -> test_expression =
1229 (AstExpression*) test_expression -> Clone(ast_pool);
1230 clone -> question_token = question_token;
1231 clone -> true_expression =
1232 (AstExpression*) true_expression -> Clone(ast_pool);
1233 clone -> colon_token = colon_token;
1234 clone -> false_expression =
1235 (AstExpression*) false_expression -> Clone(ast_pool);
1236 return clone;
1237 }
1238
Clone(StoragePool * ast_pool)1239 Ast* AstAssignmentExpression::Clone(StoragePool* ast_pool)
1240 {
1241 AstAssignmentExpression* clone = ast_pool ->
1242 GenAssignmentExpression((AssignmentExpressionTag) other_tag,
1243 assignment_operator_token);
1244 clone -> left_hand_side =
1245 (AstExpression*) left_hand_side -> Clone(ast_pool);
1246 clone -> expression = (AstExpression*) expression -> Clone(ast_pool);
1247 return clone;
1248 }
1249
1250
1251 #ifdef JIKES_DEBUG
1252
1253 //
1254 // These methods allow printing the Ast structure to Coutput (usually stdout).
1255 //
Print(LexStream & lex_stream)1256 void AstBlock::Print(LexStream& lex_stream)
1257 {
1258 unsigned i;
1259 Coutput << '#' << id << " (";
1260 if (label_opt)
1261 Coutput << lex_stream.NameString(label_opt) << ": ";
1262 Coutput << "Block at level " << nesting_level;
1263 if (block_symbol)
1264 Coutput << ", max_variable_index "
1265 << block_symbol -> max_variable_index
1266 << ", helper_variable_index "
1267 << block_symbol -> helper_variable_index;
1268 else Coutput << ", BLOCK_SYMBOL NOT SET";
1269 Coutput << ')';
1270
1271 if (NumStatements() > 0)
1272 {
1273 Coutput << " {";
1274 for (i = 0; i < NumStatements(); i++)
1275 {
1276 if (i % 10 == 0)
1277 Coutput << endl << " ";
1278 Coutput << " #" << Statement(i) -> id;
1279 }
1280 Coutput << " }" << endl;
1281 for (i = 0; i < NumStatements(); i++)
1282 Statement(i) -> Print(lex_stream);
1283 }
1284 else Coutput << endl;
1285 }
1286
Print(LexStream & lex_stream)1287 void AstName::Print(LexStream& lex_stream)
1288 {
1289 Coutput << '#' << id << " (Name): #"
1290 << (base_opt ? base_opt -> id : 0) << '.'
1291 << lex_stream.NameString(identifier_token) << endl;
1292 if (base_opt)
1293 base_opt -> Print(lex_stream);
1294 }
1295
Print(LexStream & lex_stream)1296 void AstPrimitiveType::Print(LexStream& lex_stream)
1297 {
1298 Coutput << '#' << id << " (PrimitiveType): "
1299 << lex_stream.NameString(primitive_kind_token) << endl;
1300 }
1301
Print(LexStream & lex_stream)1302 void AstBrackets::Print(LexStream& lex_stream)
1303 {
1304 Coutput << '#' << id << " (Brackets, dims=" << dims << "): ";
1305 for (TokenIndex i = left_bracket_token; i <= right_bracket_token; i++)
1306 Coutput << lex_stream.NameString(i);
1307 Coutput << endl;
1308 }
1309
Print(LexStream & lex_stream)1310 void AstArrayType::Print(LexStream& lex_stream)
1311 {
1312 Coutput << '#' << id << " (ArrayType): "
1313 << '#' << type -> id << ' ' << brackets -> id << endl;
1314 type -> Print(lex_stream);
1315 brackets -> Print(lex_stream);
1316 }
1317
Print(LexStream & lex_stream)1318 void AstWildcard::Print(LexStream& lex_stream)
1319 {
1320 Coutput << '#' << id << " (Wildcard): "
1321 << lex_stream.NameString(question_token);
1322 if (extends_token_opt)
1323 Coutput << ' ' << lex_stream.NameString(extends_token_opt) << " #"
1324 << bounds_opt -> id;
1325 else if (super_token_opt)
1326 Coutput << ' ' << lex_stream.NameString(super_token_opt) << " #"
1327 << bounds_opt -> id;
1328 Coutput << endl;
1329 if (bounds_opt)
1330 bounds_opt -> Print(lex_stream);
1331 }
1332
Print(LexStream & lex_stream)1333 void AstTypeArguments::Print(LexStream& lex_stream)
1334 {
1335 unsigned i;
1336 Coutput << '#' << id << " (TypeArguments): <";
1337 for (i = 0; i < NumTypeArguments(); i++)
1338 Coutput << " #" << TypeArgument(i) -> id;
1339 Coutput << '>' << endl;
1340 for (i = 0; i < NumTypeArguments(); i++)
1341 TypeArgument(i) -> Print(lex_stream);
1342 }
1343
Print(LexStream & lex_stream)1344 void AstTypeName::Print(LexStream& lex_stream)
1345 {
1346 Coutput << '#' << id << " (TypeName): #"
1347 << (base_opt ? base_opt -> id : 0) << ".#" << name -> id << "<#"
1348 << (type_arguments_opt ? type_arguments_opt -> id : 0) << '>'
1349 << endl;
1350 if (base_opt)
1351 base_opt -> Print(lex_stream);
1352 name -> Print(lex_stream);
1353 if (type_arguments_opt)
1354 type_arguments_opt -> Print(lex_stream);
1355 }
1356
Print(LexStream & lex_stream)1357 void AstMemberValuePair::Print(LexStream& lex_stream)
1358 {
1359 Coutput << '#' << id << " (MemberValuePair): "
1360 << (identifier_token_opt
1361 ? lex_stream.NameString(identifier_token_opt) : L"(value)")
1362 << "=#" << member_value -> id << endl;
1363 member_value -> Print(lex_stream);
1364 }
1365
Print(LexStream & lex_stream)1366 void AstAnnotation::Print(LexStream& lex_stream)
1367 {
1368 unsigned i;
1369 Coutput << '#' << id << " (Annotation): #" << name -> id << '(';
1370 for (i = 0; i < NumMemberValuePairs(); i++)
1371 {
1372 if (i % 10 == 0)
1373 Coutput << endl << " ";
1374 Coutput << " #" << MemberValuePair(i) -> id;
1375 }
1376 Coutput << ')' << endl;
1377 name -> Print(lex_stream);
1378 for (i = 0; i < NumMemberValuePairs(); i++)
1379 MemberValuePair(i) -> Print(lex_stream);
1380 }
1381
Print(LexStream & lex_stream)1382 void AstModifierKeyword::Print(LexStream& lex_stream)
1383 {
1384 Coutput << '#' << id << " (ModifierKeyword): "
1385 << lex_stream.NameString(modifier_token) << endl;
1386 }
1387
Print(LexStream & lex_stream)1388 void AstModifiers::Print(LexStream& lex_stream)
1389 {
1390 unsigned i;
1391 Coutput << '#' << id << " (Modifiers): ";
1392 for (i = 0; i < NumModifiers(); i++)
1393 Coutput << " #" << Modifier(i) -> id;
1394 Coutput << endl;
1395 for (i = 0; i < NumModifiers(); i++)
1396 Modifier(i) -> Print(lex_stream);
1397 }
1398
Print(LexStream & lex_stream)1399 void AstPackageDeclaration::Print(LexStream& lex_stream)
1400 {
1401 Coutput << '#' << id << " (PackageDeclaration): #"
1402 << (modifiers_opt ? modifiers_opt -> id : 0) << ' '
1403 << lex_stream.NameString(package_token)
1404 << " #" << name -> id << endl;
1405 if (modifiers_opt)
1406 modifiers_opt -> Print(lex_stream);
1407 name -> Print(lex_stream);
1408 }
1409
Print(LexStream & lex_stream)1410 void AstImportDeclaration::Print(LexStream& lex_stream)
1411 {
1412 Coutput << '#' << id << " (ImportDeclaration): ";
1413 if (static_token_opt)
1414 Coutput << lex_stream.NameString(static_token_opt) << ' ';
1415 Coutput << lex_stream.NameString(import_token)
1416 << " #" << name -> id;
1417 if (star_token_opt)
1418 Coutput << '.' << lex_stream.NameString(star_token_opt);
1419 Coutput << endl;
1420 name -> Print(lex_stream);
1421 }
1422
Print(LexStream & lex_stream)1423 void AstCompilationUnit::Print(LexStream& lex_stream)
1424 {
1425 unsigned i;
1426 Coutput << endl << "AST structure for "
1427 << lex_stream.FileName()
1428 << ':' << endl << endl
1429 << '#' << id << " (CompilationUnit): #"
1430 << (package_declaration_opt ? package_declaration_opt -> id : 0)
1431 << " (";
1432 for (i = 0; i < NumImportDeclarations(); i++)
1433 Coutput << " #" << ImportDeclaration(i) -> id;
1434 Coutput << " ) (";
1435 for (i = 0; i < NumTypeDeclarations(); i++)
1436 Coutput << " #" << TypeDeclaration(i) -> id;
1437 Coutput << ')' << endl;
1438
1439 if (package_declaration_opt)
1440 package_declaration_opt -> Print(lex_stream);
1441 for (i = 0; i < NumImportDeclarations(); i++)
1442 ImportDeclaration(i) -> Print(lex_stream);
1443 for (i = 0; i < NumTypeDeclarations(); i++)
1444 TypeDeclaration(i) -> Print(lex_stream);
1445 }
1446
Print(LexStream & lex_stream)1447 void AstEmptyDeclaration::Print(LexStream& lex_stream)
1448 {
1449 Coutput << '#' << id << " (EmptyDeclaration): "
1450 << lex_stream.NameString(semicolon_token) << endl;
1451 }
1452
Print(LexStream & lex_stream)1453 void AstClassBody::Print(LexStream& lex_stream)
1454 {
1455 unsigned i;
1456 Coutput << '#' << id << " (ClassBody): "
1457 << endl << " {";
1458 for (i = 0; i < NumClassBodyDeclarations(); i++)
1459 {
1460 if (i % 10 == 0)
1461 Coutput << endl << " ";
1462 Coutput << " #" << ClassBodyDeclaration(i) -> id;
1463 }
1464 Coutput << endl << " }" << endl;
1465
1466 for (i = 0; i < NumClassBodyDeclarations(); i++)
1467 ClassBodyDeclaration(i) -> Print(lex_stream);
1468 }
1469
Print(LexStream & lex_stream)1470 void AstTypeParameter::Print(LexStream& lex_stream)
1471 {
1472 unsigned i;
1473 Coutput << '#' << id << " (TypeParameter): "
1474 << lex_stream.NameString(identifier_token) << " (";
1475 for (i = 0; i < NumBounds(); i++)
1476 Coutput << " #" << Bound(i) -> id;
1477 Coutput << ')' << endl;
1478 for (i = 0; i < NumBounds(); i++)
1479 Bound(i) -> Print(lex_stream);
1480 }
1481
Print(LexStream & lex_stream)1482 void AstTypeParameters::Print(LexStream& lex_stream)
1483 {
1484 unsigned i;
1485 Coutput << '#' << id << " (TypeParameters): <";
1486 for (i = 0; i < NumTypeParameters(); i++)
1487 Coutput << " #" << TypeParameter(i) -> id;
1488 Coutput << '>' << endl;
1489 for (i = 0; i < NumTypeParameters(); i++)
1490 TypeParameter(i) -> Print(lex_stream);
1491 }
1492
Print(LexStream & lex_stream)1493 void AstClassDeclaration::Print(LexStream& lex_stream)
1494 {
1495 unsigned i;
1496 Coutput << '#' << id << " (ClassDeclaration): #"
1497 << (modifiers_opt ? modifiers_opt -> id : 0) << ' '
1498 << lex_stream.NameString(class_token) << ' '
1499 << lex_stream.NameString(class_body -> identifier_token) << " #"
1500 << (type_parameters_opt ? type_parameters_opt -> id : 0)
1501 << " #" << (super_opt ? super_opt -> id : 0) << '(';
1502 for (i = 0; i < NumInterfaces(); i++)
1503 Coutput << " #" << Interface(i) -> id;
1504 Coutput << ") #" << class_body -> id << endl;
1505 if (modifiers_opt)
1506 modifiers_opt -> Print(lex_stream);
1507 if (type_parameters_opt)
1508 type_parameters_opt -> Print(lex_stream);
1509 if (super_opt)
1510 super_opt -> Print(lex_stream);
1511 for (i = 0; i < NumInterfaces(); i++)
1512 Interface(i) -> Print(lex_stream);
1513 class_body -> Print(lex_stream);
1514 }
1515
Print(LexStream & lex_stream)1516 void AstArrayInitializer::Print(LexStream& lex_stream)
1517 {
1518 unsigned i;
1519 Coutput << '#' << id << " (ArrayInitializer): "
1520 << endl << " {";
1521 for (i = 0; i < NumVariableInitializers(); i++)
1522 {
1523 if (i % 10 == 0)
1524 Coutput << endl << " ";
1525 Coutput << " #" << VariableInitializer(i) -> id;
1526 }
1527 Coutput << endl << " }" << endl;
1528
1529 for (i = 0; i < NumVariableInitializers(); i++)
1530 VariableInitializer(i) -> Print(lex_stream);
1531 }
1532
Print(LexStream & lex_stream)1533 void AstVariableDeclaratorId::Print(LexStream& lex_stream)
1534 {
1535 Coutput << '#' << id << " (VariableDeclaratorId): "
1536 << lex_stream.NameString(identifier_token) << " #"
1537 << (brackets_opt ? brackets_opt -> id : 0) << endl;
1538 if (brackets_opt)
1539 brackets_opt -> Print(lex_stream);
1540 }
1541
Print(LexStream & lex_stream)1542 void AstVariableDeclarator::Print(LexStream& lex_stream)
1543 {
1544 Coutput << '#' << id << " (VariableDeclarator): " << '#'
1545 << variable_declarator_name -> id << " #"
1546 << (variable_initializer_opt ? variable_initializer_opt -> id : 0)
1547 << endl;
1548 variable_declarator_name -> Print(lex_stream);
1549 if (variable_initializer_opt)
1550 variable_initializer_opt -> Print(lex_stream);
1551
1552 }
1553
Print(LexStream & lex_stream)1554 void AstFieldDeclaration::Print(LexStream& lex_stream)
1555 {
1556 unsigned i;
1557 Coutput << '#' << id << " (FieldDeclaration): #"
1558 << (modifiers_opt ? modifiers_opt -> id : 0)
1559 << " #" << type -> id << '(';
1560 for (i = 0; i < NumVariableDeclarators(); i++)
1561 Coutput << " #" << VariableDeclarator(i) -> id;
1562 Coutput << ')' << endl;
1563 if (modifiers_opt)
1564 modifiers_opt -> Print(lex_stream);
1565 type -> Print(lex_stream);
1566 for (i = 0; i < NumVariableDeclarators(); i++)
1567 VariableDeclarator(i) -> Print(lex_stream);
1568 }
1569
Print(LexStream & lex_stream)1570 void AstFormalParameter::Print(LexStream& lex_stream)
1571 {
1572 Coutput << '#' << id << " (FormalParameter): #"
1573 << (modifiers_opt ? modifiers_opt -> id : 0)
1574 << " #" << type -> id << " #" << formal_declarator -> id << endl;
1575 if (modifiers_opt)
1576 modifiers_opt -> Print(lex_stream);
1577 type -> Print(lex_stream);
1578 if (ellipsis_token_opt)
1579 Coutput << lex_stream.NameString(ellipsis_token_opt);
1580 formal_declarator -> Print(lex_stream);
1581 }
1582
Print(LexStream & lex_stream)1583 void AstMethodDeclarator::Print(LexStream& lex_stream)
1584 {
1585 unsigned i;
1586 Coutput << '#' << id << " (MethodDeclarator): "
1587 << lex_stream.NameString(identifier_token)
1588 << " (";
1589 for (i = 0; i < NumFormalParameters(); i++)
1590 Coutput << " #" << FormalParameter(i) -> id;
1591 Coutput << " ) #" << (brackets_opt ? brackets_opt -> id : 0) << endl;
1592 for (i = 0; i < NumFormalParameters(); i++)
1593 FormalParameter(i) -> Print(lex_stream);
1594 if (brackets_opt)
1595 brackets_opt -> Print(lex_stream);
1596 }
1597
Print(LexStream & lex_stream)1598 void AstMethodBody::Print(LexStream& lex_stream)
1599 {
1600 Coutput << '#' << id << " (MethodBody): ";
1601 if (explicit_constructor_opt)
1602 Coutput << " #" << explicit_constructor_opt -> id << endl;
1603 else Coutput << " #0" << endl;
1604 AstBlock::Print(lex_stream);
1605
1606 if (explicit_constructor_opt)
1607 explicit_constructor_opt -> Print(lex_stream);
1608 }
1609
Print(LexStream & lex_stream)1610 void AstMethodDeclaration::Print(LexStream& lex_stream)
1611 {
1612 unsigned i;
1613 Coutput << '#' << id << " (MethodDeclaration): #"
1614 << (modifiers_opt ? modifiers_opt -> id : 0) << " <#"
1615 << (type_parameters_opt ? type_parameters_opt -> id : 0)
1616 << "> #" << type -> id << " #" << method_declarator -> id
1617 << " throws: (";
1618 for (i = 0; i < NumThrows(); i++)
1619 Coutput << " #" << Throw(i) -> id;
1620 Coutput << ") default #"
1621 << (default_value_opt ? default_value_opt -> id : 0) << ' '
1622 << (method_body_opt ? method_body_opt -> id : 0) << endl;
1623 if (modifiers_opt)
1624 modifiers_opt -> Print(lex_stream);
1625 if (type_parameters_opt)
1626 type_parameters_opt -> Print(lex_stream);
1627 type -> Print(lex_stream);
1628 method_declarator -> Print(lex_stream);
1629 for (i = 0; i < NumThrows(); i++)
1630 Throw(i) -> Print(lex_stream);
1631 if (default_value_opt)
1632 default_value_opt -> Print(lex_stream);
1633 if (method_body_opt)
1634 method_body_opt -> Print(lex_stream);
1635 }
1636
Print(LexStream & lex_stream)1637 void AstInitializerDeclaration::Print(LexStream& lex_stream)
1638 {
1639 Coutput << '#' << id << " (InitializerDeclaration): #"
1640 << (modifiers_opt ? modifiers_opt -> id : 0)
1641 << " #" << block -> id << endl;
1642 if (modifiers_opt)
1643 modifiers_opt -> Print(lex_stream);
1644 block -> Print(lex_stream);
1645 }
1646
Print(LexStream & lex_stream)1647 void AstArguments::Print(LexStream& lex_stream)
1648 {
1649 unsigned i;
1650 Coutput << '#' << id << " (Arguments): (";
1651 for (i = 0; i < NumArguments(); i++)
1652 Coutput << " #" << Argument(i) -> id;
1653 Coutput << ')' << endl;
1654 for (i = 0; i < NumArguments(); i++)
1655 Argument(i) -> Print(lex_stream);
1656 }
1657
Print(LexStream & lex_stream)1658 void AstThisCall::Print(LexStream& lex_stream)
1659 {
1660 Coutput << '#' << id << " (ThisCall): #"
1661 << (type_arguments_opt ? type_arguments_opt -> id : 0)
1662 << lex_stream.NameString(this_token) << " #" << arguments -> id
1663 << endl;
1664 if (type_arguments_opt)
1665 type_arguments_opt -> Print(lex_stream);
1666 arguments -> Print(lex_stream);
1667 }
1668
Print(LexStream & lex_stream)1669 void AstSuperCall::Print(LexStream& lex_stream)
1670 {
1671 Coutput << '#' << id << " (SuperCall): #"
1672 << (base_opt ? base_opt -> id : 0) << ".#"
1673 << (type_arguments_opt ? type_arguments_opt -> id : 0)
1674 << lex_stream.NameString(super_token) << " #" << arguments -> id
1675 << endl;
1676 if (base_opt)
1677 base_opt -> Print(lex_stream);
1678 if (type_arguments_opt)
1679 type_arguments_opt -> Print(lex_stream);
1680 arguments -> Print(lex_stream);
1681 }
1682
Print(LexStream & lex_stream)1683 void AstConstructorDeclaration::Print(LexStream& lex_stream)
1684 {
1685 unsigned i;
1686 Coutput << '#' << id << " (ConstructorDeclaration): #"
1687 << (modifiers_opt ? modifiers_opt -> id : 0) << " <#"
1688 << (type_parameters_opt ? type_parameters_opt -> id : 0)
1689 << " #" << constructor_declarator -> id << " throws: (";
1690 for (i = 0; i < NumThrows(); i++)
1691 Coutput << " #" << Throw(i) -> id;
1692 Coutput << ") #" << constructor_body -> id << endl;
1693 if (modifiers_opt)
1694 modifiers_opt -> Print(lex_stream);
1695 if (type_parameters_opt)
1696 type_parameters_opt -> Print(lex_stream);
1697 constructor_declarator -> Print(lex_stream);
1698 for (i = 0; i < NumThrows(); i++)
1699 Throw(i) -> Print(lex_stream);
1700 constructor_body -> Print(lex_stream);
1701 }
1702
Print(LexStream & lex_stream)1703 void AstEnumDeclaration::Print(LexStream& lex_stream)
1704 {
1705 unsigned i;
1706 Coutput << '#' << id << " (EnumDeclaration): #"
1707 << (modifiers_opt ? modifiers_opt -> id : 0) << ' '
1708 << lex_stream.NameString(enum_token) << ' '
1709 << lex_stream.NameString(class_body -> identifier_token) << " (";
1710 for (i = 0; i < NumInterfaces(); i++)
1711 Coutput << " #" << Interface(i) -> id;
1712 Coutput << ") {";
1713 for (i = 0; i < NumEnumConstants(); i++)
1714 Coutput << " #" << EnumConstant(i) -> id;
1715 Coutput << "} #" << class_body -> id << endl;
1716 if (modifiers_opt)
1717 modifiers_opt -> Print(lex_stream);
1718 for (i = 0; i < NumInterfaces(); i++)
1719 Interface(i) -> Print(lex_stream);
1720 for (i = 0; i < NumEnumConstants(); i++)
1721 EnumConstant(i) -> Print(lex_stream);
1722 class_body -> Print(lex_stream);
1723 }
1724
Print(LexStream & lex_stream)1725 void AstEnumConstant::Print(LexStream& lex_stream)
1726 {
1727 Coutput << '#' << id << " (EnumConstant): #"
1728 << (modifiers_opt ? modifiers_opt -> id : 0) << ' '
1729 << lex_stream.NameString(identifier_token) << " #"
1730 << (arguments_opt ? arguments_opt -> id : 0) << " #"
1731 << (class_body_opt ? class_body_opt -> id : 0) << endl;
1732 if (modifiers_opt)
1733 modifiers_opt -> Print(lex_stream);
1734 if (arguments_opt)
1735 arguments_opt -> Print(lex_stream);
1736 if (class_body_opt)
1737 class_body_opt -> Print(lex_stream);
1738 }
1739
Print(LexStream & lex_stream)1740 void AstInterfaceDeclaration::Print(LexStream& lex_stream)
1741 {
1742 unsigned i;
1743 Coutput << '#' << id << " (InterfaceDeclaration): #"
1744 << (modifiers_opt ? modifiers_opt -> id : 0) << ' '
1745 << lex_stream.NameString(interface_token) << ' '
1746 << lex_stream.NameString(class_body -> identifier_token) << " #"
1747 << (type_parameters_opt ? type_parameters_opt -> id : 0) << " (";
1748 for (i = 0; i < NumInterfaces(); i++)
1749 Coutput << " #" << Interface(i) -> id;
1750 Coutput << ") #" << class_body -> id << endl;
1751 if (modifiers_opt)
1752 modifiers_opt -> Print(lex_stream);
1753 if (type_parameters_opt)
1754 type_parameters_opt -> Print(lex_stream);
1755 for (i = 0; i < NumInterfaces(); i++)
1756 Interface(i) -> Print(lex_stream);
1757 class_body -> Print(lex_stream);
1758 }
1759
Print(LexStream & lex_stream)1760 void AstAnnotationDeclaration::Print(LexStream& lex_stream)
1761 {
1762 Coutput << '#' << id << " (AnnotationDeclaration): #"
1763 << (modifiers_opt ? modifiers_opt -> id : 0) << " @"
1764 << lex_stream.NameString(interface_token) << ' '
1765 << lex_stream.NameString(class_body -> identifier_token) << " #"
1766 << class_body -> id << endl;
1767 if (modifiers_opt)
1768 modifiers_opt -> Print(lex_stream);
1769 class_body -> Print(lex_stream);
1770 }
1771
Print(LexStream & lex_stream)1772 void AstLocalVariableStatement::Print(LexStream& lex_stream)
1773 {
1774 unsigned i;
1775 Coutput << '#' << id << " (LocalVariableStatement): #"
1776 << (modifiers_opt ? modifiers_opt -> id : 0)
1777 << " #" << type -> id << '(';
1778 for (i = 0; i < NumVariableDeclarators(); i++)
1779 Coutput << " #" << VariableDeclarator(i) -> id;
1780 Coutput << ')' << endl;
1781 if (modifiers_opt)
1782 modifiers_opt -> Print(lex_stream);
1783 type -> Print(lex_stream);
1784 for (i = 0; i < NumVariableDeclarators(); i++)
1785 VariableDeclarator(i) -> Print(lex_stream);
1786 }
1787
Print(LexStream & lex_stream)1788 void AstLocalClassStatement::Print(LexStream& lex_stream)
1789 {
1790 Coutput << '#' << id << " (LocalClassStatement): #"
1791 << declaration -> id << endl;
1792 declaration -> Print(lex_stream);
1793 }
1794
Print(LexStream & lex_stream)1795 void AstIfStatement::Print(LexStream& lex_stream)
1796 {
1797 Coutput << '#' << id << " (IfStatement): "
1798 << lex_stream.NameString(if_token)
1799 << " ( #" << expression -> id << " ) #" << true_statement -> id;
1800 if (false_statement_opt)
1801 Coutput << " else #" << false_statement_opt -> id;
1802 else Coutput << " #0";
1803 Coutput << endl;
1804
1805 expression -> Print(lex_stream);
1806 true_statement -> Print(lex_stream);
1807 if (false_statement_opt)
1808 false_statement_opt -> Print(lex_stream);
1809 }
1810
Print(LexStream & lex_stream)1811 void AstEmptyStatement::Print(LexStream& lex_stream)
1812 {
1813 Coutput << '#' << id << " (EmptyStatement): "
1814 << lex_stream.NameString(semicolon_token)
1815 << endl;
1816 }
1817
Print(LexStream & lex_stream)1818 void AstExpressionStatement::Print(LexStream& lex_stream)
1819 {
1820 Coutput << '#' << id << " (ExpressionStatement): #" << expression -> id
1821 << endl;
1822 expression -> Print(lex_stream);
1823 }
1824
Print(LexStream & lex_stream)1825 void AstSwitchLabel::Print(LexStream& lex_stream)
1826 {
1827 Coutput << '#' << id << " (SwitchLabel, map_index " << map_index << "): "
1828 << lex_stream.NameString(case_token) << '#'
1829 << (expression_opt ? expression_opt -> id : 0) << ':' << endl;
1830 if (expression_opt)
1831 expression_opt -> Print(lex_stream);
1832 }
1833
Print(LexStream & lex_stream)1834 void AstSwitchBlockStatement::Print(LexStream& lex_stream)
1835 {
1836 unsigned i;
1837 Coutput << '#' << id << " (SwitchBlockStatement): ";
1838 for (i = 0; i < NumSwitchLabels(); i++)
1839 {
1840 if (i % 10 == 0)
1841 Coutput << endl << " ";
1842 Coutput << " #" << SwitchLabel(i) -> id << ':';
1843 }
1844 Coutput << endl;
1845 for (i = 0; i < NumSwitchLabels(); i++)
1846 SwitchLabel(i) -> Print(lex_stream);
1847 AstBlock::Print(lex_stream);
1848 }
1849
Print(LexStream & lex_stream)1850 void AstSwitchStatement::Print(LexStream& lex_stream)
1851 {
1852 Coutput << '#' << id << " (SwitchStatement): "
1853 << lex_stream.NameString(switch_token)
1854 << " ( #" << expression -> id << " ) #" << switch_block -> id
1855 << endl;
1856 for (unsigned i = 0; i <= num_cases; i++)
1857 {
1858 Coutput << " case index: " << i;
1859 if (cases[i])
1860 Coutput << " block: " << cases[i] -> block_index
1861 << " label: " << cases[i] -> case_index
1862 << " value: " << cases[i] -> value << endl;
1863 else Coutput << "(none)" << endl;
1864 }
1865 expression -> Print(lex_stream);
1866 switch_block -> Print(lex_stream);
1867 }
1868
Print(LexStream & lex_stream)1869 void AstWhileStatement::Print(LexStream& lex_stream)
1870 {
1871 Coutput << '#' << id << " (WhileStatement): "
1872 << lex_stream.NameString(while_token)
1873 << " ( #" << expression -> id << " ) #" << statement -> id << endl;
1874 expression -> Print(lex_stream);
1875 statement -> Print(lex_stream);
1876 }
1877
Print(LexStream & lex_stream)1878 void AstDoStatement::Print(LexStream& lex_stream)
1879 {
1880 Coutput << '#' << id << " (DoStatement): "
1881 << lex_stream.NameString(do_token)
1882 << " { #" << statement -> id << " } "
1883 << lex_stream.NameString(while_token)
1884 << " ( #" << expression -> id << " ) #" << endl;
1885
1886 statement -> Print(lex_stream);
1887 expression -> Print(lex_stream);
1888 }
1889
Print(LexStream & lex_stream)1890 void AstForStatement::Print(LexStream& lex_stream)
1891 {
1892 unsigned i;
1893 Coutput << '#' << id << " (ForStatement): ("
1894 << lex_stream.NameString(for_token);
1895 for (i = 0; i < NumForInitStatements(); i++)
1896 Coutput << " #" << ForInitStatement(i) -> id;
1897 Coutput << "; #" << (end_expression_opt ? end_expression_opt -> id : 0)
1898 << ';';
1899 for (i = 0; i < NumForUpdateStatements(); i++)
1900 Coutput << " #" << ForUpdateStatement(i) -> id;
1901 Coutput << ") #" << statement -> id << endl;
1902
1903 for (i = 0; i < NumForInitStatements(); i++)
1904 ForInitStatement(i) -> Print(lex_stream);
1905 if (end_expression_opt)
1906 end_expression_opt -> Print(lex_stream);
1907 for (i = 0; i < NumForUpdateStatements(); i++)
1908 ForUpdateStatement(i) -> Print(lex_stream);
1909 statement -> Print(lex_stream);
1910 }
1911
Print(LexStream & lex_stream)1912 void AstForeachStatement::Print(LexStream& lex_stream)
1913 {
1914 Coutput << '#' << id << " (ForeachStatement): ("
1915 << lex_stream.NameString(for_token) << "( #"
1916 << formal_parameter -> id << ": #" << expression -> id
1917 << ") #" << statement -> id << endl;
1918 formal_parameter -> Print(lex_stream);
1919 expression -> Print(lex_stream);
1920 statement -> Print(lex_stream);
1921 }
1922
Print(LexStream & lex_stream)1923 void AstBreakStatement::Print(LexStream& lex_stream)
1924 {
1925 Coutput << '#' << id << " (BreakStatement): "
1926 << lex_stream.NameString(break_token) << ' '
1927 << (identifier_token_opt
1928 ? lex_stream.NameString(identifier_token_opt) : L"")
1929 << " at nesting_level " << nesting_level << endl;
1930 }
1931
Print(LexStream & lex_stream)1932 void AstContinueStatement::Print(LexStream& lex_stream)
1933 {
1934 Coutput << '#' << id << " (ContinueStatement): "
1935 << lex_stream.NameString(continue_token) << ' '
1936 << (identifier_token_opt
1937 ? lex_stream.NameString(identifier_token_opt) : L"")
1938 << " at nesting_level " << nesting_level << endl;
1939 }
1940
Print(LexStream & lex_stream)1941 void AstReturnStatement::Print(LexStream& lex_stream)
1942 {
1943 Coutput << '#' << id << " (ReturnStatement): "
1944 << lex_stream.NameString(return_token)
1945 << ' '
1946 << " #" << (expression_opt ? expression_opt -> id : 0) << endl;
1947 if (expression_opt)
1948 expression_opt -> Print(lex_stream);
1949 }
1950
Print(LexStream & lex_stream)1951 void AstThrowStatement::Print(LexStream& lex_stream)
1952 {
1953 Coutput << '#' << id << " (ThrowStatement): "
1954 << lex_stream.NameString(throw_token)
1955 << ' '
1956 << " #" << expression -> id << endl;
1957 expression -> Print(lex_stream);
1958 }
1959
Print(LexStream & lex_stream)1960 void AstSynchronizedStatement::Print(LexStream& lex_stream)
1961 {
1962 Coutput << '#' << id << " (SynchronizedStatement): "
1963 << lex_stream.NameString(synchronized_token)
1964 << " ( #" << expression -> id
1965 << " ) #" << block -> id << endl;
1966 expression -> Print(lex_stream);
1967 block -> Print(lex_stream);
1968 }
1969
Print(LexStream & lex_stream)1970 void AstAssertStatement::Print(LexStream& lex_stream)
1971 {
1972 Coutput << '#' << id << " (AssertStatement): "
1973 << lex_stream.NameString(assert_token)
1974 << " ( #" << condition -> id;
1975 if (message_opt)
1976 Coutput << " : " << message_opt -> id;
1977 else Coutput << " #0";
1978 Coutput << " ;" << endl;
1979 condition -> Print(lex_stream);
1980 if (message_opt)
1981 message_opt -> Print(lex_stream);
1982 }
1983
Print(LexStream & lex_stream)1984 void AstCatchClause::Print(LexStream& lex_stream)
1985 {
1986 Coutput << '#' << id << " (CatchClause): "
1987 << lex_stream.NameString(catch_token)
1988 << " #" << formal_parameter -> id
1989 << " #" << block -> id << endl;
1990 formal_parameter -> Print(lex_stream);
1991 block -> Print(lex_stream);
1992 }
1993
Print(LexStream & lex_stream)1994 void AstFinallyClause::Print(LexStream& lex_stream)
1995 {
1996 Coutput << '#' << id << " (FinallyClause): "
1997 << lex_stream.NameString(finally_token)
1998 << " #" << block -> id << endl;
1999 block -> Print(lex_stream);
2000 }
2001
Print(LexStream & lex_stream)2002 void AstTryStatement::Print(LexStream& lex_stream)
2003 {
2004 unsigned i;
2005 Coutput << '#' << id << " (TryStatement): "
2006 << lex_stream.NameString(try_token)
2007 << " #" << block -> id
2008 << " catch (";
2009 for (i = 0; i < NumCatchClauses(); i++)
2010 Coutput << " #" << CatchClause(i) -> id;
2011 Coutput << ") finally #"
2012 << (finally_clause_opt ? finally_clause_opt -> id : 0) << endl;
2013
2014 block -> Print(lex_stream);
2015 for (i = 0; i < NumCatchClauses(); i++)
2016 CatchClause(i) -> Print(lex_stream);
2017 if (finally_clause_opt)
2018 finally_clause_opt -> Print(lex_stream);
2019 }
2020
Print(LexStream & lex_stream)2021 void AstIntegerLiteral::Print(LexStream& lex_stream)
2022 {
2023 Coutput << '#' << id << " (IntegerLiteral): "
2024 << lex_stream.NameString(integer_literal_token)
2025 << endl;
2026 }
2027
Print(LexStream & lex_stream)2028 void AstLongLiteral::Print(LexStream& lex_stream)
2029 {
2030 Coutput << '#' << id << " (LongLiteral): "
2031 << lex_stream.NameString(long_literal_token)
2032 << endl;
2033 }
2034
Print(LexStream & lex_stream)2035 void AstFloatLiteral::Print(LexStream& lex_stream)
2036 {
2037 Coutput << '#' << id << " (FloatLiteral): "
2038 << lex_stream.NameString(float_literal_token)
2039 << endl;
2040 }
2041
Print(LexStream & lex_stream)2042 void AstDoubleLiteral::Print(LexStream& lex_stream)
2043 {
2044 Coutput << '#' << id << " (DoubleLiteral): "
2045 << lex_stream.NameString(double_literal_token)
2046 << endl;
2047 }
2048
Print(LexStream & lex_stream)2049 void AstTrueLiteral::Print(LexStream& lex_stream)
2050 {
2051 Coutput << '#' << id << " (TrueLiteral): "
2052 << lex_stream.NameString(true_literal_token)
2053 << endl;
2054 }
2055
Print(LexStream & lex_stream)2056 void AstFalseLiteral::Print(LexStream& lex_stream)
2057 {
2058 Coutput << '#' << id << " (FalseLiteral): "
2059 << lex_stream.NameString(false_literal_token)
2060 << endl;
2061 }
2062
Print(LexStream & lex_stream)2063 void AstStringLiteral::Print(LexStream& lex_stream)
2064 {
2065 Coutput << '#' << id << " (StringLiteral): "
2066 << lex_stream.NameString(string_literal_token)
2067 << endl;
2068 }
2069
Print(LexStream & lex_stream)2070 void AstCharacterLiteral::Print(LexStream& lex_stream)
2071 {
2072 Coutput << '#' << id << " (CharacterLiteral): "
2073 << lex_stream.NameString(character_literal_token)
2074 << endl;
2075 }
2076
Print(LexStream & lex_stream)2077 void AstNullLiteral::Print(LexStream& lex_stream)
2078 {
2079 Coutput << '#' << id << " (NullLiteral): "
2080 << lex_stream.NameString(null_token)
2081 << endl;
2082 }
2083
Print(LexStream & lex_stream)2084 void AstClassLiteral::Print(LexStream& lex_stream)
2085 {
2086 Coutput << '#' << id << " (ClassLiteral): #" << type -> id << ". "
2087 << lex_stream.NameString(class_token) << endl;
2088 type -> Print(lex_stream);
2089 }
2090
Print(LexStream & lex_stream)2091 void AstThisExpression::Print(LexStream& lex_stream)
2092 {
2093 Coutput << '#' << id << " (ThisExpression): ";
2094 if (base_opt)
2095 Coutput << '#' << base_opt -> id << ". ";
2096 Coutput << lex_stream.NameString(this_token) << endl;
2097 if (base_opt)
2098 base_opt -> Print(lex_stream);
2099 }
2100
Print(LexStream & lex_stream)2101 void AstSuperExpression::Print(LexStream& lex_stream)
2102 {
2103 Coutput << '#' << id << " (SuperExpression): ";
2104 if (base_opt)
2105 Coutput << '#' << base_opt -> id << ". ";
2106 Coutput << lex_stream.NameString(super_token) << endl;
2107 if (base_opt)
2108 base_opt -> Print(lex_stream);
2109 }
2110
Print(LexStream & lex_stream)2111 void AstParenthesizedExpression::Print(LexStream& lex_stream)
2112 {
2113 Coutput << '#' << id << " (ParenthesizedExpression): "
2114 << lex_stream.NameString(left_parenthesis_token)
2115 << '#' << expression -> id
2116 << lex_stream.NameString(right_parenthesis_token)
2117 << endl;
2118 expression -> Print(lex_stream);
2119 }
2120
Print(LexStream & lex_stream)2121 void AstClassCreationExpression::Print(LexStream& lex_stream)
2122 {
2123 Coutput << '#' << id << " (ClassCreationExpression): #"
2124 << (base_opt ? base_opt -> id : 0) << ' '
2125 << lex_stream.NameString(new_token) << " #"
2126 << (type_arguments_opt ? type_arguments_opt -> id : 0) << " #"
2127 << class_type -> id << " #" << arguments -> id << " #"
2128 << (class_body_opt ? class_body_opt -> id : 0) << endl;
2129 if (base_opt)
2130 base_opt -> Print(lex_stream);
2131 if (type_arguments_opt)
2132 type_arguments_opt -> Print(lex_stream);
2133 class_type -> Print(lex_stream);
2134 arguments -> Print(lex_stream);
2135 if (class_body_opt)
2136 class_body_opt -> Print(lex_stream);
2137 }
2138
Print(LexStream & lex_stream)2139 void AstDimExpr::Print(LexStream& lex_stream)
2140 {
2141 Coutput << '#' << id << " (DimExpr): [ #" << expression -> id << " ]"
2142 << endl;
2143 expression -> Print(lex_stream);
2144 }
2145
Print(LexStream & lex_stream)2146 void AstArrayCreationExpression::Print(LexStream& lex_stream)
2147 {
2148 unsigned i;
2149 Coutput << '#' << id << " (ArrayCreationExpression): "
2150 << lex_stream.NameString(new_token)
2151 << " #" << array_type -> id << "dimexpr:( ";
2152 for (i = 0; i < NumDimExprs(); i++)
2153 Coutput << " #" << DimExpr(i) -> id;
2154 Coutput << ") brackets:#" << (brackets_opt ? brackets_opt -> id : 0)
2155 << " initializer:#"
2156 << (array_initializer_opt ? array_initializer_opt -> id : 0)
2157 << endl;
2158 array_type -> Print(lex_stream);
2159 for (i = 0; i < NumDimExprs(); i++)
2160 DimExpr(i) -> Print(lex_stream);
2161 if (brackets_opt)
2162 brackets_opt -> Print(lex_stream);
2163 if (array_initializer_opt)
2164 array_initializer_opt -> Print(lex_stream);
2165 }
2166
Print(LexStream & lex_stream)2167 void AstFieldAccess::Print(LexStream& lex_stream)
2168 {
2169 Coutput << '#' << id << " (FieldAccess): "
2170 << " #" << base -> id << ' '
2171 << lex_stream.NameString(identifier_token)
2172 << endl;
2173
2174 base -> Print(lex_stream);
2175 }
2176
Print(LexStream & lex_stream)2177 void AstMethodInvocation::Print(LexStream& lex_stream)
2178 {
2179 Coutput << '#' << id << " (MethodInvocation): #"
2180 << (base_opt ? base_opt -> id : 0) << ".#"
2181 << (type_arguments_opt ? type_arguments_opt -> id : 0) << ' '
2182 << lex_stream.NameString(identifier_token)
2183 << " #" << arguments -> id << endl;
2184 if (base_opt)
2185 base_opt -> Print(lex_stream);
2186 if (type_arguments_opt)
2187 type_arguments_opt -> Print(lex_stream);
2188 arguments -> Print(lex_stream);
2189 }
2190
Print(LexStream & lex_stream)2191 void AstArrayAccess::Print(LexStream& lex_stream)
2192 {
2193 Coutput << '#' << id << " (ArrayAccess): "
2194 << '#' << base -> id
2195 << " [ #" << expression -> id << " ]" << endl;
2196
2197 base -> Print(lex_stream);
2198 expression -> Print(lex_stream);
2199 }
2200
Print(LexStream & lex_stream)2201 void AstPostUnaryExpression::Print(LexStream& lex_stream)
2202 {
2203 Coutput << '#' << id << " (PostUnaryExpression): "
2204 << '#' << expression -> id
2205 << lex_stream.NameString(post_operator_token)
2206 << endl;
2207
2208 expression -> Print(lex_stream);
2209 }
2210
Print(LexStream & lex_stream)2211 void AstPreUnaryExpression::Print(LexStream& lex_stream)
2212 {
2213 Coutput << '#' << id << " (PreUnaryExpression): "
2214 << lex_stream.NameString(pre_operator_token)
2215 << " #" << expression -> id << endl;
2216
2217 expression -> Print(lex_stream);
2218 }
2219
Print(LexStream & lex_stream)2220 void AstCastExpression::Print(LexStream& lex_stream)
2221 {
2222 if (type)
2223 {
2224 Coutput << '#' << id << " #" << expression -> id << endl;
2225 type -> Print(lex_stream);
2226 }
2227 else
2228 {
2229 Coutput << '#' << id << " (Java Semantic Cast to " << Type() -> Name()
2230 << "): #" << expression -> id << endl;
2231 }
2232 expression -> Print(lex_stream);
2233 }
2234
Print(LexStream & lex_stream)2235 void AstBinaryExpression::Print(LexStream& lex_stream)
2236 {
2237 Coutput << '#' << id << " (BinaryExpression): "
2238 << '#' << left_expression -> id << ' '
2239 << lex_stream.NameString(binary_operator_token)
2240 << " #" << right_expression -> id << endl;
2241
2242 left_expression -> Print(lex_stream);
2243 right_expression -> Print(lex_stream);
2244 }
2245
Print(LexStream & lex_stream)2246 void AstInstanceofExpression::Print(LexStream& lex_stream)
2247 {
2248 Coutput << '#' << id << " (InstanceofExpression): #"
2249 << expression -> id << ' '
2250 << lex_stream.NameString(instanceof_token)
2251 << " #" << type -> id << endl;
2252 expression -> Print(lex_stream);
2253 type -> Print(lex_stream);
2254 }
2255
Print(LexStream & lex_stream)2256 void AstConditionalExpression::Print(LexStream& lex_stream)
2257 {
2258 Coutput << '#' << id << " (ConditionalExpression): "
2259 << '#' << test_expression -> id
2260 << " ? #" << true_expression -> id
2261 << " : #" << false_expression -> id << endl;
2262
2263 test_expression -> Print(lex_stream);
2264 true_expression -> Print(lex_stream);
2265 false_expression -> Print(lex_stream);
2266 }
2267
Print(LexStream & lex_stream)2268 void AstAssignmentExpression::Print(LexStream& lex_stream)
2269 {
2270 Coutput << '#' << id << " (AssignmentExpression): "
2271 << '#' << left_hand_side -> id << ' '
2272 << lex_stream.NameString(assignment_operator_token)
2273 << " #" << expression -> id << endl;
2274
2275 left_hand_side -> Print(lex_stream);
2276 expression -> Print(lex_stream);
2277 }
2278
2279 #endif // JIKES_DEBUG
2280
2281
2282 #ifdef HAVE_JIKES_NAMESPACE
2283 } // Close namespace Jikes block
2284 #endif
2285