mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
Removes exception handlers in a special case when exception handler is
exactly at the start of a protected block
This commit is contained in:
parent
a4f477329d
commit
1f18148144
|
@ -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();
|
||||
|
|
|
@ -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 ");
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue
Block a user