mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-24 05:15:39 +00:00
Switch
This commit is contained in:
@@ -501,6 +501,14 @@ public class AVM2Graph extends Graph {
|
||||
finCatchName = AVM2Item.localRegName(new HashMap<>(), sl.regIndex);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//No kill ins
|
||||
if (!ncatchedCommands.isEmpty() && (ncatchedCommands.get(0) instanceof SetLocalAVM2Item)) {
|
||||
SetLocalAVM2Item sl = (SetLocalAVM2Item) ncatchedCommands.get(0);
|
||||
if (sl.value.getThroughDuplicate().getNotCoerced() instanceof ExceptionAVM2Item) {
|
||||
ncatchedCommands.remove(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1176,4 +1184,29 @@ public class AVM2Graph extends Graph {
|
||||
protected List<GraphTargetItem> filter(List<GraphTargetItem> list) {
|
||||
return avm2code.clearTemporaryRegisters(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkSwitch(BaseLocalData localData, SwitchItem switchItem, Map<Integer, GraphTargetItem> otherSides, List<GraphTargetItem> output) {
|
||||
if (output.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (!(output.get(output.size() - 1) instanceof SetLocalAVM2Item)) {
|
||||
return;
|
||||
}
|
||||
AVM2LocalData avm2LocalData = (AVM2LocalData) localData;
|
||||
SetLocalAVM2Item setLocal = (SetLocalAVM2Item) output.get(output.size() - 1);
|
||||
int setLocalIp = avm2LocalData.code.code.indexOf(setLocal.getSrc());
|
||||
Set<Integer> allUsages = new HashSet<>(avm2LocalData.setLocalPosToGetLocalPos.get(setLocalIp));
|
||||
for (GraphTargetItem otherSide : otherSides.values()) {
|
||||
if (otherSide instanceof LocalRegAVM2Item) {
|
||||
LocalRegAVM2Item otherLog = (LocalRegAVM2Item) otherSide;
|
||||
int getLocalIp = avm2LocalData.code.code.indexOf(otherLog.getSrc());
|
||||
allUsages.remove((Integer) getLocalIp);
|
||||
}
|
||||
}
|
||||
if (allUsages.isEmpty()) {
|
||||
output.remove(output.size() - 1);
|
||||
switchItem.switchedObject = setLocal.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2374,6 +2374,7 @@ public class Graph {
|
||||
Map<Integer, GraphTargetItem> caseExpressions = new HashMap<>();
|
||||
Map<Integer, GraphTargetItem> caseExpressionLeftSides = new HashMap<>();
|
||||
Map<Integer, GraphTargetItem> caseExpressionRightSides = new HashMap<>();
|
||||
|
||||
GraphTargetItem it = switchedItem;
|
||||
int defaultBranch = 0;
|
||||
boolean hasExpr = false;
|
||||
@@ -2444,6 +2445,7 @@ public class Graph {
|
||||
defaultBranch = ((IntegerValueTypeItem) it).intValue();
|
||||
}
|
||||
|
||||
Map<Integer, GraphTargetItem> caseExpressionOtherSides = caseExpressions;
|
||||
if (!caseExpressionRightSides.isEmpty()) {
|
||||
GraphTargetItem firstItem;
|
||||
firstItem = (GraphTargetItem) caseExpressionRightSides.values().toArray()[0];
|
||||
@@ -2457,6 +2459,7 @@ public class Graph {
|
||||
|
||||
if (sameRight) {
|
||||
caseExpressions = caseExpressionLeftSides;
|
||||
caseExpressionOtherSides = caseExpressionRightSides;
|
||||
switchedItem = firstItem;
|
||||
hasExpr = true;
|
||||
} else {
|
||||
@@ -2471,6 +2474,7 @@ public class Graph {
|
||||
}
|
||||
if (sameLeft) {
|
||||
caseExpressions = caseExpressionRightSides;
|
||||
caseExpressionOtherSides = caseExpressionLeftSides;
|
||||
switchedItem = firstItem;
|
||||
hasExpr = true;
|
||||
}
|
||||
@@ -2591,7 +2595,9 @@ public class Graph {
|
||||
}
|
||||
}
|
||||
SwitchItem sw = new SwitchItem(null, localData.lineStartInstruction, swLoop, switchedItem, caseValues, caseCommands, valueMappings);
|
||||
checkSwitch(localData, sw, caseExpressionOtherSides, currentRet);
|
||||
currentRet.add(sw);
|
||||
//TADY
|
||||
swLoop.phase = 2;
|
||||
if (next != null) {
|
||||
currentRet.addAll(printGraph(foundGotos, gotoTargets, partCodes, partCodePos, visited, localData, stack, allParts, part, next, stopPart, loops, null, staticOperation, path, recursionLevel + 1));
|
||||
@@ -2938,6 +2944,10 @@ public class Graph {
|
||||
return ret;
|
||||
}
|
||||
|
||||
protected void checkSwitch(BaseLocalData localData, SwitchItem switchItem, Map<Integer, GraphTargetItem> otherSides, List<GraphTargetItem> output) {
|
||||
|
||||
}
|
||||
|
||||
protected void checkGraph(List<GraphPart> allBlocks) {
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user