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