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