mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-05-31 11:44:36 +00:00
Issue #197 AS1/2 switch fixes
This commit is contained in:
@@ -382,21 +382,7 @@ public class AVM2Graph extends Graph {
|
||||
ret = new ArrayList<>();
|
||||
ret.addAll(output);
|
||||
return ret;
|
||||
}
|
||||
if(part.nextParts.size() == 2){
|
||||
if(stack.peek() instanceof StrictNeqTreeItem){
|
||||
System.out.println("1");
|
||||
if(part.nextParts.get(1).getHeight() >= 2){
|
||||
System.out.println("2");
|
||||
if(code.code.get(code.fixIPAfterDebugLine(part.nextParts.get(1).start)).definition instanceof PushIntegerTypeIns){
|
||||
System.out.println("3");
|
||||
if(code.code.get(part.nextParts.get(1).nextParts.get(0).end).definition instanceof LookupSwitchIns){
|
||||
System.out.println("4");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (((part.nextParts.size() == 2)
|
||||
&& (!stack.isEmpty())
|
||||
&& (stack.peek() instanceof StrictEqTreeItem)
|
||||
|
||||
@@ -278,7 +278,10 @@ public class ActionGraph extends Graph {
|
||||
});*/
|
||||
|
||||
//GraphPart breakPart = breakParts.isEmpty() ? null : breakParts.get(0);
|
||||
GraphPart breakPart = getMostCommonPart(caseBodyParts, loops);
|
||||
List<GraphPart> mcp=new ArrayList<>();
|
||||
mcp.addAll(caseBodyParts);
|
||||
mcp.add(defaultPart2);
|
||||
GraphPart breakPart = getMostCommonPart(mcp, loops);
|
||||
if ((defaultPart2 != breakPart) && (defaultCommands.isEmpty())) {
|
||||
defaultPart = defaultPart2;
|
||||
}
|
||||
@@ -302,6 +305,7 @@ public class ActionGraph extends Graph {
|
||||
|
||||
GraphTargetItem ti = checkLoop(next, stopPart, loops);
|
||||
currentLoop = new Loop(loops.size(), null, next);
|
||||
currentLoop.phase = 1;
|
||||
loops.add(currentLoop);
|
||||
//switchLoc.getNextPartPath(new ArrayList<GraphPart>());
|
||||
List<Integer> valuesMapping = new ArrayList<>();
|
||||
@@ -325,6 +329,15 @@ public class ActionGraph extends Graph {
|
||||
stopPart2x.add(next);
|
||||
defaultCommands = printGraph(new ArrayList<GraphPart>(), localData, stack, allParts, null, defaultPart, stopPart2x, loops);
|
||||
}
|
||||
|
||||
if(!defaultCommands.isEmpty()){
|
||||
if(defaultCommands.get(defaultCommands.size()-1) instanceof BreakItem){
|
||||
BreakItem bi=(BreakItem)defaultCommands.get(defaultCommands.size()-1);
|
||||
if(bi.loopId==currentLoop.id){
|
||||
defaultCommands.remove(defaultCommands.size()-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<GraphPart> ignored = new ArrayList<>();
|
||||
for (Loop l : loops) {
|
||||
@@ -382,7 +395,7 @@ public class ActionGraph extends Graph {
|
||||
ret.addAll(output);
|
||||
SwitchItem sti = new SwitchItem(null, currentLoop, switchedObject, caseValues, caseCommands, defaultCommands, valuesMapping);
|
||||
ret.add(sti);
|
||||
|
||||
currentLoop.phase = 2;
|
||||
if (next != null) {
|
||||
if (ti != null) {
|
||||
ret.add(ti);
|
||||
|
||||
@@ -551,10 +551,10 @@ public class Graph {
|
||||
System.out.println("</loops>");*/
|
||||
getPrecontinues(null, heads.get(0), loops, null);
|
||||
/*System.err.println("<loopspre>");
|
||||
for (Loop el : loops) {
|
||||
System.err.println(el);
|
||||
}
|
||||
System.err.println("</loopspre>");//*/
|
||||
for (Loop el : loops) {
|
||||
System.err.println(el);
|
||||
}
|
||||
System.err.println("</loopspre>");//*/
|
||||
|
||||
List<GraphTargetItem> ret = printGraph(new ArrayList<GraphPart>(), localData, stack, allParts, null, heads.get(0), null, loops);
|
||||
processIfs(ret);
|
||||
@@ -1743,7 +1743,7 @@ public class Graph {
|
||||
vis.add(p);
|
||||
}
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
SwitchItem sw = new SwitchItem(null, swLoop, switchedItem, caseValues, caseCommands, defaultCommands, valueMappings);
|
||||
currentRet.add(sw);
|
||||
swLoop.phase = 2;
|
||||
|
||||
Reference in New Issue
Block a user