📄 tree.java
字号:
public void accept(Visitor v) {
v.visitAssignop(this);
}
}
/**
* A unary operation.
*/
public static class Unary extends Tree {
public Tree arg;
public Symbol operator;
public Unary(int opcode, Tree arg, Symbol operator) {
super(opcode);
this.arg = arg;
this.operator = operator;
}
public void accept(Visitor v) {
v.visitUnary(this);
}
}
/**
* A binary operation.
*/
public static class Binary extends Tree {
public Tree lhs;
public Tree rhs;
public Symbol operator;
public Binary(int opcode, Tree lhs, Tree rhs, Symbol operator) {
super(opcode);
this.lhs = lhs;
this.rhs = rhs;
this.operator = operator;
}
public void accept(Visitor v) {
v.visitBinary(this);
}
}
/**
* A type cast.
*/
public static class TypeCast extends Tree {
public Tree clazz;
public Tree expr;
public TypeCast(Tree clazz, Tree expr) {
super(TYPECAST);
this.clazz = clazz;
this.expr = expr;
}
public void accept(Visitor v) {
v.visitTypeCast(this);
}
}
/**
* A type test.
*/
public static class TypeTest extends Tree {
public Tree expr;
public Tree clazz;
public TypeTest(Tree expr, Tree clazz) {
super(TYPETEST);
this.expr = expr;
this.clazz = clazz;
}
public void accept(Visitor v) {
v.visitTypeTest(this);
}
}
/**
* An array selection
*/
public static class Indexed extends Tree {
public Tree indexed;
public Tree index;
public Indexed(Tree indexed, Tree index) {
super(INDEXED);
this.indexed = indexed;
this.index = index;
}
public void accept(Visitor v) {
v.visitIndexed(this);
}
}
/**
* Selects through packages and classes
* @param selected selected Tree hierarchie
* @param selector name of field to select thru
* @param sym symbol of the selected class
*/
public static class Select extends Tree {
public Tree selected;
public Name name;
public Symbol sym;
public Select(Tree selected, Name name, Symbol sym) {
super(SELECT);
this.selected = selected;
this.name = name;
this.sym = sym;
}
public void accept(Visitor v) {
v.visitSelect(this);
}
}
/**
* An identifier
* @param idname the name
* @param sym the symbol
*/
public static class Ident extends Tree {
public Name name;
public Symbol sym;
public Ident(Name name, Symbol sym) {
super(IDENT);
this.name = name;
this.sym = sym;
}
public void accept(Visitor v) {
v.visitIdent(this);
}
}
/**
* A constant value given literally.
* @param value value representation
*/
public static class Literal extends Tree {
public int typetag;
public Object value;
public Literal(int typetag, Object value) {
super(LITERAL);
this.typetag = typetag;
this.value = value;
}
public void accept(Visitor v) {
v.visitLiteral(this);
}
}
/**
* Identifies a basic type.
* @param tag the basic type id
* @see SemanticConstants
*/
public static class TypeIdent extends Tree {
public int typetag;
public TypeIdent(int typetag) {
super(TYPEIDENT);
this.typetag = typetag;
}
public void accept(Visitor v) {
v.visitTypeIdent(this);
}
}
/**
* An array type, A[]
*/
public static class TypeArray extends Tree {
public Tree elemtype;
public TypeArray(Tree elemtype) {
super(TYPEARRAY);
this.elemtype = elemtype;
}
public void accept(Visitor v) {
v.visitTypeArray(this);
}
}
/**
* A formal class parameter.
* @param name name
* @param bounds bounds
*/
public static class TypeParameter extends Tree {
TypeParameter() {
super(0);
}
public static final List emptyList = new List();
}
public static class Erroneous extends Tree {
public Erroneous() {
super(ERRONEOUS);
}
public void accept(Visitor v) {
v.visitErroneous(this);
}
}
/**
* An interface for tree factories
*/
public interface Factory {
TopLevel TopLevel(Tree pid, List defs);
Import Import(Tree qualid);
ClassDef ClassDef(long flags, Name name, List typarams, Tree extending,
List implementing, List defs);
MethodDef MethodDef(long flags, Name name, Tree restype, List typarams,
List params, List thrown, Block body);
VarDef VarDef(long flags, Name name, Tree vartype, Tree init);
Skip Skip();
Block Block(long flags, List stats);
DoLoop DoLoop(Tree body, Tree cond);
WhileLoop WhileLoop(Tree cond, Tree body);
ForLoop ForLoop(List init, Tree cond, List step, Tree body);
Labelled Labelled(Name label, Tree body);
Switch Switch(Tree selector, List cases);
Case Case(Tree pat, List stats);
Synchronized Synchronized(Tree lock, Tree body);
Try Try(Tree body, List catchers, Tree finalizer);
Catch Catch(VarDef param, Tree body);
Conditional Conditional(Tree cond, Tree thenpart, Tree elsepart);
If If(Tree cond, Tree thenpart, Tree elsepart);
Exec Exec(Tree expr);
Break Break(Name label);
Continue Continue(Name label);
Return Return(Tree expr);
Throw Throw(Tree expr);
Apply Apply(Tree fn, List args);
NewClass NewClass(Tree encl, Tree clazz, List args, ClassDef def);
NewArray NewArray(Tree elemtype, List dims, List elems);
Parens Parens(Tree expr);
Assign Assign(Tree lhs, Tree rhs);
Assignop Assignop(int opcode, Tree lhs, Tree rhs);
Unary Unary(int opcode, Tree arg);
Binary Binary(int opcode, Tree lhs, Tree rhs);
TypeCast TypeCast(Tree expr, Tree type);
TypeTest TypeTest(Tree expr, Tree clazz);
Indexed Indexed(Tree indexed, Tree index);
Select Select(Tree selected, Name selector);
Ident Ident(Name idname);
Literal Literal(int tag, Object value);
TypeIdent TypeIdent(int typetag);
TypeArray TypeArray(Tree elemtype);
Erroneous Erroneous();
}
/**
* A generic visitor class for trees.
*/
public static abstract class Visitor {
public Visitor() {
super();
}
public void visitTopLevel(TopLevel that) {
visitTree(that);
}
public void visitImport(Import that) {
visitTree(that);
}
public void visitClassDef(ClassDef that) {
visitTree(that);
}
public void visitMethodDef(MethodDef that) {
visitTree(that);
}
public void visitVarDef(VarDef that) {
visitTree(that);
}
public void visitSkip(Skip that) {
visitTree(that);
}
public void visitBlock(Block that) {
visitTree(that);
}
public void visitDoLoop(DoLoop that) {
visitTree(that);
}
public void visitWhileLoop(WhileLoop that) {
visitTree(that);
}
public void visitForLoop(ForLoop that) {
visitTree(that);
}
public void visitLabelled(Labelled that) {
visitTree(that);
}
public void visitSwitch(Switch that) {
visitTree(that);
}
public void visitCase(Case that) {
visitTree(that);
}
public void visitSynchronized(Synchronized that) {
visitTree(that);
}
public void visitTry(Try that) {
visitTree(that);
}
public void visitCatch(Catch that) {
visitTree(that);
}
public void visitConditional(Conditional that) {
visitTree(that);
}
public void visitIf(If that) {
visitTree(that);
}
public void visitExec(Exec that) {
visitTree(that);
}
public void visitBreak(Break that) {
visitTree(that);
}
public void visitContinue(Continue that) {
visitTree(that);
}
public void visitReturn(Return that) {
visitTree(that);
}
public void visitThrow(Throw that) {
visitTree(that);
}
public void visitAssert(Assert that) {
visitTree(that);
}
public void visitApply(Apply that) {
visitTree(that);
}
public void visitNewClass(NewClass that) {
visitTree(that);
}
public void visitNewArray(NewArray that) {
visitTree(that);
}
public void visitParens(Parens that) {
visitTree(that);
}
public void visitAssign(Assign that) {
visitTree(that);
}
public void visitAssignop(Assignop that) {
visitTree(that);
}
public void visitUnary(Unary that) {
visitTree(that);
}
public void visitBinary(Binary that) {
visitTree(that);
}
public void visitTypeCast(TypeCast that) {
visitTree(that);
}
public void visitTypeTest(TypeTest that) {
visitTree(that);
}
public void visitIndexed(Indexed that) {
visitTree(that);
}
public void visitSelect(Select that) {
visitTree(that);
}
public void visitIdent(Ident that) {
visitTree(that);
}
public void visitLiteral(Literal that) {
visitTree(that);
}
public void visitTypeIdent(TypeIdent that) {
visitTree(that);
}
public void visitTypeArray(TypeArray that) {
visitTree(that);
}
public void visitErroneous(Erroneous that) {
visitTree(that);
}
public void visitTree(Tree that) {
assert false;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -