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

Print this page

        

*** 40,49 **** --- 40,50 ---- import com.sun.tools.javac.code.Scope.*; import com.sun.tools.javac.code.Symbol.*; import com.sun.source.tree.*; import static com.sun.tools.javac.code.BoundKind.*; + import static com.sun.tools.javac.tree.JCTree.Tag.*; /** * Root class for abstract syntax tree nodes. It provides definitions * for specific tree nodes as subclasses nested inside. *
*** 77,333 **** * @see Pretty */ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition { /* Tree tag values, identifying kinds of trees */ /** Toplevel nodes, of type TopLevel, representing entire source files. */ ! public static final int TOPLEVEL = 1; /** Import clauses, of type Import. */ ! public static final int IMPORT = TOPLEVEL + 1; /** Class definitions, of type ClassDef. */ ! public static final int CLASSDEF = IMPORT + 1; /** Method definitions, of type MethodDef. */ ! public static final int METHODDEF = CLASSDEF + 1; /** Variable definitions, of type VarDef. */ ! public static final int VARDEF = METHODDEF + 1; /** The no-op statement ";", of type Skip */ ! public static final int SKIP = VARDEF + 1; /** Blocks, of type Block. */ ! public static final int BLOCK = SKIP + 1; /** Do-while loops, of type DoLoop. */ ! public static final int DOLOOP = BLOCK + 1; /** While-loops, of type WhileLoop. */ ! public static final int WHILELOOP = DOLOOP + 1; /** For-loops, of type ForLoop. */ ! public static final int FORLOOP = WHILELOOP + 1; /** Foreach-loops, of type ForeachLoop. */ ! public static final int FOREACHLOOP = FORLOOP + 1; /** Labelled statements, of type Labelled. */ ! public static final int LABELLED = FOREACHLOOP + 1; /** Switch statements, of type Switch. */ ! public static final int SWITCH = LABELLED + 1; /** Case parts in switch statements, of type Case. */ ! public static final int CASE = SWITCH + 1; /** Synchronized statements, of type Synchonized. */ ! public static final int SYNCHRONIZED = CASE + 1; /** Try statements, of type Try. */ ! public static final int TRY = SYNCHRONIZED + 1; /** Catch clauses in try statements, of type Catch. */ ! public static final int CATCH = TRY + 1; /** Conditional expressions, of type Conditional. */ ! public static final int CONDEXPR = CATCH + 1; /** Conditional statements, of type If. */ ! public static final int IF = CONDEXPR + 1; /** Expression statements, of type Exec. */ ! public static final int EXEC = IF + 1; /** Break statements, of type Break. */ ! public static final int BREAK = EXEC + 1; /** Continue statements, of type Continue. */ ! public static final int CONTINUE = BREAK + 1; /** Return statements, of type Return. */ ! public static final int RETURN = CONTINUE + 1; /** Throw statements, of type Throw. */ ! public static final int THROW = RETURN + 1; /** Assert statements, of type Assert. */ ! public static final int ASSERT = THROW + 1; /** Method invocation expressions, of type Apply. */ ! public static final int APPLY = ASSERT + 1; /** Class instance creation expressions, of type NewClass. */ ! public static final int NEWCLASS = APPLY + 1; /** Array creation expressions, of type NewArray. */ ! public static final int NEWARRAY = NEWCLASS + 1; /** Parenthesized subexpressions, of type Parens. */ ! public static final int PARENS = NEWARRAY + 1; /** Assignment expressions, of type Assign. */ ! public static final int ASSIGN = PARENS + 1; /** Type cast expressions, of type TypeCast. */ ! public static final int TYPECAST = ASSIGN + 1; /** Type test expressions, of type TypeTest. */ ! public static final int TYPETEST = TYPECAST + 1; /** Indexed array expressions, of type Indexed. */ ! public static final int INDEXED = TYPETEST + 1; /** Selections, of type Select. */ ! public static final int SELECT = INDEXED + 1; /** Simple identifiers, of type Ident. */ ! public static final int IDENT = SELECT + 1; /** Literals, of type Literal. */ ! public static final int LITERAL = IDENT + 1; /** Basic type identifiers, of type TypeIdent. */ ! public static final int TYPEIDENT = LITERAL + 1; /** Array types, of type TypeArray. */ ! public static final int TYPEARRAY = TYPEIDENT + 1; /** Parameterized types, of type TypeApply. */ ! public static final int TYPEAPPLY = TYPEARRAY + 1; /** Union types, of type TypeUnion */ ! public static final int TYPEUNION = TYPEAPPLY + 1; /** Formal type parameters, of type TypeParameter. */ ! public static final int TYPEPARAMETER = TYPEUNION + 1; /** Type argument. */ ! public static final int WILDCARD = TYPEPARAMETER + 1; /** Bound kind: extends, super, exact, or unbound */ ! public static final int TYPEBOUNDKIND = WILDCARD + 1; /** metadata: Annotation. */ ! public static final int ANNOTATION = TYPEBOUNDKIND + 1; /** metadata: Modifiers */ ! public static final int MODIFIERS = ANNOTATION + 1; ! public static final int ANNOTATED_TYPE = MODIFIERS + 1; /** Error trees, of type Erroneous. */ ! public static final int ERRONEOUS = ANNOTATED_TYPE + 1; /** Unary operators, of type Unary. */ ! public static final int POS = ERRONEOUS + 1; // + ! public static final int NEG = POS + 1; // - ! public static final int NOT = NEG + 1; // ! ! public static final int COMPL = NOT + 1; // ~ ! public static final int PREINC = COMPL + 1; // ++ _ ! public static final int PREDEC = PREINC + 1; // -- _ ! public static final int POSTINC = PREDEC + 1; // _ ++ ! public static final int POSTDEC = POSTINC + 1; // _ -- /** unary operator for null reference checks, only used internally. */ ! public static final int NULLCHK = POSTDEC + 1; /** Binary operators, of type Binary. */ ! public static final int OR = NULLCHK + 1; // || ! public static final int AND = OR + 1; // && ! public static final int BITOR = AND + 1; // | ! public static final int BITXOR = BITOR + 1; // ^ ! public static final int BITAND = BITXOR + 1; // & ! public static final int EQ = BITAND + 1; // == ! public static final int NE = EQ + 1; // != ! public static final int LT = NE + 1; // < ! public static final int GT = LT + 1; // > ! public static final int LE = GT + 1; // <= ! public static final int GE = LE + 1; // >= ! public static final int SL = GE + 1; // << ! public static final int SR = SL + 1; // >> ! public static final int USR = SR + 1; // >>> ! public static final int PLUS = USR + 1; // + ! public static final int MINUS = PLUS + 1; // - ! public static final int MUL = MINUS + 1; // * ! public static final int DIV = MUL + 1; // / ! public static final int MOD = DIV + 1; // % /** Assignment operators, of type Assignop. */ ! public static final int BITOR_ASG = MOD + 1; // |= ! public static final int BITXOR_ASG = BITOR_ASG + 1; // ^= ! public static final int BITAND_ASG = BITXOR_ASG + 1; // &= ! ! public static final int SL_ASG = SL + BITOR_ASG - BITOR; // <<= ! public static final int SR_ASG = SL_ASG + 1; // >>= ! public static final int USR_ASG = SR_ASG + 1; // >>>= ! public static final int PLUS_ASG = USR_ASG + 1; // += ! public static final int MINUS_ASG = PLUS_ASG + 1; // -= ! public static final int MUL_ASG = MINUS_ASG + 1; // *= ! public static final int DIV_ASG = MUL_ASG + 1; // /= ! public static final int MOD_ASG = DIV_ASG + 1; // %= /** A synthetic let expression, of type LetExpr. */ ! public static final int LETEXPR = MOD_ASG + 1; // ala scheme ! /** The offset between assignment operators and normal operators. ! */ ! public static final int ASGOffset = BITOR_ASG - BITOR; /* The (encoded) position in the source file. @see util.Position. */ public int pos; --- 78,352 ---- * @see Pretty */ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition { /* Tree tag values, identifying kinds of trees */ + public enum Tag{ + /** For methods that return an invalid tag if a given condition is not met + */ + NO_TAG, /** Toplevel nodes, of type TopLevel, representing entire source files. */ ! TOPLEVEL, /** Import clauses, of type Import. */ ! IMPORT, /** Class definitions, of type ClassDef. */ ! CLASSDEF, /** Method definitions, of type MethodDef. */ ! METHODDEF, /** Variable definitions, of type VarDef. */ ! VARDEF, /** The no-op statement ";", of type Skip */ ! SKIP, /** Blocks, of type Block. */ ! BLOCK, /** Do-while loops, of type DoLoop. */ ! DOLOOP, /** While-loops, of type WhileLoop. */ ! WHILELOOP, /** For-loops, of type ForLoop. */ ! FORLOOP, /** Foreach-loops, of type ForeachLoop. */ ! FOREACHLOOP, /** Labelled statements, of type Labelled. */ ! LABELLED, /** Switch statements, of type Switch. */ ! SWITCH, /** Case parts in switch statements, of type Case. */ ! CASE, /** Synchronized statements, of type Synchonized. */ ! SYNCHRONIZED, /** Try statements, of type Try. */ ! TRY, /** Catch clauses in try statements, of type Catch. */ ! CATCH, /** Conditional expressions, of type Conditional. */ ! CONDEXPR, /** Conditional statements, of type If. */ ! IF, /** Expression statements, of type Exec. */ ! EXEC, /** Break statements, of type Break. */ ! BREAK, /** Continue statements, of type Continue. */ ! CONTINUE, /** Return statements, of type Return. */ ! RETURN, /** Throw statements, of type Throw. */ ! THROW, /** Assert statements, of type Assert. */ ! ASSERT, /** Method invocation expressions, of type Apply. */ ! APPLY, /** Class instance creation expressions, of type NewClass. */ ! NEWCLASS, /** Array creation expressions, of type NewArray. */ ! NEWARRAY, /** Parenthesized subexpressions, of type Parens. */ ! PARENS, /** Assignment expressions, of type Assign. */ ! ASSIGN, /** Type cast expressions, of type TypeCast. */ ! TYPECAST, /** Type test expressions, of type TypeTest. */ ! TYPETEST, /** Indexed array expressions, of type Indexed. */ ! INDEXED, /** Selections, of type Select. */ ! SELECT, /** Simple identifiers, of type Ident. */ ! IDENT, /** Literals, of type Literal. */ ! LITERAL, /** Basic type identifiers, of type TypeIdent. */ ! TYPEIDENT, /** Array types, of type TypeArray. */ ! TYPEARRAY, /** Parameterized types, of type TypeApply. */ ! TYPEAPPLY, /** Union types, of type TypeUnion */ ! TYPEUNION, /** Formal type parameters, of type TypeParameter. */ ! TYPEPARAMETER, /** Type argument. */ ! WILDCARD, /** Bound kind: extends, super, exact, or unbound */ ! TYPEBOUNDKIND, /** metadata: Annotation. */ ! ANNOTATION, /** metadata: Modifiers */ ! MODIFIERS, ! ANNOTATED_TYPE, /** Error trees, of type Erroneous. */ ! ERRONEOUS, /** Unary operators, of type Unary. */ ! POS, // + ! NEG, // - ! NOT, // ! ! COMPL, // ~ ! PREINC, // ++ _ ! PREDEC, // -- _ ! POSTINC, // _ ++ ! POSTDEC, // _ -- /** unary operator for null reference checks, only used internally. */ ! NULLCHK, /** Binary operators, of type Binary. */ ! OR, // || ! AND, // && ! BITOR, // | ! BITXOR, // ^ ! BITAND, // & ! EQ, // == ! NE, // != ! LT, // < ! GT, // > ! LE, // <= ! GE, // >= ! SL, // << ! SR, // >> ! USR, // >>> ! PLUS, // + ! MINUS, // - ! MUL, // * ! DIV, // / ! MOD, // % /** Assignment operators, of type Assignop. */ ! BITOR_ASG(BITOR), // |= ! BITXOR_ASG(BITXOR), // ^= ! BITAND_ASG(BITAND), // &= ! ! SL_ASG(SL), // <<= ! SR_ASG(SR), // >>= ! USR_ASG(USR), // >>>= ! PLUS_ASG(PLUS), // += ! MINUS_ASG(MINUS), // -= ! MUL_ASG(MUL), // *= ! DIV_ASG(DIV), // /= ! MOD_ASG(MOD), // %= /** A synthetic let expression, of type LetExpr. */ ! LETEXPR; // ala scheme + private Tag noAssignTag; ! private Tag(Tag noAssignTag) ! { ! this.noAssignTag = noAssignTag; ! } ! ! private Tag() ! { ! } ! ! public Tag noAssignOp() ! { ! if (this.noAssignTag != null) ! return noAssignTag; ! throw new AssertionError("noAssignOp() method is not available for non assignment tags"); ! } ! } /* The (encoded) position in the source file. @see util.Position. */ public int pos;
*** 335,345 **** */ public Type type; /* The tag of this node -- one of the constants declared above. */ ! public abstract int getTag(); /** Convert a tree to a pretty-printed string. */ @Override public String toString() { StringWriter s = new StringWriter(); --- 354,368 ---- */ public Type type; /* The tag of this node -- one of the constants declared above. */ ! public abstract Tag getTag(); ! ! /* Returns true if the tag of this node is equals to tag. ! */ ! public abstract boolean hasTag(Tag tag); /** Convert a tree to a pretty-printed string. */ @Override public String toString() { StringWriter s = new StringWriter();
*** 462,475 **** return packageAnnotations; } public List<JCImport> getImports() { ListBuffer<JCImport> imports = new ListBuffer<JCImport>(); for (JCTree tree : defs) { ! int tag = tree.getTag(); ! if (tag == IMPORT) imports.append((JCImport)tree); ! else if (tag != SKIP) break; } return imports.toList(); } public JCExpression getPackageName() { return pid; } --- 485,497 ---- return packageAnnotations; } public List<JCImport> getImports() { ListBuffer<JCImport> imports = new ListBuffer<JCImport>(); for (JCTree tree : defs) { ! if (tree.hasTag(IMPORT)) imports.append((JCImport)tree); ! else if (!tree.hasTag(SKIP)) break; } return imports.toList(); } public JCExpression getPackageName() { return pid; }
*** 480,502 **** return lineMap; } public List<JCTree> getTypeDecls() { List<JCTree> typeDefs; for (typeDefs = defs; !typeDefs.isEmpty(); typeDefs = typeDefs.tail) ! if (typeDefs.head.getTag() != IMPORT) break; return typeDefs; } @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitCompilationUnit(this, d); } @Override ! public int getTag() { return TOPLEVEL; } } /** * An import clause. * @param qualid The imported class(es). --- 502,529 ---- return lineMap; } public List<JCTree> getTypeDecls() { List<JCTree> typeDefs; for (typeDefs = defs; !typeDefs.isEmpty(); typeDefs = typeDefs.tail) ! if (!typeDefs.head.hasTag(IMPORT)) break; return typeDefs; } @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitCompilationUnit(this, d); } @Override ! public Tag getTag() { return TOPLEVEL; } + + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(TOPLEVEL)); + } } /** * An import clause. * @param qualid The imported class(es).
*** 519,531 **** public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitImport(this, d); } @Override ! public int getTag() { return IMPORT; } } public static abstract class JCStatement extends JCTree implements StatementTree { @Override public JCStatement setType(Type type) { --- 546,563 ---- public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitImport(this, d); } @Override ! public Tag getTag() { return IMPORT; } + + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(IMPORT)); + } } public static abstract class JCStatement extends JCTree implements StatementTree { @Override public JCStatement setType(Type type) {
*** 616,628 **** public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitClass(this, d); } @Override ! public int getTag() { return CLASSDEF; } } /** * A method definition. * @param modifiers method modifiers --- 648,665 ---- public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitClass(this, d); } @Override ! public Tag getTag() { return CLASSDEF; } + + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(CLASSDEF)); + } } /** * A method definition. * @param modifiers method modifiers
*** 688,700 **** public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitMethod(this, d); } @Override ! public int getTag() { return METHODDEF; } } /** * A variable definition. * @param modifiers variable modifiers --- 725,742 ---- public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitMethod(this, d); } @Override ! public Tag getTag() { return METHODDEF; } + + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(METHODDEF)); + } } /** * A variable definition. * @param modifiers variable modifiers
*** 734,746 **** public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitVariable(this, d); } @Override ! public int getTag() { return VARDEF; } } /** * A no-op statement ";". */ --- 776,793 ---- public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitVariable(this, d); } @Override ! public Tag getTag() { return VARDEF; } + + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(VARDEF)); + } } /** * A no-op statement ";". */
*** 755,767 **** public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitEmptyStatement(this, d); } @Override ! public int getTag() { return SKIP; } } /** * A statement block. * @param stats statements --- 802,819 ---- public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitEmptyStatement(this, d); } @Override ! public Tag getTag() { return SKIP; } + + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(SKIP)); + } } /** * A statement block. * @param stats statements
*** 788,800 **** public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitBlock(this, d); } @Override ! public int getTag() { return BLOCK; } } /** * A do loop */ --- 840,857 ---- public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitBlock(this, d); } @Override ! public Tag getTag() { return BLOCK; } + + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(BLOCK)); + } } /** * A do loop */
*** 815,827 **** public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitDoWhileLoop(this, d); } @Override ! public int getTag() { return DOLOOP; } } /** * A while loop */ --- 872,889 ---- public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitDoWhileLoop(this, d); } @Override ! public Tag getTag() { return DOLOOP; } + + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(DOLOOP)); + } } /** * A while loop */
*** 842,854 **** public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitWhileLoop(this, d); } @Override ! public int getTag() { return WHILELOOP; } } /** * A for loop. */ --- 904,921 ---- public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitWhileLoop(this, d); } @Override ! public Tag getTag() { return WHILELOOP; } + + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(WHILELOOP)); + } } /** * A for loop. */
*** 883,895 **** public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitForLoop(this, d); } @Override ! public int getTag() { return FORLOOP; } } /** * The enhanced for loop. */ --- 950,967 ---- public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitForLoop(this, d); } @Override ! public Tag getTag() { return FORLOOP; } + + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(FORLOOP)); + } } /** * The enhanced for loop. */
*** 912,924 **** @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitEnhancedForLoop(this, d); } @Override ! public int getTag() { return FOREACHLOOP; } } /** * A labelled expression or statement. */ --- 984,1000 ---- @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitEnhancedForLoop(this, d); } @Override ! public Tag getTag() { return FOREACHLOOP; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(FOREACHLOOP)); + } } /** * A labelled expression or statement. */
*** 937,949 **** @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitLabeledStatement(this, d); } @Override ! public int getTag() { return LABELLED; } } /** * A "switch ( ) { }" construction. */ --- 1013,1029 ---- @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitLabeledStatement(this, d); } @Override ! public Tag getTag() { return LABELLED; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(LABELLED)); + } } /** * A "switch ( ) { }" construction. */
*** 963,975 **** @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitSwitch(this, d); } @Override ! public int getTag() { return SWITCH; } } /** * A "case :" of a switch. */ --- 1043,1059 ---- @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitSwitch(this, d); } @Override ! public Tag getTag() { return SWITCH; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(SWITCH)); + } } /** * A "case :" of a switch. */
*** 989,1001 **** @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitCase(this, d); } @Override ! public int getTag() { return CASE; } } /** * A synchronized block. */ --- 1073,1089 ---- @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitCase(this, d); } @Override ! public Tag getTag() { return CASE; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(CASE)); + } } /** * A synchronized block. */
*** 1015,1027 **** @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitSynchronized(this, d); } @Override ! public int getTag() { return SYNCHRONIZED; } } /** * A "try { } catch ( ) { } finally { }" block. */ --- 1103,1119 ---- @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitSynchronized(this, d); } @Override ! public Tag getTag() { return SYNCHRONIZED; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(SYNCHRONIZED)); + } } /** * A "try { } catch ( ) { } finally { }" block. */
*** 1055,1067 **** @Override public List<? extends JCTree> getResources() { return resources; } @Override ! public int getTag() { return TRY; } } /** * A catch block. */ --- 1147,1163 ---- @Override public List<? extends JCTree> getResources() { return resources; } @Override ! public Tag getTag() { return TRY; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(TRY)); + } } /** * A catch block. */
*** 1081,1093 **** @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitCatch(this, d); } @Override ! public int getTag() { return CATCH; } } /** * A ( ) ? ( ) : ( ) conditional expression */ --- 1177,1193 ---- @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitCatch(this, d); } @Override ! public Tag getTag() { return CATCH; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(CATCH)); + } } /** * A ( ) ? ( ) : ( ) conditional expression */
*** 1113,1125 **** @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitConditionalExpression(this, d); } @Override ! public int getTag() { return CONDEXPR; } } /** * An "if ( ) { } else { }" block */ --- 1213,1229 ---- @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitConditionalExpression(this, d); } @Override ! public Tag getTag() { return CONDEXPR; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(CONDEXPR)); + } } /** * An "if ( ) { } else { }" block */
*** 1145,1157 **** @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitIf(this, d); } @Override ! public int getTag() { return IF; } } /** * an expression statement * @param expr expression structure --- 1249,1265 ---- @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitIf(this, d); } @Override ! public Tag getTag() { return IF; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(IF)); + } } /** * an expression statement * @param expr expression structure
*** 1170,1182 **** @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitExpressionStatement(this, d); } @Override ! public int getTag() { return EXEC; } /** Convert a expression-statement tree to a pretty-printed string. */ @Override public String toString() { StringWriter s = new StringWriter(); --- 1278,1294 ---- @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitExpressionStatement(this, d); } @Override ! public Tag getTag() { return EXEC; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(EXEC)); + } /** Convert a expression-statement tree to a pretty-printed string. */ @Override public String toString() { StringWriter s = new StringWriter();
*** 1210,1222 **** @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitBreak(this, d); } @Override ! public int getTag() { return BREAK; } } /** * A continue of a loop. */ --- 1322,1338 ---- @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitBreak(this, d); } @Override ! public Tag getTag() { return BREAK; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(BREAK)); + } } /** * A continue of a loop. */
*** 1235,1247 **** @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitContinue(this, d); } @Override ! public int getTag() { return CONTINUE; } } /** * A return statement. */ --- 1351,1367 ---- @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitContinue(this, d); } @Override ! public Tag getTag() { return CONTINUE; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(CONTINUE)); + } } /** * A return statement. */
*** 1258,1270 **** @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitReturn(this, d); } @Override ! public int getTag() { return RETURN; } } /** * A throw statement. */ --- 1378,1394 ---- @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitReturn(this, d); } @Override ! public Tag getTag() { return RETURN; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(RETURN)); + } } /** * A throw statement. */
*** 1281,1293 **** @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitThrow(this, d); } @Override ! public int getTag() { return THROW; } } /** * An assert statement. */ --- 1405,1421 ---- @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitThrow(this, d); } @Override ! public Tag getTag() { return THROW; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(THROW)); + } } /** * An assert statement. */
*** 1307,1319 **** @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitAssert(this, d); } @Override ! public int getTag() { return ASSERT; } } /** * A method invocation */ --- 1435,1451 ---- @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitAssert(this, d); } @Override ! public Tag getTag() { return ASSERT; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(ASSERT)); + } } /** * A method invocation */
*** 1350,1362 **** public JCMethodInvocation setType(Type type) { super.setType(type); return this; } @Override ! public int getTag() { return(APPLY); } } /** * A new(...) operation. */ --- 1482,1498 ---- public JCMethodInvocation setType(Type type) { super.setType(type); return this; } @Override ! public Tag getTag() { return(APPLY); } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(APPLY)); + } } /** * A new(...) operation. */
*** 1400,1412 **** @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitNewClass(this, d); } @Override ! public int getTag() { return NEWCLASS; } } /** * A new[...] operation. */ --- 1536,1552 ---- @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitNewClass(this, d); } @Override ! public Tag getTag() { return NEWCLASS; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(NEWCLASS)); + } } /** * A new[...] operation. */
*** 1436,1448 **** @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitNewArray(this, d); } @Override ! public int getTag() { return NEWARRAY; } } /** * A parenthesized subexpression ( ... ) */ --- 1576,1592 ---- @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitNewArray(this, d); } @Override ! public Tag getTag() { return NEWARRAY; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(NEWARRAY)); + } } /** * A parenthesized subexpression ( ... ) */
*** 1459,1471 **** @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitParenthesized(this, d); } @Override ! public int getTag() { return PARENS; } } /** * A assignment with "=". */ --- 1603,1619 ---- @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitParenthesized(this, d); } @Override ! public Tag getTag() { return PARENS; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(PARENS)); + } } /** * A assignment with "=". */
*** 1485,1508 **** @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitAssignment(this, d); } @Override ! public int getTag() { return ASSIGN; } } /** * An assignment with "+=", "|=" ... */ public static class JCAssignOp extends JCExpression implements CompoundAssignmentTree { ! private int opcode; public JCExpression lhs; public JCExpression rhs; public Symbol operator; ! protected JCAssignOp(int opcode, JCTree lhs, JCTree rhs, Symbol operator) { this.opcode = opcode; this.lhs = (JCExpression)lhs; this.rhs = (JCExpression)rhs; this.operator = operator; } --- 1633,1660 ---- @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitAssignment(this, d); } @Override ! public Tag getTag() { return ASSIGN; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(ASSIGN)); + } } /** * An assignment with "+=", "|=" ... */ public static class JCAssignOp extends JCExpression implements CompoundAssignmentTree { ! private Tag opcode; public JCExpression lhs; public JCExpression rhs; public Symbol operator; ! protected JCAssignOp(Tag opcode, JCTree lhs, JCTree rhs, Symbol operator) { this.opcode = opcode; this.lhs = (JCExpression)lhs; this.rhs = (JCExpression)rhs; this.operator = operator; }
*** 1518,1540 **** @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitCompoundAssignment(this, d); } @Override ! public int getTag() { return opcode; } } /** * A unary operation. */ public static class JCUnary extends JCExpression implements UnaryTree { ! private int opcode; public JCExpression arg; public Symbol operator; ! protected JCUnary(int opcode, JCExpression arg) { this.opcode = opcode; this.arg = arg; } @Override public void accept(Visitor v) { v.visitUnary(this); } --- 1670,1696 ---- @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitCompoundAssignment(this, d); } @Override ! public Tag getTag() { return opcode; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(opcode)); + } } /** * A unary operation. */ public static class JCUnary extends JCExpression implements UnaryTree { ! private Tag opcode; public JCExpression arg; public Symbol operator; ! protected JCUnary(Tag opcode, JCExpression arg) { this.opcode = opcode; this.arg = arg; } @Override public void accept(Visitor v) { v.visitUnary(this); }
*** 1547,1574 **** @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitUnary(this, d); } @Override ! public int getTag() { return opcode; } ! public void setTag(int tag) { opcode = tag; } } /** * A binary operation. */ public static class JCBinary extends JCExpression implements BinaryTree { ! private int opcode; public JCExpression lhs; public JCExpression rhs; public Symbol operator; ! protected JCBinary(int opcode, JCExpression lhs, JCExpression rhs, Symbol operator) { this.opcode = opcode; this.lhs = lhs; --- 1703,1734 ---- @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitUnary(this, d); } @Override ! public Tag getTag() { return opcode; } ! public void setTag(Tag tag) { opcode = tag; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(opcode)); + } } /** * A binary operation. */ public static class JCBinary extends JCExpression implements BinaryTree { ! private Tag opcode; public JCExpression lhs; public JCExpression rhs; public Symbol operator; ! protected JCBinary(Tag opcode, JCExpression lhs, JCExpression rhs, Symbol operator) { this.opcode = opcode; this.lhs = lhs;
*** 1587,1599 **** @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitBinary(this, d); } @Override ! public int getTag() { return opcode; } } /** * A type cast. */ --- 1747,1763 ---- @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitBinary(this, d); } @Override ! public Tag getTag() { return opcode; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(opcode)); + } } /** * A type cast. */
*** 1613,1625 **** @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitTypeCast(this, d); } @Override ! public int getTag() { return TYPECAST; } } /** * A type test. */ --- 1777,1793 ---- @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitTypeCast(this, d); } @Override ! public Tag getTag() { return TYPECAST; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(TYPECAST)); + } } /** * A type test. */
*** 1639,1651 **** @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitInstanceOf(this, d); } @Override ! public int getTag() { return TYPETEST; } } /** * An array selection */ --- 1807,1823 ---- @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitInstanceOf(this, d); } @Override ! public Tag getTag() { return TYPETEST; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(TYPETEST)); + } } /** * An array selection */
*** 1665,1677 **** @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitArrayAccess(this, d); } @Override ! public int getTag() { return INDEXED; } } /** * Selects through packages and classes * @param selected selected Tree hierarchie --- 1837,1853 ---- @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitArrayAccess(this, d); } @Override ! public Tag getTag() { return INDEXED; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(INDEXED)); + } } /** * Selects through packages and classes * @param selected selected Tree hierarchie
*** 1696,1708 **** public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitMemberSelect(this, d); } public Name getIdentifier() { return name; } @Override ! public int getTag() { return SELECT; } } /** * An identifier * @param idname the name --- 1872,1888 ---- public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitMemberSelect(this, d); } public Name getIdentifier() { return name; } @Override ! public Tag getTag() { return SELECT; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(SELECT)); + } } /** * An identifier * @param idname the name
*** 1722,1734 **** public Name getName() { return name; } @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitIdentifier(this, d); } ! public int getTag() { return IDENT; } } /** * A constant value given literally. * @param value value representation --- 1902,1919 ---- public Name getName() { return name; } @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitIdentifier(this, d); } ! @Override ! public Tag getTag() { return IDENT; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(IDENT)); + } } /** * A constant value given literally. * @param value value representation
*** 1788,1800 **** public JCLiteral setType(Type type) { super.setType(type); return this; } @Override ! public int getTag() { return LITERAL; } } /** * Identifies a basic type. * @param tag the basic type id --- 1973,1989 ---- public JCLiteral setType(Type type) { super.setType(type); return this; } @Override ! public Tag getTag() { return LITERAL; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(LITERAL)); + } } /** * Identifies a basic type. * @param tag the basic type id
*** 1836,1848 **** @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitPrimitiveType(this, d); } @Override ! public int getTag() { return TYPEIDENT; } } /** * An array type, A[] */ --- 2025,2041 ---- @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitPrimitiveType(this, d); } @Override ! public Tag getTag() { return TYPEIDENT; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(TYPEIDENT)); + } } /** * An array type, A[] */
*** 1859,1871 **** @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitArrayType(this, d); } @Override ! public int getTag() { return TYPEARRAY; } } /** * A parameterized type, T<...> */ --- 2052,2068 ---- @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitArrayType(this, d); } @Override ! public Tag getTag() { return TYPEARRAY; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(TYPEARRAY)); + } } /** * A parameterized type, T<...> */
*** 1887,1899 **** @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitParameterizedType(this, d); } @Override ! public int getTag() { return TYPEAPPLY; } } /** * A union type, T1 | T2 | ... Tn (used in multicatch statements) */ --- 2084,2100 ---- @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitParameterizedType(this, d); } @Override ! public Tag getTag() { return TYPEAPPLY; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(TYPEAPPLY)); + } } /** * A union type, T1 | T2 | ... Tn (used in multicatch statements) */
*** 1915,1927 **** @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitUnionType(this, d); } @Override ! public int getTag() { return TYPEUNION; } } /** * A formal class parameter. * @param name name --- 2116,2132 ---- @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitUnionType(this, d); } @Override ! public Tag getTag() { return TYPEUNION; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(TYPEUNION)); + } } /** * A formal class parameter. * @param name name
*** 1945,1957 **** @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitTypeParameter(this, d); } @Override ! public int getTag() { return TYPEPARAMETER; } } public static class JCWildcard extends JCExpression implements WildcardTree { public TypeBoundKind kind; public JCTree inner; --- 2150,2166 ---- @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitTypeParameter(this, d); } @Override ! public Tag getTag() { return TYPEPARAMETER; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(TYPEPARAMETER)); + } } public static class JCWildcard extends JCExpression implements WildcardTree { public TypeBoundKind kind; public JCTree inner;
*** 1979,1991 **** @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitWildcard(this, d); } @Override ! public int getTag() { return WILDCARD; } } public static class TypeBoundKind extends JCTree { public BoundKind kind; protected TypeBoundKind(BoundKind kind) { --- 2188,2204 ---- @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitWildcard(this, d); } @Override ! public Tag getTag() { return WILDCARD; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(WILDCARD)); + } } public static class TypeBoundKind extends JCTree { public BoundKind kind; protected TypeBoundKind(BoundKind kind) {
*** 2000,2012 **** @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { throw new AssertionError("TypeBoundKind is not part of a public API"); } @Override ! public int getTag() { return TYPEBOUNDKIND; } } public static class JCAnnotation extends JCExpression implements AnnotationTree { public JCTree annotationType; public List<JCExpression> args; --- 2213,2229 ---- @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { throw new AssertionError("TypeBoundKind is not part of a public API"); } @Override ! public Tag getTag() { return TYPEBOUNDKIND; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(TYPEBOUNDKIND)); + } } public static class JCAnnotation extends JCExpression implements AnnotationTree { public JCTree annotationType; public List<JCExpression> args;
*** 2025,2037 **** @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitAnnotation(this, d); } @Override ! public int getTag() { return ANNOTATION; } } public static class JCModifiers extends JCTree implements com.sun.source.tree.ModifiersTree { public long flags; public List<JCAnnotation> annotations; --- 2242,2258 ---- @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitAnnotation(this, d); } @Override ! public Tag getTag() { return ANNOTATION; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(ANNOTATION)); + } } public static class JCModifiers extends JCTree implements com.sun.source.tree.ModifiersTree { public long flags; public List<JCAnnotation> annotations;
*** 2052,2064 **** @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitModifiers(this, d); } @Override ! public int getTag() { return MODIFIERS; } } public static class JCErroneous extends JCExpression implements com.sun.source.tree.ErroneousTree { public List<? extends JCTree> errs; --- 2273,2289 ---- @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitModifiers(this, d); } @Override ! public Tag getTag() { return MODIFIERS; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(MODIFIERS)); + } } public static class JCErroneous extends JCExpression implements com.sun.source.tree.ErroneousTree { public List<? extends JCTree> errs;
*** 2077,2089 **** @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitErroneous(this, d); } @Override ! public int getTag() { return ERRONEOUS; } } /** (let int x = 3; in x+2) */ public static class LetExpr extends JCExpression { public List<JCVariableDecl> defs; --- 2302,2318 ---- @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { return v.visitErroneous(this, d); } @Override ! public Tag getTag() { return ERRONEOUS; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(ERRONEOUS)); + } } /** (let int x = 3; in x+2) */ public static class LetExpr extends JCExpression { public List<JCVariableDecl> defs;
*** 2101,2113 **** @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { throw new AssertionError("LetExpr is not part of a public API"); } @Override ! public int getTag() { return LETEXPR; } } /** An interface for tree factories */ public interface Factory { --- 2330,2346 ---- @Override public <R,D> R accept(TreeVisitor<R,D> v, D d) { throw new AssertionError("LetExpr is not part of a public API"); } @Override ! public Tag getTag() { return LETEXPR; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(LETEXPR)); + } } /** An interface for tree factories */ public interface Factory {
*** 2173,2185 **** JCNewArray NewArray(JCExpression elemtype, List<JCExpression> dims, List<JCExpression> elems); JCParens Parens(JCExpression expr); JCAssign Assign(JCExpression lhs, JCExpression rhs); ! JCAssignOp Assignop(int opcode, JCTree lhs, JCTree rhs); ! JCUnary Unary(int opcode, JCExpression arg); ! JCBinary Binary(int opcode, JCExpression lhs, JCExpression rhs); JCTypeCast TypeCast(JCTree expr, JCExpression type); JCInstanceOf TypeTest(JCExpression expr, JCTree clazz); JCArrayAccess Indexed(JCExpression indexed, JCExpression index); JCFieldAccess Select(JCExpression selected, Name selector); JCIdent Ident(Name idname); --- 2406,2418 ---- JCNewArray NewArray(JCExpression elemtype, List<JCExpression> dims, List<JCExpression> elems); JCParens Parens(JCExpression expr); JCAssign Assign(JCExpression lhs, JCExpression rhs); ! JCAssignOp Assignop(Tag opcode, JCTree lhs, JCTree rhs); ! JCUnary Unary(Tag opcode, JCExpression arg); ! JCBinary Binary(Tag opcode, JCExpression lhs, JCExpression rhs); JCTypeCast TypeCast(JCTree expr, JCExpression type); JCInstanceOf TypeTest(JCExpression expr, JCTree clazz); JCArrayAccess Indexed(JCExpression indexed, JCExpression index); JCFieldAccess Select(JCExpression selected, Name selector); JCIdent Ident(Name idname);