diff options
Diffstat (limited to 'src/main/javassist/compiler/ast')
23 files changed, 119 insertions, 23 deletions
diff --git a/src/main/javassist/compiler/ast/ASTList.java b/src/main/javassist/compiler/ast/ASTList.java index cf398966..67fbd97a 100644 --- a/src/main/javassist/compiler/ast/ASTList.java +++ b/src/main/javassist/compiler/ast/ASTList.java @@ -23,6 +23,8 @@ import javassist.compiler.CompileError; * The right subtree must be an ASTList object or null. */ public class ASTList extends ASTree { + /** default serialVersionUID */ + private static final long serialVersionUID = 1L; private ASTree left; private ASTList right; @@ -40,12 +42,16 @@ public class ASTList extends ASTree { return new ASTList(e1, new ASTList(e2, new ASTList(e3))); } + @Override public ASTree getLeft() { return left; } + @Override public ASTree getRight() { return right; } + @Override public void setLeft(ASTree _left) { left = _left; } + @Override public void setRight(ASTree _right) { right = (ASTList)_right; } @@ -68,8 +74,10 @@ public class ASTList extends ASTree { right = _tail; } + @Override public void accept(Visitor v) throws CompileError { v.atASTList(this); } + @Override public String toString() { StringBuffer sbuf = new StringBuffer(); sbuf.append("(<"); @@ -148,13 +156,11 @@ public class ASTList extends ASTree { public static ASTList concat(ASTList a, ASTList b) { if (a == null) return b; - else { - ASTList list = a; - while (list.right != null) - list = list.right; + ASTList list = a; + while (list.right != null) + list = list.right; - list.right = b; - return a; - } + list.right = b; + return a; } } diff --git a/src/main/javassist/compiler/ast/ASTree.java b/src/main/javassist/compiler/ast/ASTree.java index aaad0732..7fd05fd4 100644 --- a/src/main/javassist/compiler/ast/ASTree.java +++ b/src/main/javassist/compiler/ast/ASTree.java @@ -17,6 +17,7 @@ package javassist.compiler.ast; import java.io.Serializable; + import javassist.compiler.CompileError; /** @@ -25,6 +26,9 @@ import javassist.compiler.CompileError; * and <code>getRight()</code> returns null. */ public abstract class ASTree implements Serializable { + /** default serialVersionUID */ + private static final long serialVersionUID = 1L; + public ASTree getLeft() { return null; } public ASTree getRight() { return null; } @@ -40,6 +44,7 @@ public abstract class ASTree implements Serializable { */ public abstract void accept(Visitor v) throws CompileError; + @Override public String toString() { StringBuffer sbuf = new StringBuffer(); sbuf.append('<'); diff --git a/src/main/javassist/compiler/ast/ArrayInit.java b/src/main/javassist/compiler/ast/ArrayInit.java index 26838fca..f992f426 100644 --- a/src/main/javassist/compiler/ast/ArrayInit.java +++ b/src/main/javassist/compiler/ast/ArrayInit.java @@ -22,11 +22,16 @@ import javassist.compiler.CompileError; * Array initializer such as <code>{ 1, 2, 3 }</code>. */ public class ArrayInit extends ASTList { + /** default serialVersionUID */ + private static final long serialVersionUID = 1L; + public ArrayInit(ASTree firstElement) { super(firstElement); } + @Override public void accept(Visitor v) throws CompileError { v.atArrayInit(this); } + @Override public String getTag() { return "array"; } } diff --git a/src/main/javassist/compiler/ast/AssignExpr.java b/src/main/javassist/compiler/ast/AssignExpr.java index 060a5bd3..a5e1857d 100644 --- a/src/main/javassist/compiler/ast/AssignExpr.java +++ b/src/main/javassist/compiler/ast/AssignExpr.java @@ -26,6 +26,9 @@ public class AssignExpr extends Expr { * =, %=, &=, *=, +=, -=, /=, ^=, |=, <<=, >>=, >>>= */ + /** default serialVersionUID */ + private static final long serialVersionUID = 1L; + private AssignExpr(int op, ASTree _head, ASTList _tail) { super(op, _head, _tail); } @@ -35,6 +38,7 @@ public class AssignExpr extends Expr { return new AssignExpr(op, oprand1, new ASTList(oprand2)); } + @Override public void accept(Visitor v) throws CompileError { v.atAssignExpr(this); } diff --git a/src/main/javassist/compiler/ast/BinExpr.java b/src/main/javassist/compiler/ast/BinExpr.java index 3b9f8ea2..9630ada9 100644 --- a/src/main/javassist/compiler/ast/BinExpr.java +++ b/src/main/javassist/compiler/ast/BinExpr.java @@ -30,6 +30,9 @@ public class BinExpr extends Expr { * <<, >>, >>>, +, -, *, /, % */ + /** default serialVersionUID */ + private static final long serialVersionUID = 1L; + private BinExpr(int op, ASTree _head, ASTList _tail) { super(op, _head, _tail); } @@ -38,5 +41,6 @@ public class BinExpr extends Expr { return new BinExpr(op, oprand1, new ASTList(oprand2)); } + @Override public void accept(Visitor v) throws CompileError { v.atBinExpr(this); } } diff --git a/src/main/javassist/compiler/ast/CallExpr.java b/src/main/javassist/compiler/ast/CallExpr.java index 5e3dd434..395915ed 100644 --- a/src/main/javassist/compiler/ast/CallExpr.java +++ b/src/main/javassist/compiler/ast/CallExpr.java @@ -17,13 +17,15 @@ package javassist.compiler.ast; import javassist.compiler.CompileError; -import javassist.compiler.TokenId; import javassist.compiler.MemberResolver; +import javassist.compiler.TokenId; /** * Method call expression. */ public class CallExpr extends Expr { + /** default serialVersionUID */ + private static final long serialVersionUID = 1L; private MemberResolver.Method method; // cached result of lookupMethod() private CallExpr(ASTree _head, ASTList _tail) { @@ -43,5 +45,6 @@ public class CallExpr extends Expr { return new CallExpr(target, new ASTList(args)); } + @Override public void accept(Visitor v) throws CompileError { v.atCallExpr(this); } } diff --git a/src/main/javassist/compiler/ast/CastExpr.java b/src/main/javassist/compiler/ast/CastExpr.java index 7d4f4d80..903e5bbd 100644 --- a/src/main/javassist/compiler/ast/CastExpr.java +++ b/src/main/javassist/compiler/ast/CastExpr.java @@ -16,13 +16,15 @@ package javassist.compiler.ast; -import javassist.compiler.TokenId; import javassist.compiler.CompileError; +import javassist.compiler.TokenId; /** * Cast expression. */ public class CastExpr extends ASTList implements TokenId { + /** default serialVersionUID */ + private static final long serialVersionUID = 1L; protected int castType; protected int arrayDim; @@ -50,7 +52,9 @@ public class CastExpr extends ASTList implements TokenId { public void setOprand(ASTree t) { getRight().setLeft(t); } + @Override public String getTag() { return "cast:" + castType + ":" + arrayDim; } + @Override public void accept(Visitor v) throws CompileError { v.atCastExpr(this); } } diff --git a/src/main/javassist/compiler/ast/CondExpr.java b/src/main/javassist/compiler/ast/CondExpr.java index 8645736f..46435012 100644 --- a/src/main/javassist/compiler/ast/CondExpr.java +++ b/src/main/javassist/compiler/ast/CondExpr.java @@ -22,6 +22,9 @@ import javassist.compiler.CompileError; * Conditional expression. */ public class CondExpr extends ASTList { + /** default serialVersionUID */ + private static final long serialVersionUID = 1L; + public CondExpr(ASTree cond, ASTree thenp, ASTree elsep) { super(cond, new ASTList(thenp, new ASTList(elsep))); } @@ -38,7 +41,9 @@ public class CondExpr extends ASTList { public void setElse(ASTree t) { tail().tail().setHead(t); } + @Override public String getTag() { return "?:"; } + @Override public void accept(Visitor v) throws CompileError { v.atCondExpr(this); } } diff --git a/src/main/javassist/compiler/ast/Declarator.java b/src/main/javassist/compiler/ast/Declarator.java index 5f14ac57..24170db0 100644 --- a/src/main/javassist/compiler/ast/Declarator.java +++ b/src/main/javassist/compiler/ast/Declarator.java @@ -16,13 +16,15 @@ package javassist.compiler.ast; -import javassist.compiler.TokenId; import javassist.compiler.CompileError; +import javassist.compiler.TokenId; /** * Variable declarator. */ public class Declarator extends ASTList implements TokenId { + /** default serialVersionUID */ + private static final long serialVersionUID = 1L; protected int varType; protected int arrayDim; protected int localVar; @@ -86,16 +88,17 @@ public class Declarator extends ASTList implements TokenId { ASTList t = tail(); if (t != null) return t.head(); - else - return null; + return null; } public void setLocalVar(int n) { localVar = n; } public int getLocalVar() { return localVar; } + @Override public String getTag() { return "decl"; } + @Override public void accept(Visitor v) throws CompileError { v.atDeclarator(this); } diff --git a/src/main/javassist/compiler/ast/DoubleConst.java b/src/main/javassist/compiler/ast/DoubleConst.java index 23ff0b65..f8d0afde 100644 --- a/src/main/javassist/compiler/ast/DoubleConst.java +++ b/src/main/javassist/compiler/ast/DoubleConst.java @@ -23,6 +23,8 @@ import javassist.compiler.TokenId; * Double constant. */ public class DoubleConst extends ASTree { + /** default serialVersionUID */ + private static final long serialVersionUID = 1L; protected double value; protected int type; @@ -36,8 +38,10 @@ public class DoubleConst extends ASTree { */ public int getType() { return type; } + @Override public String toString() { return Double.toString(value); } + @Override public void accept(Visitor v) throws CompileError { v.atDoubleConst(this); } @@ -63,7 +67,7 @@ public class DoubleConst extends ASTree { } private DoubleConst compute0(int op, IntConst right) { - return compute(op, this.value, (double)right.value, this.type); + return compute(op, this.value, right.value, this.type); } private static DoubleConst compute(int op, double value1, double value2, diff --git a/src/main/javassist/compiler/ast/Expr.java b/src/main/javassist/compiler/ast/Expr.java index bc798bbc..ed5cb60b 100644 --- a/src/main/javassist/compiler/ast/Expr.java +++ b/src/main/javassist/compiler/ast/Expr.java @@ -16,8 +16,8 @@ package javassist.compiler.ast; -import javassist.compiler.TokenId; import javassist.compiler.CompileError; +import javassist.compiler.TokenId; /** * Expression. @@ -29,6 +29,8 @@ public class Expr extends ASTList implements TokenId { * Otherwise, the object should be an instance of a subclass. */ + /** default serialVersionUID */ + private static final long serialVersionUID = 1L; protected int operatorId; Expr(int op, ASTree _head, ASTList _tail) { @@ -65,6 +67,7 @@ public class Expr extends ASTList implements TokenId { getRight().setLeft(expr); } + @Override public void accept(Visitor v) throws CompileError { v.atExpr(this); } public String getName() { @@ -79,6 +82,7 @@ public class Expr extends ASTList implements TokenId { return String.valueOf(id); } + @Override protected String getTag() { return "op:" + getName(); } diff --git a/src/main/javassist/compiler/ast/FieldDecl.java b/src/main/javassist/compiler/ast/FieldDecl.java index 82d4856c..e2a066e9 100644 --- a/src/main/javassist/compiler/ast/FieldDecl.java +++ b/src/main/javassist/compiler/ast/FieldDecl.java @@ -19,6 +19,9 @@ package javassist.compiler.ast; import javassist.compiler.CompileError; public class FieldDecl extends ASTList { + /** default serialVersionUID */ + private static final long serialVersionUID = 1L; + public FieldDecl(ASTree _head, ASTList _tail) { super(_head, _tail); } @@ -27,8 +30,9 @@ public class FieldDecl extends ASTList { public Declarator getDeclarator() { return (Declarator)tail().head(); } - public ASTree getInit() { return (ASTree)sublist(2).head(); } + public ASTree getInit() { return sublist(2).head(); } + @Override public void accept(Visitor v) throws CompileError { v.atFieldDecl(this); } diff --git a/src/main/javassist/compiler/ast/InstanceOfExpr.java b/src/main/javassist/compiler/ast/InstanceOfExpr.java index cddf0317..ddf07bd2 100644 --- a/src/main/javassist/compiler/ast/InstanceOfExpr.java +++ b/src/main/javassist/compiler/ast/InstanceOfExpr.java @@ -22,6 +22,9 @@ import javassist.compiler.CompileError; * Instanceof expression. */ public class InstanceOfExpr extends CastExpr { + /** default serialVersionUID */ + private static final long serialVersionUID = 1L; + public InstanceOfExpr(ASTList className, int dim, ASTree expr) { super(className, dim, expr); } @@ -30,10 +33,12 @@ public class InstanceOfExpr extends CastExpr { super(type, dim, expr); } + @Override public String getTag() { return "instanceof:" + castType + ":" + arrayDim; } + @Override public void accept(Visitor v) throws CompileError { v.atInstanceOfExpr(this); } diff --git a/src/main/javassist/compiler/ast/IntConst.java b/src/main/javassist/compiler/ast/IntConst.java index 90feeb58..7040b0c9 100644 --- a/src/main/javassist/compiler/ast/IntConst.java +++ b/src/main/javassist/compiler/ast/IntConst.java @@ -23,6 +23,8 @@ import javassist.compiler.TokenId; * Integer constant. */ public class IntConst extends ASTree { + /** default serialVersionUID */ + private static final long serialVersionUID = 1L; protected long value; protected int type; @@ -36,8 +38,10 @@ public class IntConst extends ASTree { */ public int getType() { return type; } + @Override public String toString() { return Long.toString(value); } + @Override public void accept(Visitor v) throws CompileError { v.atIntConst(this); } @@ -111,7 +115,7 @@ public class IntConst extends ASTree { } private DoubleConst compute0(int op, DoubleConst right) { - double value1 = (double)this.value; + double value1 = this.value; double value2 = right.value; double newValue; switch (op) { diff --git a/src/main/javassist/compiler/ast/Keyword.java b/src/main/javassist/compiler/ast/Keyword.java index 8127dc1e..b509375c 100644 --- a/src/main/javassist/compiler/ast/Keyword.java +++ b/src/main/javassist/compiler/ast/Keyword.java @@ -22,6 +22,8 @@ import javassist.compiler.CompileError; * Keyword. */ public class Keyword extends ASTree { + /** default serialVersionUID */ + private static final long serialVersionUID = 1L; protected int tokenId; public Keyword(int token) { @@ -30,7 +32,9 @@ public class Keyword extends ASTree { public int get() { return tokenId; } + @Override public String toString() { return "id:" + tokenId; } + @Override public void accept(Visitor v) throws CompileError { v.atKeyword(this); } } diff --git a/src/main/javassist/compiler/ast/Member.java b/src/main/javassist/compiler/ast/Member.java index f77de616..192c9ef3 100644 --- a/src/main/javassist/compiler/ast/Member.java +++ b/src/main/javassist/compiler/ast/Member.java @@ -16,13 +16,15 @@ package javassist.compiler.ast; -import javassist.compiler.CompileError; import javassist.CtField; +import javassist.compiler.CompileError; /** * Member name. */ public class Member extends Symbol { + /** default serialVersionUID */ + private static final long serialVersionUID = 1L; // cache maintained by fieldAccess() in TypeChecker. // this is used to obtain the value of a static final field. private CtField field; @@ -36,5 +38,6 @@ public class Member extends Symbol { public CtField getField() { return field; } + @Override public void accept(Visitor v) throws CompileError { v.atMember(this); } } diff --git a/src/main/javassist/compiler/ast/MethodDecl.java b/src/main/javassist/compiler/ast/MethodDecl.java index 0a7d828f..d96e3d4d 100644 --- a/src/main/javassist/compiler/ast/MethodDecl.java +++ b/src/main/javassist/compiler/ast/MethodDecl.java @@ -19,6 +19,8 @@ package javassist.compiler.ast; import javassist.compiler.CompileError; public class MethodDecl extends ASTList { + /** default serialVersionUID */ + private static final long serialVersionUID = 1L; public static final String initName = "<init>"; public MethodDecl(ASTree _head, ASTList _tail) { @@ -40,6 +42,7 @@ public class MethodDecl extends ASTList { public Stmnt getBody() { return (Stmnt)sublist(4).head(); } + @Override public void accept(Visitor v) throws CompileError { v.atMethodDecl(this); } diff --git a/src/main/javassist/compiler/ast/NewExpr.java b/src/main/javassist/compiler/ast/NewExpr.java index b1413f60..44b264c0 100644 --- a/src/main/javassist/compiler/ast/NewExpr.java +++ b/src/main/javassist/compiler/ast/NewExpr.java @@ -16,13 +16,15 @@ package javassist.compiler.ast; -import javassist.compiler.TokenId; import javassist.compiler.CompileError; +import javassist.compiler.TokenId; /** * New Expression. */ public class NewExpr extends ASTList implements TokenId { + /** default serialVersionUID */ + private static final long serialVersionUID = 1L; protected boolean newArray; protected int arrayType; @@ -66,12 +68,13 @@ public class NewExpr extends ASTList implements TokenId { ASTree t = getRight().getRight(); if (t == null) return null; - else - return (ArrayInit)t.getLeft(); + return (ArrayInit)t.getLeft(); } + @Override public void accept(Visitor v) throws CompileError { v.atNewExpr(this); } + @Override protected String getTag() { return newArray ? "new[]" : "new"; } diff --git a/src/main/javassist/compiler/ast/Pair.java b/src/main/javassist/compiler/ast/Pair.java index b050dd28..840c1145 100644 --- a/src/main/javassist/compiler/ast/Pair.java +++ b/src/main/javassist/compiler/ast/Pair.java @@ -23,6 +23,8 @@ import javassist.compiler.CompileError; * overriding abstract methods in ASTree. */ public class Pair extends ASTree { + /** default serialVersionUID */ + private static final long serialVersionUID = 1L; protected ASTree left, right; public Pair(ASTree _left, ASTree _right) { @@ -30,8 +32,10 @@ public class Pair extends ASTree { right = _right; } + @Override public void accept(Visitor v) throws CompileError { v.atPair(this); } + @Override public String toString() { StringBuffer sbuf = new StringBuffer(); sbuf.append("(<Pair> "); @@ -42,11 +46,15 @@ public class Pair extends ASTree { return sbuf.toString(); } + @Override public ASTree getLeft() { return left; } + @Override public ASTree getRight() { return right; } + @Override public void setLeft(ASTree _left) { left = _left; } + @Override public void setRight(ASTree _right) { right = _right; } } diff --git a/src/main/javassist/compiler/ast/Stmnt.java b/src/main/javassist/compiler/ast/Stmnt.java index 251f66c3..c5aa5df3 100644 --- a/src/main/javassist/compiler/ast/Stmnt.java +++ b/src/main/javassist/compiler/ast/Stmnt.java @@ -16,13 +16,15 @@ package javassist.compiler.ast; -import javassist.compiler.TokenId; import javassist.compiler.CompileError; +import javassist.compiler.TokenId; /** * Statement. */ public class Stmnt extends ASTList implements TokenId { + /** default serialVersionUID */ + private static final long serialVersionUID = 1L; protected int operatorId; public Stmnt(int op, ASTree _head, ASTList _tail) { @@ -47,14 +49,15 @@ public class Stmnt extends ASTList implements TokenId { return new Stmnt(op, op1, new ASTList(op2, new ASTList(op3))); } + @Override public void accept(Visitor v) throws CompileError { v.atStmnt(this); } public int getOperator() { return operatorId; } + @Override protected String getTag() { if (operatorId < 128) return "stmnt:" + (char)operatorId; - else - return "stmnt:" + operatorId; + return "stmnt:" + operatorId; } } diff --git a/src/main/javassist/compiler/ast/StringL.java b/src/main/javassist/compiler/ast/StringL.java index f52186e5..7c7e00c3 100644 --- a/src/main/javassist/compiler/ast/StringL.java +++ b/src/main/javassist/compiler/ast/StringL.java @@ -22,6 +22,8 @@ import javassist.compiler.CompileError; * String literal. */ public class StringL extends ASTree { + /** default serialVersionUID */ + private static final long serialVersionUID = 1L; protected String text; public StringL(String t) { @@ -30,7 +32,9 @@ public class StringL extends ASTree { public String get() { return text; } + @Override public String toString() { return "\"" + text + "\""; } + @Override public void accept(Visitor v) throws CompileError { v.atStringL(this); } } diff --git a/src/main/javassist/compiler/ast/Symbol.java b/src/main/javassist/compiler/ast/Symbol.java index f71d0f91..2b66207a 100644 --- a/src/main/javassist/compiler/ast/Symbol.java +++ b/src/main/javassist/compiler/ast/Symbol.java @@ -22,6 +22,8 @@ import javassist.compiler.CompileError; * Identifier. */ public class Symbol extends ASTree { + /** default serialVersionUID */ + private static final long serialVersionUID = 1L; protected String identifier; public Symbol(String sym) { @@ -30,7 +32,9 @@ public class Symbol extends ASTree { public String get() { return identifier; } + @Override public String toString() { return identifier; } + @Override public void accept(Visitor v) throws CompileError { v.atSymbol(this); } } diff --git a/src/main/javassist/compiler/ast/Variable.java b/src/main/javassist/compiler/ast/Variable.java index 88a31daa..c9224a7a 100644 --- a/src/main/javassist/compiler/ast/Variable.java +++ b/src/main/javassist/compiler/ast/Variable.java @@ -22,6 +22,8 @@ import javassist.compiler.CompileError; * Variable. */ public class Variable extends Symbol { + /** default serialVersionUID */ + private static final long serialVersionUID = 1L; protected Declarator declarator; public Variable(String sym, Declarator d) { @@ -31,9 +33,11 @@ public class Variable extends Symbol { public Declarator getDeclarator() { return declarator; } + @Override public String toString() { return identifier + ":" + declarator.getType(); } + @Override public void accept(Visitor v) throws CompileError { v.atVariable(this); } } |