use of org.candle.decompiler.ast.tcf.TryBlock in project candle-decompiler by bradsdavis.
the class BlockVisitor method visitTryIntermediate.
@Override
public void visitTryIntermediate(TryIntermediate line) {
if (seen.contains(line)) {
// do nothing.
return;
} else {
seen.add(line);
}
// set current block...
TryBlock tryBlock = new TryBlock(line);
// add it as a child of current..
this.current.addChild(tryBlock);
// set the current...
this.current = tryBlock;
// now, get the nested blocks...
List<AbstractIntermediate> successors = getUnseenSuccessors(line);
AbstractIntermediate inner = null;
List<AbstractIntermediate> catchBlocks = new LinkedList<AbstractIntermediate>();
AbstractIntermediate finallyIntermediate = null;
// find the non-catch/finally...
for (AbstractIntermediate successor : successors) {
if (successor instanceof CatchIntermediate) {
catchBlocks.add(successor);
} else if (successor instanceof FinallyIntermediate) {
finallyIntermediate = successor;
} else {
if (inner != null) {
throw new IllegalStateException("Inner direction already set.");
}
inner = successor;
}
}
Collections.sort(catchBlocks, new IntermediateComparator());
if (inner == null) {
throw new IllegalStateException("Inner is not set.");
}
inner.accept(this);
// set the current up.
moveUp();
for (AbstractIntermediate catchBlock : catchBlocks) {
current = tryBlock;
catchBlock.accept(this);
}
if (finallyIntermediate != null) {
current = tryBlock;
finallyIntermediate.accept(this);
}
}
Aggregations