#1597 Option to use old style lookupswitch in AS3 P-code

This commit is contained in:
Jindra Petřík
2021-02-12 06:13:38 +01:00
parent e450f7a082
commit b9660cdfec
6 changed files with 28 additions and 9 deletions

View File

@@ -348,8 +348,13 @@ public class AVM2Instruction implements Cloneable, GraphSourceItem {
s.append(Helper.formatAddress(address + operands[i]));
break;
case AVM2Code.OPT_CASE_OFFSETS:
s.append(" [");
boolean first = true;
if (Configuration.useOldStyleLookupSwitchAs3PCode.get()) {
s.append(" ");
s.append(operands[i]);
} else {
s.append(" [");
}
boolean first = !Configuration.useOldStyleLookupSwitchAs3PCode.get();
for (int j = i + 1; j < operands.length; j++) {
if (!first) {
s.append(", ");
@@ -358,7 +363,9 @@ public class AVM2Instruction implements Cloneable, GraphSourceItem {
s.append("ofs");
s.append(Helper.formatAddress(address + operands[j]));
}
s.append("]");
if (!Configuration.useOldStyleLookupSwitchAs3PCode.get()) {
s.append("]");
}
break;
default:
s.append(" ");

View File

@@ -1061,14 +1061,13 @@ public class ASM3Parser {
while (parsedOperand.type == ParsedSymbol.TYPE_IDENTIFIER) {
offsetItems.add(new CaseOffsetItem((String) parsedOperand.value, code.code.size(), i + (c + 1)));
c++;
parsedOperand = lexer.lex();
parsedOperand = lexer.lex();
if (parsedOperand.type == ParsedSymbol.TYPE_BRACKET_CLOSE) {
break;
}
if (parsedOperand.type != ParsedSymbol.TYPE_COMMA) {
throw new AVM2ParseException("Comma , expected", lexer.yyline());
if (parsedOperand.type == ParsedSymbol.TYPE_COMMA) {
parsedOperand = lexer.lex();
}
parsedOperand = lexer.lex();
}
if (parsedOperand.type != ParsedSymbol.TYPE_BRACKET_CLOSE) {
throw new AVM2ParseException("Bracket close ] expected", lexer.yyline());
@@ -1087,6 +1086,9 @@ public class ASM3Parser {
for (int c = 0; c <= patCount; c++) {
parsedOperand = lexer.lex();
if (parsedOperand.type == ParsedSymbol.TYPE_COMMA) {
parsedOperand = lexer.lex();
}
if (parsedOperand.type == ParsedSymbol.TYPE_IDENTIFIER) {
offsetItems.add(new CaseOffsetItem((String) parsedOperand.value, code.code.size(), i + (c + 1)));
operandsList.add(0);

View File

@@ -667,6 +667,10 @@ public final class Configuration {
@ConfigurationDefaultBoolean(false)
@ConfigurationCategory("script")
public static ConfigurationItem<Boolean> useOldStyleGetSetLocalsAs3PCode = null;
@ConfigurationDefaultBoolean(false)
@ConfigurationCategory("script")
public static ConfigurationItem<Boolean> useOldStyleLookupSwitchAs3PCode = null;
private enum OSId {
WINDOWS, OSX, UNIX