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