mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2025-01-09 08:24:10 -08:00
Fix bug in decompiler that causes expression statement containing || or && with side effects to be removed
This commit is contained in:
parent
15be89a758
commit
6bfbd38e22
|
@ -16,6 +16,8 @@
|
||||||
package org.teavm.ast.optimization;
|
package org.teavm.ast.optimization;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.teavm.ast.BinaryExpr;
|
||||||
|
import org.teavm.ast.BinaryOperation;
|
||||||
import org.teavm.ast.ConditionalExpr;
|
import org.teavm.ast.ConditionalExpr;
|
||||||
import org.teavm.ast.ConditionalStatement;
|
import org.teavm.ast.ConditionalStatement;
|
||||||
import org.teavm.ast.InvocationExpr;
|
import org.teavm.ast.InvocationExpr;
|
||||||
|
@ -47,4 +49,13 @@ public class ExpressionSideEffectDecomposer extends RecursiveVisitor {
|
||||||
public void visit(NewExpr expr) {
|
public void visit(NewExpr expr) {
|
||||||
target.add(Statement.assign(null, expr));
|
target.add(Statement.assign(null, expr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void visit(BinaryExpr expr) {
|
||||||
|
if (expr.getOperation() == BinaryOperation.AND || expr.getOperation() == BinaryOperation.OR) {
|
||||||
|
target.add(Statement.assign(null, expr));
|
||||||
|
} else {
|
||||||
|
super.visit(expr);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -766,6 +766,9 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
|
||||||
|
|
||||||
private void normalizeConditional(ConditionalStatement stmt) {
|
private void normalizeConditional(ConditionalStatement stmt) {
|
||||||
if (stmt.getConsequent().isEmpty()) {
|
if (stmt.getConsequent().isEmpty()) {
|
||||||
|
if (stmt.getAlternative().isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
stmt.getConsequent().addAll(stmt.getAlternative());
|
stmt.getConsequent().addAll(stmt.getAlternative());
|
||||||
stmt.getAlternative().clear();
|
stmt.getAlternative().clear();
|
||||||
stmt.setCondition(ExprOptimizer.invert(stmt.getCondition()));
|
stmt.setCondition(ExprOptimizer.invert(stmt.getCondition()));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user