mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-23 00:24:11 -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()) {
|
for (Instruction insn : generator.currentBlock.getInstructions()) {
|
||||||
insn.acceptVisitor(generator);
|
insn.acceptVisitor(generator);
|
||||||
}
|
}
|
||||||
block.body.addAll(generator.statements);
|
|
||||||
for (TryCatchBlock tryCatch : generator.currentBlock.getTryCatchBlocks()) {
|
for (TryCatchBlock tryCatch : generator.currentBlock.getTryCatchBlocks()) {
|
||||||
TryCatchStatement tryCatchStmt = new TryCatchStatement();
|
TryCatchStatement tryCatchStmt = new TryCatchStatement();
|
||||||
tryCatchStmt.setExceptionType(tryCatch.getExceptionType());
|
tryCatchStmt.setExceptionType(tryCatch.getExceptionType());
|
||||||
tryCatchStmt.setExceptionVariable(tryCatch.getExceptionVariable().getIndex());
|
tryCatchStmt.setExceptionVariable(tryCatch.getExceptionVariable().getIndex());
|
||||||
tryCatchStmt.getProtectedBody().addAll(block.body);
|
tryCatchStmt.getProtectedBody().addAll(generator.statements);
|
||||||
block.body.clear();
|
generator.statements.clear();
|
||||||
block.body.add(tryCatchStmt);
|
generator.statements.add(tryCatchStmt);
|
||||||
Statement handlerStmt = generator.generateJumpStatement(tryCatch.getHandler());
|
Statement handlerStmt = generator.generateJumpStatement(tryCatch.getHandler());
|
||||||
if (handlerStmt != null) {
|
if (handlerStmt != null) {
|
||||||
tryCatchStmt.getHandler().add(handlerStmt);
|
tryCatchStmt.getHandler().add(handlerStmt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
block.body.addAll(generator.statements);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SequentialStatement result = new SequentialStatement();
|
SequentialStatement result = new SequentialStatement();
|
||||||
|
|
|
@ -1280,7 +1280,7 @@ public class Renderer implements ExprVisitor, StatementVisitor {
|
||||||
.append("$e;").softNewLine();
|
.append("$e;").softNewLine();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Statement part : statement.getHandler()) {
|
for (Statement part : catchClause.getHandler()) {
|
||||||
part.acceptVisitor(this);
|
part.acceptVisitor(this);
|
||||||
}
|
}
|
||||||
writer.outdent().append("}").ws().append("else ");
|
writer.outdent().append("}").ws().append("else ");
|
||||||
|
|
|
@ -178,6 +178,9 @@ public class ProgramParser {
|
||||||
Deque<Step> workStack = new ArrayDeque<>();
|
Deque<Step> workStack = new ArrayDeque<>();
|
||||||
for (Object obj : method.tryCatchBlocks) {
|
for (Object obj : method.tryCatchBlocks) {
|
||||||
TryCatchBlockNode tryCatchNode = (TryCatchBlockNode)obj;
|
TryCatchBlockNode tryCatchNode = (TryCatchBlockNode)obj;
|
||||||
|
if (tryCatchNode.start == tryCatchNode.handler) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
workStack.push(new Step(-2, labelIndexes.get(tryCatchNode.handler.getLabel())));
|
workStack.push(new Step(-2, labelIndexes.get(tryCatchNode.handler.getLabel())));
|
||||||
}
|
}
|
||||||
workStack.push(new Step(-1, 0));
|
workStack.push(new Step(-1, 0));
|
||||||
|
@ -213,6 +216,9 @@ public class ProgramParser {
|
||||||
}
|
}
|
||||||
for (Object obj : method.tryCatchBlocks) {
|
for (Object obj : method.tryCatchBlocks) {
|
||||||
TryCatchBlockNode tryCatchNode = (TryCatchBlockNode)obj;
|
TryCatchBlockNode tryCatchNode = (TryCatchBlockNode)obj;
|
||||||
|
if (tryCatchNode.start == tryCatchNode.handler) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
int start = labelIndexes.get(tryCatchNode.start.getLabel());
|
int start = labelIndexes.get(tryCatchNode.start.getLabel());
|
||||||
int end = labelIndexes.get(tryCatchNode.end.getLabel());
|
int end = labelIndexes.get(tryCatchNode.end.getLabel());
|
||||||
getBasicBlock(start);
|
getBasicBlock(start);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user