📄 crtable.java
字号:
public void visitCatch(Catch tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.param));
sr.mergeWith(csp(tree.body));
result = sr;
}
public void visitConditional(Conditional tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.cond));
sr.mergeWith(csp(tree.truepart));
sr.mergeWith(csp(tree.falsepart));
result = sr;
}
public void visitIf(If tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.cond));
sr.mergeWith(csp(tree.thenpart));
sr.mergeWith(csp(tree.elsepart));
result = sr;
}
public void visitExec(Exec tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.expr));
result = sr;
}
public void visitBreak(Break tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
result = sr;
}
public void visitContinue(Continue tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
result = sr;
}
public void visitReturn(Return tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.expr));
result = sr;
}
public void visitThrow(Throw tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.expr));
result = sr;
}
public void visitAssert(Assert tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.cond));
sr.mergeWith(csp(tree.detail));
result = sr;
}
public void visitApply(Apply tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.meth));
sr.mergeWith(csp(tree.args));
result = sr;
}
public void visitNewClass(NewClass tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.encl));
sr.mergeWith(csp(tree.clazz));
sr.mergeWith(csp(tree.args));
sr.mergeWith(csp(tree.def));
result = sr;
}
public void visitNewArray(NewArray tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.elemtype));
sr.mergeWith(csp(tree.dims));
sr.mergeWith(csp(tree.elems));
result = sr;
}
public void visitParens(Parens tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.expr));
result = sr;
}
public void visitAssign(Assign tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.lhs));
sr.mergeWith(csp(tree.rhs));
result = sr;
}
public void visitAssignop(Assignop tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.lhs));
sr.mergeWith(csp(tree.rhs));
result = sr;
}
public void visitUnary(Unary tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.arg));
result = sr;
}
public void visitBinary(Binary tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.lhs));
sr.mergeWith(csp(tree.rhs));
result = sr;
}
public void visitTypeCast(TypeCast tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.clazz));
sr.mergeWith(csp(tree.expr));
result = sr;
}
public void visitTypeTest(TypeTest tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.expr));
sr.mergeWith(csp(tree.clazz));
result = sr;
}
public void visitIndexed(Indexed tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.indexed));
sr.mergeWith(csp(tree.index));
result = sr;
}
public void visitSelect(Select tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.selected));
result = sr;
}
public void visitIdent(Ident tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
result = sr;
}
public void visitLiteral(Literal tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
result = sr;
}
public void visitTypeIdent(TypeIdent tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
result = sr;
}
public void visitTypeArray(TypeArray tree) {
SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
sr.mergeWith(csp(tree.elemtype));
result = sr;
}
public void visitErroneous(Erroneous tree) {
result = null;
}
public void visitTree(Tree tree) {
assert false;
}
/**
* The start position of given tree.
*/
public int startPos(Tree tree) {
if (tree == null)
return Position.NOPOS;
return tree.pos;
}
/**
* The end position of given tree, if it has
* defined endpos, NOPOS otherwise.
*/
public int endPos(Tree tree) {
if (tree == null)
return Position.NOPOS;
if (tree.tag == Tree.BLOCK)
return ((Block) tree).endpos;
Integer endpos = (Integer) endPositions.get(tree);
if (endpos != null)
return endpos.intValue();
return Position.NOPOS;
}
}
/**
* This class contains a CharacterRangeTableEntry.
*/
class CRTEntry {
/**
* A tree or a list of trees to obtain source positions.
*/
Object tree;
/**
* The flags described in the CharacterRangeTable spec.
*/
int flags;
/**
* The starting code position of this entry.
*/
int startPc;
/**
* The ending code position of this entry.
*/
int endPc;
/**
* Constructor
*/
CRTEntry(Object tree, int flags, int startPc, int endPc) {
super();
this.tree = tree;
this.flags = flags;
this.startPc = startPc;
this.endPc = endPc;
}
}
/**
* This class contains source positions
* for some tree or list of trees.
*/
class SourceRange {
/**
* The starting source position.
*/
int startPos;
/**
* The ending source position.
*/
int endPos;
/**
* Constructor
*/
SourceRange() {
super();
startPos = Position.NOPOS;
endPos = Position.NOPOS;
}
/**
* Constructor
*/
SourceRange(int startPos, int endPos) {
super();
this.startPos = startPos;
this.endPos = endPos;
}
/**
* Compare the starting and the ending positions
* of the source range and combines them assigning
* the widest range to this.
*/
SourceRange mergeWith(SourceRange sr) {
if (sr == null)
return this;
if (startPos == Position.NOPOS)
startPos = sr.startPos;
else if (sr.startPos != Position.NOPOS)
startPos = (startPos < sr.startPos ? startPos : sr.startPos);
if (endPos == Position.NOPOS)
endPos = sr.endPos;
else if (sr.endPos != Position.NOPOS)
endPos = (endPos > sr.endPos ? endPos : sr.endPos);
return this;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -