--- old/src/share/classes/com/sun/tools/javac/tree/JCTree.java 2011-11-02 11:34:04.297646822 -0700 +++ new/src/share/classes/com/sun/tools/javac/tree/JCTree.java 2011-11-02 11:34:04.229506481 -0700 @@ -42,6 +42,7 @@ 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 @@ -79,253 +80,271 @@ 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; + 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. */ @@ -337,7 +356,11 @@ /* The tag of this node -- one of the constants declared above. */ - public abstract int getTag(); + 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 @@ -464,10 +487,9 @@ public List getImports() { ListBuffer imports = new ListBuffer(); for (JCTree tree : defs) { - int tag = tree.getTag(); - if (tag == IMPORT) + if (tree.hasTag(IMPORT)) imports.append((JCImport)tree); - else if (tag != SKIP) + else if (!tree.hasTag(SKIP)) break; } return imports.toList(); @@ -482,7 +504,7 @@ public List getTypeDecls() { List typeDefs; for (typeDefs = defs; !typeDefs.isEmpty(); typeDefs = typeDefs.tail) - if (typeDefs.head.getTag() != IMPORT) + if (!typeDefs.head.hasTag(IMPORT)) break; return typeDefs; } @@ -492,9 +514,14 @@ } @Override - public int getTag() { + public Tag getTag() { return TOPLEVEL; } + + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(TOPLEVEL)); + } } /** @@ -521,9 +548,14 @@ } @Override - public int getTag() { + public Tag getTag() { return IMPORT; } + + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(IMPORT)); + } } public static abstract class JCStatement extends JCTree implements StatementTree { @@ -618,9 +650,14 @@ } @Override - public int getTag() { + public Tag getTag() { return CLASSDEF; } + + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(CLASSDEF)); + } } /** @@ -690,9 +727,14 @@ } @Override - public int getTag() { + public Tag getTag() { return METHODDEF; } + + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(METHODDEF)); + } } /** @@ -736,9 +778,14 @@ } @Override - public int getTag() { + public Tag getTag() { return VARDEF; } + + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(VARDEF)); + } } /** @@ -757,9 +804,14 @@ } @Override - public int getTag() { + public Tag getTag() { return SKIP; } + + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(SKIP)); + } } /** @@ -790,9 +842,14 @@ } @Override - public int getTag() { + public Tag getTag() { return BLOCK; } + + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(BLOCK)); + } } /** @@ -817,9 +874,14 @@ } @Override - public int getTag() { + public Tag getTag() { return DOLOOP; } + + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(DOLOOP)); + } } /** @@ -844,9 +906,14 @@ } @Override - public int getTag() { + public Tag getTag() { return WHILELOOP; } + + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(WHILELOOP)); + } } /** @@ -885,9 +952,14 @@ } @Override - public int getTag() { + public Tag getTag() { return FORLOOP; } + + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(FORLOOP)); + } } /** @@ -914,9 +986,13 @@ return v.visitEnhancedForLoop(this, d); } @Override - public int getTag() { + public Tag getTag() { return FOREACHLOOP; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(FOREACHLOOP)); + } } /** @@ -939,9 +1015,13 @@ return v.visitLabeledStatement(this, d); } @Override - public int getTag() { + public Tag getTag() { return LABELLED; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(LABELLED)); + } } /** @@ -965,9 +1045,13 @@ return v.visitSwitch(this, d); } @Override - public int getTag() { + public Tag getTag() { return SWITCH; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(SWITCH)); + } } /** @@ -991,9 +1075,13 @@ return v.visitCase(this, d); } @Override - public int getTag() { + public Tag getTag() { return CASE; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(CASE)); + } } /** @@ -1017,9 +1105,13 @@ return v.visitSynchronized(this, d); } @Override - public int getTag() { + public Tag getTag() { return SYNCHRONIZED; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(SYNCHRONIZED)); + } } /** @@ -1057,9 +1149,13 @@ return resources; } @Override - public int getTag() { + public Tag getTag() { return TRY; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(TRY)); + } } /** @@ -1083,9 +1179,13 @@ return v.visitCatch(this, d); } @Override - public int getTag() { + public Tag getTag() { return CATCH; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(CATCH)); + } } /** @@ -1115,9 +1215,13 @@ return v.visitConditionalExpression(this, d); } @Override - public int getTag() { + public Tag getTag() { return CONDEXPR; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(CONDEXPR)); + } } /** @@ -1147,9 +1251,13 @@ return v.visitIf(this, d); } @Override - public int getTag() { + public Tag getTag() { return IF; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(IF)); + } } /** @@ -1172,9 +1280,13 @@ return v.visitExpressionStatement(this, d); } @Override - public int getTag() { + 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 @@ -1212,9 +1324,13 @@ return v.visitBreak(this, d); } @Override - public int getTag() { + public Tag getTag() { return BREAK; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(BREAK)); + } } /** @@ -1237,9 +1353,13 @@ return v.visitContinue(this, d); } @Override - public int getTag() { + public Tag getTag() { return CONTINUE; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(CONTINUE)); + } } /** @@ -1260,9 +1380,13 @@ return v.visitReturn(this, d); } @Override - public int getTag() { + public Tag getTag() { return RETURN; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(RETURN)); + } } /** @@ -1283,9 +1407,13 @@ return v.visitThrow(this, d); } @Override - public int getTag() { + public Tag getTag() { return THROW; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(THROW)); + } } /** @@ -1309,9 +1437,13 @@ return v.visitAssert(this, d); } @Override - public int getTag() { + public Tag getTag() { return ASSERT; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(ASSERT)); + } } /** @@ -1352,9 +1484,13 @@ return this; } @Override - public int getTag() { + public Tag getTag() { return(APPLY); } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(APPLY)); + } } /** @@ -1402,9 +1538,13 @@ return v.visitNewClass(this, d); } @Override - public int getTag() { + public Tag getTag() { return NEWCLASS; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(NEWCLASS)); + } } /** @@ -1438,9 +1578,13 @@ return v.visitNewArray(this, d); } @Override - public int getTag() { + public Tag getTag() { return NEWARRAY; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(NEWARRAY)); + } } /** @@ -1461,9 +1605,13 @@ return v.visitParenthesized(this, d); } @Override - public int getTag() { + public Tag getTag() { return PARENS; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(PARENS)); + } } /** @@ -1487,20 +1635,24 @@ return v.visitAssignment(this, d); } @Override - public int getTag() { + 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 int opcode; + private Tag opcode; public JCExpression lhs; public JCExpression rhs; public Symbol operator; - protected JCAssignOp(int opcode, JCTree lhs, JCTree rhs, Symbol operator) { + protected JCAssignOp(Tag opcode, JCTree lhs, JCTree rhs, Symbol operator) { this.opcode = opcode; this.lhs = (JCExpression)lhs; this.rhs = (JCExpression)rhs; @@ -1520,19 +1672,23 @@ return v.visitCompoundAssignment(this, d); } @Override - public int getTag() { + 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 int opcode; + private Tag opcode; public JCExpression arg; public Symbol operator; - protected JCUnary(int opcode, JCExpression arg) { + protected JCUnary(Tag opcode, JCExpression arg) { this.opcode = opcode; this.arg = arg; } @@ -1549,24 +1705,28 @@ return v.visitUnary(this, d); } @Override - public int getTag() { + public Tag getTag() { return opcode; } - public void setTag(int tag) { + 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 int opcode; + private Tag opcode; public JCExpression lhs; public JCExpression rhs; public Symbol operator; - protected JCBinary(int opcode, + protected JCBinary(Tag opcode, JCExpression lhs, JCExpression rhs, Symbol operator) { @@ -1589,9 +1749,13 @@ return v.visitBinary(this, d); } @Override - public int getTag() { + public Tag getTag() { return opcode; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(opcode)); + } } /** @@ -1615,9 +1779,13 @@ return v.visitTypeCast(this, d); } @Override - public int getTag() { + public Tag getTag() { return TYPECAST; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(TYPECAST)); + } } /** @@ -1641,9 +1809,13 @@ return v.visitInstanceOf(this, d); } @Override - public int getTag() { + public Tag getTag() { return TYPETEST; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(TYPETEST)); + } } /** @@ -1667,9 +1839,13 @@ return v.visitArrayAccess(this, d); } @Override - public int getTag() { + public Tag getTag() { return INDEXED; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(INDEXED)); + } } /** @@ -1698,9 +1874,13 @@ } public Name getIdentifier() { return name; } @Override - public int getTag() { + public Tag getTag() { return SELECT; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(SELECT)); + } } /** @@ -1724,9 +1904,14 @@ public R accept(TreeVisitor v, D d) { return v.visitIdentifier(this, d); } - public int getTag() { + @Override + public Tag getTag() { return IDENT; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(IDENT)); + } } /** @@ -1790,9 +1975,13 @@ return this; } @Override - public int getTag() { + public Tag getTag() { return LITERAL; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(LITERAL)); + } } /** @@ -1838,9 +2027,13 @@ return v.visitPrimitiveType(this, d); } @Override - public int getTag() { + public Tag getTag() { return TYPEIDENT; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(TYPEIDENT)); + } } /** @@ -1861,9 +2054,13 @@ return v.visitArrayType(this, d); } @Override - public int getTag() { + public Tag getTag() { return TYPEARRAY; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(TYPEARRAY)); + } } /** @@ -1889,9 +2086,13 @@ return v.visitParameterizedType(this, d); } @Override - public int getTag() { + public Tag getTag() { return TYPEAPPLY; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(TYPEAPPLY)); + } } /** @@ -1917,9 +2118,13 @@ return v.visitUnionType(this, d); } @Override - public int getTag() { + public Tag getTag() { return TYPEUNION; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(TYPEUNION)); + } } /** @@ -1947,9 +2152,13 @@ return v.visitTypeParameter(this, d); } @Override - public int getTag() { + public Tag getTag() { return TYPEPARAMETER; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(TYPEPARAMETER)); + } } public static class JCWildcard extends JCExpression implements WildcardTree { @@ -1981,9 +2190,13 @@ return v.visitWildcard(this, d); } @Override - public int getTag() { + public Tag getTag() { return WILDCARD; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(WILDCARD)); + } } public static class TypeBoundKind extends JCTree { @@ -2002,9 +2215,13 @@ throw new AssertionError("TypeBoundKind is not part of a public API"); } @Override - public int getTag() { + public Tag getTag() { return TYPEBOUNDKIND; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(TYPEBOUNDKIND)); + } } public static class JCAnnotation extends JCExpression implements AnnotationTree { @@ -2027,9 +2244,13 @@ return v.visitAnnotation(this, d); } @Override - public int getTag() { + 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 { @@ -2054,9 +2275,13 @@ return v.visitModifiers(this, d); } @Override - public int getTag() { + public Tag getTag() { return MODIFIERS; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(MODIFIERS)); + } } public static class JCErroneous extends JCExpression @@ -2079,9 +2304,13 @@ return v.visitErroneous(this, d); } @Override - public int getTag() { + public Tag getTag() { return ERRONEOUS; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(ERRONEOUS)); + } } /** (let int x = 3; in x+2) */ @@ -2103,9 +2332,13 @@ throw new AssertionError("LetExpr is not part of a public API"); } @Override - public int getTag() { + public Tag getTag() { return LETEXPR; } + @Override + public boolean hasTag(Tag tag){ + return (tag.equals(LETEXPR)); + } } /** An interface for tree factories @@ -2175,9 +2408,9 @@ List 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); + 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);