diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java index 47eba4cce..2f44e29f1 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.abc.avm2.graph; import com.jpexs.decompiler.flash.BaseLocalData; @@ -80,6 +81,7 @@ import com.jpexs.decompiler.graph.model.SwitchItem; import com.jpexs.decompiler.graph.model.WhileItem; import com.jpexs.helpers.Reference; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; @@ -716,11 +718,14 @@ public class AVM2Graph extends Graph { } } + List otherSide = new ArrayList<>(); if (leftReg > 0) { switchedObject = new LocalRegAVM2Item(null, null, leftReg, null); caseValuesMap = caseValuesMapRight; + otherSide = caseValuesMapLeft; } else if (rightReg > 0) { switchedObject = new LocalRegAVM2Item(null, null, rightReg, null); + otherSide = caseValuesMapRight; } if ((leftReg < 0 && rightReg < 0) || (cnt == 1)) { @@ -737,7 +742,9 @@ public class AVM2Graph extends Graph { ret.addAll(output); Reference nextRef = new Reference<>(null); Reference tiRef = new Reference<>(null); - ret.add(handleSwitch(switchedObject, switchStartItem, foundGotos, partCodes, partCodePos, allParts, stack, stopPart, loops, localData, staticOperation, path, caseValuesMap, defaultPart, caseBodyParts, nextRef, tiRef)); + SwitchItem sw = handleSwitch(switchedObject, switchStartItem, foundGotos, partCodes, partCodePos, allParts, stack, stopPart, loops, localData, staticOperation, path, caseValuesMap, defaultPart, caseBodyParts, nextRef, tiRef); + checkSwitch(localData, sw, otherSide, ret); + ret.add(sw); if (nextRef.getVal() != null) { if (tiRef.getVal() != null) { ret.add(tiRef.getVal()); @@ -1203,7 +1210,7 @@ public class AVM2Graph extends Graph { } @Override - protected void checkSwitch(BaseLocalData localData, SwitchItem switchItem, Map otherSides, List output) { + protected void checkSwitch(BaseLocalData localData, SwitchItem switchItem, Collection otherSides, List output) { if (output.isEmpty()) { return; } @@ -1215,7 +1222,7 @@ public class AVM2Graph extends Graph { int setLocalIp = InstructionDefinition.getItemIp(avm2LocalData, setLocal);; Set allUsages = new HashSet<>(avm2LocalData.getSetLocalUsages(setLocalIp)); boolean isOtherSideReg = false; - for (GraphTargetItem otherSide : otherSides.values()) { + for (GraphTargetItem otherSide : otherSides) { if (otherSide instanceof LocalRegAVM2Item) { LocalRegAVM2Item otherLog = (LocalRegAVM2Item) otherSide; if (otherLog.regIndex != setLocal.regIndex) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Graph.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Graph.java index 94f04e0f1..7c34e7068 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Graph.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Graph.java @@ -1567,6 +1567,10 @@ public class Graph { parts = ((GraphPartMulti) part).parts; } else { parts.add(part); + while (part.nextParts.size() == 1 && part.nextParts.get(0).refs.size() == 1) { + part = part.nextParts.get(0); + parts.add(part); + } } for (GraphPart p : parts) { int end = p.end; @@ -1750,7 +1754,7 @@ public class Graph { SwitchItem sw = handleSwitch(switchedItem, originalSwitchedItem.getSrc(), foundGotos, partCodes, partCodePos, allParts, stack, stopPart, loops, localData, staticOperation, path, caseValues, defaultPart, caseBodyParts, nextRef, tiRef); GraphPart next = nextRef.getVal(); - checkSwitch(localData, sw, caseExpressionOtherSides, currentRet); + checkSwitch(localData, sw, caseExpressionOtherSides.values(), currentRet); currentRet.add(sw); if (next != null) { if (tiRef.getVal() != null) { @@ -2119,7 +2123,7 @@ public class Graph { return ret; } - protected void checkSwitch(BaseLocalData localData, SwitchItem switchItem, Map otherSides, List output) { + protected void checkSwitch(BaseLocalData localData, SwitchItem switchItem, Collection otherSides, List output) { }