Issue #197 AS1/2 switch fixes

This commit is contained in:
Jindra Petk
2013-07-07 08:13:28 +02:00
parent 8bf113af6e
commit 77628bf739
3 changed files with 21 additions and 22 deletions

View File

@@ -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)

View File

@@ -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);

View File

@@ -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;