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