For in break detection with inner switch statement

This commit is contained in:
Jindra Petřík
2018-05-27 22:10:54 +02:00
parent 6c998254b9
commit f61772c8f7
6 changed files with 54 additions and 1 deletions
@@ -56,6 +56,7 @@ import com.jpexs.decompiler.graph.model.ContinueItem;
import com.jpexs.decompiler.graph.model.DefaultItem;
import com.jpexs.decompiler.graph.model.IfItem;
import com.jpexs.decompiler.graph.model.SwitchItem;
import com.jpexs.decompiler.graph.model.UniversalLoopItem;
import com.jpexs.decompiler.graph.model.WhileItem;
import com.jpexs.helpers.Helper;
import java.util.ArrayList;
@@ -140,6 +141,24 @@ public class ActionGraph extends Graph {
}
}
@Override
protected boolean canBeBreakCandidate(GraphPart part) {
if (part.refs.size() <= 1) {
return true;
}
boolean isSwitch = true;
for (GraphPart r : part.refs) {
if (code.get(r.end) instanceof ActionIf) {
if (!(r.start < r.end - 1 && (code.get(r.end - 1) instanceof ActionStrictEquals))) {
isSwitch = false;
}
} else {
isSwitch = false;
}
}
return !isSwitch;
}
@Override
protected void finalProcess(List<GraphTargetItem> list, int level, FinalProcessLocalData localData, String path) throws InterruptedException {