AS3 direct editation - do not add popscope twice when continue/break as last statement in catch block

This commit is contained in:
Jindra Petřík
2021-02-21 15:51:19 +01:00
parent 3faf00de02
commit bac1c799be
2 changed files with 11 additions and 4 deletions

View File

@@ -849,8 +849,14 @@ public class AVM2SourceGenerator implements SourceGenerator {
localData.catchesOpenedLoops.remove(localData.catchesOpenedLoops.size() - 1);
localData.scopeStack.remove(localData.scopeStack.size() - 1);
localData.catchesTempRegs.remove(localData.catchesTempRegs.size() - 1);
catchCmd.add(ins(AVM2Instructions.PopScope));
catchCmd.addAll(toInsList(AssignableAVM2Item.killTemp(localData, this, Arrays.asList(tempReg))));
if (!item.catchCommands.get(c).isEmpty()
&& ((item.catchCommands.get(c).get(item.catchCommands.get(c).size() - 1) instanceof ContinueItem)
|| (item.catchCommands.get(c).get(item.catchCommands.get(c).size() - 1) instanceof BreakItem))) {
AssignableAVM2Item.killRegister(localData, this, tempReg.getVal());
} else {
catchCmd.add(ins(AVM2Instructions.PopScope));
catchCmd.addAll(toInsList(AssignableAVM2Item.killTemp(localData, this, Arrays.asList(tempReg))));
}
catchCmds.add(catchCmd);
}
for (int c = item.catchCommands.size() - 1; c >= 0; c--) {

View File

@@ -1736,9 +1736,10 @@ public class ActionScript3Parser {
e.setSlotNumber(1);
e.setSlotScope(Integer.MAX_VALUE); //will be changed later
expectedType(SymbolType.PARENT_CLOSE);
List<GraphTargetItem> cc = new ArrayList<>();
List<AssignableAVM2Item> catchVars = new ArrayList<>();
cc.add(command(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, true, catchVars));
expectedType(SymbolType.CURLY_OPEN);
List<GraphTargetItem> cc = commands(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, catchVars);
expectedType(SymbolType.CURLY_CLOSE);
catchesVars.add(catchVars);
variables.addAll(catchVars);