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