author | jjg |
Thu, 13 Sep 2012 14:29:36 -0700 | |
changeset 13844 | 56339cf983a3 |
parent 13077 | 16fb753bb5dc |
child 14062 | b7439971a094 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
13077 | 2 |
* Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. |
10 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5520 | 7 |
* published by the Free Software Foundation. Oracle designates this |
10 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5520 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
10 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5520 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
10 | 24 |
*/ |
25 |
||
26 |
package com.sun.tools.javac.tree; |
|
27 |
||
13077 | 28 |
import java.io.IOException; |
29 |
import java.io.StringWriter; |
|
10 | 30 |
import java.util.*; |
31 |
||
32 |
import javax.lang.model.element.Modifier; |
|
33 |
import javax.lang.model.type.TypeKind; |
|
34 |
import javax.tools.JavaFileObject; |
|
35 |
||
13077 | 36 |
import com.sun.source.tree.*; |
37 |
import com.sun.source.tree.LambdaExpressionTree.BodyKind; |
|
38 |
import com.sun.source.tree.MemberReferenceTree.ReferenceMode; |
|
10 | 39 |
import com.sun.tools.javac.code.*; |
7615 | 40 |
import com.sun.tools.javac.code.Scope.*; |
10 | 41 |
import com.sun.tools.javac.code.Symbol.*; |
13077 | 42 |
import com.sun.tools.javac.util.*; |
43 |
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; |
|
44 |
import com.sun.tools.javac.util.List; |
|
10 | 45 |
import static com.sun.tools.javac.code.BoundKind.*; |
10950 | 46 |
import static com.sun.tools.javac.tree.JCTree.Tag.*; |
10 | 47 |
|
48 |
/** |
|
49 |
* Root class for abstract syntax tree nodes. It provides definitions |
|
50 |
* for specific tree nodes as subclasses nested inside. |
|
51 |
* |
|
52 |
* <p>Each subclass is highly standardized. It generally contains |
|
53 |
* only tree fields for the syntactic subcomponents of the node. Some |
|
54 |
* classes that represent identifier uses or definitions also define a |
|
55 |
* Symbol field that denotes the represented identifier. Classes for |
|
56 |
* non-local jumps also carry the jump target as a field. The root |
|
57 |
* class Tree itself defines fields for the tree's type and position. |
|
58 |
* No other fields are kept in a tree node; instead parameters are |
|
59 |
* passed to methods accessing the node. |
|
60 |
* |
|
61 |
* <p>Except for the methods defined by com.sun.source, the only |
|
62 |
* method defined in subclasses is `visit' which applies a given |
|
63 |
* visitor to the tree. The actual tree processing is done by visitor |
|
64 |
* classes in other packages. The abstract class Visitor, as well as |
|
65 |
* an Factory interface for trees, are defined as inner classes in |
|
66 |
* Tree. |
|
67 |
* |
|
68 |
* <p>To avoid ambiguities with the Tree API in com.sun.source all sub |
|
69 |
* classes should, by convention, start with JC (javac). |
|
70 |
* |
|
5847
1908176fd6e3
6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents:
5520
diff
changeset
|
71 |
* <p><b>This is NOT part of any supported API. |
10 | 72 |
* If you write code that depends on this, you do so at your own risk. |
73 |
* This code and its internal interfaces are subject to change or |
|
74 |
* deletion without notice.</b> |
|
75 |
* |
|
76 |
* @see TreeMaker |
|
77 |
* @see TreeInfo |
|
78 |
* @see TreeTranslator |
|
79 |
* @see Pretty |
|
80 |
*/ |
|
81 |
public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition { |
|
82 |
||
83 |
/* Tree tag values, identifying kinds of trees */ |
|
10950 | 84 |
public enum Tag{ |
85 |
/** For methods that return an invalid tag if a given condition is not met |
|
86 |
*/ |
|
87 |
NO_TAG, |
|
10 | 88 |
|
10950 | 89 |
/** Toplevel nodes, of type TopLevel, representing entire source files. |
90 |
*/ |
|
91 |
TOPLEVEL, |
|
10 | 92 |
|
10950 | 93 |
/** Import clauses, of type Import. |
94 |
*/ |
|
95 |
IMPORT, |
|
10 | 96 |
|
10950 | 97 |
/** Class definitions, of type ClassDef. |
98 |
*/ |
|
99 |
CLASSDEF, |
|
10 | 100 |
|
10950 | 101 |
/** Method definitions, of type MethodDef. |
102 |
*/ |
|
103 |
METHODDEF, |
|
10 | 104 |
|
10950 | 105 |
/** Variable definitions, of type VarDef. |
106 |
*/ |
|
107 |
VARDEF, |
|
10 | 108 |
|
10950 | 109 |
/** The no-op statement ";", of type Skip |
110 |
*/ |
|
111 |
SKIP, |
|
112 |
||
113 |
/** Blocks, of type Block. |
|
114 |
*/ |
|
115 |
BLOCK, |
|
10 | 116 |
|
10950 | 117 |
/** Do-while loops, of type DoLoop. |
118 |
*/ |
|
119 |
DOLOOP, |
|
10 | 120 |
|
10950 | 121 |
/** While-loops, of type WhileLoop. |
122 |
*/ |
|
123 |
WHILELOOP, |
|
10 | 124 |
|
10950 | 125 |
/** For-loops, of type ForLoop. |
126 |
*/ |
|
127 |
FORLOOP, |
|
10 | 128 |
|
10950 | 129 |
/** Foreach-loops, of type ForeachLoop. |
130 |
*/ |
|
131 |
FOREACHLOOP, |
|
10 | 132 |
|
10950 | 133 |
/** Labelled statements, of type Labelled. |
134 |
*/ |
|
135 |
LABELLED, |
|
10 | 136 |
|
10950 | 137 |
/** Switch statements, of type Switch. |
138 |
*/ |
|
139 |
SWITCH, |
|
10 | 140 |
|
10950 | 141 |
/** Case parts in switch statements, of type Case. |
142 |
*/ |
|
143 |
CASE, |
|
10 | 144 |
|
10950 | 145 |
/** Synchronized statements, of type Synchonized. |
146 |
*/ |
|
147 |
SYNCHRONIZED, |
|
148 |
||
149 |
/** Try statements, of type Try. |
|
150 |
*/ |
|
151 |
TRY, |
|
10 | 152 |
|
10950 | 153 |
/** Catch clauses in try statements, of type Catch. |
154 |
*/ |
|
155 |
CATCH, |
|
10 | 156 |
|
10950 | 157 |
/** Conditional expressions, of type Conditional. |
158 |
*/ |
|
159 |
CONDEXPR, |
|
10 | 160 |
|
10950 | 161 |
/** Conditional statements, of type If. |
162 |
*/ |
|
163 |
IF, |
|
10 | 164 |
|
10950 | 165 |
/** Expression statements, of type Exec. |
166 |
*/ |
|
167 |
EXEC, |
|
10 | 168 |
|
10950 | 169 |
/** Break statements, of type Break. |
170 |
*/ |
|
171 |
BREAK, |
|
10 | 172 |
|
10950 | 173 |
/** Continue statements, of type Continue. |
174 |
*/ |
|
175 |
CONTINUE, |
|
10 | 176 |
|
10950 | 177 |
/** Return statements, of type Return. |
178 |
*/ |
|
179 |
RETURN, |
|
10 | 180 |
|
10950 | 181 |
/** Throw statements, of type Throw. |
182 |
*/ |
|
183 |
THROW, |
|
184 |
||
185 |
/** Assert statements, of type Assert. |
|
186 |
*/ |
|
187 |
ASSERT, |
|
10 | 188 |
|
10950 | 189 |
/** Method invocation expressions, of type Apply. |
190 |
*/ |
|
191 |
APPLY, |
|
10 | 192 |
|
10950 | 193 |
/** Class instance creation expressions, of type NewClass. |
194 |
*/ |
|
195 |
NEWCLASS, |
|
10 | 196 |
|
10950 | 197 |
/** Array creation expressions, of type NewArray. |
198 |
*/ |
|
199 |
NEWARRAY, |
|
10 | 200 |
|
11141 | 201 |
/** Lambda expression, of type Lambda. |
202 |
*/ |
|
203 |
LAMBDA, |
|
204 |
||
10950 | 205 |
/** Parenthesized subexpressions, of type Parens. |
206 |
*/ |
|
207 |
PARENS, |
|
10 | 208 |
|
10950 | 209 |
/** Assignment expressions, of type Assign. |
210 |
*/ |
|
211 |
ASSIGN, |
|
10 | 212 |
|
10950 | 213 |
/** Type cast expressions, of type TypeCast. |
214 |
*/ |
|
215 |
TYPECAST, |
|
10 | 216 |
|
10950 | 217 |
/** Type test expressions, of type TypeTest. |
218 |
*/ |
|
219 |
TYPETEST, |
|
10 | 220 |
|
10950 | 221 |
/** Indexed array expressions, of type Indexed. |
222 |
*/ |
|
223 |
INDEXED, |
|
224 |
||
225 |
/** Selections, of type Select. |
|
226 |
*/ |
|
227 |
SELECT, |
|
10 | 228 |
|
11142 | 229 |
/** Member references, of type Reference. |
230 |
*/ |
|
231 |
REFERENCE, |
|
232 |
||
10950 | 233 |
/** Simple identifiers, of type Ident. |
234 |
*/ |
|
235 |
IDENT, |
|
236 |
||
237 |
/** Literals, of type Literal. |
|
238 |
*/ |
|
239 |
LITERAL, |
|
10 | 240 |
|
10950 | 241 |
/** Basic type identifiers, of type TypeIdent. |
242 |
*/ |
|
243 |
TYPEIDENT, |
|
10 | 244 |
|
10950 | 245 |
/** Array types, of type TypeArray. |
246 |
*/ |
|
247 |
TYPEARRAY, |
|
10 | 248 |
|
10950 | 249 |
/** Parameterized types, of type TypeApply. |
250 |
*/ |
|
251 |
TYPEAPPLY, |
|
10 | 252 |
|
10950 | 253 |
/** Union types, of type TypeUnion |
254 |
*/ |
|
255 |
TYPEUNION, |
|
10 | 256 |
|
10950 | 257 |
/** Formal type parameters, of type TypeParameter. |
258 |
*/ |
|
259 |
TYPEPARAMETER, |
|
10 | 260 |
|
10950 | 261 |
/** Type argument. |
262 |
*/ |
|
263 |
WILDCARD, |
|
10 | 264 |
|
10950 | 265 |
/** Bound kind: extends, super, exact, or unbound |
266 |
*/ |
|
267 |
TYPEBOUNDKIND, |
|
10 | 268 |
|
10950 | 269 |
/** metadata: Annotation. |
270 |
*/ |
|
271 |
ANNOTATION, |
|
5492
515e4b33b335
6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents:
3149
diff
changeset
|
272 |
|
10950 | 273 |
/** metadata: Modifiers |
274 |
*/ |
|
275 |
MODIFIERS, |
|
276 |
||
277 |
ANNOTATED_TYPE, |
|
10 | 278 |
|
10950 | 279 |
/** Error trees, of type Erroneous. |
280 |
*/ |
|
281 |
ERRONEOUS, |
|
10 | 282 |
|
10950 | 283 |
/** Unary operators, of type Unary. |
284 |
*/ |
|
285 |
POS, // + |
|
286 |
NEG, // - |
|
287 |
NOT, // ! |
|
288 |
COMPL, // ~ |
|
289 |
PREINC, // ++ _ |
|
290 |
PREDEC, // -- _ |
|
291 |
POSTINC, // _ ++ |
|
292 |
POSTDEC, // _ -- |
|
10 | 293 |
|
10950 | 294 |
/** unary operator for null reference checks, only used internally. |
295 |
*/ |
|
296 |
NULLCHK, |
|
3149 | 297 |
|
10950 | 298 |
/** Binary operators, of type Binary. |
299 |
*/ |
|
300 |
OR, // || |
|
301 |
AND, // && |
|
302 |
BITOR, // | |
|
303 |
BITXOR, // ^ |
|
304 |
BITAND, // & |
|
305 |
EQ, // == |
|
306 |
NE, // != |
|
307 |
LT, // < |
|
308 |
GT, // > |
|
309 |
LE, // <= |
|
310 |
GE, // >= |
|
311 |
SL, // << |
|
312 |
SR, // >> |
|
313 |
USR, // >>> |
|
314 |
PLUS, // + |
|
315 |
MINUS, // - |
|
316 |
MUL, // * |
|
317 |
DIV, // / |
|
318 |
MOD, // % |
|
10 | 319 |
|
10950 | 320 |
/** Assignment operators, of type Assignop. |
321 |
*/ |
|
322 |
BITOR_ASG(BITOR), // |= |
|
323 |
BITXOR_ASG(BITXOR), // ^= |
|
324 |
BITAND_ASG(BITAND), // &= |
|
10 | 325 |
|
10950 | 326 |
SL_ASG(SL), // <<= |
327 |
SR_ASG(SR), // >>= |
|
328 |
USR_ASG(USR), // >>>= |
|
329 |
PLUS_ASG(PLUS), // += |
|
330 |
MINUS_ASG(MINUS), // -= |
|
331 |
MUL_ASG(MUL), // *= |
|
332 |
DIV_ASG(DIV), // /= |
|
333 |
MOD_ASG(MOD), // %= |
|
10 | 334 |
|
10950 | 335 |
/** A synthetic let expression, of type LetExpr. |
336 |
*/ |
|
337 |
LETEXPR; // ala scheme |
|
338 |
||
339 |
private Tag noAssignTag; |
|
340 |
||
341 |
private static int numberOfOperators = MOD.ordinal() - POS.ordinal() + 1; |
|
342 |
||
343 |
private Tag(Tag noAssignTag) { |
|
344 |
this.noAssignTag = noAssignTag; |
|
345 |
} |
|
346 |
||
347 |
private Tag() { } |
|
348 |
||
349 |
public static int getNumberOfOperators() { |
|
350 |
return numberOfOperators; |
|
351 |
} |
|
10 | 352 |
|
10950 | 353 |
public Tag noAssignOp() { |
354 |
if (noAssignTag != null) |
|
355 |
return noAssignTag; |
|
356 |
throw new AssertionError("noAssignOp() method is not available for non assignment tags"); |
|
357 |
} |
|
358 |
||
359 |
public boolean isPostUnaryOp() { |
|
360 |
return (this == POSTINC || this == POSTDEC); |
|
361 |
} |
|
10 | 362 |
|
10950 | 363 |
public boolean isIncOrDecUnaryOp() { |
364 |
return (this == PREINC || this == PREDEC || this == POSTINC || this == POSTDEC); |
|
365 |
} |
|
10 | 366 |
|
10950 | 367 |
public boolean isAssignop() { |
368 |
return noAssignTag != null; |
|
369 |
} |
|
10 | 370 |
|
10950 | 371 |
public int operatorIndex() { |
372 |
return (this.ordinal() - POS.ordinal()); |
|
373 |
} |
|
374 |
} |
|
10 | 375 |
|
376 |
/* The (encoded) position in the source file. @see util.Position. |
|
377 |
*/ |
|
378 |
public int pos; |
|
379 |
||
380 |
/* The type of this node. |
|
381 |
*/ |
|
382 |
public Type type; |
|
383 |
||
384 |
/* The tag of this node -- one of the constants declared above. |
|
385 |
*/ |
|
10950 | 386 |
public abstract Tag getTag(); |
387 |
||
388 |
/* Returns true if the tag of this node is equals to tag. |
|
389 |
*/ |
|
390 |
public boolean hasTag(Tag tag) { |
|
391 |
return tag == getTag(); |
|
392 |
} |
|
10 | 393 |
|
394 |
/** Convert a tree to a pretty-printed string. */ |
|
6580
d3d578d22cc7
6570730: com.sun.source.tree.ModifiersTree.getFlags() should return class type
jjg
parents:
6148
diff
changeset
|
395 |
@Override |
10 | 396 |
public String toString() { |
397 |
StringWriter s = new StringWriter(); |
|
398 |
try { |
|
399 |
new Pretty(s, false).printExpr(this); |
|
400 |
} |
|
401 |
catch (IOException e) { |
|
402 |
// should never happen, because StringWriter is defined |
|
403 |
// never to throw any IOExceptions |
|
404 |
throw new AssertionError(e); |
|
405 |
} |
|
406 |
return s.toString(); |
|
407 |
} |
|
408 |
||
409 |
/** Set position field and return this tree. |
|
410 |
*/ |
|
411 |
public JCTree setPos(int pos) { |
|
412 |
this.pos = pos; |
|
413 |
return this; |
|
414 |
} |
|
415 |
||
416 |
/** Set type field and return this tree. |
|
417 |
*/ |
|
418 |
public JCTree setType(Type type) { |
|
419 |
this.type = type; |
|
420 |
return this; |
|
421 |
} |
|
422 |
||
423 |
/** Visit this tree with a given visitor. |
|
424 |
*/ |
|
425 |
public abstract void accept(Visitor v); |
|
426 |
||
427 |
public abstract <R,D> R accept(TreeVisitor<R,D> v, D d); |
|
428 |
||
429 |
/** Return a shallow copy of this tree. |
|
430 |
*/ |
|
6580
d3d578d22cc7
6570730: com.sun.source.tree.ModifiersTree.getFlags() should return class type
jjg
parents:
6148
diff
changeset
|
431 |
@Override |
10 | 432 |
public Object clone() { |
433 |
try { |
|
434 |
return super.clone(); |
|
435 |
} catch(CloneNotSupportedException e) { |
|
436 |
throw new RuntimeException(e); |
|
437 |
} |
|
438 |
} |
|
439 |
||
440 |
/** Get a default position for this tree node. |
|
441 |
*/ |
|
442 |
public DiagnosticPosition pos() { |
|
443 |
return this; |
|
444 |
} |
|
445 |
||
446 |
// for default DiagnosticPosition |
|
447 |
public JCTree getTree() { |
|
448 |
return this; |
|
449 |
} |
|
450 |
||
451 |
// for default DiagnosticPosition |
|
452 |
public int getStartPosition() { |
|
453 |
return TreeInfo.getStartPos(this); |
|
454 |
} |
|
455 |
||
456 |
// for default DiagnosticPosition |
|
457 |
public int getPreferredPosition() { |
|
458 |
return pos; |
|
459 |
} |
|
460 |
||
461 |
// for default DiagnosticPosition |
|
11055 | 462 |
public int getEndPosition(EndPosTable endPosTable) { |
10 | 463 |
return TreeInfo.getEndPos(this, endPosTable); |
464 |
} |
|
465 |
||
466 |
/** |
|
467 |
* Everything in one source file is kept in a TopLevel structure. |
|
468 |
* @param pid The tree representing the package clause. |
|
469 |
* @param sourcefile The source file name. |
|
470 |
* @param defs All definitions in this file (ClassDef, Import, and Skip) |
|
471 |
* @param packge The package it belongs to. |
|
472 |
* @param namedImportScope A scope for all named imports. |
|
473 |
* @param starImportScope A scope for all import-on-demands. |
|
474 |
* @param lineMap Line starting positions, defined only |
|
475 |
* if option -g is set. |
|
476 |
* @param docComments A hashtable that stores all documentation comments |
|
477 |
* indexed by the tree nodes they refer to. |
|
478 |
* defined only if option -s is set. |
|
11055 | 479 |
* @param endPositions An object encapsulating ending positions of source |
10 | 480 |
* ranges indexed by the tree nodes they belong to. |
481 |
* Defined only if option -Xjcov is set. |
|
482 |
*/ |
|
483 |
public static class JCCompilationUnit extends JCTree implements CompilationUnitTree { |
|
484 |
public List<JCAnnotation> packageAnnotations; |
|
485 |
public JCExpression pid; |
|
486 |
public List<JCTree> defs; |
|
487 |
public JavaFileObject sourcefile; |
|
488 |
public PackageSymbol packge; |
|
7615 | 489 |
public ImportScope namedImportScope; |
490 |
public StarImportScope starImportScope; |
|
10 | 491 |
public Position.LineMap lineMap = null; |
13077 | 492 |
public DocCommentTable docComments = null; |
11055 | 493 |
public EndPosTable endPositions = null; |
10 | 494 |
protected JCCompilationUnit(List<JCAnnotation> packageAnnotations, |
495 |
JCExpression pid, |
|
496 |
List<JCTree> defs, |
|
497 |
JavaFileObject sourcefile, |
|
498 |
PackageSymbol packge, |
|
7615 | 499 |
ImportScope namedImportScope, |
500 |
StarImportScope starImportScope) { |
|
10 | 501 |
this.packageAnnotations = packageAnnotations; |
502 |
this.pid = pid; |
|
503 |
this.defs = defs; |
|
504 |
this.sourcefile = sourcefile; |
|
505 |
this.packge = packge; |
|
506 |
this.namedImportScope = namedImportScope; |
|
507 |
this.starImportScope = starImportScope; |
|
508 |
} |
|
509 |
@Override |
|
510 |
public void accept(Visitor v) { v.visitTopLevel(this); } |
|
511 |
||
512 |
public Kind getKind() { return Kind.COMPILATION_UNIT; } |
|
513 |
public List<JCAnnotation> getPackageAnnotations() { |
|
514 |
return packageAnnotations; |
|
515 |
} |
|
516 |
public List<JCImport> getImports() { |
|
517 |
ListBuffer<JCImport> imports = new ListBuffer<JCImport>(); |
|
518 |
for (JCTree tree : defs) { |
|
10950 | 519 |
if (tree.hasTag(IMPORT)) |
10 | 520 |
imports.append((JCImport)tree); |
10950 | 521 |
else if (!tree.hasTag(SKIP)) |
10 | 522 |
break; |
523 |
} |
|
524 |
return imports.toList(); |
|
525 |
} |
|
526 |
public JCExpression getPackageName() { return pid; } |
|
527 |
public JavaFileObject getSourceFile() { |
|
528 |
return sourcefile; |
|
529 |
} |
|
530 |
public Position.LineMap getLineMap() { |
|
531 |
return lineMap; |
|
532 |
} |
|
533 |
public List<JCTree> getTypeDecls() { |
|
534 |
List<JCTree> typeDefs; |
|
535 |
for (typeDefs = defs; !typeDefs.isEmpty(); typeDefs = typeDefs.tail) |
|
10950 | 536 |
if (!typeDefs.head.hasTag(IMPORT)) |
10 | 537 |
break; |
538 |
return typeDefs; |
|
539 |
} |
|
540 |
@Override |
|
541 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
542 |
return v.visitCompilationUnit(this, d); |
|
543 |
} |
|
544 |
||
545 |
@Override |
|
10950 | 546 |
public Tag getTag() { |
10 | 547 |
return TOPLEVEL; |
548 |
} |
|
549 |
} |
|
550 |
||
551 |
/** |
|
552 |
* An import clause. |
|
553 |
* @param qualid The imported class(es). |
|
554 |
*/ |
|
555 |
public static class JCImport extends JCTree implements ImportTree { |
|
556 |
public boolean staticImport; |
|
557 |
public JCTree qualid; |
|
558 |
protected JCImport(JCTree qualid, boolean importStatic) { |
|
559 |
this.qualid = qualid; |
|
560 |
this.staticImport = importStatic; |
|
561 |
} |
|
562 |
@Override |
|
563 |
public void accept(Visitor v) { v.visitImport(this); } |
|
564 |
||
565 |
public boolean isStatic() { return staticImport; } |
|
566 |
public JCTree getQualifiedIdentifier() { return qualid; } |
|
567 |
||
568 |
public Kind getKind() { return Kind.IMPORT; } |
|
569 |
@Override |
|
570 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
571 |
return v.visitImport(this, d); |
|
572 |
} |
|
573 |
||
574 |
@Override |
|
10950 | 575 |
public Tag getTag() { |
10 | 576 |
return IMPORT; |
577 |
} |
|
578 |
} |
|
579 |
||
580 |
public static abstract class JCStatement extends JCTree implements StatementTree { |
|
581 |
@Override |
|
582 |
public JCStatement setType(Type type) { |
|
583 |
super.setType(type); |
|
584 |
return this; |
|
585 |
} |
|
586 |
@Override |
|
587 |
public JCStatement setPos(int pos) { |
|
588 |
super.setPos(pos); |
|
589 |
return this; |
|
590 |
} |
|
591 |
} |
|
592 |
||
593 |
public static abstract class JCExpression extends JCTree implements ExpressionTree { |
|
594 |
@Override |
|
595 |
public JCExpression setType(Type type) { |
|
596 |
super.setType(type); |
|
597 |
return this; |
|
598 |
} |
|
599 |
@Override |
|
600 |
public JCExpression setPos(int pos) { |
|
601 |
super.setPos(pos); |
|
602 |
return this; |
|
603 |
} |
|
604 |
} |
|
605 |
||
606 |
/** |
|
607 |
* A class definition. |
|
608 |
* @param modifiers the modifiers |
|
609 |
* @param name the name of the class |
|
610 |
* @param typarams formal class parameters |
|
611 |
* @param extending the classes this class extends |
|
612 |
* @param implementing the interfaces implemented by this class |
|
613 |
* @param defs all variables and methods defined in this class |
|
614 |
* @param sym the symbol |
|
615 |
*/ |
|
616 |
public static class JCClassDecl extends JCStatement implements ClassTree { |
|
617 |
public JCModifiers mods; |
|
618 |
public Name name; |
|
619 |
public List<JCTypeParameter> typarams; |
|
8625
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8221
diff
changeset
|
620 |
public JCExpression extending; |
10 | 621 |
public List<JCExpression> implementing; |
622 |
public List<JCTree> defs; |
|
623 |
public ClassSymbol sym; |
|
624 |
protected JCClassDecl(JCModifiers mods, |
|
625 |
Name name, |
|
626 |
List<JCTypeParameter> typarams, |
|
8625
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8221
diff
changeset
|
627 |
JCExpression extending, |
10 | 628 |
List<JCExpression> implementing, |
629 |
List<JCTree> defs, |
|
630 |
ClassSymbol sym) |
|
631 |
{ |
|
632 |
this.mods = mods; |
|
633 |
this.name = name; |
|
634 |
this.typarams = typarams; |
|
635 |
this.extending = extending; |
|
636 |
this.implementing = implementing; |
|
637 |
this.defs = defs; |
|
638 |
this.sym = sym; |
|
639 |
} |
|
640 |
@Override |
|
641 |
public void accept(Visitor v) { v.visitClassDef(this); } |
|
642 |
||
6580
d3d578d22cc7
6570730: com.sun.source.tree.ModifiersTree.getFlags() should return class type
jjg
parents:
6148
diff
changeset
|
643 |
public Kind getKind() { |
d3d578d22cc7
6570730: com.sun.source.tree.ModifiersTree.getFlags() should return class type
jjg
parents:
6148
diff
changeset
|
644 |
if ((mods.flags & Flags.ANNOTATION) != 0) |
d3d578d22cc7
6570730: com.sun.source.tree.ModifiersTree.getFlags() should return class type
jjg
parents:
6148
diff
changeset
|
645 |
return Kind.ANNOTATION_TYPE; |
d3d578d22cc7
6570730: com.sun.source.tree.ModifiersTree.getFlags() should return class type
jjg
parents:
6148
diff
changeset
|
646 |
else if ((mods.flags & Flags.INTERFACE) != 0) |
d3d578d22cc7
6570730: com.sun.source.tree.ModifiersTree.getFlags() should return class type
jjg
parents:
6148
diff
changeset
|
647 |
return Kind.INTERFACE; |
d3d578d22cc7
6570730: com.sun.source.tree.ModifiersTree.getFlags() should return class type
jjg
parents:
6148
diff
changeset
|
648 |
else if ((mods.flags & Flags.ENUM) != 0) |
d3d578d22cc7
6570730: com.sun.source.tree.ModifiersTree.getFlags() should return class type
jjg
parents:
6148
diff
changeset
|
649 |
return Kind.ENUM; |
d3d578d22cc7
6570730: com.sun.source.tree.ModifiersTree.getFlags() should return class type
jjg
parents:
6148
diff
changeset
|
650 |
else |
d3d578d22cc7
6570730: com.sun.source.tree.ModifiersTree.getFlags() should return class type
jjg
parents:
6148
diff
changeset
|
651 |
return Kind.CLASS; |
d3d578d22cc7
6570730: com.sun.source.tree.ModifiersTree.getFlags() should return class type
jjg
parents:
6148
diff
changeset
|
652 |
} |
d3d578d22cc7
6570730: com.sun.source.tree.ModifiersTree.getFlags() should return class type
jjg
parents:
6148
diff
changeset
|
653 |
|
10 | 654 |
public JCModifiers getModifiers() { return mods; } |
655 |
public Name getSimpleName() { return name; } |
|
656 |
public List<JCTypeParameter> getTypeParameters() { |
|
657 |
return typarams; |
|
658 |
} |
|
659 |
public JCTree getExtendsClause() { return extending; } |
|
660 |
public List<JCExpression> getImplementsClause() { |
|
661 |
return implementing; |
|
662 |
} |
|
663 |
public List<JCTree> getMembers() { |
|
664 |
return defs; |
|
665 |
} |
|
666 |
@Override |
|
667 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
668 |
return v.visitClass(this, d); |
|
669 |
} |
|
670 |
||
671 |
@Override |
|
10950 | 672 |
public Tag getTag() { |
10 | 673 |
return CLASSDEF; |
674 |
} |
|
675 |
} |
|
676 |
||
677 |
/** |
|
678 |
* A method definition. |
|
679 |
* @param modifiers method modifiers |
|
680 |
* @param name method name |
|
681 |
* @param restype type of method return value |
|
682 |
* @param typarams type parameters |
|
683 |
* @param params value parameters |
|
684 |
* @param thrown exceptions thrown by this method |
|
685 |
* @param stats statements in the method |
|
686 |
* @param sym method symbol |
|
687 |
*/ |
|
688 |
public static class JCMethodDecl extends JCTree implements MethodTree { |
|
689 |
public JCModifiers mods; |
|
690 |
public Name name; |
|
691 |
public JCExpression restype; |
|
692 |
public List<JCTypeParameter> typarams; |
|
693 |
public List<JCVariableDecl> params; |
|
694 |
public List<JCExpression> thrown; |
|
695 |
public JCBlock body; |
|
696 |
public JCExpression defaultValue; // for annotation types |
|
697 |
public MethodSymbol sym; |
|
698 |
protected JCMethodDecl(JCModifiers mods, |
|
699 |
Name name, |
|
700 |
JCExpression restype, |
|
701 |
List<JCTypeParameter> typarams, |
|
702 |
List<JCVariableDecl> params, |
|
703 |
List<JCExpression> thrown, |
|
704 |
JCBlock body, |
|
705 |
JCExpression defaultValue, |
|
706 |
MethodSymbol sym) |
|
707 |
{ |
|
708 |
this.mods = mods; |
|
709 |
this.name = name; |
|
710 |
this.restype = restype; |
|
711 |
this.typarams = typarams; |
|
712 |
this.params = params; |
|
713 |
this.thrown = thrown; |
|
714 |
this.body = body; |
|
715 |
this.defaultValue = defaultValue; |
|
716 |
this.sym = sym; |
|
717 |
} |
|
718 |
@Override |
|
719 |
public void accept(Visitor v) { v.visitMethodDef(this); } |
|
720 |
||
721 |
public Kind getKind() { return Kind.METHOD; } |
|
722 |
public JCModifiers getModifiers() { return mods; } |
|
723 |
public Name getName() { return name; } |
|
724 |
public JCTree getReturnType() { return restype; } |
|
725 |
public List<JCTypeParameter> getTypeParameters() { |
|
726 |
return typarams; |
|
727 |
} |
|
728 |
public List<JCVariableDecl> getParameters() { |
|
729 |
return params; |
|
730 |
} |
|
731 |
public List<JCExpression> getThrows() { |
|
732 |
return thrown; |
|
733 |
} |
|
734 |
public JCBlock getBody() { return body; } |
|
735 |
public JCTree getDefaultValue() { // for annotation types |
|
736 |
return defaultValue; |
|
737 |
} |
|
738 |
@Override |
|
739 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
740 |
return v.visitMethod(this, d); |
|
741 |
} |
|
742 |
||
743 |
@Override |
|
10950 | 744 |
public Tag getTag() { |
10 | 745 |
return METHODDEF; |
746 |
} |
|
747 |
} |
|
748 |
||
749 |
/** |
|
750 |
* A variable definition. |
|
751 |
* @param modifiers variable modifiers |
|
752 |
* @param name variable name |
|
753 |
* @param vartype type of the variable |
|
754 |
* @param init variables initial value |
|
755 |
* @param sym symbol |
|
756 |
*/ |
|
757 |
public static class JCVariableDecl extends JCStatement implements VariableTree { |
|
758 |
public JCModifiers mods; |
|
759 |
public Name name; |
|
760 |
public JCExpression vartype; |
|
761 |
public JCExpression init; |
|
762 |
public VarSymbol sym; |
|
763 |
protected JCVariableDecl(JCModifiers mods, |
|
764 |
Name name, |
|
765 |
JCExpression vartype, |
|
766 |
JCExpression init, |
|
767 |
VarSymbol sym) { |
|
768 |
this.mods = mods; |
|
769 |
this.name = name; |
|
770 |
this.vartype = vartype; |
|
771 |
this.init = init; |
|
772 |
this.sym = sym; |
|
773 |
} |
|
774 |
@Override |
|
775 |
public void accept(Visitor v) { v.visitVarDef(this); } |
|
776 |
||
777 |
public Kind getKind() { return Kind.VARIABLE; } |
|
778 |
public JCModifiers getModifiers() { return mods; } |
|
779 |
public Name getName() { return name; } |
|
780 |
public JCTree getType() { return vartype; } |
|
781 |
public JCExpression getInitializer() { |
|
782 |
return init; |
|
783 |
} |
|
784 |
@Override |
|
785 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
786 |
return v.visitVariable(this, d); |
|
787 |
} |
|
788 |
||
789 |
@Override |
|
10950 | 790 |
public Tag getTag() { |
10 | 791 |
return VARDEF; |
792 |
} |
|
793 |
} |
|
794 |
||
795 |
/** |
|
796 |
* A no-op statement ";". |
|
797 |
*/ |
|
798 |
public static class JCSkip extends JCStatement implements EmptyStatementTree { |
|
799 |
protected JCSkip() { |
|
800 |
} |
|
801 |
@Override |
|
802 |
public void accept(Visitor v) { v.visitSkip(this); } |
|
803 |
||
804 |
public Kind getKind() { return Kind.EMPTY_STATEMENT; } |
|
805 |
@Override |
|
806 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
807 |
return v.visitEmptyStatement(this, d); |
|
808 |
} |
|
809 |
||
810 |
@Override |
|
10950 | 811 |
public Tag getTag() { |
10 | 812 |
return SKIP; |
813 |
} |
|
814 |
} |
|
815 |
||
816 |
/** |
|
817 |
* A statement block. |
|
818 |
* @param stats statements |
|
819 |
* @param flags flags |
|
820 |
*/ |
|
821 |
public static class JCBlock extends JCStatement implements BlockTree { |
|
822 |
public long flags; |
|
823 |
public List<JCStatement> stats; |
|
824 |
/** Position of closing brace, optional. */ |
|
825 |
public int endpos = Position.NOPOS; |
|
826 |
protected JCBlock(long flags, List<JCStatement> stats) { |
|
827 |
this.stats = stats; |
|
828 |
this.flags = flags; |
|
829 |
} |
|
830 |
@Override |
|
831 |
public void accept(Visitor v) { v.visitBlock(this); } |
|
832 |
||
833 |
public Kind getKind() { return Kind.BLOCK; } |
|
834 |
public List<JCStatement> getStatements() { |
|
835 |
return stats; |
|
836 |
} |
|
837 |
public boolean isStatic() { return (flags & Flags.STATIC) != 0; } |
|
838 |
@Override |
|
839 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
840 |
return v.visitBlock(this, d); |
|
841 |
} |
|
842 |
||
843 |
@Override |
|
10950 | 844 |
public Tag getTag() { |
10 | 845 |
return BLOCK; |
846 |
} |
|
847 |
} |
|
848 |
||
849 |
/** |
|
850 |
* A do loop |
|
851 |
*/ |
|
852 |
public static class JCDoWhileLoop extends JCStatement implements DoWhileLoopTree { |
|
853 |
public JCStatement body; |
|
854 |
public JCExpression cond; |
|
855 |
protected JCDoWhileLoop(JCStatement body, JCExpression cond) { |
|
856 |
this.body = body; |
|
857 |
this.cond = cond; |
|
858 |
} |
|
859 |
@Override |
|
860 |
public void accept(Visitor v) { v.visitDoLoop(this); } |
|
861 |
||
862 |
public Kind getKind() { return Kind.DO_WHILE_LOOP; } |
|
863 |
public JCExpression getCondition() { return cond; } |
|
864 |
public JCStatement getStatement() { return body; } |
|
865 |
@Override |
|
866 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
867 |
return v.visitDoWhileLoop(this, d); |
|
868 |
} |
|
869 |
||
870 |
@Override |
|
10950 | 871 |
public Tag getTag() { |
10 | 872 |
return DOLOOP; |
873 |
} |
|
874 |
} |
|
875 |
||
876 |
/** |
|
877 |
* A while loop |
|
878 |
*/ |
|
879 |
public static class JCWhileLoop extends JCStatement implements WhileLoopTree { |
|
880 |
public JCExpression cond; |
|
881 |
public JCStatement body; |
|
882 |
protected JCWhileLoop(JCExpression cond, JCStatement body) { |
|
883 |
this.cond = cond; |
|
884 |
this.body = body; |
|
885 |
} |
|
886 |
@Override |
|
887 |
public void accept(Visitor v) { v.visitWhileLoop(this); } |
|
888 |
||
889 |
public Kind getKind() { return Kind.WHILE_LOOP; } |
|
890 |
public JCExpression getCondition() { return cond; } |
|
891 |
public JCStatement getStatement() { return body; } |
|
892 |
@Override |
|
893 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
894 |
return v.visitWhileLoop(this, d); |
|
895 |
} |
|
896 |
||
897 |
@Override |
|
10950 | 898 |
public Tag getTag() { |
10 | 899 |
return WHILELOOP; |
900 |
} |
|
901 |
} |
|
902 |
||
903 |
/** |
|
904 |
* A for loop. |
|
905 |
*/ |
|
906 |
public static class JCForLoop extends JCStatement implements ForLoopTree { |
|
907 |
public List<JCStatement> init; |
|
908 |
public JCExpression cond; |
|
909 |
public List<JCExpressionStatement> step; |
|
910 |
public JCStatement body; |
|
911 |
protected JCForLoop(List<JCStatement> init, |
|
912 |
JCExpression cond, |
|
913 |
List<JCExpressionStatement> update, |
|
914 |
JCStatement body) |
|
915 |
{ |
|
916 |
this.init = init; |
|
917 |
this.cond = cond; |
|
918 |
this.step = update; |
|
919 |
this.body = body; |
|
920 |
} |
|
921 |
@Override |
|
922 |
public void accept(Visitor v) { v.visitForLoop(this); } |
|
923 |
||
924 |
public Kind getKind() { return Kind.FOR_LOOP; } |
|
925 |
public JCExpression getCondition() { return cond; } |
|
926 |
public JCStatement getStatement() { return body; } |
|
927 |
public List<JCStatement> getInitializer() { |
|
928 |
return init; |
|
929 |
} |
|
930 |
public List<JCExpressionStatement> getUpdate() { |
|
931 |
return step; |
|
932 |
} |
|
933 |
@Override |
|
934 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
935 |
return v.visitForLoop(this, d); |
|
936 |
} |
|
937 |
||
938 |
@Override |
|
10950 | 939 |
public Tag getTag() { |
10 | 940 |
return FORLOOP; |
941 |
} |
|
942 |
} |
|
943 |
||
944 |
/** |
|
945 |
* The enhanced for loop. |
|
946 |
*/ |
|
947 |
public static class JCEnhancedForLoop extends JCStatement implements EnhancedForLoopTree { |
|
948 |
public JCVariableDecl var; |
|
949 |
public JCExpression expr; |
|
950 |
public JCStatement body; |
|
951 |
protected JCEnhancedForLoop(JCVariableDecl var, JCExpression expr, JCStatement body) { |
|
952 |
this.var = var; |
|
953 |
this.expr = expr; |
|
954 |
this.body = body; |
|
955 |
} |
|
956 |
@Override |
|
957 |
public void accept(Visitor v) { v.visitForeachLoop(this); } |
|
958 |
||
959 |
public Kind getKind() { return Kind.ENHANCED_FOR_LOOP; } |
|
960 |
public JCVariableDecl getVariable() { return var; } |
|
961 |
public JCExpression getExpression() { return expr; } |
|
962 |
public JCStatement getStatement() { return body; } |
|
963 |
@Override |
|
964 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
965 |
return v.visitEnhancedForLoop(this, d); |
|
966 |
} |
|
967 |
@Override |
|
10950 | 968 |
public Tag getTag() { |
10 | 969 |
return FOREACHLOOP; |
970 |
} |
|
971 |
} |
|
972 |
||
973 |
/** |
|
974 |
* A labelled expression or statement. |
|
975 |
*/ |
|
976 |
public static class JCLabeledStatement extends JCStatement implements LabeledStatementTree { |
|
977 |
public Name label; |
|
978 |
public JCStatement body; |
|
979 |
protected JCLabeledStatement(Name label, JCStatement body) { |
|
980 |
this.label = label; |
|
981 |
this.body = body; |
|
982 |
} |
|
983 |
@Override |
|
984 |
public void accept(Visitor v) { v.visitLabelled(this); } |
|
985 |
public Kind getKind() { return Kind.LABELED_STATEMENT; } |
|
986 |
public Name getLabel() { return label; } |
|
987 |
public JCStatement getStatement() { return body; } |
|
988 |
@Override |
|
989 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
990 |
return v.visitLabeledStatement(this, d); |
|
991 |
} |
|
992 |
@Override |
|
10950 | 993 |
public Tag getTag() { |
10 | 994 |
return LABELLED; |
995 |
} |
|
996 |
} |
|
997 |
||
998 |
/** |
|
999 |
* A "switch ( ) { }" construction. |
|
1000 |
*/ |
|
1001 |
public static class JCSwitch extends JCStatement implements SwitchTree { |
|
1002 |
public JCExpression selector; |
|
1003 |
public List<JCCase> cases; |
|
1004 |
protected JCSwitch(JCExpression selector, List<JCCase> cases) { |
|
1005 |
this.selector = selector; |
|
1006 |
this.cases = cases; |
|
1007 |
} |
|
1008 |
@Override |
|
1009 |
public void accept(Visitor v) { v.visitSwitch(this); } |
|
1010 |
||
1011 |
public Kind getKind() { return Kind.SWITCH; } |
|
1012 |
public JCExpression getExpression() { return selector; } |
|
1013 |
public List<JCCase> getCases() { return cases; } |
|
1014 |
@Override |
|
1015 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
1016 |
return v.visitSwitch(this, d); |
|
1017 |
} |
|
1018 |
@Override |
|
10950 | 1019 |
public Tag getTag() { |
10 | 1020 |
return SWITCH; |
1021 |
} |
|
1022 |
} |
|
1023 |
||
1024 |
/** |
|
1025 |
* A "case :" of a switch. |
|
1026 |
*/ |
|
1027 |
public static class JCCase extends JCStatement implements CaseTree { |
|
1028 |
public JCExpression pat; |
|
1029 |
public List<JCStatement> stats; |
|
1030 |
protected JCCase(JCExpression pat, List<JCStatement> stats) { |
|
1031 |
this.pat = pat; |
|
1032 |
this.stats = stats; |
|
1033 |
} |
|
1034 |
@Override |
|
1035 |
public void accept(Visitor v) { v.visitCase(this); } |
|
1036 |
||
1037 |
public Kind getKind() { return Kind.CASE; } |
|
1038 |
public JCExpression getExpression() { return pat; } |
|
1039 |
public List<JCStatement> getStatements() { return stats; } |
|
1040 |
@Override |
|
1041 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
1042 |
return v.visitCase(this, d); |
|
1043 |
} |
|
1044 |
@Override |
|
10950 | 1045 |
public Tag getTag() { |
10 | 1046 |
return CASE; |
1047 |
} |
|
1048 |
} |
|
1049 |
||
1050 |
/** |
|
1051 |
* A synchronized block. |
|
1052 |
*/ |
|
1053 |
public static class JCSynchronized extends JCStatement implements SynchronizedTree { |
|
1054 |
public JCExpression lock; |
|
1055 |
public JCBlock body; |
|
1056 |
protected JCSynchronized(JCExpression lock, JCBlock body) { |
|
1057 |
this.lock = lock; |
|
1058 |
this.body = body; |
|
1059 |
} |
|
1060 |
@Override |
|
1061 |
public void accept(Visitor v) { v.visitSynchronized(this); } |
|
1062 |
||
1063 |
public Kind getKind() { return Kind.SYNCHRONIZED; } |
|
1064 |
public JCExpression getExpression() { return lock; } |
|
1065 |
public JCBlock getBlock() { return body; } |
|
1066 |
@Override |
|
1067 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
1068 |
return v.visitSynchronized(this, d); |
|
1069 |
} |
|
1070 |
@Override |
|
10950 | 1071 |
public Tag getTag() { |
10 | 1072 |
return SYNCHRONIZED; |
1073 |
} |
|
1074 |
} |
|
1075 |
||
1076 |
/** |
|
1077 |
* A "try { } catch ( ) { } finally { }" block. |
|
1078 |
*/ |
|
1079 |
public static class JCTry extends JCStatement implements TryTree { |
|
1080 |
public JCBlock body; |
|
1081 |
public List<JCCatch> catchers; |
|
1082 |
public JCBlock finalizer; |
|
6148
3a8158299c51
6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents:
5847
diff
changeset
|
1083 |
public List<JCTree> resources; |
12333
7b02d0529a97
7151580: Separate DA/DU logic from exception checking logic in Flow.java
mcimadamore
parents:
11142
diff
changeset
|
1084 |
public boolean finallyCanCompleteNormally; |
6148
3a8158299c51
6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents:
5847
diff
changeset
|
1085 |
protected JCTry(List<JCTree> resources, |
3a8158299c51
6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents:
5847
diff
changeset
|
1086 |
JCBlock body, |
3a8158299c51
6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents:
5847
diff
changeset
|
1087 |
List<JCCatch> catchers, |
3a8158299c51
6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents:
5847
diff
changeset
|
1088 |
JCBlock finalizer) { |
10 | 1089 |
this.body = body; |
1090 |
this.catchers = catchers; |
|
1091 |
this.finalizer = finalizer; |
|
6148
3a8158299c51
6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents:
5847
diff
changeset
|
1092 |
this.resources = resources; |
10 | 1093 |
} |
1094 |
@Override |
|
1095 |
public void accept(Visitor v) { v.visitTry(this); } |
|
1096 |
||
1097 |
public Kind getKind() { return Kind.TRY; } |
|
1098 |
public JCBlock getBlock() { return body; } |
|
1099 |
public List<JCCatch> getCatches() { |
|
1100 |
return catchers; |
|
1101 |
} |
|
1102 |
public JCBlock getFinallyBlock() { return finalizer; } |
|
1103 |
@Override |
|
1104 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
1105 |
return v.visitTry(this, d); |
|
1106 |
} |
|
1107 |
@Override |
|
6148
3a8158299c51
6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents:
5847
diff
changeset
|
1108 |
public List<? extends JCTree> getResources() { |
3a8158299c51
6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents:
5847
diff
changeset
|
1109 |
return resources; |
3a8158299c51
6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents:
5847
diff
changeset
|
1110 |
} |
3a8158299c51
6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents:
5847
diff
changeset
|
1111 |
@Override |
10950 | 1112 |
public Tag getTag() { |
10 | 1113 |
return TRY; |
1114 |
} |
|
1115 |
} |
|
1116 |
||
1117 |
/** |
|
1118 |
* A catch block. |
|
1119 |
*/ |
|
1120 |
public static class JCCatch extends JCTree implements CatchTree { |
|
1121 |
public JCVariableDecl param; |
|
1122 |
public JCBlock body; |
|
1123 |
protected JCCatch(JCVariableDecl param, JCBlock body) { |
|
1124 |
this.param = param; |
|
1125 |
this.body = body; |
|
1126 |
} |
|
1127 |
@Override |
|
1128 |
public void accept(Visitor v) { v.visitCatch(this); } |
|
1129 |
||
1130 |
public Kind getKind() { return Kind.CATCH; } |
|
1131 |
public JCVariableDecl getParameter() { return param; } |
|
1132 |
public JCBlock getBlock() { return body; } |
|
1133 |
@Override |
|
1134 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
1135 |
return v.visitCatch(this, d); |
|
1136 |
} |
|
1137 |
@Override |
|
10950 | 1138 |
public Tag getTag() { |
10 | 1139 |
return CATCH; |
1140 |
} |
|
1141 |
} |
|
1142 |
||
1143 |
/** |
|
1144 |
* A ( ) ? ( ) : ( ) conditional expression |
|
1145 |
*/ |
|
1146 |
public static class JCConditional extends JCExpression implements ConditionalExpressionTree { |
|
1147 |
public JCExpression cond; |
|
1148 |
public JCExpression truepart; |
|
1149 |
public JCExpression falsepart; |
|
1150 |
protected JCConditional(JCExpression cond, |
|
1151 |
JCExpression truepart, |
|
1152 |
JCExpression falsepart) |
|
1153 |
{ |
|
1154 |
this.cond = cond; |
|
1155 |
this.truepart = truepart; |
|
1156 |
this.falsepart = falsepart; |
|
1157 |
} |
|
1158 |
@Override |
|
1159 |
public void accept(Visitor v) { v.visitConditional(this); } |
|
1160 |
||
1161 |
public Kind getKind() { return Kind.CONDITIONAL_EXPRESSION; } |
|
1162 |
public JCExpression getCondition() { return cond; } |
|
1163 |
public JCExpression getTrueExpression() { return truepart; } |
|
1164 |
public JCExpression getFalseExpression() { return falsepart; } |
|
1165 |
@Override |
|
1166 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
1167 |
return v.visitConditionalExpression(this, d); |
|
1168 |
} |
|
1169 |
@Override |
|
10950 | 1170 |
public Tag getTag() { |
10 | 1171 |
return CONDEXPR; |
1172 |
} |
|
1173 |
} |
|
1174 |
||
1175 |
/** |
|
1176 |
* An "if ( ) { } else { }" block |
|
1177 |
*/ |
|
1178 |
public static class JCIf extends JCStatement implements IfTree { |
|
1179 |
public JCExpression cond; |
|
1180 |
public JCStatement thenpart; |
|
1181 |
public JCStatement elsepart; |
|
1182 |
protected JCIf(JCExpression cond, |
|
1183 |
JCStatement thenpart, |
|
1184 |
JCStatement elsepart) |
|
1185 |
{ |
|
1186 |
this.cond = cond; |
|
1187 |
this.thenpart = thenpart; |
|
1188 |
this.elsepart = elsepart; |
|
1189 |
} |
|
1190 |
@Override |
|
1191 |
public void accept(Visitor v) { v.visitIf(this); } |
|
1192 |
||
1193 |
public Kind getKind() { return Kind.IF; } |
|
1194 |
public JCExpression getCondition() { return cond; } |
|
1195 |
public JCStatement getThenStatement() { return thenpart; } |
|
1196 |
public JCStatement getElseStatement() { return elsepart; } |
|
1197 |
@Override |
|
1198 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
1199 |
return v.visitIf(this, d); |
|
1200 |
} |
|
1201 |
@Override |
|
10950 | 1202 |
public Tag getTag() { |
10 | 1203 |
return IF; |
1204 |
} |
|
1205 |
} |
|
1206 |
||
1207 |
/** |
|
1208 |
* an expression statement |
|
1209 |
* @param expr expression structure |
|
1210 |
*/ |
|
1211 |
public static class JCExpressionStatement extends JCStatement implements ExpressionStatementTree { |
|
1212 |
public JCExpression expr; |
|
1213 |
protected JCExpressionStatement(JCExpression expr) |
|
1214 |
{ |
|
1215 |
this.expr = expr; |
|
1216 |
} |
|
1217 |
@Override |
|
1218 |
public void accept(Visitor v) { v.visitExec(this); } |
|
1219 |
||
1220 |
public Kind getKind() { return Kind.EXPRESSION_STATEMENT; } |
|
1221 |
public JCExpression getExpression() { return expr; } |
|
1222 |
@Override |
|
1223 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
1224 |
return v.visitExpressionStatement(this, d); |
|
1225 |
} |
|
1226 |
@Override |
|
10950 | 1227 |
public Tag getTag() { |
10 | 1228 |
return EXEC; |
1229 |
} |
|
10632 | 1230 |
|
1231 |
/** Convert a expression-statement tree to a pretty-printed string. */ |
|
1232 |
@Override |
|
1233 |
public String toString() { |
|
1234 |
StringWriter s = new StringWriter(); |
|
1235 |
try { |
|
1236 |
new Pretty(s, false).printStat(this); |
|
1237 |
} |
|
1238 |
catch (IOException e) { |
|
1239 |
// should never happen, because StringWriter is defined |
|
1240 |
// never to throw any IOExceptions |
|
1241 |
throw new AssertionError(e); |
|
1242 |
} |
|
1243 |
return s.toString(); |
|
1244 |
} |
|
10 | 1245 |
} |
1246 |
||
1247 |
/** |
|
1248 |
* A break from a loop or switch. |
|
1249 |
*/ |
|
1250 |
public static class JCBreak extends JCStatement implements BreakTree { |
|
1251 |
public Name label; |
|
1252 |
public JCTree target; |
|
1253 |
protected JCBreak(Name label, JCTree target) { |
|
1254 |
this.label = label; |
|
1255 |
this.target = target; |
|
1256 |
} |
|
1257 |
@Override |
|
1258 |
public void accept(Visitor v) { v.visitBreak(this); } |
|
1259 |
||
1260 |
public Kind getKind() { return Kind.BREAK; } |
|
1261 |
public Name getLabel() { return label; } |
|
1262 |
@Override |
|
1263 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
1264 |
return v.visitBreak(this, d); |
|
1265 |
} |
|
1266 |
@Override |
|
10950 | 1267 |
public Tag getTag() { |
10 | 1268 |
return BREAK; |
1269 |
} |
|
1270 |
} |
|
1271 |
||
1272 |
/** |
|
1273 |
* A continue of a loop. |
|
1274 |
*/ |
|
1275 |
public static class JCContinue extends JCStatement implements ContinueTree { |
|
1276 |
public Name label; |
|
1277 |
public JCTree target; |
|
1278 |
protected JCContinue(Name label, JCTree target) { |
|
1279 |
this.label = label; |
|
1280 |
this.target = target; |
|
1281 |
} |
|
1282 |
@Override |
|
1283 |
public void accept(Visitor v) { v.visitContinue(this); } |
|
1284 |
||
1285 |
public Kind getKind() { return Kind.CONTINUE; } |
|
1286 |
public Name getLabel() { return label; } |
|
1287 |
@Override |
|
1288 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
1289 |
return v.visitContinue(this, d); |
|
1290 |
} |
|
1291 |
@Override |
|
10950 | 1292 |
public Tag getTag() { |
10 | 1293 |
return CONTINUE; |
1294 |
} |
|
1295 |
} |
|
1296 |
||
1297 |
/** |
|
1298 |
* A return statement. |
|
1299 |
*/ |
|
1300 |
public static class JCReturn extends JCStatement implements ReturnTree { |
|
1301 |
public JCExpression expr; |
|
1302 |
protected JCReturn(JCExpression expr) { |
|
1303 |
this.expr = expr; |
|
1304 |
} |
|
1305 |
@Override |
|
1306 |
public void accept(Visitor v) { v.visitReturn(this); } |
|
1307 |
||
1308 |
public Kind getKind() { return Kind.RETURN; } |
|
1309 |
public JCExpression getExpression() { return expr; } |
|
1310 |
@Override |
|
1311 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
1312 |
return v.visitReturn(this, d); |
|
1313 |
} |
|
1314 |
@Override |
|
10950 | 1315 |
public Tag getTag() { |
10 | 1316 |
return RETURN; |
1317 |
} |
|
1318 |
} |
|
1319 |
||
1320 |
/** |
|
1321 |
* A throw statement. |
|
1322 |
*/ |
|
1323 |
public static class JCThrow extends JCStatement implements ThrowTree { |
|
1324 |
public JCExpression expr; |
|
1325 |
protected JCThrow(JCTree expr) { |
|
1326 |
this.expr = (JCExpression)expr; |
|
1327 |
} |
|
1328 |
@Override |
|
1329 |
public void accept(Visitor v) { v.visitThrow(this); } |
|
1330 |
||
1331 |
public Kind getKind() { return Kind.THROW; } |
|
1332 |
public JCExpression getExpression() { return expr; } |
|
1333 |
@Override |
|
1334 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
1335 |
return v.visitThrow(this, d); |
|
1336 |
} |
|
1337 |
@Override |
|
10950 | 1338 |
public Tag getTag() { |
10 | 1339 |
return THROW; |
1340 |
} |
|
1341 |
} |
|
1342 |
||
1343 |
/** |
|
1344 |
* An assert statement. |
|
1345 |
*/ |
|
1346 |
public static class JCAssert extends JCStatement implements AssertTree { |
|
1347 |
public JCExpression cond; |
|
1348 |
public JCExpression detail; |
|
1349 |
protected JCAssert(JCExpression cond, JCExpression detail) { |
|
1350 |
this.cond = cond; |
|
1351 |
this.detail = detail; |
|
1352 |
} |
|
1353 |
@Override |
|
1354 |
public void accept(Visitor v) { v.visitAssert(this); } |
|
1355 |
||
1356 |
public Kind getKind() { return Kind.ASSERT; } |
|
1357 |
public JCExpression getCondition() { return cond; } |
|
1358 |
public JCExpression getDetail() { return detail; } |
|
1359 |
@Override |
|
1360 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
1361 |
return v.visitAssert(this, d); |
|
1362 |
} |
|
1363 |
@Override |
|
10950 | 1364 |
public Tag getTag() { |
10 | 1365 |
return ASSERT; |
1366 |
} |
|
1367 |
} |
|
1368 |
||
1369 |
/** |
|
1370 |
* A method invocation |
|
1371 |
*/ |
|
1372 |
public static class JCMethodInvocation extends JCExpression implements MethodInvocationTree { |
|
1373 |
public List<JCExpression> typeargs; |
|
1374 |
public JCExpression meth; |
|
1375 |
public List<JCExpression> args; |
|
1376 |
public Type varargsElement; |
|
1377 |
protected JCMethodInvocation(List<JCExpression> typeargs, |
|
1378 |
JCExpression meth, |
|
1379 |
List<JCExpression> args) |
|
1380 |
{ |
|
1381 |
this.typeargs = (typeargs == null) ? List.<JCExpression>nil() |
|
1382 |
: typeargs; |
|
1383 |
this.meth = meth; |
|
1384 |
this.args = args; |
|
1385 |
} |
|
1386 |
@Override |
|
1387 |
public void accept(Visitor v) { v.visitApply(this); } |
|
1388 |
||
1389 |
public Kind getKind() { return Kind.METHOD_INVOCATION; } |
|
1390 |
public List<JCExpression> getTypeArguments() { |
|
1391 |
return typeargs; |
|
1392 |
} |
|
1393 |
public JCExpression getMethodSelect() { return meth; } |
|
1394 |
public List<JCExpression> getArguments() { |
|
1395 |
return args; |
|
1396 |
} |
|
1397 |
@Override |
|
1398 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
1399 |
return v.visitMethodInvocation(this, d); |
|
1400 |
} |
|
1401 |
@Override |
|
1402 |
public JCMethodInvocation setType(Type type) { |
|
1403 |
super.setType(type); |
|
1404 |
return this; |
|
1405 |
} |
|
1406 |
@Override |
|
10950 | 1407 |
public Tag getTag() { |
10 | 1408 |
return(APPLY); |
1409 |
} |
|
1410 |
} |
|
1411 |
||
1412 |
/** |
|
1413 |
* A new(...) operation. |
|
1414 |
*/ |
|
1415 |
public static class JCNewClass extends JCExpression implements NewClassTree { |
|
1416 |
public JCExpression encl; |
|
1417 |
public List<JCExpression> typeargs; |
|
1418 |
public JCExpression clazz; |
|
1419 |
public List<JCExpression> args; |
|
1420 |
public JCClassDecl def; |
|
1421 |
public Symbol constructor; |
|
1422 |
public Type varargsElement; |
|
1791
d378f023c36d
6723444: javac fails to substitute type variables into a constructor's throws clause
mcimadamore
parents:
1264
diff
changeset
|
1423 |
public Type constructorType; |
10 | 1424 |
protected JCNewClass(JCExpression encl, |
1425 |
List<JCExpression> typeargs, |
|
1426 |
JCExpression clazz, |
|
1427 |
List<JCExpression> args, |
|
1428 |
JCClassDecl def) |
|
1429 |
{ |
|
1430 |
this.encl = encl; |
|
1431 |
this.typeargs = (typeargs == null) ? List.<JCExpression>nil() |
|
1432 |
: typeargs; |
|
1433 |
this.clazz = clazz; |
|
1434 |
this.args = args; |
|
1435 |
this.def = def; |
|
1436 |
} |
|
1437 |
@Override |
|
1438 |
public void accept(Visitor v) { v.visitNewClass(this); } |
|
1439 |
||
1440 |
public Kind getKind() { return Kind.NEW_CLASS; } |
|
1441 |
public JCExpression getEnclosingExpression() { // expr.new C< ... > ( ... ) |
|
1442 |
return encl; |
|
1443 |
} |
|
1444 |
public List<JCExpression> getTypeArguments() { |
|
1445 |
return typeargs; |
|
1446 |
} |
|
1447 |
public JCExpression getIdentifier() { return clazz; } |
|
1448 |
public List<JCExpression> getArguments() { |
|
1449 |
return args; |
|
1450 |
} |
|
1451 |
public JCClassDecl getClassBody() { return def; } |
|
1452 |
@Override |
|
1453 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
1454 |
return v.visitNewClass(this, d); |
|
1455 |
} |
|
1456 |
@Override |
|
10950 | 1457 |
public Tag getTag() { |
10 | 1458 |
return NEWCLASS; |
1459 |
} |
|
1460 |
} |
|
1461 |
||
1462 |
/** |
|
1463 |
* A new[...] operation. |
|
1464 |
*/ |
|
1465 |
public static class JCNewArray extends JCExpression implements NewArrayTree { |
|
1466 |
public JCExpression elemtype; |
|
1467 |
public List<JCExpression> dims; |
|
1468 |
public List<JCExpression> elems; |
|
1469 |
protected JCNewArray(JCExpression elemtype, |
|
1470 |
List<JCExpression> dims, |
|
1471 |
List<JCExpression> elems) |
|
1472 |
{ |
|
1473 |
this.elemtype = elemtype; |
|
1474 |
this.dims = dims; |
|
1475 |
this.elems = elems; |
|
1476 |
} |
|
1477 |
@Override |
|
1478 |
public void accept(Visitor v) { v.visitNewArray(this); } |
|
1479 |
||
1480 |
public Kind getKind() { return Kind.NEW_ARRAY; } |
|
1481 |
public JCExpression getType() { return elemtype; } |
|
1482 |
public List<JCExpression> getDimensions() { |
|
1483 |
return dims; |
|
1484 |
} |
|
1485 |
public List<JCExpression> getInitializers() { |
|
1486 |
return elems; |
|
1487 |
} |
|
1488 |
@Override |
|
1489 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
1490 |
return v.visitNewArray(this, d); |
|
1491 |
} |
|
1492 |
@Override |
|
10950 | 1493 |
public Tag getTag() { |
10 | 1494 |
return NEWARRAY; |
1495 |
} |
|
1496 |
} |
|
1497 |
||
1498 |
/** |
|
11141 | 1499 |
* A lambda expression. |
1500 |
*/ |
|
1501 |
public static class JCLambda extends JCExpression implements LambdaExpressionTree { |
|
1502 |
||
1503 |
public List<JCVariableDecl> params; |
|
1504 |
public JCTree body; |
|
1505 |
public Type targetType; |
|
1506 |
public boolean canCompleteNormally = true; |
|
1507 |
public List<Type> inferredThrownTypes; |
|
1508 |
||
1509 |
public JCLambda(List<JCVariableDecl> params, |
|
1510 |
JCTree body) { |
|
1511 |
this.params = params; |
|
1512 |
this.body = body; |
|
1513 |
} |
|
1514 |
@Override |
|
1515 |
public Tag getTag() { |
|
1516 |
return LAMBDA; |
|
1517 |
} |
|
1518 |
@Override |
|
1519 |
public void accept(Visitor v) { |
|
1520 |
v.visitLambda(this); |
|
1521 |
} |
|
1522 |
@Override |
|
1523 |
public <R, D> R accept(TreeVisitor<R, D> v, D d) { |
|
1524 |
return v.visitLambdaExpression(this, d); |
|
1525 |
} |
|
1526 |
public Kind getKind() { |
|
1527 |
return Kind.LAMBDA_EXPRESSION; |
|
1528 |
} |
|
1529 |
public JCTree getBody() { |
|
1530 |
return body; |
|
1531 |
} |
|
1532 |
public java.util.List<? extends VariableTree> getParameters() { |
|
1533 |
return params; |
|
1534 |
} |
|
1535 |
@Override |
|
1536 |
public JCLambda setType(Type type) { |
|
1537 |
super.setType(type); |
|
1538 |
return this; |
|
1539 |
} |
|
1540 |
@Override |
|
1541 |
public BodyKind getBodyKind() { |
|
1542 |
return body.hasTag(BLOCK) ? |
|
1543 |
BodyKind.STATEMENT : |
|
1544 |
BodyKind.EXPRESSION; |
|
1545 |
} |
|
1546 |
} |
|
1547 |
||
1548 |
/** |
|
10 | 1549 |
* A parenthesized subexpression ( ... ) |
1550 |
*/ |
|
1551 |
public static class JCParens extends JCExpression implements ParenthesizedTree { |
|
1552 |
public JCExpression expr; |
|
1553 |
protected JCParens(JCExpression expr) { |
|
1554 |
this.expr = expr; |
|
1555 |
} |
|
1556 |
@Override |
|
1557 |
public void accept(Visitor v) { v.visitParens(this); } |
|
1558 |
||
1559 |
public Kind getKind() { return Kind.PARENTHESIZED; } |
|
1560 |
public JCExpression getExpression() { return expr; } |
|
1561 |
@Override |
|
1562 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
1563 |
return v.visitParenthesized(this, d); |
|
1564 |
} |
|
1565 |
@Override |
|
10950 | 1566 |
public Tag getTag() { |
10 | 1567 |
return PARENS; |
1568 |
} |
|
1569 |
} |
|
1570 |
||
1571 |
/** |
|
1572 |
* A assignment with "=". |
|
1573 |
*/ |
|
1574 |
public static class JCAssign extends JCExpression implements AssignmentTree { |
|
1575 |
public JCExpression lhs; |
|
1576 |
public JCExpression rhs; |
|
1577 |
protected JCAssign(JCExpression lhs, JCExpression rhs) { |
|
1578 |
this.lhs = lhs; |
|
1579 |
this.rhs = rhs; |
|
1580 |
} |
|
1581 |
@Override |
|
1582 |
public void accept(Visitor v) { v.visitAssign(this); } |
|
1583 |
||
1584 |
public Kind getKind() { return Kind.ASSIGNMENT; } |
|
1585 |
public JCExpression getVariable() { return lhs; } |
|
1586 |
public JCExpression getExpression() { return rhs; } |
|
1587 |
@Override |
|
1588 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
1589 |
return v.visitAssignment(this, d); |
|
1590 |
} |
|
1591 |
@Override |
|
10950 | 1592 |
public Tag getTag() { |
10 | 1593 |
return ASSIGN; |
1594 |
} |
|
1595 |
} |
|
1596 |
||
1597 |
/** |
|
1598 |
* An assignment with "+=", "|=" ... |
|
1599 |
*/ |
|
1600 |
public static class JCAssignOp extends JCExpression implements CompoundAssignmentTree { |
|
10950 | 1601 |
private Tag opcode; |
10 | 1602 |
public JCExpression lhs; |
1603 |
public JCExpression rhs; |
|
1604 |
public Symbol operator; |
|
10950 | 1605 |
protected JCAssignOp(Tag opcode, JCTree lhs, JCTree rhs, Symbol operator) { |
10 | 1606 |
this.opcode = opcode; |
1607 |
this.lhs = (JCExpression)lhs; |
|
1608 |
this.rhs = (JCExpression)rhs; |
|
1609 |
this.operator = operator; |
|
1610 |
} |
|
1611 |
@Override |
|
1612 |
public void accept(Visitor v) { v.visitAssignop(this); } |
|
1613 |
||
1614 |
public Kind getKind() { return TreeInfo.tagToKind(getTag()); } |
|
1615 |
public JCExpression getVariable() { return lhs; } |
|
1616 |
public JCExpression getExpression() { return rhs; } |
|
1617 |
public Symbol getOperator() { |
|
1618 |
return operator; |
|
1619 |
} |
|
1620 |
@Override |
|
1621 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
1622 |
return v.visitCompoundAssignment(this, d); |
|
1623 |
} |
|
1624 |
@Override |
|
10950 | 1625 |
public Tag getTag() { |
10 | 1626 |
return opcode; |
1627 |
} |
|
1628 |
} |
|
1629 |
||
1630 |
/** |
|
1631 |
* A unary operation. |
|
1632 |
*/ |
|
1633 |
public static class JCUnary extends JCExpression implements UnaryTree { |
|
10950 | 1634 |
private Tag opcode; |
10 | 1635 |
public JCExpression arg; |
1636 |
public Symbol operator; |
|
10950 | 1637 |
protected JCUnary(Tag opcode, JCExpression arg) { |
10 | 1638 |
this.opcode = opcode; |
1639 |
this.arg = arg; |
|
1640 |
} |
|
1641 |
@Override |
|
1642 |
public void accept(Visitor v) { v.visitUnary(this); } |
|
1643 |
||
1644 |
public Kind getKind() { return TreeInfo.tagToKind(getTag()); } |
|
1645 |
public JCExpression getExpression() { return arg; } |
|
1646 |
public Symbol getOperator() { |
|
1647 |
return operator; |
|
1648 |
} |
|
1649 |
@Override |
|
1650 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
1651 |
return v.visitUnary(this, d); |
|
1652 |
} |
|
1653 |
@Override |
|
10950 | 1654 |
public Tag getTag() { |
10 | 1655 |
return opcode; |
1656 |
} |
|
1657 |
||
10950 | 1658 |
public void setTag(Tag tag) { |
10 | 1659 |
opcode = tag; |
1660 |
} |
|
1661 |
} |
|
1662 |
||
1663 |
/** |
|
1664 |
* A binary operation. |
|
1665 |
*/ |
|
1666 |
public static class JCBinary extends JCExpression implements BinaryTree { |
|
10950 | 1667 |
private Tag opcode; |
10 | 1668 |
public JCExpression lhs; |
1669 |
public JCExpression rhs; |
|
1670 |
public Symbol operator; |
|
10950 | 1671 |
protected JCBinary(Tag opcode, |
10 | 1672 |
JCExpression lhs, |
1673 |
JCExpression rhs, |
|
1674 |
Symbol operator) { |
|
1675 |
this.opcode = opcode; |
|
1676 |
this.lhs = lhs; |
|
1677 |
this.rhs = rhs; |
|
1678 |
this.operator = operator; |
|
1679 |
} |
|
1680 |
@Override |
|
1681 |
public void accept(Visitor v) { v.visitBinary(this); } |
|
1682 |
||
1683 |
public Kind getKind() { return TreeInfo.tagToKind(getTag()); } |
|
1684 |
public JCExpression getLeftOperand() { return lhs; } |
|
1685 |
public JCExpression getRightOperand() { return rhs; } |
|
1686 |
public Symbol getOperator() { |
|
1687 |
return operator; |
|
1688 |
} |
|
1689 |
@Override |
|
1690 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
1691 |
return v.visitBinary(this, d); |
|
1692 |
} |
|
1693 |
@Override |
|
10950 | 1694 |
public Tag getTag() { |
10 | 1695 |
return opcode; |
1696 |
} |
|
1697 |
} |
|
1698 |
||
1699 |
/** |
|
1700 |
* A type cast. |
|
1701 |
*/ |
|
1702 |
public static class JCTypeCast extends JCExpression implements TypeCastTree { |
|
1703 |
public JCTree clazz; |
|
1704 |
public JCExpression expr; |
|
1705 |
protected JCTypeCast(JCTree clazz, JCExpression expr) { |
|
1706 |
this.clazz = clazz; |
|
1707 |
this.expr = expr; |
|
1708 |
} |
|
1709 |
@Override |
|
1710 |
public void accept(Visitor v) { v.visitTypeCast(this); } |
|
1711 |
||
1712 |
public Kind getKind() { return Kind.TYPE_CAST; } |
|
1713 |
public JCTree getType() { return clazz; } |
|
1714 |
public JCExpression getExpression() { return expr; } |
|
1715 |
@Override |
|
1716 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
1717 |
return v.visitTypeCast(this, d); |
|
1718 |
} |
|
1719 |
@Override |
|
10950 | 1720 |
public Tag getTag() { |
10 | 1721 |
return TYPECAST; |
1722 |
} |
|
1723 |
} |
|
1724 |
||
1725 |
/** |
|
1726 |
* A type test. |
|
1727 |
*/ |
|
1728 |
public static class JCInstanceOf extends JCExpression implements InstanceOfTree { |
|
1729 |
public JCExpression expr; |
|
1730 |
public JCTree clazz; |
|
1731 |
protected JCInstanceOf(JCExpression expr, JCTree clazz) { |
|
1732 |
this.expr = expr; |
|
1733 |
this.clazz = clazz; |
|
1734 |
} |
|
1735 |
@Override |
|
1736 |
public void accept(Visitor v) { v.visitTypeTest(this); } |
|
1737 |
||
1738 |
public Kind getKind() { return Kind.INSTANCE_OF; } |
|
1739 |
public JCTree getType() { return clazz; } |
|
1740 |
public JCExpression getExpression() { return expr; } |
|
1741 |
@Override |
|
1742 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
1743 |
return v.visitInstanceOf(this, d); |
|
1744 |
} |
|
1745 |
@Override |
|
10950 | 1746 |
public Tag getTag() { |
10 | 1747 |
return TYPETEST; |
1748 |
} |
|
1749 |
} |
|
1750 |
||
1751 |
/** |
|
1752 |
* An array selection |
|
1753 |
*/ |
|
1754 |
public static class JCArrayAccess extends JCExpression implements ArrayAccessTree { |
|
1755 |
public JCExpression indexed; |
|
1756 |
public JCExpression index; |
|
1757 |
protected JCArrayAccess(JCExpression indexed, JCExpression index) { |
|
1758 |
this.indexed = indexed; |
|
1759 |
this.index = index; |
|
1760 |
} |
|
1761 |
@Override |
|
1762 |
public void accept(Visitor v) { v.visitIndexed(this); } |
|
1763 |
||
1764 |
public Kind getKind() { return Kind.ARRAY_ACCESS; } |
|
1765 |
public JCExpression getExpression() { return indexed; } |
|
1766 |
public JCExpression getIndex() { return index; } |
|
1767 |
@Override |
|
1768 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
1769 |
return v.visitArrayAccess(this, d); |
|
1770 |
} |
|
1771 |
@Override |
|
10950 | 1772 |
public Tag getTag() { |
10 | 1773 |
return INDEXED; |
1774 |
} |
|
1775 |
} |
|
1776 |
||
1777 |
/** |
|
1778 |
* Selects through packages and classes |
|
1779 |
* @param selected selected Tree hierarchie |
|
1780 |
* @param selector name of field to select thru |
|
1781 |
* @param sym symbol of the selected class |
|
1782 |
*/ |
|
1783 |
public static class JCFieldAccess extends JCExpression implements MemberSelectTree { |
|
1784 |
public JCExpression selected; |
|
1785 |
public Name name; |
|
1786 |
public Symbol sym; |
|
1787 |
protected JCFieldAccess(JCExpression selected, Name name, Symbol sym) { |
|
1788 |
this.selected = selected; |
|
1789 |
this.name = name; |
|
1790 |
this.sym = sym; |
|
1791 |
} |
|
1792 |
@Override |
|
1793 |
public void accept(Visitor v) { v.visitSelect(this); } |
|
1794 |
||
1795 |
public Kind getKind() { return Kind.MEMBER_SELECT; } |
|
1796 |
public JCExpression getExpression() { return selected; } |
|
1797 |
@Override |
|
1798 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
1799 |
return v.visitMemberSelect(this, d); |
|
1800 |
} |
|
1801 |
public Name getIdentifier() { return name; } |
|
1802 |
@Override |
|
10950 | 1803 |
public Tag getTag() { |
10 | 1804 |
return SELECT; |
1805 |
} |
|
1806 |
} |
|
1807 |
||
1808 |
/** |
|
11142 | 1809 |
* Selects a member expression. |
1810 |
*/ |
|
1811 |
public static class JCMemberReference extends JCExpression implements MemberReferenceTree { |
|
1812 |
public ReferenceMode mode; |
|
1813 |
public Name name; |
|
1814 |
public JCExpression expr; |
|
1815 |
public List<JCExpression> typeargs; |
|
1816 |
public Type targetType; |
|
1817 |
public Symbol sym; |
|
1818 |
||
1819 |
protected JCMemberReference(ReferenceMode mode, Name name, JCExpression expr, List<JCExpression> typeargs) { |
|
1820 |
this.mode = mode; |
|
1821 |
this.name = name; |
|
1822 |
this.expr = expr; |
|
1823 |
this.typeargs = typeargs; |
|
1824 |
} |
|
1825 |
@Override |
|
1826 |
public void accept(Visitor v) { v.visitReference(this); } |
|
1827 |
||
1828 |
public Kind getKind() { return Kind.MEMBER_REFERENCE; } |
|
1829 |
@Override |
|
1830 |
public ReferenceMode getMode() { return mode; } |
|
1831 |
@Override |
|
1832 |
public JCExpression getQualifierExpression() { return expr; } |
|
1833 |
@Override |
|
1834 |
public Name getName() { return name; } |
|
1835 |
@Override |
|
1836 |
public List<JCExpression> getTypeArguments() { return typeargs; } |
|
1837 |
||
1838 |
@Override |
|
1839 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
1840 |
return v.visitMemberReference(this, d); |
|
1841 |
} |
|
1842 |
@Override |
|
1843 |
public Tag getTag() { |
|
1844 |
return REFERENCE; |
|
1845 |
} |
|
1846 |
} |
|
1847 |
||
1848 |
/** |
|
10 | 1849 |
* An identifier |
1850 |
* @param idname the name |
|
1851 |
* @param sym the symbol |
|
1852 |
*/ |
|
1853 |
public static class JCIdent extends JCExpression implements IdentifierTree { |
|
1854 |
public Name name; |
|
1855 |
public Symbol sym; |
|
1856 |
protected JCIdent(Name name, Symbol sym) { |
|
1857 |
this.name = name; |
|
1858 |
this.sym = sym; |
|
1859 |
} |
|
1860 |
@Override |
|
1861 |
public void accept(Visitor v) { v.visitIdent(this); } |
|
1862 |
||
1863 |
public Kind getKind() { return Kind.IDENTIFIER; } |
|
1864 |
public Name getName() { return name; } |
|
1865 |
@Override |
|
1866 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
1867 |
return v.visitIdentifier(this, d); |
|
1868 |
} |
|
10950 | 1869 |
@Override |
1870 |
public Tag getTag() { |
|
10 | 1871 |
return IDENT; |
1872 |
} |
|
1873 |
} |
|
1874 |
||
1875 |
/** |
|
1876 |
* A constant value given literally. |
|
1877 |
* @param value value representation |
|
1878 |
*/ |
|
1879 |
public static class JCLiteral extends JCExpression implements LiteralTree { |
|
1880 |
public int typetag; |
|
1881 |
public Object value; |
|
1882 |
protected JCLiteral(int typetag, Object value) { |
|
1883 |
this.typetag = typetag; |
|
1884 |
this.value = value; |
|
1885 |
} |
|
1886 |
@Override |
|
1887 |
public void accept(Visitor v) { v.visitLiteral(this); } |
|
1888 |
||
1889 |
public Kind getKind() { |
|
1890 |
switch (typetag) { |
|
1891 |
case TypeTags.INT: |
|
1892 |
return Kind.INT_LITERAL; |
|
1893 |
case TypeTags.LONG: |
|
1894 |
return Kind.LONG_LITERAL; |
|
1895 |
case TypeTags.FLOAT: |
|
1896 |
return Kind.FLOAT_LITERAL; |
|
1897 |
case TypeTags.DOUBLE: |
|
1898 |
return Kind.DOUBLE_LITERAL; |
|
1899 |
case TypeTags.BOOLEAN: |
|
1900 |
return Kind.BOOLEAN_LITERAL; |
|
1901 |
case TypeTags.CHAR: |
|
1902 |
return Kind.CHAR_LITERAL; |
|
1903 |
case TypeTags.CLASS: |
|
1904 |
return Kind.STRING_LITERAL; |
|
1905 |
case TypeTags.BOT: |
|
1906 |
return Kind.NULL_LITERAL; |
|
1907 |
default: |
|
1908 |
throw new AssertionError("unknown literal kind " + this); |
|
1909 |
} |
|
1910 |
} |
|
1911 |
public Object getValue() { |
|
1912 |
switch (typetag) { |
|
1913 |
case TypeTags.BOOLEAN: |
|
1914 |
int bi = (Integer) value; |
|
1915 |
return (bi != 0); |
|
1916 |
case TypeTags.CHAR: |
|
1917 |
int ci = (Integer) value; |
|
1918 |
char c = (char) ci; |
|
1919 |
if (c != ci) |
|
1920 |
throw new AssertionError("bad value for char literal"); |
|
1921 |
return c; |
|
1922 |
default: |
|
1923 |
return value; |
|
1924 |
} |
|
1925 |
} |
|
1926 |
@Override |
|
1927 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
1928 |
return v.visitLiteral(this, d); |
|
1929 |
} |
|
1930 |
@Override |
|
1931 |
public JCLiteral setType(Type type) { |
|
1932 |
super.setType(type); |
|
1933 |
return this; |
|
1934 |
} |
|
1935 |
@Override |
|
10950 | 1936 |
public Tag getTag() { |
10 | 1937 |
return LITERAL; |
1938 |
} |
|
1939 |
} |
|
1940 |
||
1941 |
/** |
|
1942 |
* Identifies a basic type. |
|
1943 |
* @param tag the basic type id |
|
1944 |
* @see TypeTags |
|
1945 |
*/ |
|
1946 |
public static class JCPrimitiveTypeTree extends JCExpression implements PrimitiveTypeTree { |
|
1947 |
public int typetag; |
|
1948 |
protected JCPrimitiveTypeTree(int typetag) { |
|
1949 |
this.typetag = typetag; |
|
1950 |
} |
|
1951 |
@Override |
|
1952 |
public void accept(Visitor v) { v.visitTypeIdent(this); } |
|
1953 |
||
1954 |
public Kind getKind() { return Kind.PRIMITIVE_TYPE; } |
|
1955 |
public TypeKind getPrimitiveTypeKind() { |
|
1956 |
switch (typetag) { |
|
1957 |
case TypeTags.BOOLEAN: |
|
1958 |
return TypeKind.BOOLEAN; |
|
1959 |
case TypeTags.BYTE: |
|
1960 |
return TypeKind.BYTE; |
|
1961 |
case TypeTags.SHORT: |
|
1962 |
return TypeKind.SHORT; |
|
1963 |
case TypeTags.INT: |
|
1964 |
return TypeKind.INT; |
|
1965 |
case TypeTags.LONG: |
|
1966 |
return TypeKind.LONG; |
|
1967 |
case TypeTags.CHAR: |
|
1968 |
return TypeKind.CHAR; |
|
1969 |
case TypeTags.FLOAT: |
|
1970 |
return TypeKind.FLOAT; |
|
1971 |
case TypeTags.DOUBLE: |
|
1972 |
return TypeKind.DOUBLE; |
|
1973 |
case TypeTags.VOID: |
|
1974 |
return TypeKind.VOID; |
|
1975 |
default: |
|
1976 |
throw new AssertionError("unknown primitive type " + this); |
|
1977 |
} |
|
1978 |
} |
|
1979 |
@Override |
|
1980 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
1981 |
return v.visitPrimitiveType(this, d); |
|
1982 |
} |
|
1983 |
@Override |
|
10950 | 1984 |
public Tag getTag() { |
10 | 1985 |
return TYPEIDENT; |
1986 |
} |
|
1987 |
} |
|
1988 |
||
1989 |
/** |
|
1990 |
* An array type, A[] |
|
1991 |
*/ |
|
1992 |
public static class JCArrayTypeTree extends JCExpression implements ArrayTypeTree { |
|
1993 |
public JCExpression elemtype; |
|
1994 |
protected JCArrayTypeTree(JCExpression elemtype) { |
|
1995 |
this.elemtype = elemtype; |
|
1996 |
} |
|
1997 |
@Override |
|
1998 |
public void accept(Visitor v) { v.visitTypeArray(this); } |
|
1999 |
||
2000 |
public Kind getKind() { return Kind.ARRAY_TYPE; } |
|
2001 |
public JCTree getType() { return elemtype; } |
|
2002 |
@Override |
|
2003 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
2004 |
return v.visitArrayType(this, d); |
|
2005 |
} |
|
2006 |
@Override |
|
10950 | 2007 |
public Tag getTag() { |
10 | 2008 |
return TYPEARRAY; |
2009 |
} |
|
2010 |
} |
|
2011 |
||
2012 |
/** |
|
13844 | 2013 |
* A parameterized type, {@literal T<...>} |
10 | 2014 |
*/ |
2015 |
public static class JCTypeApply extends JCExpression implements ParameterizedTypeTree { |
|
2016 |
public JCExpression clazz; |
|
2017 |
public List<JCExpression> arguments; |
|
2018 |
protected JCTypeApply(JCExpression clazz, List<JCExpression> arguments) { |
|
2019 |
this.clazz = clazz; |
|
2020 |
this.arguments = arguments; |
|
2021 |
} |
|
2022 |
@Override |
|
2023 |
public void accept(Visitor v) { v.visitTypeApply(this); } |
|
2024 |
||
2025 |
public Kind getKind() { return Kind.PARAMETERIZED_TYPE; } |
|
2026 |
public JCTree getType() { return clazz; } |
|
2027 |
public List<JCExpression> getTypeArguments() { |
|
2028 |
return arguments; |
|
2029 |
} |
|
2030 |
@Override |
|
2031 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
2032 |
return v.visitParameterizedType(this, d); |
|
2033 |
} |
|
2034 |
@Override |
|
10950 | 2035 |
public Tag getTag() { |
10 | 2036 |
return TYPEAPPLY; |
2037 |
} |
|
2038 |
} |
|
2039 |
||
2040 |
/** |
|
9300
c2de4dd9853b
7033809: Rename "disjunctive" to "union" in javax.lang.model
darcy
parents:
8625
diff
changeset
|
2041 |
* A union type, T1 | T2 | ... Tn (used in multicatch statements) |
5492
515e4b33b335
6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents:
3149
diff
changeset
|
2042 |
*/ |
9300
c2de4dd9853b
7033809: Rename "disjunctive" to "union" in javax.lang.model
darcy
parents:
8625
diff
changeset
|
2043 |
public static class JCTypeUnion extends JCExpression implements UnionTypeTree { |
5492
515e4b33b335
6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents:
3149
diff
changeset
|
2044 |
|
7074 | 2045 |
public List<JCExpression> alternatives; |
5492
515e4b33b335
6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents:
3149
diff
changeset
|
2046 |
|
9300
c2de4dd9853b
7033809: Rename "disjunctive" to "union" in javax.lang.model
darcy
parents:
8625
diff
changeset
|
2047 |
protected JCTypeUnion(List<JCExpression> components) { |
7074 | 2048 |
this.alternatives = components; |
5492
515e4b33b335
6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents:
3149
diff
changeset
|
2049 |
} |
515e4b33b335
6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents:
3149
diff
changeset
|
2050 |
@Override |
9300
c2de4dd9853b
7033809: Rename "disjunctive" to "union" in javax.lang.model
darcy
parents:
8625
diff
changeset
|
2051 |
public void accept(Visitor v) { v.visitTypeUnion(this); } |
5492
515e4b33b335
6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents:
3149
diff
changeset
|
2052 |
|
9300
c2de4dd9853b
7033809: Rename "disjunctive" to "union" in javax.lang.model
darcy
parents:
8625
diff
changeset
|
2053 |
public Kind getKind() { return Kind.UNION_TYPE; } |
5492
515e4b33b335
6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents:
3149
diff
changeset
|
2054 |
|
7074 | 2055 |
public List<JCExpression> getTypeAlternatives() { |
2056 |
return alternatives; |
|
5492
515e4b33b335
6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents:
3149
diff
changeset
|
2057 |
} |
515e4b33b335
6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents:
3149
diff
changeset
|
2058 |
@Override |
515e4b33b335
6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents:
3149
diff
changeset
|
2059 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
9300
c2de4dd9853b
7033809: Rename "disjunctive" to "union" in javax.lang.model
darcy
parents:
8625
diff
changeset
|
2060 |
return v.visitUnionType(this, d); |
5492
515e4b33b335
6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents:
3149
diff
changeset
|
2061 |
} |
515e4b33b335
6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents:
3149
diff
changeset
|
2062 |
@Override |
10950 | 2063 |
public Tag getTag() { |
9300
c2de4dd9853b
7033809: Rename "disjunctive" to "union" in javax.lang.model
darcy
parents:
8625
diff
changeset
|
2064 |
return TYPEUNION; |
5492
515e4b33b335
6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents:
3149
diff
changeset
|
2065 |
} |
515e4b33b335
6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents:
3149
diff
changeset
|
2066 |
} |
515e4b33b335
6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents:
3149
diff
changeset
|
2067 |
|
515e4b33b335
6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents:
3149
diff
changeset
|
2068 |
/** |
10 | 2069 |
* A formal class parameter. |
2070 |
* @param name name |
|
2071 |
* @param bounds bounds |
|
2072 |
*/ |
|
2073 |
public static class JCTypeParameter extends JCTree implements TypeParameterTree { |
|
2074 |
public Name name; |
|
2075 |
public List<JCExpression> bounds; |
|
8031 | 2076 |
protected JCTypeParameter(Name name, List<JCExpression> bounds) { |
10 | 2077 |
this.name = name; |
2078 |
this.bounds = bounds; |
|
2079 |
} |
|
2080 |
@Override |
|
2081 |
public void accept(Visitor v) { v.visitTypeParameter(this); } |
|
2082 |
||
2083 |
public Kind getKind() { return Kind.TYPE_PARAMETER; } |
|
2084 |
public Name getName() { return name; } |
|
2085 |
public List<JCExpression> getBounds() { |
|
2086 |
return bounds; |
|
2087 |
} |
|
2088 |
@Override |
|
2089 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
2090 |
return v.visitTypeParameter(this, d); |
|
2091 |
} |
|
2092 |
@Override |
|
10950 | 2093 |
public Tag getTag() { |
10 | 2094 |
return TYPEPARAMETER; |
2095 |
} |
|
2096 |
} |
|
2097 |
||
2098 |
public static class JCWildcard extends JCExpression implements WildcardTree { |
|
2099 |
public TypeBoundKind kind; |
|
2100 |
public JCTree inner; |
|
2101 |
protected JCWildcard(TypeBoundKind kind, JCTree inner) { |
|
2102 |
kind.getClass(); // null-check |
|
2103 |
this.kind = kind; |
|
2104 |
this.inner = inner; |
|
2105 |
} |
|
2106 |
@Override |
|
2107 |
public void accept(Visitor v) { v.visitWildcard(this); } |
|
2108 |
||
2109 |
public Kind getKind() { |
|
2110 |
switch (kind.kind) { |
|
2111 |
case UNBOUND: |
|
2112 |
return Kind.UNBOUNDED_WILDCARD; |
|
2113 |
case EXTENDS: |
|
2114 |
return Kind.EXTENDS_WILDCARD; |
|
2115 |
case SUPER: |
|
2116 |
return Kind.SUPER_WILDCARD; |
|
2117 |
default: |
|
2118 |
throw new AssertionError("Unknown wildcard bound " + kind); |
|
2119 |
} |
|
2120 |
} |
|
2121 |
public JCTree getBound() { return inner; } |
|
2122 |
@Override |
|
2123 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
2124 |
return v.visitWildcard(this, d); |
|
2125 |
} |
|
2126 |
@Override |
|
10950 | 2127 |
public Tag getTag() { |
10 | 2128 |
return WILDCARD; |
2129 |
} |
|
2130 |
} |
|
2131 |
||
2132 |
public static class TypeBoundKind extends JCTree { |
|
2133 |
public BoundKind kind; |
|
2134 |
protected TypeBoundKind(BoundKind kind) { |
|
2135 |
this.kind = kind; |
|
2136 |
} |
|
2137 |
@Override |
|
2138 |
public void accept(Visitor v) { v.visitTypeBoundKind(this); } |
|
2139 |
||
2140 |
public Kind getKind() { |
|
2141 |
throw new AssertionError("TypeBoundKind is not part of a public API"); |
|
2142 |
} |
|
2143 |
@Override |
|
2144 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
2145 |
throw new AssertionError("TypeBoundKind is not part of a public API"); |
|
2146 |
} |
|
2147 |
@Override |
|
10950 | 2148 |
public Tag getTag() { |
10 | 2149 |
return TYPEBOUNDKIND; |
2150 |
} |
|
2151 |
} |
|
2152 |
||
2153 |
public static class JCAnnotation extends JCExpression implements AnnotationTree { |
|
2154 |
public JCTree annotationType; |
|
2155 |
public List<JCExpression> args; |
|
2156 |
protected JCAnnotation(JCTree annotationType, List<JCExpression> args) { |
|
2157 |
this.annotationType = annotationType; |
|
2158 |
this.args = args; |
|
2159 |
} |
|
2160 |
@Override |
|
2161 |
public void accept(Visitor v) { v.visitAnnotation(this); } |
|
2162 |
||
2163 |
public Kind getKind() { return Kind.ANNOTATION; } |
|
2164 |
public JCTree getAnnotationType() { return annotationType; } |
|
2165 |
public List<JCExpression> getArguments() { |
|
2166 |
return args; |
|
2167 |
} |
|
2168 |
@Override |
|
2169 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
2170 |
return v.visitAnnotation(this, d); |
|
2171 |
} |
|
2172 |
@Override |
|
10950 | 2173 |
public Tag getTag() { |
10 | 2174 |
return ANNOTATION; |
2175 |
} |
|
2176 |
} |
|
2177 |
||
2178 |
public static class JCModifiers extends JCTree implements com.sun.source.tree.ModifiersTree { |
|
2179 |
public long flags; |
|
2180 |
public List<JCAnnotation> annotations; |
|
2181 |
protected JCModifiers(long flags, List<JCAnnotation> annotations) { |
|
2182 |
this.flags = flags; |
|
2183 |
this.annotations = annotations; |
|
2184 |
} |
|
2185 |
@Override |
|
2186 |
public void accept(Visitor v) { v.visitModifiers(this); } |
|
2187 |
||
2188 |
public Kind getKind() { return Kind.MODIFIERS; } |
|
2189 |
public Set<Modifier> getFlags() { |
|
2190 |
return Flags.asModifierSet(flags); |
|
2191 |
} |
|
2192 |
public List<JCAnnotation> getAnnotations() { |
|
2193 |
return annotations; |
|
2194 |
} |
|
2195 |
@Override |
|
2196 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
2197 |
return v.visitModifiers(this, d); |
|
2198 |
} |
|
2199 |
@Override |
|
10950 | 2200 |
public Tag getTag() { |
10 | 2201 |
return MODIFIERS; |
2202 |
} |
|
2203 |
} |
|
2204 |
||
2205 |
public static class JCErroneous extends JCExpression |
|
2206 |
implements com.sun.source.tree.ErroneousTree { |
|
2207 |
public List<? extends JCTree> errs; |
|
2208 |
protected JCErroneous(List<? extends JCTree> errs) { |
|
2209 |
this.errs = errs; |
|
2210 |
} |
|
2211 |
@Override |
|
2212 |
public void accept(Visitor v) { v.visitErroneous(this); } |
|
2213 |
||
2214 |
public Kind getKind() { return Kind.ERRONEOUS; } |
|
2215 |
||
2216 |
public List<? extends JCTree> getErrorTrees() { |
|
2217 |
return errs; |
|
2218 |
} |
|
2219 |
||
2220 |
@Override |
|
2221 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
2222 |
return v.visitErroneous(this, d); |
|
2223 |
} |
|
2224 |
@Override |
|
10950 | 2225 |
public Tag getTag() { |
10 | 2226 |
return ERRONEOUS; |
2227 |
} |
|
2228 |
} |
|
2229 |
||
2230 |
/** (let int x = 3; in x+2) */ |
|
2231 |
public static class LetExpr extends JCExpression { |
|
2232 |
public List<JCVariableDecl> defs; |
|
2233 |
public JCTree expr; |
|
2234 |
protected LetExpr(List<JCVariableDecl> defs, JCTree expr) { |
|
2235 |
this.defs = defs; |
|
2236 |
this.expr = expr; |
|
2237 |
} |
|
2238 |
@Override |
|
2239 |
public void accept(Visitor v) { v.visitLetExpr(this); } |
|
2240 |
||
2241 |
public Kind getKind() { |
|
2242 |
throw new AssertionError("LetExpr is not part of a public API"); |
|
2243 |
} |
|
2244 |
@Override |
|
2245 |
public <R,D> R accept(TreeVisitor<R,D> v, D d) { |
|
2246 |
throw new AssertionError("LetExpr is not part of a public API"); |
|
2247 |
} |
|
2248 |
@Override |
|
10950 | 2249 |
public Tag getTag() { |
10 | 2250 |
return LETEXPR; |
2251 |
} |
|
2252 |
} |
|
2253 |
||
2254 |
/** An interface for tree factories |
|
2255 |
*/ |
|
2256 |
public interface Factory { |
|
2257 |
JCCompilationUnit TopLevel(List<JCAnnotation> packageAnnotations, |
|
2258 |
JCExpression pid, |
|
2259 |
List<JCTree> defs); |
|
2260 |
JCImport Import(JCTree qualid, boolean staticImport); |
|
2261 |
JCClassDecl ClassDef(JCModifiers mods, |
|
2262 |
Name name, |
|
2263 |
List<JCTypeParameter> typarams, |
|
8625
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8221
diff
changeset
|
2264 |
JCExpression extending, |
10 | 2265 |
List<JCExpression> implementing, |
2266 |
List<JCTree> defs); |
|
2267 |
JCMethodDecl MethodDef(JCModifiers mods, |
|
2268 |
Name name, |
|
2269 |
JCExpression restype, |
|
2270 |
List<JCTypeParameter> typarams, |
|
2271 |
List<JCVariableDecl> params, |
|
2272 |
List<JCExpression> thrown, |
|
2273 |
JCBlock body, |
|
2274 |
JCExpression defaultValue); |
|
2275 |
JCVariableDecl VarDef(JCModifiers mods, |
|
2276 |
Name name, |
|
2277 |
JCExpression vartype, |
|
2278 |
JCExpression init); |
|
2279 |
JCSkip Skip(); |
|
2280 |
JCBlock Block(long flags, List<JCStatement> stats); |
|
2281 |
JCDoWhileLoop DoLoop(JCStatement body, JCExpression cond); |
|
2282 |
JCWhileLoop WhileLoop(JCExpression cond, JCStatement body); |
|
2283 |
JCForLoop ForLoop(List<JCStatement> init, |
|
2284 |
JCExpression cond, |
|
2285 |
List<JCExpressionStatement> step, |
|
2286 |
JCStatement body); |
|
2287 |
JCEnhancedForLoop ForeachLoop(JCVariableDecl var, JCExpression expr, JCStatement body); |
|
2288 |
JCLabeledStatement Labelled(Name label, JCStatement body); |
|
2289 |
JCSwitch Switch(JCExpression selector, List<JCCase> cases); |
|
2290 |
JCCase Case(JCExpression pat, List<JCStatement> stats); |
|
2291 |
JCSynchronized Synchronized(JCExpression lock, JCBlock body); |
|
2292 |
JCTry Try(JCBlock body, List<JCCatch> catchers, JCBlock finalizer); |
|
6148
3a8158299c51
6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents:
5847
diff
changeset
|
2293 |
JCTry Try(List<JCTree> resources, |
3a8158299c51
6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents:
5847
diff
changeset
|
2294 |
JCBlock body, |
3a8158299c51
6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents:
5847
diff
changeset
|
2295 |
List<JCCatch> catchers, |
3a8158299c51
6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents:
5847
diff
changeset
|
2296 |
JCBlock finalizer); |
10 | 2297 |
JCCatch Catch(JCVariableDecl param, JCBlock body); |
2298 |
JCConditional Conditional(JCExpression cond, |
|
2299 |
JCExpression thenpart, |
|
2300 |
JCExpression elsepart); |
|
2301 |
JCIf If(JCExpression cond, JCStatement thenpart, JCStatement elsepart); |
|
2302 |
JCExpressionStatement Exec(JCExpression expr); |
|
2303 |
JCBreak Break(Name label); |
|
2304 |
JCContinue Continue(Name label); |
|
2305 |
JCReturn Return(JCExpression expr); |
|
2306 |
JCThrow Throw(JCTree expr); |
|
2307 |
JCAssert Assert(JCExpression cond, JCExpression detail); |
|
2308 |
JCMethodInvocation Apply(List<JCExpression> typeargs, |
|
2309 |
JCExpression fn, |
|
2310 |
List<JCExpression> args); |
|
2311 |
JCNewClass NewClass(JCExpression encl, |
|
2312 |
List<JCExpression> typeargs, |
|
2313 |
JCExpression clazz, |
|
2314 |
List<JCExpression> args, |
|
2315 |
JCClassDecl def); |
|
2316 |
JCNewArray NewArray(JCExpression elemtype, |
|
2317 |
List<JCExpression> dims, |
|
2318 |
List<JCExpression> elems); |
|
2319 |
JCParens Parens(JCExpression expr); |
|
2320 |
JCAssign Assign(JCExpression lhs, JCExpression rhs); |
|
10950 | 2321 |
JCAssignOp Assignop(Tag opcode, JCTree lhs, JCTree rhs); |
2322 |
JCUnary Unary(Tag opcode, JCExpression arg); |
|
2323 |
JCBinary Binary(Tag opcode, JCExpression lhs, JCExpression rhs); |
|
10 | 2324 |
JCTypeCast TypeCast(JCTree expr, JCExpression type); |
2325 |
JCInstanceOf TypeTest(JCExpression expr, JCTree clazz); |
|
2326 |
JCArrayAccess Indexed(JCExpression indexed, JCExpression index); |
|
2327 |
JCFieldAccess Select(JCExpression selected, Name selector); |
|
2328 |
JCIdent Ident(Name idname); |
|
2329 |
JCLiteral Literal(int tag, Object value); |
|
2330 |
JCPrimitiveTypeTree TypeIdent(int typetag); |
|
2331 |
JCArrayTypeTree TypeArray(JCExpression elemtype); |
|
2332 |
JCTypeApply TypeApply(JCExpression clazz, List<JCExpression> arguments); |
|
2333 |
JCTypeParameter TypeParameter(Name name, List<JCExpression> bounds); |
|
2334 |
JCWildcard Wildcard(TypeBoundKind kind, JCTree type); |
|
2335 |
TypeBoundKind TypeBoundKind(BoundKind kind); |
|
2336 |
JCAnnotation Annotation(JCTree annotationType, List<JCExpression> args); |
|
2337 |
JCModifiers Modifiers(long flags, List<JCAnnotation> annotations); |
|
2338 |
JCErroneous Erroneous(List<? extends JCTree> errs); |
|
2339 |
LetExpr LetExpr(List<JCVariableDecl> defs, JCTree expr); |
|
2340 |
} |
|
2341 |
||
2342 |
/** A generic visitor class for trees. |
|
2343 |
*/ |
|
2344 |
public static abstract class Visitor { |
|
2345 |
public void visitTopLevel(JCCompilationUnit that) { visitTree(that); } |
|
2346 |
public void visitImport(JCImport that) { visitTree(that); } |
|
2347 |
public void visitClassDef(JCClassDecl that) { visitTree(that); } |
|
2348 |
public void visitMethodDef(JCMethodDecl that) { visitTree(that); } |
|
2349 |
public void visitVarDef(JCVariableDecl that) { visitTree(that); } |
|
2350 |
public void visitSkip(JCSkip that) { visitTree(that); } |
|
2351 |
public void visitBlock(JCBlock that) { visitTree(that); } |
|
2352 |
public void visitDoLoop(JCDoWhileLoop that) { visitTree(that); } |
|
2353 |
public void visitWhileLoop(JCWhileLoop that) { visitTree(that); } |
|
2354 |
public void visitForLoop(JCForLoop that) { visitTree(that); } |
|
2355 |
public void visitForeachLoop(JCEnhancedForLoop that) { visitTree(that); } |
|
2356 |
public void visitLabelled(JCLabeledStatement that) { visitTree(that); } |
|
2357 |
public void visitSwitch(JCSwitch that) { visitTree(that); } |
|
2358 |
public void visitCase(JCCase that) { visitTree(that); } |
|
2359 |
public void visitSynchronized(JCSynchronized that) { visitTree(that); } |
|
2360 |
public void visitTry(JCTry that) { visitTree(that); } |
|
2361 |
public void visitCatch(JCCatch that) { visitTree(that); } |
|
2362 |
public void visitConditional(JCConditional that) { visitTree(that); } |
|
2363 |
public void visitIf(JCIf that) { visitTree(that); } |
|
2364 |
public void visitExec(JCExpressionStatement that) { visitTree(that); } |
|
2365 |
public void visitBreak(JCBreak that) { visitTree(that); } |
|
2366 |
public void visitContinue(JCContinue that) { visitTree(that); } |
|
2367 |
public void visitReturn(JCReturn that) { visitTree(that); } |
|
2368 |
public void visitThrow(JCThrow that) { visitTree(that); } |
|
2369 |
public void visitAssert(JCAssert that) { visitTree(that); } |
|
2370 |
public void visitApply(JCMethodInvocation that) { visitTree(that); } |
|
2371 |
public void visitNewClass(JCNewClass that) { visitTree(that); } |
|
2372 |
public void visitNewArray(JCNewArray that) { visitTree(that); } |
|
11141 | 2373 |
public void visitLambda(JCLambda that) { visitTree(that); } |
10 | 2374 |
public void visitParens(JCParens that) { visitTree(that); } |
2375 |
public void visitAssign(JCAssign that) { visitTree(that); } |
|
2376 |
public void visitAssignop(JCAssignOp that) { visitTree(that); } |
|
2377 |
public void visitUnary(JCUnary that) { visitTree(that); } |
|
2378 |
public void visitBinary(JCBinary that) { visitTree(that); } |
|
2379 |
public void visitTypeCast(JCTypeCast that) { visitTree(that); } |
|
2380 |
public void visitTypeTest(JCInstanceOf that) { visitTree(that); } |
|
2381 |
public void visitIndexed(JCArrayAccess that) { visitTree(that); } |
|
2382 |
public void visitSelect(JCFieldAccess that) { visitTree(that); } |
|
11142 | 2383 |
public void visitReference(JCMemberReference that) { visitTree(that); } |
10 | 2384 |
public void visitIdent(JCIdent that) { visitTree(that); } |
2385 |
public void visitLiteral(JCLiteral that) { visitTree(that); } |
|
2386 |
public void visitTypeIdent(JCPrimitiveTypeTree that) { visitTree(that); } |
|
2387 |
public void visitTypeArray(JCArrayTypeTree that) { visitTree(that); } |
|
2388 |
public void visitTypeApply(JCTypeApply that) { visitTree(that); } |
|
9300
c2de4dd9853b
7033809: Rename "disjunctive" to "union" in javax.lang.model
darcy
parents:
8625
diff
changeset
|
2389 |
public void visitTypeUnion(JCTypeUnion that) { visitTree(that); } |
10 | 2390 |
public void visitTypeParameter(JCTypeParameter that) { visitTree(that); } |
2391 |
public void visitWildcard(JCWildcard that) { visitTree(that); } |
|
2392 |
public void visitTypeBoundKind(TypeBoundKind that) { visitTree(that); } |
|
2393 |
public void visitAnnotation(JCAnnotation that) { visitTree(that); } |
|
2394 |
public void visitModifiers(JCModifiers that) { visitTree(that); } |
|
2395 |
public void visitErroneous(JCErroneous that) { visitTree(that); } |
|
2396 |
public void visitLetExpr(LetExpr that) { visitTree(that); } |
|
2397 |
||
8032 | 2398 |
public void visitTree(JCTree that) { Assert.error(); } |
10 | 2399 |
} |
2400 |
||
2401 |
} |