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