Removes exception handlers in a special case when exception handler is

exactly at the start of a protected block
This commit is contained in:
konsoletyper 2014-02-26 21:45:58 +04:00
parent a4f477329d
commit 1f18148144
3 changed files with 11 additions and 5 deletions

View File

@ -221,19 +221,19 @@ public class Decompiler {
for (Instruction insn : generator.currentBlock.getInstructions()) {
insn.acceptVisitor(generator);
}
block.body.addAll(generator.statements);
for (TryCatchBlock tryCatch : generator.currentBlock.getTryCatchBlocks()) {
TryCatchStatement tryCatchStmt = new TryCatchStatement();
tryCatchStmt.setExceptionType(tryCatch.getExceptionType());
tryCatchStmt.setExceptionVariable(tryCatch.getExceptionVariable().getIndex());
tryCatchStmt.getProtectedBody().addAll(block.body);
block.body.clear();
block.body.add(tryCatchStmt);
tryCatchStmt.getProtectedBody().addAll(generator.statements);
generator.statements.clear();
generator.statements.add(tryCatchStmt);
Statement handlerStmt = generator.generateJumpStatement(tryCatch.getHandler());
if (handlerStmt != null) {
tryCatchStmt.getHandler().add(handlerStmt);
}
}
block.body.addAll(generator.statements);
}
}
SequentialStatement result = new SequentialStatement();

View File

@ -1280,7 +1280,7 @@ public class Renderer implements ExprVisitor, StatementVisitor {
.append("$e;").softNewLine();
}
}
for (Statement part : statement.getHandler()) {
for (Statement part : catchClause.getHandler()) {
part.acceptVisitor(this);
}
writer.outdent().append("}").ws().append("else ");

View File

@ -178,6 +178,9 @@ public class ProgramParser {
Deque<Step> workStack = new ArrayDeque<>();
for (Object obj : method.tryCatchBlocks) {
TryCatchBlockNode tryCatchNode = (TryCatchBlockNode)obj;
if (tryCatchNode.start == tryCatchNode.handler) {
continue;
}
workStack.push(new Step(-2, labelIndexes.get(tryCatchNode.handler.getLabel())));
}
workStack.push(new Step(-1, 0));
@ -213,6 +216,9 @@ public class ProgramParser {
}
for (Object obj : method.tryCatchBlocks) {
TryCatchBlockNode tryCatchNode = (TryCatchBlockNode)obj;
if (tryCatchNode.start == tryCatchNode.handler) {
continue;
}
int start = labelIndexes.get(tryCatchNode.start.getLabel());
int end = labelIndexes.get(tryCatchNode.end.getLabel());
getBasicBlock(start);