PageRenderTime 68ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/src/com/sun/tools/javac/tree/JCTree.java

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