Source Code Cross Referenced for JCTree.java in  » 6.0-JDK-Modules-sun » javac-compiler » com » sun » tools » javac » tree » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules sun » javac compiler » com.sun.tools.javac.tree 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * Copyright 1999-2006 Sun Microsystems, Inc.  All Rights Reserved.
0003:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0004:         *
0005:         * This code is free software; you can redistribute it and/or modify it
0006:         * under the terms of the GNU General Public License version 2 only, as
0007:         * published by the Free Software Foundation.  Sun designates this
0008:         * particular file as subject to the "Classpath" exception as provided
0009:         * by Sun in the LICENSE file that accompanied this code.
0010:         *
0011:         * This code is distributed in the hope that it will be useful, but WITHOUT
0012:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0013:         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
0014:         * version 2 for more details (a copy is included in the LICENSE file that
0015:         * accompanied this code).
0016:         *
0017:         * You should have received a copy of the GNU General Public License version
0018:         * 2 along with this work; if not, write to the Free Software Foundation,
0019:         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0020:         *
0021:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
0022:         * CA 95054 USA or visit www.sun.com if you need additional information or
0023:         * have any questions.
0024:         */
0025:
0026:        package com.sun.tools.javac.tree;
0027:
0028:        import java.util.*;
0029:
0030:        import java.io.File;
0031:        import java.io.IOException;
0032:        import java.io.PrintWriter;
0033:        import java.io.StringWriter;
0034:        import javax.lang.model.element.Modifier;
0035:        import javax.lang.model.type.TypeKind;
0036:        import javax.tools.JavaFileObject;
0037:
0038:        import com.sun.tools.javac.util.*;
0039:        import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
0040:        import com.sun.tools.javac.util.List;
0041:        import com.sun.tools.javac.code.*;
0042:        import com.sun.tools.javac.code.Scope;
0043:        import com.sun.tools.javac.code.Symbol.*;
0044:        import com.sun.source.tree.Tree;
0045:        import com.sun.source.tree.*;
0046:
0047:        import static com.sun.tools.javac.code.BoundKind.*;
0048:
0049:        /**
0050:         * Root class for abstract syntax tree nodes. It provides definitions
0051:         * for specific tree nodes as subclasses nested inside.
0052:         *
0053:         * <p>Each subclass is highly standardized.  It generally contains
0054:         * only tree fields for the syntactic subcomponents of the node.  Some
0055:         * classes that represent identifier uses or definitions also define a
0056:         * Symbol field that denotes the represented identifier.  Classes for
0057:         * non-local jumps also carry the jump target as a field.  The root
0058:         * class Tree itself defines fields for the tree's type and position.
0059:         * No other fields are kept in a tree node; instead parameters are
0060:         * passed to methods accessing the node.
0061:         *
0062:         * <p>Except for the methods defined by com.sun.source, the only
0063:         * method defined in subclasses is `visit' which applies a given
0064:         * visitor to the tree. The actual tree processing is done by visitor
0065:         * classes in other packages. The abstract class Visitor, as well as
0066:         * an Factory interface for trees, are defined as inner classes in
0067:         * Tree.
0068:         *
0069:         * <p>To avoid ambiguities with the Tree API in com.sun.source all sub
0070:         * classes should, by convention, start with JC (javac).
0071:         *
0072:         * <p><b>This is NOT part of any API supported by Sun Microsystems.
0073:         * If you write code that depends on this, you do so at your own risk.
0074:         * This code and its internal interfaces are subject to change or
0075:         * deletion without notice.</b>
0076:         *
0077:         * @see TreeMaker
0078:         * @see TreeInfo
0079:         * @see TreeTranslator
0080:         * @see Pretty
0081:         */
0082:        @Version("@(#)JCTree.java	1.84 07/06/14")
0083:        public abstract class JCTree implements  Tree, Cloneable,
0084:                DiagnosticPosition {
0085:
0086:            /* Tree tag values, identifying kinds of trees */
0087:
0088:            /** Toplevel nodes, of type TopLevel, representing entire source files.
0089:             */
0090:            public static final int TOPLEVEL = 1;
0091:
0092:            /** Import clauses, of type Import.
0093:             */
0094:            public static final int IMPORT = TOPLEVEL + 1;
0095:
0096:            /** Class definitions, of type ClassDef.
0097:             */
0098:            public static final int CLASSDEF = IMPORT + 1;
0099:
0100:            /** Method definitions, of type MethodDef.
0101:             */
0102:            public static final int METHODDEF = CLASSDEF + 1;
0103:
0104:            /** Variable definitions, of type VarDef.
0105:             */
0106:            public static final int VARDEF = METHODDEF + 1;
0107:
0108:            /** The no-op statement ";", of type Skip
0109:             */
0110:            public static final int SKIP = VARDEF + 1;
0111:
0112:            /** Blocks, of type Block.
0113:             */
0114:            public static final int BLOCK = SKIP + 1;
0115:
0116:            /** Do-while loops, of type DoLoop.
0117:             */
0118:            public static final int DOLOOP = BLOCK + 1;
0119:
0120:            /** While-loops, of type WhileLoop.
0121:             */
0122:            public static final int WHILELOOP = DOLOOP + 1;
0123:
0124:            /** For-loops, of type ForLoop.
0125:             */
0126:            public static final int FORLOOP = WHILELOOP + 1;
0127:
0128:            /** Foreach-loops, of type ForeachLoop.
0129:             */
0130:            public static final int FOREACHLOOP = FORLOOP + 1;
0131:
0132:            /** Labelled statements, of type Labelled.
0133:             */
0134:            public static final int LABELLED = FOREACHLOOP + 1;
0135:
0136:            /** Switch statements, of type Switch.
0137:             */
0138:            public static final int SWITCH = LABELLED + 1;
0139:
0140:            /** Case parts in switch statements, of type Case.
0141:             */
0142:            public static final int CASE = SWITCH + 1;
0143:
0144:            /** Synchronized statements, of type Synchonized.
0145:             */
0146:            public static final int SYNCHRONIZED = CASE + 1;
0147:
0148:            /** Try statements, of type Try.
0149:             */
0150:            public static final int TRY = SYNCHRONIZED + 1;
0151:
0152:            /** Catch clauses in try statements, of type Catch.
0153:             */
0154:            public static final int CATCH = TRY + 1;
0155:
0156:            /** Conditional expressions, of type Conditional.
0157:             */
0158:            public static final int CONDEXPR = CATCH + 1;
0159:
0160:            /** Conditional statements, of type If.
0161:             */
0162:            public static final int IF = CONDEXPR + 1;
0163:
0164:            /** Expression statements, of type Exec.
0165:             */
0166:            public static final int EXEC = IF + 1;
0167:
0168:            /** Break statements, of type Break.
0169:             */
0170:            public static final int BREAK = EXEC + 1;
0171:
0172:            /** Continue statements, of type Continue.
0173:             */
0174:            public static final int CONTINUE = BREAK + 1;
0175:
0176:            /** Return statements, of type Return.
0177:             */
0178:            public static final int RETURN = CONTINUE + 1;
0179:
0180:            /** Throw statements, of type Throw.
0181:             */
0182:            public static final int THROW = RETURN + 1;
0183:
0184:            /** Assert statements, of type Assert.
0185:             */
0186:            public static final int ASSERT = THROW + 1;
0187:
0188:            /** Method invocation expressions, of type Apply.
0189:             */
0190:            public static final int APPLY = ASSERT + 1;
0191:
0192:            /** Class instance creation expressions, of type NewClass.
0193:             */
0194:            public static final int NEWCLASS = APPLY + 1;
0195:
0196:            /** Array creation expressions, of type NewArray.
0197:             */
0198:            public static final int NEWARRAY = NEWCLASS + 1;
0199:
0200:            /** Parenthesized subexpressions, of type Parens.
0201:             */
0202:            public static final int PARENS = NEWARRAY + 1;
0203:
0204:            /** Assignment expressions, of type Assign.
0205:             */
0206:            public static final int ASSIGN = PARENS + 1;
0207:
0208:            /** Type cast expressions, of type TypeCast.
0209:             */
0210:            public static final int TYPECAST = ASSIGN + 1;
0211:
0212:            /** Type test expressions, of type TypeTest.
0213:             */
0214:            public static final int TYPETEST = TYPECAST + 1;
0215:
0216:            /** Indexed array expressions, of type Indexed.
0217:             */
0218:            public static final int INDEXED = TYPETEST + 1;
0219:
0220:            /** Selections, of type Select.
0221:             */
0222:            public static final int SELECT = INDEXED + 1;
0223:
0224:            /** Simple identifiers, of type Ident.
0225:             */
0226:            public static final int IDENT = SELECT + 1;
0227:
0228:            /** Literals, of type Literal.
0229:             */
0230:            public static final int LITERAL = IDENT + 1;
0231:
0232:            /** Basic type identifiers, of type TypeIdent.
0233:             */
0234:            public static final int TYPEIDENT = LITERAL + 1;
0235:
0236:            /** Array types, of type TypeArray.
0237:             */
0238:            public static final int TYPEARRAY = TYPEIDENT + 1;
0239:
0240:            /** Parameterized types, of type TypeApply.
0241:             */
0242:            public static final int TYPEAPPLY = TYPEARRAY + 1;
0243:
0244:            /** Formal type parameters, of type TypeParameter.
0245:             */
0246:            public static final int TYPEPARAMETER = TYPEAPPLY + 1;
0247:
0248:            /** Type argument.
0249:             */
0250:            public static final int WILDCARD = TYPEPARAMETER + 1;
0251:
0252:            /** Bound kind: extends, super, exact, or unbound
0253:             */
0254:            public static final int TYPEBOUNDKIND = WILDCARD + 1;
0255:
0256:            /** metadata: Annotation.
0257:             */
0258:            public static final int ANNOTATION = TYPEBOUNDKIND + 1;
0259:
0260:            /** metadata: Modifiers
0261:             */
0262:            public static final int MODIFIERS = ANNOTATION + 1;
0263:
0264:            /** Error trees, of type Erroneous.
0265:             */
0266:            public static final int ERRONEOUS = MODIFIERS + 1;
0267:
0268:            /** Unary operators, of type Unary.
0269:             */
0270:            public static final int POS = ERRONEOUS + 1; // +
0271:            public static final int NEG = POS + 1; // -
0272:            public static final int NOT = NEG + 1; // !
0273:            public static final int COMPL = NOT + 1; // ~
0274:            public static final int PREINC = COMPL + 1; // ++ _
0275:            public static final int PREDEC = PREINC + 1; // -- _
0276:            public static final int POSTINC = PREDEC + 1; // _ ++
0277:            public static final int POSTDEC = POSTINC + 1; // _ --
0278:
0279:            /** unary operator for null reference checks, only used internally.
0280:             */
0281:            public static final int NULLCHK = POSTDEC + 1;
0282:
0283:            /** Binary operators, of type Binary.
0284:             */
0285:            public static final int OR = NULLCHK + 1; // ||
0286:            public static final int AND = OR + 1; // &&
0287:            public static final int BITOR = AND + 1; // |
0288:            public static final int BITXOR = BITOR + 1; // ^
0289:            public static final int BITAND = BITXOR + 1; // &
0290:            public static final int EQ = BITAND + 1; // ==
0291:            public static final int NE = EQ + 1; // !=
0292:            public static final int LT = NE + 1; // <
0293:            public static final int GT = LT + 1; // >
0294:            public static final int LE = GT + 1; // <=
0295:            public static final int GE = LE + 1; // >=
0296:            public static final int SL = GE + 1; // <<
0297:            public static final int SR = SL + 1; // >>
0298:            public static final int USR = SR + 1; // >>>
0299:            public static final int PLUS = USR + 1; // +
0300:            public static final int MINUS = PLUS + 1; // -
0301:            public static final int MUL = MINUS + 1; // *
0302:            public static final int DIV = MUL + 1; // /
0303:            public static final int MOD = DIV + 1; // %
0304:
0305:            /** Assignment operators, of type Assignop.
0306:             */
0307:            public static final int BITOR_ASG = MOD + 1; // |=
0308:            public static final int BITXOR_ASG = BITOR_ASG + 1; // ^=
0309:            public static final int BITAND_ASG = BITXOR_ASG + 1; // &=
0310:
0311:            public static final int SL_ASG = SL + BITOR_ASG - BITOR; // <<=
0312:            public static final int SR_ASG = SL_ASG + 1; // >>=
0313:            public static final int USR_ASG = SR_ASG + 1; // >>>=
0314:            public static final int PLUS_ASG = USR_ASG + 1; // +=
0315:            public static final int MINUS_ASG = PLUS_ASG + 1; // -=
0316:            public static final int MUL_ASG = MINUS_ASG + 1; // *=
0317:            public static final int DIV_ASG = MUL_ASG + 1; // /=
0318:            public static final int MOD_ASG = DIV_ASG + 1; // %=
0319:
0320:            /** A synthetic let expression, of type LetExpr.
0321:             */
0322:            public static final int LETEXPR = MOD_ASG + 1; // ala scheme
0323:
0324:            /** The offset between assignment operators and normal operators.
0325:             */
0326:            public static final int ASGOffset = BITOR_ASG - BITOR;
0327:
0328:            /* The (encoded) position in the source file. @see util.Position.
0329:             */
0330:            public int pos;
0331:
0332:            /* The type of this node.
0333:             */
0334:            public Type type;
0335:
0336:            /* The tag of this node -- one of the constants declared above.
0337:             */
0338:            public abstract int getTag();
0339:
0340:            /** Convert a tree to a pretty-printed string. */
0341:            public String toString() {
0342:                StringWriter s = new StringWriter();
0343:                try {
0344:                    new Pretty(s, false).printExpr(this );
0345:                } catch (IOException e) {
0346:                    // should never happen, because StringWriter is defined
0347:                    // never to throw any IOExceptions
0348:                    throw new AssertionError(e);
0349:                }
0350:                return s.toString();
0351:            }
0352:
0353:            /** Set position field and return this tree.
0354:             */
0355:            public JCTree setPos(int pos) {
0356:                this .pos = pos;
0357:                return this ;
0358:            }
0359:
0360:            /** Set type field and return this tree.
0361:             */
0362:            public JCTree setType(Type type) {
0363:                this .type = type;
0364:                return this ;
0365:            }
0366:
0367:            /** Visit this tree with a given visitor.
0368:             */
0369:            public abstract void accept(Visitor v);
0370:
0371:            public abstract <R, D> R accept(TreeVisitor<R, D> v, D d);
0372:
0373:            /** Return a shallow copy of this tree.
0374:             */
0375:            public Object clone() {
0376:                try {
0377:                    return super .clone();
0378:                } catch (CloneNotSupportedException e) {
0379:                    throw new RuntimeException(e);
0380:                }
0381:            }
0382:
0383:            /** Get a default position for this tree node.
0384:             */
0385:            public DiagnosticPosition pos() {
0386:                return this ;
0387:            }
0388:
0389:            // for default DiagnosticPosition
0390:            public JCTree getTree() {
0391:                return this ;
0392:            }
0393:
0394:            // for default DiagnosticPosition
0395:            public int getStartPosition() {
0396:                return TreeInfo.getStartPos(this );
0397:            }
0398:
0399:            // for default DiagnosticPosition
0400:            public int getPreferredPosition() {
0401:                return pos;
0402:            }
0403:
0404:            // for default DiagnosticPosition
0405:            public int getEndPosition(Map<JCTree, Integer> endPosTable) {
0406:                return TreeInfo.getEndPos(this , endPosTable);
0407:            }
0408:
0409:            /**
0410:             * Everything in one source file is kept in a TopLevel structure.
0411:             * @param pid              The tree representing the package clause.
0412:             * @param sourcefile       The source file name.
0413:             * @param defs             All definitions in this file (ClassDef, Import, and Skip)
0414:             * @param packge           The package it belongs to.
0415:             * @param namedImportScope A scope for all named imports.
0416:             * @param starImportScope  A scope for all import-on-demands.
0417:             * @param lineMap          Line starting positions, defined only
0418:             *                         if option -g is set.
0419:             * @param docComments      A hashtable that stores all documentation comments
0420:             *                         indexed by the tree nodes they refer to.
0421:             *                         defined only if option -s is set.
0422:             * @param endPositions     A hashtable that stores ending positions of source
0423:             *                         ranges indexed by the tree nodes they belong to.
0424:             *                         Defined only if option -Xjcov is set.
0425:             */
0426:            public static class JCCompilationUnit extends JCTree implements 
0427:                    CompilationUnitTree {
0428:                public List<JCAnnotation> packageAnnotations;
0429:                public JCExpression pid;
0430:                public List<JCTree> defs;
0431:                public JavaFileObject sourcefile;
0432:                public PackageSymbol packge;
0433:                public Scope namedImportScope;
0434:                public Scope starImportScope;
0435:                public long flags;
0436:                public Position.LineMap lineMap = null;
0437:                public Map<JCTree, String> docComments = null;
0438:                public Map<JCTree, Integer> endPositions = null;
0439:
0440:                protected JCCompilationUnit(
0441:                        List<JCAnnotation> packageAnnotations,
0442:                        JCExpression pid, List<JCTree> defs,
0443:                        JavaFileObject sourcefile, PackageSymbol packge,
0444:                        Scope namedImportScope, Scope starImportScope) {
0445:                    this .packageAnnotations = packageAnnotations;
0446:                    this .pid = pid;
0447:                    this .defs = defs;
0448:                    this .sourcefile = sourcefile;
0449:                    this .packge = packge;
0450:                    this .namedImportScope = namedImportScope;
0451:                    this .starImportScope = starImportScope;
0452:                }
0453:
0454:                @Override
0455:                public void accept(Visitor v) {
0456:                    v.visitTopLevel(this );
0457:                }
0458:
0459:                public Kind getKind() {
0460:                    return Kind.COMPILATION_UNIT;
0461:                }
0462:
0463:                public List<JCAnnotation> getPackageAnnotations() {
0464:                    return packageAnnotations;
0465:                }
0466:
0467:                public List<JCImport> getImports() {
0468:                    ListBuffer<JCImport> imports = new ListBuffer<JCImport>();
0469:                    for (JCTree tree : defs) {
0470:                        if (tree.getTag() == IMPORT)
0471:                            imports.append((JCImport) tree);
0472:                        else
0473:                            break;
0474:                    }
0475:                    return imports.toList();
0476:                }
0477:
0478:                public JCExpression getPackageName() {
0479:                    return pid;
0480:                }
0481:
0482:                public JavaFileObject getSourceFile() {
0483:                    return sourcefile;
0484:                }
0485:
0486:                public Position.LineMap getLineMap() {
0487:                    return lineMap;
0488:                }
0489:
0490:                public List<JCTree> getTypeDecls() {
0491:                    List<JCTree> typeDefs;
0492:                    for (typeDefs = defs; !typeDefs.isEmpty(); typeDefs = typeDefs.tail)
0493:                        if (typeDefs.head.getTag() != IMPORT)
0494:                            break;
0495:                    return typeDefs;
0496:                }
0497:
0498:                @Override
0499:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
0500:                    return v.visitCompilationUnit(this , d);
0501:                }
0502:
0503:                @Override
0504:                public int getTag() {
0505:                    return TOPLEVEL;
0506:                }
0507:            }
0508:
0509:            /**
0510:             * An import clause.
0511:             * @param qualid    The imported class(es).
0512:             */
0513:            public static class JCImport extends JCTree implements  ImportTree {
0514:                public boolean staticImport;
0515:                public JCTree qualid;
0516:
0517:                protected JCImport(JCTree qualid, boolean importStatic) {
0518:                    this .qualid = qualid;
0519:                    this .staticImport = importStatic;
0520:                }
0521:
0522:                @Override
0523:                public void accept(Visitor v) {
0524:                    v.visitImport(this );
0525:                }
0526:
0527:                public boolean isStatic() {
0528:                    return staticImport;
0529:                }
0530:
0531:                public JCTree getQualifiedIdentifier() {
0532:                    return qualid;
0533:                }
0534:
0535:                public Kind getKind() {
0536:                    return Kind.IMPORT;
0537:                }
0538:
0539:                @Override
0540:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
0541:                    return v.visitImport(this , d);
0542:                }
0543:
0544:                @Override
0545:                public int getTag() {
0546:                    return IMPORT;
0547:                }
0548:            }
0549:
0550:            public static abstract class JCStatement extends JCTree implements 
0551:                    StatementTree {
0552:                @Override
0553:                public JCStatement setType(Type type) {
0554:                    super .setType(type);
0555:                    return this ;
0556:                }
0557:
0558:                @Override
0559:                public JCStatement setPos(int pos) {
0560:                    super .setPos(pos);
0561:                    return this ;
0562:                }
0563:            }
0564:
0565:            public static abstract class JCExpression extends JCTree implements 
0566:                    ExpressionTree {
0567:                @Override
0568:                public JCExpression setType(Type type) {
0569:                    super .setType(type);
0570:                    return this ;
0571:                }
0572:
0573:                @Override
0574:                public JCExpression setPos(int pos) {
0575:                    super .setPos(pos);
0576:                    return this ;
0577:                }
0578:            }
0579:
0580:            /**
0581:             * A class definition.
0582:             * @param modifiers the modifiers
0583:             * @param name the name of the class
0584:             * @param typarams formal class parameters
0585:             * @param extending the classes this class extends
0586:             * @param implementing the interfaces implemented by this class
0587:             * @param defs all variables and methods defined in this class
0588:             * @param sym the symbol
0589:             */
0590:            public static class JCClassDecl extends JCStatement implements 
0591:                    ClassTree {
0592:                public JCModifiers mods;
0593:                public Name name;
0594:                public List<JCTypeParameter> typarams;
0595:                public JCTree extending;
0596:                public List<JCExpression> implementing;
0597:                public List<JCTree> defs;
0598:                public ClassSymbol sym;
0599:
0600:                protected JCClassDecl(JCModifiers mods, Name name,
0601:                        List<JCTypeParameter> typarams, JCTree extending,
0602:                        List<JCExpression> implementing, List<JCTree> defs,
0603:                        ClassSymbol sym) {
0604:                    this .mods = mods;
0605:                    this .name = name;
0606:                    this .typarams = typarams;
0607:                    this .extending = extending;
0608:                    this .implementing = implementing;
0609:                    this .defs = defs;
0610:                    this .sym = sym;
0611:                }
0612:
0613:                @Override
0614:                public void accept(Visitor v) {
0615:                    v.visitClassDef(this );
0616:                }
0617:
0618:                public Kind getKind() {
0619:                    return Kind.CLASS;
0620:                }
0621:
0622:                public JCModifiers getModifiers() {
0623:                    return mods;
0624:                }
0625:
0626:                public Name getSimpleName() {
0627:                    return name;
0628:                }
0629:
0630:                public List<JCTypeParameter> getTypeParameters() {
0631:                    return typarams;
0632:                }
0633:
0634:                public JCTree getExtendsClause() {
0635:                    return extending;
0636:                }
0637:
0638:                public List<JCExpression> getImplementsClause() {
0639:                    return implementing;
0640:                }
0641:
0642:                public List<JCTree> getMembers() {
0643:                    return defs;
0644:                }
0645:
0646:                @Override
0647:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
0648:                    return v.visitClass(this , d);
0649:                }
0650:
0651:                @Override
0652:                public int getTag() {
0653:                    return CLASSDEF;
0654:                }
0655:            }
0656:
0657:            /**
0658:             * A method definition.
0659:             * @param modifiers method modifiers
0660:             * @param name method name
0661:             * @param restype type of method return value
0662:             * @param typarams type parameters
0663:             * @param params value parameters
0664:             * @param thrown exceptions thrown by this method
0665:             * @param stats statements in the method
0666:             * @param sym method symbol
0667:             */
0668:            public static class JCMethodDecl extends JCTree implements 
0669:                    MethodTree {
0670:                public JCModifiers mods;
0671:                public Name name;
0672:                public JCExpression restype;
0673:                public List<JCTypeParameter> typarams;
0674:                public List<JCVariableDecl> params;
0675:                public List<JCExpression> thrown;
0676:                public JCBlock body;
0677:                public JCExpression defaultValue; // for annotation types
0678:                public MethodSymbol sym;
0679:
0680:                protected JCMethodDecl(JCModifiers mods, Name name,
0681:                        JCExpression restype, List<JCTypeParameter> typarams,
0682:                        List<JCVariableDecl> params, List<JCExpression> thrown,
0683:                        JCBlock body, JCExpression defaultValue,
0684:                        MethodSymbol sym) {
0685:                    this .mods = mods;
0686:                    this .name = name;
0687:                    this .restype = restype;
0688:                    this .typarams = typarams;
0689:                    this .params = params;
0690:                    this .thrown = thrown;
0691:                    this .body = body;
0692:                    this .defaultValue = defaultValue;
0693:                    this .sym = sym;
0694:                }
0695:
0696:                @Override
0697:                public void accept(Visitor v) {
0698:                    v.visitMethodDef(this );
0699:                }
0700:
0701:                public Kind getKind() {
0702:                    return Kind.METHOD;
0703:                }
0704:
0705:                public JCModifiers getModifiers() {
0706:                    return mods;
0707:                }
0708:
0709:                public Name getName() {
0710:                    return name;
0711:                }
0712:
0713:                public JCTree getReturnType() {
0714:                    return restype;
0715:                }
0716:
0717:                public List<JCTypeParameter> getTypeParameters() {
0718:                    return typarams;
0719:                }
0720:
0721:                public List<JCVariableDecl> getParameters() {
0722:                    return params;
0723:                }
0724:
0725:                public List<JCExpression> getThrows() {
0726:                    return thrown;
0727:                }
0728:
0729:                public JCBlock getBody() {
0730:                    return body;
0731:                }
0732:
0733:                public JCTree getDefaultValue() { // for annotation types
0734:                    return defaultValue;
0735:                }
0736:
0737:                @Override
0738:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
0739:                    return v.visitMethod(this , d);
0740:                }
0741:
0742:                @Override
0743:                public int getTag() {
0744:                    return METHODDEF;
0745:                }
0746:            }
0747:
0748:            /**
0749:             * A variable definition.
0750:             * @param modifiers variable modifiers
0751:             * @param name variable name
0752:             * @param vartype type of the variable
0753:             * @param init variables initial value
0754:             * @param sym symbol
0755:             */
0756:            public static class JCVariableDecl extends JCStatement implements 
0757:                    VariableTree {
0758:                public JCModifiers mods;
0759:                public Name name;
0760:                public JCExpression vartype;
0761:                public JCExpression init;
0762:                public VarSymbol sym;
0763:
0764:                protected JCVariableDecl(JCModifiers mods, Name name,
0765:                        JCExpression vartype, JCExpression init, VarSymbol sym) {
0766:                    this .mods = mods;
0767:                    this .name = name;
0768:                    this .vartype = vartype;
0769:                    this .init = init;
0770:                    this .sym = sym;
0771:                }
0772:
0773:                @Override
0774:                public void accept(Visitor v) {
0775:                    v.visitVarDef(this );
0776:                }
0777:
0778:                public Kind getKind() {
0779:                    return Kind.VARIABLE;
0780:                }
0781:
0782:                public JCModifiers getModifiers() {
0783:                    return mods;
0784:                }
0785:
0786:                public Name getName() {
0787:                    return name;
0788:                }
0789:
0790:                public JCTree getType() {
0791:                    return vartype;
0792:                }
0793:
0794:                public JCExpression getInitializer() {
0795:                    return init;
0796:                }
0797:
0798:                @Override
0799:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
0800:                    return v.visitVariable(this , d);
0801:                }
0802:
0803:                @Override
0804:                public int getTag() {
0805:                    return VARDEF;
0806:                }
0807:            }
0808:
0809:            /**
0810:             * A no-op statement ";".
0811:             */
0812:            public static class JCSkip extends JCStatement implements 
0813:                    EmptyStatementTree {
0814:                protected JCSkip() {
0815:                }
0816:
0817:                @Override
0818:                public void accept(Visitor v) {
0819:                    v.visitSkip(this );
0820:                }
0821:
0822:                public Kind getKind() {
0823:                    return Kind.EMPTY_STATEMENT;
0824:                }
0825:
0826:                @Override
0827:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
0828:                    return v.visitEmptyStatement(this , d);
0829:                }
0830:
0831:                @Override
0832:                public int getTag() {
0833:                    return SKIP;
0834:                }
0835:            }
0836:
0837:            /**
0838:             * A statement block.
0839:             * @param stats statements
0840:             * @param flags flags
0841:             */
0842:            public static class JCBlock extends JCStatement implements 
0843:                    BlockTree {
0844:                public long flags;
0845:                public List<JCStatement> stats;
0846:                /** Position of closing brace, optional. */
0847:                public int endpos = Position.NOPOS;
0848:
0849:                protected JCBlock(long flags, List<JCStatement> stats) {
0850:                    this .stats = stats;
0851:                    this .flags = flags;
0852:                }
0853:
0854:                @Override
0855:                public void accept(Visitor v) {
0856:                    v.visitBlock(this );
0857:                }
0858:
0859:                public Kind getKind() {
0860:                    return Kind.BLOCK;
0861:                }
0862:
0863:                public List<JCStatement> getStatements() {
0864:                    return stats;
0865:                }
0866:
0867:                public boolean isStatic() {
0868:                    return (flags & Flags.STATIC) != 0;
0869:                }
0870:
0871:                @Override
0872:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
0873:                    return v.visitBlock(this , d);
0874:                }
0875:
0876:                @Override
0877:                public int getTag() {
0878:                    return BLOCK;
0879:                }
0880:            }
0881:
0882:            /**
0883:             * A do loop
0884:             */
0885:            public static class JCDoWhileLoop extends JCStatement implements 
0886:                    DoWhileLoopTree {
0887:                public JCStatement body;
0888:                public JCExpression cond;
0889:
0890:                protected JCDoWhileLoop(JCStatement body, JCExpression cond) {
0891:                    this .body = body;
0892:                    this .cond = cond;
0893:                }
0894:
0895:                @Override
0896:                public void accept(Visitor v) {
0897:                    v.visitDoLoop(this );
0898:                }
0899:
0900:                public Kind getKind() {
0901:                    return Kind.DO_WHILE_LOOP;
0902:                }
0903:
0904:                public JCExpression getCondition() {
0905:                    return cond;
0906:                }
0907:
0908:                public JCStatement getStatement() {
0909:                    return body;
0910:                }
0911:
0912:                @Override
0913:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
0914:                    return v.visitDoWhileLoop(this , d);
0915:                }
0916:
0917:                @Override
0918:                public int getTag() {
0919:                    return DOLOOP;
0920:                }
0921:            }
0922:
0923:            /**
0924:             * A while loop
0925:             */
0926:            public static class JCWhileLoop extends JCStatement implements 
0927:                    WhileLoopTree {
0928:                public JCExpression cond;
0929:                public JCStatement body;
0930:
0931:                protected JCWhileLoop(JCExpression cond, JCStatement body) {
0932:                    this .cond = cond;
0933:                    this .body = body;
0934:                }
0935:
0936:                @Override
0937:                public void accept(Visitor v) {
0938:                    v.visitWhileLoop(this );
0939:                }
0940:
0941:                public Kind getKind() {
0942:                    return Kind.WHILE_LOOP;
0943:                }
0944:
0945:                public JCExpression getCondition() {
0946:                    return cond;
0947:                }
0948:
0949:                public JCStatement getStatement() {
0950:                    return body;
0951:                }
0952:
0953:                @Override
0954:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
0955:                    return v.visitWhileLoop(this , d);
0956:                }
0957:
0958:                @Override
0959:                public int getTag() {
0960:                    return WHILELOOP;
0961:                }
0962:            }
0963:
0964:            /**
0965:             * A for loop.
0966:             */
0967:            public static class JCForLoop extends JCStatement implements 
0968:                    ForLoopTree {
0969:                public List<JCStatement> init;
0970:                public JCExpression cond;
0971:                public List<JCExpressionStatement> step;
0972:                public JCStatement body;
0973:
0974:                protected JCForLoop(List<JCStatement> init, JCExpression cond,
0975:                        List<JCExpressionStatement> update, JCStatement body) {
0976:                    this .init = init;
0977:                    this .cond = cond;
0978:                    this .step = update;
0979:                    this .body = body;
0980:                }
0981:
0982:                @Override
0983:                public void accept(Visitor v) {
0984:                    v.visitForLoop(this );
0985:                }
0986:
0987:                public Kind getKind() {
0988:                    return Kind.FOR_LOOP;
0989:                }
0990:
0991:                public JCExpression getCondition() {
0992:                    return cond;
0993:                }
0994:
0995:                public JCStatement getStatement() {
0996:                    return body;
0997:                }
0998:
0999:                public List<JCStatement> getInitializer() {
1000:                    return init;
1001:                }
1002:
1003:                public List<JCExpressionStatement> getUpdate() {
1004:                    return step;
1005:                }
1006:
1007:                @Override
1008:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
1009:                    return v.visitForLoop(this , d);
1010:                }
1011:
1012:                @Override
1013:                public int getTag() {
1014:                    return FORLOOP;
1015:                }
1016:            }
1017:
1018:            /**
1019:             * The enhanced for loop.
1020:             */
1021:            public static class JCEnhancedForLoop extends JCStatement implements 
1022:                    EnhancedForLoopTree {
1023:                public JCVariableDecl var;
1024:                public JCExpression expr;
1025:                public JCStatement body;
1026:
1027:                protected JCEnhancedForLoop(JCVariableDecl var,
1028:                        JCExpression expr, JCStatement body) {
1029:                    this .var = var;
1030:                    this .expr = expr;
1031:                    this .body = body;
1032:                }
1033:
1034:                @Override
1035:                public void accept(Visitor v) {
1036:                    v.visitForeachLoop(this );
1037:                }
1038:
1039:                public Kind getKind() {
1040:                    return Kind.ENHANCED_FOR_LOOP;
1041:                }
1042:
1043:                public JCVariableDecl getVariable() {
1044:                    return var;
1045:                }
1046:
1047:                public JCExpression getExpression() {
1048:                    return expr;
1049:                }
1050:
1051:                public JCStatement getStatement() {
1052:                    return body;
1053:                }
1054:
1055:                @Override
1056:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
1057:                    return v.visitEnhancedForLoop(this , d);
1058:                }
1059:
1060:                @Override
1061:                public int getTag() {
1062:                    return FOREACHLOOP;
1063:                }
1064:            }
1065:
1066:            /**
1067:             * A labelled expression or statement.
1068:             */
1069:            public static class JCLabeledStatement extends JCStatement
1070:                    implements  LabeledStatementTree {
1071:                public Name label;
1072:                public JCStatement body;
1073:
1074:                protected JCLabeledStatement(Name label, JCStatement body) {
1075:                    this .label = label;
1076:                    this .body = body;
1077:                }
1078:
1079:                @Override
1080:                public void accept(Visitor v) {
1081:                    v.visitLabelled(this );
1082:                }
1083:
1084:                public Kind getKind() {
1085:                    return Kind.LABELED_STATEMENT;
1086:                }
1087:
1088:                public Name getLabel() {
1089:                    return label;
1090:                }
1091:
1092:                public JCStatement getStatement() {
1093:                    return body;
1094:                }
1095:
1096:                @Override
1097:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
1098:                    return v.visitLabeledStatement(this , d);
1099:                }
1100:
1101:                @Override
1102:                public int getTag() {
1103:                    return LABELLED;
1104:                }
1105:            }
1106:
1107:            /**
1108:             * A "switch ( ) { }" construction.
1109:             */
1110:            public static class JCSwitch extends JCStatement implements 
1111:                    SwitchTree {
1112:                public JCExpression selector;
1113:                public List<JCCase> cases;
1114:
1115:                protected JCSwitch(JCExpression selector, List<JCCase> cases) {
1116:                    this .selector = selector;
1117:                    this .cases = cases;
1118:                }
1119:
1120:                @Override
1121:                public void accept(Visitor v) {
1122:                    v.visitSwitch(this );
1123:                }
1124:
1125:                public Kind getKind() {
1126:                    return Kind.SWITCH;
1127:                }
1128:
1129:                public JCExpression getExpression() {
1130:                    return selector;
1131:                }
1132:
1133:                public List<JCCase> getCases() {
1134:                    return cases;
1135:                }
1136:
1137:                @Override
1138:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
1139:                    return v.visitSwitch(this , d);
1140:                }
1141:
1142:                @Override
1143:                public int getTag() {
1144:                    return SWITCH;
1145:                }
1146:            }
1147:
1148:            /**
1149:             * A "case  :" of a switch.
1150:             */
1151:            public static class JCCase extends JCStatement implements  CaseTree {
1152:                public JCExpression pat;
1153:                public List<JCStatement> stats;
1154:
1155:                protected JCCase(JCExpression pat, List<JCStatement> stats) {
1156:                    this .pat = pat;
1157:                    this .stats = stats;
1158:                }
1159:
1160:                @Override
1161:                public void accept(Visitor v) {
1162:                    v.visitCase(this );
1163:                }
1164:
1165:                public Kind getKind() {
1166:                    return Kind.CASE;
1167:                }
1168:
1169:                public JCExpression getExpression() {
1170:                    return pat;
1171:                }
1172:
1173:                public List<JCStatement> getStatements() {
1174:                    return stats;
1175:                }
1176:
1177:                @Override
1178:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
1179:                    return v.visitCase(this , d);
1180:                }
1181:
1182:                @Override
1183:                public int getTag() {
1184:                    return CASE;
1185:                }
1186:            }
1187:
1188:            /**
1189:             * A synchronized block.
1190:             */
1191:            public static class JCSynchronized extends JCStatement implements 
1192:                    SynchronizedTree {
1193:                public JCExpression lock;
1194:                public JCBlock body;
1195:
1196:                protected JCSynchronized(JCExpression lock, JCBlock body) {
1197:                    this .lock = lock;
1198:                    this .body = body;
1199:                }
1200:
1201:                @Override
1202:                public void accept(Visitor v) {
1203:                    v.visitSynchronized(this );
1204:                }
1205:
1206:                public Kind getKind() {
1207:                    return Kind.SYNCHRONIZED;
1208:                }
1209:
1210:                public JCExpression getExpression() {
1211:                    return lock;
1212:                }
1213:
1214:                public JCBlock getBlock() {
1215:                    return body;
1216:                }
1217:
1218:                @Override
1219:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
1220:                    return v.visitSynchronized(this , d);
1221:                }
1222:
1223:                @Override
1224:                public int getTag() {
1225:                    return SYNCHRONIZED;
1226:                }
1227:            }
1228:
1229:            /**
1230:             * A "try { } catch ( ) { } finally { }" block.
1231:             */
1232:            public static class JCTry extends JCStatement implements  TryTree {
1233:                public JCBlock body;
1234:                public List<JCCatch> catchers;
1235:                public JCBlock finalizer;
1236:
1237:                protected JCTry(JCBlock body, List<JCCatch> catchers,
1238:                        JCBlock finalizer) {
1239:                    this .body = body;
1240:                    this .catchers = catchers;
1241:                    this .finalizer = finalizer;
1242:                }
1243:
1244:                @Override
1245:                public void accept(Visitor v) {
1246:                    v.visitTry(this );
1247:                }
1248:
1249:                public Kind getKind() {
1250:                    return Kind.TRY;
1251:                }
1252:
1253:                public JCBlock getBlock() {
1254:                    return body;
1255:                }
1256:
1257:                public List<JCCatch> getCatches() {
1258:                    return catchers;
1259:                }
1260:
1261:                public JCBlock getFinallyBlock() {
1262:                    return finalizer;
1263:                }
1264:
1265:                @Override
1266:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
1267:                    return v.visitTry(this , d);
1268:                }
1269:
1270:                @Override
1271:                public int getTag() {
1272:                    return TRY;
1273:                }
1274:            }
1275:
1276:            /**
1277:             * A catch block.
1278:             */
1279:            public static class JCCatch extends JCTree implements  CatchTree {
1280:                public JCVariableDecl param;
1281:                public JCBlock body;
1282:
1283:                protected JCCatch(JCVariableDecl param, JCBlock body) {
1284:                    this .param = param;
1285:                    this .body = body;
1286:                }
1287:
1288:                @Override
1289:                public void accept(Visitor v) {
1290:                    v.visitCatch(this );
1291:                }
1292:
1293:                public Kind getKind() {
1294:                    return Kind.CATCH;
1295:                }
1296:
1297:                public JCVariableDecl getParameter() {
1298:                    return param;
1299:                }
1300:
1301:                public JCBlock getBlock() {
1302:                    return body;
1303:                }
1304:
1305:                @Override
1306:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
1307:                    return v.visitCatch(this , d);
1308:                }
1309:
1310:                @Override
1311:                public int getTag() {
1312:                    return CATCH;
1313:                }
1314:            }
1315:
1316:            /**
1317:             * A ( ) ? ( ) : ( ) conditional expression
1318:             */
1319:            public static class JCConditional extends JCExpression implements 
1320:                    ConditionalExpressionTree {
1321:                public JCExpression cond;
1322:                public JCExpression truepart;
1323:                public JCExpression falsepart;
1324:
1325:                protected JCConditional(JCExpression cond,
1326:                        JCExpression truepart, JCExpression falsepart) {
1327:                    this .cond = cond;
1328:                    this .truepart = truepart;
1329:                    this .falsepart = falsepart;
1330:                }
1331:
1332:                @Override
1333:                public void accept(Visitor v) {
1334:                    v.visitConditional(this );
1335:                }
1336:
1337:                public Kind getKind() {
1338:                    return Kind.CONDITIONAL_EXPRESSION;
1339:                }
1340:
1341:                public JCExpression getCondition() {
1342:                    return cond;
1343:                }
1344:
1345:                public JCExpression getTrueExpression() {
1346:                    return truepart;
1347:                }
1348:
1349:                public JCExpression getFalseExpression() {
1350:                    return falsepart;
1351:                }
1352:
1353:                @Override
1354:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
1355:                    return v.visitConditionalExpression(this , d);
1356:                }
1357:
1358:                @Override
1359:                public int getTag() {
1360:                    return CONDEXPR;
1361:                }
1362:            }
1363:
1364:            /**
1365:             * An "if ( ) { } else { }" block
1366:             */
1367:            public static class JCIf extends JCStatement implements  IfTree {
1368:                public JCExpression cond;
1369:                public JCStatement thenpart;
1370:                public JCStatement elsepart;
1371:
1372:                protected JCIf(JCExpression cond, JCStatement thenpart,
1373:                        JCStatement elsepart) {
1374:                    this .cond = cond;
1375:                    this .thenpart = thenpart;
1376:                    this .elsepart = elsepart;
1377:                }
1378:
1379:                @Override
1380:                public void accept(Visitor v) {
1381:                    v.visitIf(this );
1382:                }
1383:
1384:                public Kind getKind() {
1385:                    return Kind.IF;
1386:                }
1387:
1388:                public JCExpression getCondition() {
1389:                    return cond;
1390:                }
1391:
1392:                public JCStatement getThenStatement() {
1393:                    return thenpart;
1394:                }
1395:
1396:                public JCStatement getElseStatement() {
1397:                    return elsepart;
1398:                }
1399:
1400:                @Override
1401:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
1402:                    return v.visitIf(this , d);
1403:                }
1404:
1405:                @Override
1406:                public int getTag() {
1407:                    return IF;
1408:                }
1409:            }
1410:
1411:            /**
1412:             * an expression statement
1413:             * @param expr expression structure
1414:             */
1415:            public static class JCExpressionStatement extends JCStatement
1416:                    implements  ExpressionStatementTree {
1417:                public JCExpression expr;
1418:
1419:                protected JCExpressionStatement(JCExpression expr) {
1420:                    this .expr = expr;
1421:                }
1422:
1423:                @Override
1424:                public void accept(Visitor v) {
1425:                    v.visitExec(this );
1426:                }
1427:
1428:                public Kind getKind() {
1429:                    return Kind.EXPRESSION_STATEMENT;
1430:                }
1431:
1432:                public JCExpression getExpression() {
1433:                    return expr;
1434:                }
1435:
1436:                @Override
1437:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
1438:                    return v.visitExpressionStatement(this , d);
1439:                }
1440:
1441:                @Override
1442:                public int getTag() {
1443:                    return EXEC;
1444:                }
1445:            }
1446:
1447:            /**
1448:             * A break from a loop or switch.
1449:             */
1450:            public static class JCBreak extends JCStatement implements 
1451:                    BreakTree {
1452:                public Name label;
1453:                public JCTree target;
1454:
1455:                protected JCBreak(Name label, JCTree target) {
1456:                    this .label = label;
1457:                    this .target = target;
1458:                }
1459:
1460:                @Override
1461:                public void accept(Visitor v) {
1462:                    v.visitBreak(this );
1463:                }
1464:
1465:                public Kind getKind() {
1466:                    return Kind.BREAK;
1467:                }
1468:
1469:                public Name getLabel() {
1470:                    return label;
1471:                }
1472:
1473:                @Override
1474:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
1475:                    return v.visitBreak(this , d);
1476:                }
1477:
1478:                @Override
1479:                public int getTag() {
1480:                    return BREAK;
1481:                }
1482:            }
1483:
1484:            /**
1485:             * A continue of a loop.
1486:             */
1487:            public static class JCContinue extends JCStatement implements 
1488:                    ContinueTree {
1489:                public Name label;
1490:                public JCTree target;
1491:
1492:                protected JCContinue(Name label, JCTree target) {
1493:                    this .label = label;
1494:                    this .target = target;
1495:                }
1496:
1497:                @Override
1498:                public void accept(Visitor v) {
1499:                    v.visitContinue(this );
1500:                }
1501:
1502:                public Kind getKind() {
1503:                    return Kind.CONTINUE;
1504:                }
1505:
1506:                public Name getLabel() {
1507:                    return label;
1508:                }
1509:
1510:                @Override
1511:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
1512:                    return v.visitContinue(this , d);
1513:                }
1514:
1515:                @Override
1516:                public int getTag() {
1517:                    return CONTINUE;
1518:                }
1519:            }
1520:
1521:            /**
1522:             * A return statement.
1523:             */
1524:            public static class JCReturn extends JCStatement implements 
1525:                    ReturnTree {
1526:                public JCExpression expr;
1527:
1528:                protected JCReturn(JCExpression expr) {
1529:                    this .expr = expr;
1530:                }
1531:
1532:                @Override
1533:                public void accept(Visitor v) {
1534:                    v.visitReturn(this );
1535:                }
1536:
1537:                public Kind getKind() {
1538:                    return Kind.RETURN;
1539:                }
1540:
1541:                public JCExpression getExpression() {
1542:                    return expr;
1543:                }
1544:
1545:                @Override
1546:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
1547:                    return v.visitReturn(this , d);
1548:                }
1549:
1550:                @Override
1551:                public int getTag() {
1552:                    return RETURN;
1553:                }
1554:            }
1555:
1556:            /**
1557:             * A throw statement.
1558:             */
1559:            public static class JCThrow extends JCStatement implements 
1560:                    ThrowTree {
1561:                public JCExpression expr;
1562:
1563:                protected JCThrow(JCTree expr) {
1564:                    this .expr = (JCExpression) expr;
1565:                }
1566:
1567:                @Override
1568:                public void accept(Visitor v) {
1569:                    v.visitThrow(this );
1570:                }
1571:
1572:                public Kind getKind() {
1573:                    return Kind.THROW;
1574:                }
1575:
1576:                public JCExpression getExpression() {
1577:                    return expr;
1578:                }
1579:
1580:                @Override
1581:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
1582:                    return v.visitThrow(this , d);
1583:                }
1584:
1585:                @Override
1586:                public int getTag() {
1587:                    return THROW;
1588:                }
1589:            }
1590:
1591:            /**
1592:             * An assert statement.
1593:             */
1594:            public static class JCAssert extends JCStatement implements 
1595:                    AssertTree {
1596:                public JCExpression cond;
1597:                public JCExpression detail;
1598:
1599:                protected JCAssert(JCExpression cond, JCExpression detail) {
1600:                    this .cond = cond;
1601:                    this .detail = detail;
1602:                }
1603:
1604:                @Override
1605:                public void accept(Visitor v) {
1606:                    v.visitAssert(this );
1607:                }
1608:
1609:                public Kind getKind() {
1610:                    return Kind.ASSERT;
1611:                }
1612:
1613:                public JCExpression getCondition() {
1614:                    return cond;
1615:                }
1616:
1617:                public JCExpression getDetail() {
1618:                    return detail;
1619:                }
1620:
1621:                @Override
1622:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
1623:                    return v.visitAssert(this , d);
1624:                }
1625:
1626:                @Override
1627:                public int getTag() {
1628:                    return ASSERT;
1629:                }
1630:            }
1631:
1632:            /**
1633:             * A method invocation
1634:             */
1635:            public static class JCMethodInvocation extends JCExpression
1636:                    implements  MethodInvocationTree {
1637:                public List<JCExpression> typeargs;
1638:                public JCExpression meth;
1639:                public List<JCExpression> args;
1640:                public Type varargsElement;
1641:
1642:                protected JCMethodInvocation(List<JCExpression> typeargs,
1643:                        JCExpression meth, List<JCExpression> args) {
1644:                    this .typeargs = (typeargs == null) ? List
1645:                            .<JCExpression> nil() : typeargs;
1646:                    this .meth = meth;
1647:                    this .args = args;
1648:                }
1649:
1650:                @Override
1651:                public void accept(Visitor v) {
1652:                    v.visitApply(this );
1653:                }
1654:
1655:                public Kind getKind() {
1656:                    return Kind.METHOD_INVOCATION;
1657:                }
1658:
1659:                public List<JCExpression> getTypeArguments() {
1660:                    return typeargs;
1661:                }
1662:
1663:                public JCExpression getMethodSelect() {
1664:                    return meth;
1665:                }
1666:
1667:                public List<JCExpression> getArguments() {
1668:                    return args;
1669:                }
1670:
1671:                @Override
1672:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
1673:                    return v.visitMethodInvocation(this , d);
1674:                }
1675:
1676:                @Override
1677:                public JCMethodInvocation setType(Type type) {
1678:                    super .setType(type);
1679:                    return this ;
1680:                }
1681:
1682:                @Override
1683:                public int getTag() {
1684:                    return (APPLY);
1685:                }
1686:            }
1687:
1688:            /**
1689:             * A new(...) operation.
1690:             */
1691:            public static class JCNewClass extends JCExpression implements 
1692:                    NewClassTree {
1693:                public JCExpression encl;
1694:                public List<JCExpression> typeargs;
1695:                public JCExpression clazz;
1696:                public List<JCExpression> args;
1697:                public JCClassDecl def;
1698:                public Symbol constructor;
1699:                public Type varargsElement;
1700:
1701:                protected JCNewClass(JCExpression encl,
1702:                        List<JCExpression> typeargs, JCExpression clazz,
1703:                        List<JCExpression> args, JCClassDecl def) {
1704:                    this .encl = encl;
1705:                    this .typeargs = (typeargs == null) ? List
1706:                            .<JCExpression> nil() : typeargs;
1707:                    this .clazz = clazz;
1708:                    this .args = args;
1709:                    this .def = def;
1710:                }
1711:
1712:                @Override
1713:                public void accept(Visitor v) {
1714:                    v.visitNewClass(this );
1715:                }
1716:
1717:                public Kind getKind() {
1718:                    return Kind.NEW_CLASS;
1719:                }
1720:
1721:                public JCExpression getEnclosingExpression() { // expr.new C< ... > ( ... )
1722:                    return encl;
1723:                }
1724:
1725:                public List<JCExpression> getTypeArguments() {
1726:                    return typeargs;
1727:                }
1728:
1729:                public JCExpression getIdentifier() {
1730:                    return clazz;
1731:                }
1732:
1733:                public List<JCExpression> getArguments() {
1734:                    return args;
1735:                }
1736:
1737:                public JCClassDecl getClassBody() {
1738:                    return def;
1739:                }
1740:
1741:                @Override
1742:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
1743:                    return v.visitNewClass(this , d);
1744:                }
1745:
1746:                @Override
1747:                public int getTag() {
1748:                    return NEWCLASS;
1749:                }
1750:            }
1751:
1752:            /**
1753:             * A new[...] operation.
1754:             */
1755:            public static class JCNewArray extends JCExpression implements 
1756:                    NewArrayTree {
1757:                public JCExpression elemtype;
1758:                public List<JCExpression> dims;
1759:                public List<JCExpression> elems;
1760:
1761:                protected JCNewArray(JCExpression elemtype,
1762:                        List<JCExpression> dims, List<JCExpression> elems) {
1763:                    this .elemtype = elemtype;
1764:                    this .dims = dims;
1765:                    this .elems = elems;
1766:                }
1767:
1768:                @Override
1769:                public void accept(Visitor v) {
1770:                    v.visitNewArray(this );
1771:                }
1772:
1773:                public Kind getKind() {
1774:                    return Kind.NEW_ARRAY;
1775:                }
1776:
1777:                public JCExpression getType() {
1778:                    return elemtype;
1779:                }
1780:
1781:                public List<JCExpression> getDimensions() {
1782:                    return dims;
1783:                }
1784:
1785:                public List<JCExpression> getInitializers() {
1786:                    return elems;
1787:                }
1788:
1789:                @Override
1790:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
1791:                    return v.visitNewArray(this , d);
1792:                }
1793:
1794:                @Override
1795:                public int getTag() {
1796:                    return NEWARRAY;
1797:                }
1798:            }
1799:
1800:            /**
1801:             * A parenthesized subexpression ( ... )
1802:             */
1803:            public static class JCParens extends JCExpression implements 
1804:                    ParenthesizedTree {
1805:                public JCExpression expr;
1806:
1807:                protected JCParens(JCExpression expr) {
1808:                    this .expr = expr;
1809:                }
1810:
1811:                @Override
1812:                public void accept(Visitor v) {
1813:                    v.visitParens(this );
1814:                }
1815:
1816:                public Kind getKind() {
1817:                    return Kind.PARENTHESIZED;
1818:                }
1819:
1820:                public JCExpression getExpression() {
1821:                    return expr;
1822:                }
1823:
1824:                @Override
1825:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
1826:                    return v.visitParenthesized(this , d);
1827:                }
1828:
1829:                @Override
1830:                public int getTag() {
1831:                    return PARENS;
1832:                }
1833:            }
1834:
1835:            /**
1836:             * A assignment with "=".
1837:             */
1838:            public static class JCAssign extends JCExpression implements 
1839:                    AssignmentTree {
1840:                public JCExpression lhs;
1841:                public JCExpression rhs;
1842:
1843:                protected JCAssign(JCExpression lhs, JCExpression rhs) {
1844:                    this .lhs = lhs;
1845:                    this .rhs = rhs;
1846:                }
1847:
1848:                @Override
1849:                public void accept(Visitor v) {
1850:                    v.visitAssign(this );
1851:                }
1852:
1853:                public Kind getKind() {
1854:                    return Kind.ASSIGNMENT;
1855:                }
1856:
1857:                public JCExpression getVariable() {
1858:                    return lhs;
1859:                }
1860:
1861:                public JCExpression getExpression() {
1862:                    return rhs;
1863:                }
1864:
1865:                @Override
1866:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
1867:                    return v.visitAssignment(this , d);
1868:                }
1869:
1870:                @Override
1871:                public int getTag() {
1872:                    return ASSIGN;
1873:                }
1874:            }
1875:
1876:            /**
1877:             * An assignment with "+=", "|=" ...
1878:             */
1879:            public static class JCAssignOp extends JCExpression implements 
1880:                    CompoundAssignmentTree {
1881:                private int opcode;
1882:                public JCExpression lhs;
1883:                public JCExpression rhs;
1884:                public Symbol operator;
1885:
1886:                protected JCAssignOp(int opcode, JCTree lhs, JCTree rhs,
1887:                        Symbol operator) {
1888:                    this .opcode = opcode;
1889:                    this .lhs = (JCExpression) lhs;
1890:                    this .rhs = (JCExpression) rhs;
1891:                    this .operator = operator;
1892:                }
1893:
1894:                @Override
1895:                public void accept(Visitor v) {
1896:                    v.visitAssignop(this );
1897:                }
1898:
1899:                public Kind getKind() {
1900:                    return TreeInfo.tagToKind(getTag());
1901:                }
1902:
1903:                public JCExpression getVariable() {
1904:                    return lhs;
1905:                }
1906:
1907:                public JCExpression getExpression() {
1908:                    return rhs;
1909:                }
1910:
1911:                public Symbol getOperator() {
1912:                    return operator;
1913:                }
1914:
1915:                @Override
1916:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
1917:                    return v.visitCompoundAssignment(this , d);
1918:                }
1919:
1920:                @Override
1921:                public int getTag() {
1922:                    return opcode;
1923:                }
1924:            }
1925:
1926:            /**
1927:             * A unary operation.
1928:             */
1929:            public static class JCUnary extends JCExpression implements 
1930:                    UnaryTree {
1931:                private int opcode;
1932:                public JCExpression arg;
1933:                public Symbol operator;
1934:
1935:                protected JCUnary(int opcode, JCExpression arg) {
1936:                    this .opcode = opcode;
1937:                    this .arg = arg;
1938:                }
1939:
1940:                @Override
1941:                public void accept(Visitor v) {
1942:                    v.visitUnary(this );
1943:                }
1944:
1945:                public Kind getKind() {
1946:                    return TreeInfo.tagToKind(getTag());
1947:                }
1948:
1949:                public JCExpression getExpression() {
1950:                    return arg;
1951:                }
1952:
1953:                public Symbol getOperator() {
1954:                    return operator;
1955:                }
1956:
1957:                @Override
1958:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
1959:                    return v.visitUnary(this , d);
1960:                }
1961:
1962:                @Override
1963:                public int getTag() {
1964:                    return opcode;
1965:                }
1966:
1967:                public void setTag(int tag) {
1968:                    opcode = tag;
1969:                }
1970:            }
1971:
1972:            /**
1973:             * A binary operation.
1974:             */
1975:            public static class JCBinary extends JCExpression implements 
1976:                    BinaryTree {
1977:                private int opcode;
1978:                public JCExpression lhs;
1979:                public JCExpression rhs;
1980:                public Symbol operator;
1981:
1982:                protected JCBinary(int opcode, JCExpression lhs,
1983:                        JCExpression rhs, Symbol operator) {
1984:                    this .opcode = opcode;
1985:                    this .lhs = lhs;
1986:                    this .rhs = rhs;
1987:                    this .operator = operator;
1988:                }
1989:
1990:                @Override
1991:                public void accept(Visitor v) {
1992:                    v.visitBinary(this );
1993:                }
1994:
1995:                public Kind getKind() {
1996:                    return TreeInfo.tagToKind(getTag());
1997:                }
1998:
1999:                public JCExpression getLeftOperand() {
2000:                    return lhs;
2001:                }
2002:
2003:                public JCExpression getRightOperand() {
2004:                    return rhs;
2005:                }
2006:
2007:                public Symbol getOperator() {
2008:                    return operator;
2009:                }
2010:
2011:                @Override
2012:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
2013:                    return v.visitBinary(this , d);
2014:                }
2015:
2016:                @Override
2017:                public int getTag() {
2018:                    return opcode;
2019:                }
2020:            }
2021:
2022:            /**
2023:             * A type cast.
2024:             */
2025:            public static class JCTypeCast extends JCExpression implements 
2026:                    TypeCastTree {
2027:                public JCTree clazz;
2028:                public JCExpression expr;
2029:
2030:                protected JCTypeCast(JCTree clazz, JCExpression expr) {
2031:                    this .clazz = clazz;
2032:                    this .expr = expr;
2033:                }
2034:
2035:                @Override
2036:                public void accept(Visitor v) {
2037:                    v.visitTypeCast(this );
2038:                }
2039:
2040:                public Kind getKind() {
2041:                    return Kind.TYPE_CAST;
2042:                }
2043:
2044:                public JCTree getType() {
2045:                    return clazz;
2046:                }
2047:
2048:                public JCExpression getExpression() {
2049:                    return expr;
2050:                }
2051:
2052:                @Override
2053:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
2054:                    return v.visitTypeCast(this , d);
2055:                }
2056:
2057:                @Override
2058:                public int getTag() {
2059:                    return TYPECAST;
2060:                }
2061:            }
2062:
2063:            /**
2064:             * A type test.
2065:             */
2066:            public static class JCInstanceOf extends JCExpression implements 
2067:                    InstanceOfTree {
2068:                public JCExpression expr;
2069:                public JCTree clazz;
2070:
2071:                protected JCInstanceOf(JCExpression expr, JCTree clazz) {
2072:                    this .expr = expr;
2073:                    this .clazz = clazz;
2074:                }
2075:
2076:                @Override
2077:                public void accept(Visitor v) {
2078:                    v.visitTypeTest(this );
2079:                }
2080:
2081:                public Kind getKind() {
2082:                    return Kind.INSTANCE_OF;
2083:                }
2084:
2085:                public JCTree getType() {
2086:                    return clazz;
2087:                }
2088:
2089:                public JCExpression getExpression() {
2090:                    return expr;
2091:                }
2092:
2093:                @Override
2094:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
2095:                    return v.visitInstanceOf(this , d);
2096:                }
2097:
2098:                @Override
2099:                public int getTag() {
2100:                    return TYPETEST;
2101:                }
2102:            }
2103:
2104:            /**
2105:             * An array selection
2106:             */
2107:            public static class JCArrayAccess extends JCExpression implements 
2108:                    ArrayAccessTree {
2109:                public JCExpression indexed;
2110:                public JCExpression index;
2111:
2112:                protected JCArrayAccess(JCExpression indexed, JCExpression index) {
2113:                    this .indexed = indexed;
2114:                    this .index = index;
2115:                }
2116:
2117:                @Override
2118:                public void accept(Visitor v) {
2119:                    v.visitIndexed(this );
2120:                }
2121:
2122:                public Kind getKind() {
2123:                    return Kind.ARRAY_ACCESS;
2124:                }
2125:
2126:                public JCExpression getExpression() {
2127:                    return indexed;
2128:                }
2129:
2130:                public JCExpression getIndex() {
2131:                    return index;
2132:                }
2133:
2134:                @Override
2135:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
2136:                    return v.visitArrayAccess(this , d);
2137:                }
2138:
2139:                @Override
2140:                public int getTag() {
2141:                    return INDEXED;
2142:                }
2143:            }
2144:
2145:            /**
2146:             * Selects through packages and classes
2147:             * @param selected selected Tree hierarchie
2148:             * @param selector name of field to select thru
2149:             * @param sym symbol of the selected class
2150:             */
2151:            public static class JCFieldAccess extends JCExpression implements 
2152:                    MemberSelectTree {
2153:                public JCExpression selected;
2154:                public Name name;
2155:                public Symbol sym;
2156:
2157:                protected JCFieldAccess(JCExpression selected, Name name,
2158:                        Symbol sym) {
2159:                    this .selected = selected;
2160:                    this .name = name;
2161:                    this .sym = sym;
2162:                }
2163:
2164:                @Override
2165:                public void accept(Visitor v) {
2166:                    v.visitSelect(this );
2167:                }
2168:
2169:                public Kind getKind() {
2170:                    return Kind.MEMBER_SELECT;
2171:                }
2172:
2173:                public JCExpression getExpression() {
2174:                    return selected;
2175:                }
2176:
2177:                @Override
2178:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
2179:                    return v.visitMemberSelect(this , d);
2180:                }
2181:
2182:                public Name getIdentifier() {
2183:                    return name;
2184:                }
2185:
2186:                @Override
2187:                public int getTag() {
2188:                    return SELECT;
2189:                }
2190:            }
2191:
2192:            /**
2193:             * An identifier
2194:             * @param idname the name
2195:             * @param sym the symbol
2196:             */
2197:            public static class JCIdent extends JCExpression implements 
2198:                    IdentifierTree {
2199:                public Name name;
2200:                public Symbol sym;
2201:
2202:                protected JCIdent(Name name, Symbol sym) {
2203:                    this .name = name;
2204:                    this .sym = sym;
2205:                }
2206:
2207:                @Override
2208:                public void accept(Visitor v) {
2209:                    v.visitIdent(this );
2210:                }
2211:
2212:                public Kind getKind() {
2213:                    return Kind.IDENTIFIER;
2214:                }
2215:
2216:                public Name getName() {
2217:                    return name;
2218:                }
2219:
2220:                @Override
2221:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
2222:                    return v.visitIdentifier(this , d);
2223:                }
2224:
2225:                public int getTag() {
2226:                    return IDENT;
2227:                }
2228:            }
2229:
2230:            /**
2231:             * A constant value given literally.
2232:             * @param value value representation
2233:             */
2234:            public static class JCLiteral extends JCExpression implements 
2235:                    LiteralTree {
2236:                public int typetag;
2237:                public Object value;
2238:
2239:                protected JCLiteral(int typetag, Object value) {
2240:                    this .typetag = typetag;
2241:                    this .value = value;
2242:                }
2243:
2244:                @Override
2245:                public void accept(Visitor v) {
2246:                    v.visitLiteral(this );
2247:                }
2248:
2249:                public Kind getKind() {
2250:                    switch (typetag) {
2251:                    case TypeTags.INT:
2252:                        return Kind.INT_LITERAL;
2253:                    case TypeTags.LONG:
2254:                        return Kind.LONG_LITERAL;
2255:                    case TypeTags.FLOAT:
2256:                        return Kind.FLOAT_LITERAL;
2257:                    case TypeTags.DOUBLE:
2258:                        return Kind.DOUBLE_LITERAL;
2259:                    case TypeTags.BOOLEAN:
2260:                        return Kind.BOOLEAN_LITERAL;
2261:                    case TypeTags.CHAR:
2262:                        return Kind.CHAR_LITERAL;
2263:                    case TypeTags.CLASS:
2264:                        return Kind.STRING_LITERAL;
2265:                    case TypeTags.BOT:
2266:                        return Kind.NULL_LITERAL;
2267:                    default:
2268:                        throw new AssertionError("unknown literal kind " + this );
2269:                    }
2270:                }
2271:
2272:                public Object getValue() {
2273:                    switch (typetag) {
2274:                    case TypeTags.BOOLEAN:
2275:                        int bi = (Integer) value;
2276:                        return (bi != 0);
2277:                    case TypeTags.CHAR:
2278:                        int ci = (Integer) value;
2279:                        char c = (char) ci;
2280:                        if (c != ci)
2281:                            throw new AssertionError(
2282:                                    "bad value for char literal");
2283:                        return c;
2284:                    default:
2285:                        return value;
2286:                    }
2287:                }
2288:
2289:                @Override
2290:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
2291:                    return v.visitLiteral(this , d);
2292:                }
2293:
2294:                @Override
2295:                public JCLiteral setType(Type type) {
2296:                    super .setType(type);
2297:                    return this ;
2298:                }
2299:
2300:                @Override
2301:                public int getTag() {
2302:                    return LITERAL;
2303:                }
2304:            }
2305:
2306:            /**
2307:             * Identifies a basic type.
2308:             * @param tag the basic type id
2309:             * @see TypeTags
2310:             */
2311:            public static class JCPrimitiveTypeTree extends JCExpression
2312:                    implements  PrimitiveTypeTree {
2313:                public int typetag;
2314:
2315:                protected JCPrimitiveTypeTree(int typetag) {
2316:                    this .typetag = typetag;
2317:                }
2318:
2319:                @Override
2320:                public void accept(Visitor v) {
2321:                    v.visitTypeIdent(this );
2322:                }
2323:
2324:                public Kind getKind() {
2325:                    return Kind.PRIMITIVE_TYPE;
2326:                }
2327:
2328:                public TypeKind getPrimitiveTypeKind() {
2329:                    switch (typetag) {
2330:                    case TypeTags.BOOLEAN:
2331:                        return TypeKind.BOOLEAN;
2332:                    case TypeTags.BYTE:
2333:                        return TypeKind.BYTE;
2334:                    case TypeTags.SHORT:
2335:                        return TypeKind.SHORT;
2336:                    case TypeTags.INT:
2337:                        return TypeKind.INT;
2338:                    case TypeTags.LONG:
2339:                        return TypeKind.LONG;
2340:                    case TypeTags.CHAR:
2341:                        return TypeKind.CHAR;
2342:                    case TypeTags.FLOAT:
2343:                        return TypeKind.FLOAT;
2344:                    case TypeTags.DOUBLE:
2345:                        return TypeKind.DOUBLE;
2346:                    case TypeTags.VOID:
2347:                        return TypeKind.VOID;
2348:                    default:
2349:                        throw new AssertionError("unknown primitive type "
2350:                                + this );
2351:                    }
2352:                }
2353:
2354:                @Override
2355:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
2356:                    return v.visitPrimitiveType(this , d);
2357:                }
2358:
2359:                @Override
2360:                public int getTag() {
2361:                    return TYPEIDENT;
2362:                }
2363:            }
2364:
2365:            /**
2366:             * An array type, A[]
2367:             */
2368:            public static class JCArrayTypeTree extends JCExpression implements 
2369:                    ArrayTypeTree {
2370:                public JCExpression elemtype;
2371:
2372:                protected JCArrayTypeTree(JCExpression elemtype) {
2373:                    this .elemtype = elemtype;
2374:                }
2375:
2376:                @Override
2377:                public void accept(Visitor v) {
2378:                    v.visitTypeArray(this );
2379:                }
2380:
2381:                public Kind getKind() {
2382:                    return Kind.ARRAY_TYPE;
2383:                }
2384:
2385:                public JCTree getType() {
2386:                    return elemtype;
2387:                }
2388:
2389:                @Override
2390:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
2391:                    return v.visitArrayType(this , d);
2392:                }
2393:
2394:                @Override
2395:                public int getTag() {
2396:                    return TYPEARRAY;
2397:                }
2398:            }
2399:
2400:            /**
2401:             * A parameterized type, T<...>
2402:             */
2403:            public static class JCTypeApply extends JCExpression implements 
2404:                    ParameterizedTypeTree {
2405:                public JCExpression clazz;
2406:                public List<JCExpression> arguments;
2407:
2408:                protected JCTypeApply(JCExpression clazz,
2409:                        List<JCExpression> arguments) {
2410:                    this .clazz = clazz;
2411:                    this .arguments = arguments;
2412:                }
2413:
2414:                @Override
2415:                public void accept(Visitor v) {
2416:                    v.visitTypeApply(this );
2417:                }
2418:
2419:                public Kind getKind() {
2420:                    return Kind.PARAMETERIZED_TYPE;
2421:                }
2422:
2423:                public JCTree getType() {
2424:                    return clazz;
2425:                }
2426:
2427:                public List<JCExpression> getTypeArguments() {
2428:                    return arguments;
2429:                }
2430:
2431:                @Override
2432:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
2433:                    return v.visitParameterizedType(this , d);
2434:                }
2435:
2436:                @Override
2437:                public int getTag() {
2438:                    return TYPEAPPLY;
2439:                }
2440:            }
2441:
2442:            /**
2443:             * A formal class parameter.
2444:             * @param name name
2445:             * @param bounds bounds
2446:             */
2447:            public static class JCTypeParameter extends JCTree implements 
2448:                    TypeParameterTree {
2449:                public Name name;
2450:                public List<JCExpression> bounds;
2451:
2452:                protected JCTypeParameter(Name name, List<JCExpression> bounds) {
2453:                    this .name = name;
2454:                    this .bounds = bounds;
2455:                }
2456:
2457:                @Override
2458:                public void accept(Visitor v) {
2459:                    v.visitTypeParameter(this );
2460:                }
2461:
2462:                public Kind getKind() {
2463:                    return Kind.TYPE_PARAMETER;
2464:                }
2465:
2466:                public Name getName() {
2467:                    return name;
2468:                }
2469:
2470:                public List<JCExpression> getBounds() {
2471:                    return bounds;
2472:                }
2473:
2474:                @Override
2475:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
2476:                    return v.visitTypeParameter(this , d);
2477:                }
2478:
2479:                @Override
2480:                public int getTag() {
2481:                    return TYPEPARAMETER;
2482:                }
2483:            }
2484:
2485:            public static class JCWildcard extends JCExpression implements 
2486:                    WildcardTree {
2487:                public TypeBoundKind kind;
2488:                public JCTree inner;
2489:
2490:                protected JCWildcard(TypeBoundKind kind, JCTree inner) {
2491:                    kind.getClass(); // null-check
2492:                    this .kind = kind;
2493:                    this .inner = inner;
2494:                }
2495:
2496:                @Override
2497:                public void accept(Visitor v) {
2498:                    v.visitWildcard(this );
2499:                }
2500:
2501:                public Kind getKind() {
2502:                    switch (kind.kind) {
2503:                    case UNBOUND:
2504:                        return Kind.UNBOUNDED_WILDCARD;
2505:                    case EXTENDS:
2506:                        return Kind.EXTENDS_WILDCARD;
2507:                    case SUPER:
2508:                        return Kind.SUPER_WILDCARD;
2509:                    default:
2510:                        throw new AssertionError("Unknown wildcard bound "
2511:                                + kind);
2512:                    }
2513:                }
2514:
2515:                public JCTree getBound() {
2516:                    return inner;
2517:                }
2518:
2519:                @Override
2520:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
2521:                    return v.visitWildcard(this , d);
2522:                }
2523:
2524:                @Override
2525:                public int getTag() {
2526:                    return WILDCARD;
2527:                }
2528:            }
2529:
2530:            public static class TypeBoundKind extends JCTree {
2531:                public BoundKind kind;
2532:
2533:                protected TypeBoundKind(BoundKind kind) {
2534:                    this .kind = kind;
2535:                }
2536:
2537:                @Override
2538:                public void accept(Visitor v) {
2539:                    v.visitTypeBoundKind(this );
2540:                }
2541:
2542:                public Kind getKind() {
2543:                    throw new AssertionError(
2544:                            "TypeBoundKind is not part of a public API");
2545:                }
2546:
2547:                @Override
2548:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
2549:                    throw new AssertionError(
2550:                            "TypeBoundKind is not part of a public API");
2551:                }
2552:
2553:                @Override
2554:                public int getTag() {
2555:                    return TYPEBOUNDKIND;
2556:                }
2557:            }
2558:
2559:            public static class JCAnnotation extends JCExpression implements 
2560:                    AnnotationTree {
2561:                public JCTree annotationType;
2562:                public List<JCExpression> args;
2563:
2564:                protected JCAnnotation(JCTree annotationType,
2565:                        List<JCExpression> args) {
2566:                    this .annotationType = annotationType;
2567:                    this .args = args;
2568:                }
2569:
2570:                @Override
2571:                public void accept(Visitor v) {
2572:                    v.visitAnnotation(this );
2573:                }
2574:
2575:                public Kind getKind() {
2576:                    return Kind.ANNOTATION;
2577:                }
2578:
2579:                public JCTree getAnnotationType() {
2580:                    return annotationType;
2581:                }
2582:
2583:                public List<JCExpression> getArguments() {
2584:                    return args;
2585:                }
2586:
2587:                @Override
2588:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
2589:                    return v.visitAnnotation(this , d);
2590:                }
2591:
2592:                @Override
2593:                public int getTag() {
2594:                    return ANNOTATION;
2595:                }
2596:            }
2597:
2598:            public static class JCModifiers extends JCTree implements 
2599:                    com.sun.source.tree.ModifiersTree {
2600:                public long flags;
2601:                public List<JCAnnotation> annotations;
2602:
2603:                protected JCModifiers(long flags, List<JCAnnotation> annotations) {
2604:                    this .flags = flags;
2605:                    this .annotations = annotations;
2606:                }
2607:
2608:                @Override
2609:                public void accept(Visitor v) {
2610:                    v.visitModifiers(this );
2611:                }
2612:
2613:                public Kind getKind() {
2614:                    return Kind.MODIFIERS;
2615:                }
2616:
2617:                public Set<Modifier> getFlags() {
2618:                    return Flags.asModifierSet(flags);
2619:                }
2620:
2621:                public List<JCAnnotation> getAnnotations() {
2622:                    return annotations;
2623:                }
2624:
2625:                @Override
2626:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
2627:                    return v.visitModifiers(this , d);
2628:                }
2629:
2630:                @Override
2631:                public int getTag() {
2632:                    return MODIFIERS;
2633:                }
2634:            }
2635:
2636:            public static class JCErroneous extends JCExpression implements 
2637:                    com.sun.source.tree.ErroneousTree {
2638:                public List<? extends JCTree> errs;
2639:
2640:                protected JCErroneous(List<? extends JCTree> errs) {
2641:                    this .errs = errs;
2642:                }
2643:
2644:                @Override
2645:                public void accept(Visitor v) {
2646:                    v.visitErroneous(this );
2647:                }
2648:
2649:                public Kind getKind() {
2650:                    return Kind.ERRONEOUS;
2651:                }
2652:
2653:                public List<? extends JCTree> getErrorTrees() {
2654:                    return errs;
2655:                }
2656:
2657:                @Override
2658:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
2659:                    return v.visitErroneous(this , d);
2660:                }
2661:
2662:                @Override
2663:                public int getTag() {
2664:                    return ERRONEOUS;
2665:                }
2666:            }
2667:
2668:            /** (let int x = 3; in x+2) */
2669:            public static class LetExpr extends JCExpression {
2670:                public List<JCVariableDecl> defs;
2671:                public JCTree expr;
2672:
2673:                protected LetExpr(List<JCVariableDecl> defs, JCTree expr) {
2674:                    this .defs = defs;
2675:                    this .expr = expr;
2676:                }
2677:
2678:                @Override
2679:                public void accept(Visitor v) {
2680:                    v.visitLetExpr(this );
2681:                }
2682:
2683:                public Kind getKind() {
2684:                    throw new AssertionError(
2685:                            "LetExpr is not part of a public API");
2686:                }
2687:
2688:                @Override
2689:                public <R, D> R accept(TreeVisitor<R, D> v, D d) {
2690:                    throw new AssertionError(
2691:                            "LetExpr is not part of a public API");
2692:                }
2693:
2694:                @Override
2695:                public int getTag() {
2696:                    return LETEXPR;
2697:                }
2698:            }
2699:
2700:            /** An interface for tree factories
2701:             */
2702:            public interface Factory {
2703:                JCCompilationUnit TopLevel(
2704:                        List<JCAnnotation> packageAnnotations,
2705:                        JCExpression pid, List<JCTree> defs);
2706:
2707:                JCImport Import(JCTree qualid, boolean staticImport);
2708:
2709:                JCClassDecl ClassDef(JCModifiers mods, Name name,
2710:                        List<JCTypeParameter> typarams, JCTree extending,
2711:                        List<JCExpression> implementing, List<JCTree> defs);
2712:
2713:                JCMethodDecl MethodDef(JCModifiers mods, Name name,
2714:                        JCExpression restype, List<JCTypeParameter> typarams,
2715:                        List<JCVariableDecl> params, List<JCExpression> thrown,
2716:                        JCBlock body, JCExpression defaultValue);
2717:
2718:                JCVariableDecl VarDef(JCModifiers mods, Name name,
2719:                        JCExpression vartype, JCExpression init);
2720:
2721:                JCSkip Skip();
2722:
2723:                JCBlock Block(long flags, List<JCStatement> stats);
2724:
2725:                JCDoWhileLoop DoLoop(JCStatement body, JCExpression cond);
2726:
2727:                JCWhileLoop WhileLoop(JCExpression cond, JCStatement body);
2728:
2729:                JCForLoop ForLoop(List<JCStatement> init, JCExpression cond,
2730:                        List<JCExpressionStatement> step, JCStatement body);
2731:
2732:                JCEnhancedForLoop ForeachLoop(JCVariableDecl var,
2733:                        JCExpression expr, JCStatement body);
2734:
2735:                JCLabeledStatement Labelled(Name label, JCStatement body);
2736:
2737:                JCSwitch Switch(JCExpression selector, List<JCCase> cases);
2738:
2739:                JCCase Case(JCExpression pat, List<JCStatement> stats);
2740:
2741:                JCSynchronized Synchronized(JCExpression lock, JCBlock body);
2742:
2743:                JCTry Try(JCBlock body, List<JCCatch> catchers,
2744:                        JCBlock finalizer);
2745:
2746:                JCCatch Catch(JCVariableDecl param, JCBlock body);
2747:
2748:                JCConditional Conditional(JCExpression cond,
2749:                        JCExpression thenpart, JCExpression elsepart);
2750:
2751:                JCIf If(JCExpression cond, JCStatement thenpart,
2752:                        JCStatement elsepart);
2753:
2754:                JCExpressionStatement Exec(JCExpression expr);
2755:
2756:                JCBreak Break(Name label);
2757:
2758:                JCContinue Continue(Name label);
2759:
2760:                JCReturn Return(JCExpression expr);
2761:
2762:                JCThrow Throw(JCTree expr);
2763:
2764:                JCAssert Assert(JCExpression cond, JCExpression detail);
2765:
2766:                JCMethodInvocation Apply(List<JCExpression> typeargs,
2767:                        JCExpression fn, List<JCExpression> args);
2768:
2769:                JCNewClass NewClass(JCExpression encl,
2770:                        List<JCExpression> typeargs, JCExpression clazz,
2771:                        List<JCExpression> args, JCClassDecl def);
2772:
2773:                JCNewArray NewArray(JCExpression elemtype,
2774:                        List<JCExpression> dims, List<JCExpression> elems);
2775:
2776:                JCParens Parens(JCExpression expr);
2777:
2778:                JCAssign Assign(JCExpression lhs, JCExpression rhs);
2779:
2780:                JCAssignOp Assignop(int opcode, JCTree lhs, JCTree rhs);
2781:
2782:                JCUnary Unary(int opcode, JCExpression arg);
2783:
2784:                JCBinary Binary(int opcode, JCExpression lhs, JCExpression rhs);
2785:
2786:                JCTypeCast TypeCast(JCTree expr, JCExpression type);
2787:
2788:                JCInstanceOf TypeTest(JCExpression expr, JCTree clazz);
2789:
2790:                JCArrayAccess Indexed(JCExpression indexed, JCExpression index);
2791:
2792:                JCFieldAccess Select(JCExpression selected, Name selector);
2793:
2794:                JCIdent Ident(Name idname);
2795:
2796:                JCLiteral Literal(int tag, Object value);
2797:
2798:                JCPrimitiveTypeTree TypeIdent(int typetag);
2799:
2800:                JCArrayTypeTree TypeArray(JCExpression elemtype);
2801:
2802:                JCTypeApply TypeApply(JCExpression clazz,
2803:                        List<JCExpression> arguments);
2804:
2805:                JCTypeParameter TypeParameter(Name name,
2806:                        List<JCExpression> bounds);
2807:
2808:                JCWildcard Wildcard(TypeBoundKind kind, JCTree type);
2809:
2810:                TypeBoundKind TypeBoundKind(BoundKind kind);
2811:
2812:                JCAnnotation Annotation(JCTree annotationType,
2813:                        List<JCExpression> args);
2814:
2815:                JCModifiers Modifiers(long flags, List<JCAnnotation> annotations);
2816:
2817:                JCErroneous Erroneous(List<? extends JCTree> errs);
2818:
2819:                LetExpr LetExpr(List<JCVariableDecl> defs, JCTree expr);
2820:            }
2821:
2822:            /** A generic visitor class for trees.
2823:             */
2824:            public static abstract class Visitor {
2825:                public void visitTopLevel(JCCompilationUnit that) {
2826:                    visitTree(that);
2827:                }
2828:
2829:                public void visitImport(JCImport that) {
2830:                    visitTree(that);
2831:                }
2832:
2833:                public void visitClassDef(JCClassDecl that) {
2834:                    visitTree(that);
2835:                }
2836:
2837:                public void visitMethodDef(JCMethodDecl that) {
2838:                    visitTree(that);
2839:                }
2840:
2841:                public void visitVarDef(JCVariableDecl that) {
2842:                    visitTree(that);
2843:                }
2844:
2845:                public void visitSkip(JCSkip that) {
2846:                    visitTree(that);
2847:                }
2848:
2849:                public void visitBlock(JCBlock that) {
2850:                    visitTree(that);
2851:                }
2852:
2853:                public void visitDoLoop(JCDoWhileLoop that) {
2854:                    visitTree(that);
2855:                }
2856:
2857:                public void visitWhileLoop(JCWhileLoop that) {
2858:                    visitTree(that);
2859:                }
2860:
2861:                public void visitForLoop(JCForLoop that) {
2862:                    visitTree(that);
2863:                }
2864:
2865:                public void visitForeachLoop(JCEnhancedForLoop that) {
2866:                    visitTree(that);
2867:                }
2868:
2869:                public void visitLabelled(JCLabeledStatement that) {
2870:                    visitTree(that);
2871:                }
2872:
2873:                public void visitSwitch(JCSwitch that) {
2874:                    visitTree(that);
2875:                }
2876:
2877:                public void visitCase(JCCase that) {
2878:                    visitTree(that);
2879:                }
2880:
2881:                public void visitSynchronized(JCSynchronized that) {
2882:                    visitTree(that);
2883:                }
2884:
2885:                public void visitTry(JCTry that) {
2886:                    visitTree(that);
2887:                }
2888:
2889:                public void visitCatch(JCCatch that) {
2890:                    visitTree(that);
2891:                }
2892:
2893:                public void visitConditional(JCConditional that) {
2894:                    visitTree(that);
2895:                }
2896:
2897:                public void visitIf(JCIf that) {
2898:                    visitTree(that);
2899:                }
2900:
2901:                public void visitExec(JCExpressionStatement that) {
2902:                    visitTree(that);
2903:                }
2904:
2905:                public void visitBreak(JCBreak that) {
2906:                    visitTree(that);
2907:                }
2908:
2909:                public void visitContinue(JCContinue that) {
2910:                    visitTree(that);
2911:                }
2912:
2913:                public void visitReturn(JCReturn that) {
2914:                    visitTree(that);
2915:                }
2916:
2917:                public void visitThrow(JCThrow that) {
2918:                    visitTree(that);
2919:                }
2920:
2921:                public void visitAssert(JCAssert that) {
2922:                    visitTree(that);
2923:                }
2924:
2925:                public void visitApply(JCMethodInvocation that) {
2926:                    visitTree(that);
2927:                }
2928:
2929:                public void visitNewClass(JCNewClass that) {
2930:                    visitTree(that);
2931:                }
2932:
2933:                public void visitNewArray(JCNewArray that) {
2934:                    visitTree(that);
2935:                }
2936:
2937:                public void visitParens(JCParens that) {
2938:                    visitTree(that);
2939:                }
2940:
2941:                public void visitAssign(JCAssign that) {
2942:                    visitTree(that);
2943:                }
2944:
2945:                public void visitAssignop(JCAssignOp that) {
2946:                    visitTree(that);
2947:                }
2948:
2949:                public void visitUnary(JCUnary that) {
2950:                    visitTree(that);
2951:                }
2952:
2953:                public void visitBinary(JCBinary that) {
2954:                    visitTree(that);
2955:                }
2956:
2957:                public void visitTypeCast(JCTypeCast that) {
2958:                    visitTree(that);
2959:                }
2960:
2961:                public void visitTypeTest(JCInstanceOf that) {
2962:                    visitTree(that);
2963:                }
2964:
2965:                public void visitIndexed(JCArrayAccess that) {
2966:                    visitTree(that);
2967:                }
2968:
2969:                public void visitSelect(JCFieldAccess that) {
2970:                    visitTree(that);
2971:                }
2972:
2973:                public void visitIdent(JCIdent that) {
2974:                    visitTree(that);
2975:                }
2976:
2977:                public void visitLiteral(JCLiteral that) {
2978:                    visitTree(that);
2979:                }
2980:
2981:                public void visitTypeIdent(JCPrimitiveTypeTree that) {
2982:                    visitTree(that);
2983:                }
2984:
2985:                public void visitTypeArray(JCArrayTypeTree that) {
2986:                    visitTree(that);
2987:                }
2988:
2989:                public void visitTypeApply(JCTypeApply that) {
2990:                    visitTree(that);
2991:                }
2992:
2993:                public void visitTypeParameter(JCTypeParameter that) {
2994:                    visitTree(that);
2995:                }
2996:
2997:                public void visitWildcard(JCWildcard that) {
2998:                    visitTree(that);
2999:                }
3000:
3001:                public void visitTypeBoundKind(TypeBoundKind that) {
3002:                    visitTree(that);
3003:                }
3004:
3005:                public void visitAnnotation(JCAnnotation that) {
3006:                    visitTree(that);
3007:                }
3008:
3009:                public void visitModifiers(JCModifiers that) {
3010:                    visitTree(that);
3011:                }
3012:
3013:                public void visitErroneous(JCErroneous that) {
3014:                    visitTree(that);
3015:                }
3016:
3017:                public void visitLetExpr(LetExpr that) {
3018:                    visitTree(that);
3019:                }
3020:
3021:                public void visitTree(JCTree that) {
3022:                    assert false;
3023:                }
3024:            }
3025:
3026:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.