AS1/2: continue, break fix

This commit is contained in:
Jindra Petk
2013-01-13 18:11:41 +01:00
parent 99a98e2d8f
commit b97a37648e
4 changed files with 13 additions and 7 deletions

View File

@@ -494,14 +494,20 @@ public class Action {
loopStack.add(stripped.substring(0, stripped.length() - 1));
}
if (stripped.startsWith("break ")) {
if (stripped.equals("break " + loopStack.peek() + ";")) {
parts[p] = parts[p].replace(" " + loopStack.peek(), "");
if (stripped.equals("break " + loopStack.peek().replace("switch", "") + ";")) {
parts[p] = parts[p].replace(" " + loopStack.peek().replace("switch", ""), "");
}
}
if (stripped.startsWith("continue ")) {
if (loopStack.size() > 0) {
if (stripped.equals("continue " + loopStack.peek() + ";")) {
parts[p] = parts[p].replace(" " + loopStack.peek(), "");
int pos=loopStack.size()-1;
String loopname="";
do{
loopname=loopStack.get(pos);
pos--;
}while((pos>=0)&&(loopname.startsWith("loopswitch")));
if (stripped.equals("continue " + loopname + ";")) {
parts[p] = parts[p].replace(" " + loopname, "");
}
}
}

View File

@@ -35,6 +35,6 @@ public class BreakTreeItem extends TreeItem {
@Override
public String toString(ConstantPool constants) {
return hilight("break") + " loop" + loopPos;
return hilight("break") + " loop" + loopPos+";";
}
}

View File

@@ -36,6 +36,6 @@ public class ContinueTreeItem extends TreeItem {
@Override
public String toString(ConstantPool constants) {
return hilight(isBreak ? "break" : "continue") + " " + (isKnown ? "loop" : "unk") + loopPos;
return hilight(isBreak ? "break" : "continue") + " " + (isKnown ? "loop" : "unk") + loopPos+";";
}
}

View File

@@ -41,7 +41,7 @@ public class SwitchTreeItem extends LoopTreeItem implements Block {
@Override
public String toString(ConstantPool constants) {
String ret = "";
ret += "loop" + loopBreak + ":\r\n";
ret += "loopswitch" + loopBreak + ":\r\n";
ret += hilight("switch(") + switchedObject.toString(constants) + hilight(")") + "\r\n{\r\n";
for (int i = 0; i < caseValues.size(); i++) {
ret += "case " + caseValues.get(i).toString(constants) + ":\r\n";