#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

@@ -4,7 +4,8 @@ All notable changes to this project will be documented in this file.
## [Unreleased]
### Added
- #1594 Option to disable AS3 P-code indentation, label on separate line
- #1594 Option to use old style of getlocalx, setlocalx with underscore
- #1594 Option to use old style of getlocalx, setlocalx with underscore in AS3 P-code
- #1597 Option to use old style lookupswitch in AS3 P-code
### Fixed
- #1114 Script search results dialogs closing on swf close

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

View File

@@ -495,4 +495,6 @@ config.description.labelOnSeparateLineAs3PCode = Make label in AS3 P-code stand
config.name.useOldStyleGetSetLocalsAs3PCode = Use oldstyle getlocal_x instead of getlocalx in AS3 P-code
config.description.useOldStyleGetSetLocalsAs3PCode = Use oldstyle getlocal_x, setlocal_x from FFDec 12.x or older
config.name.useOldStyleLookupSwitchAs3PCode = Use oldstyle lookupswitch without brackets in AS3 P-code
config.description.useOldStyleLookupSwitchAs3PCode = Use oldstyle lookupswitch from FFDec 12.x or older

View File

@@ -485,4 +485,7 @@ config.name.labelOnSeparateLineAs3PCode = N\u00e1v\u011b\u0161t\u00ed v AS3 P-k\
config.description.labelOnSeparateLineAs3PCode = N\u00e1v\u011b\u0161t\u00ed v AS3 P-k\u00f3du budou st\u00e1t na zvl\u00e1\u0161tn\u00edm \u0159\u00e1dku
config.name.useOldStyleGetSetLocalsAs3PCode = Pou\u017e\u00edvat postaru getlocal_x m\u00edsto getlocalx v AS3 P-k\u00f3du
config.description.useOldStyleGetSetLocalsAs3PCode = Pou\u017e\u00edvat postaru getlocal_x, setlocal_x z FFDec 12.x \u010di star\u0161\u00edho
config.description.useOldStyleGetSetLocalsAs3PCode = Pou\u017e\u00edvat postaru getlocal_x, setlocal_x z FFDec 12.x a star\u0161\u00edho
config.name.useOldStyleLookupSwitchAs3PCode = Pou\u017e\u00edvat star\u00fd styl lookupswitch bez hranat\u00fdch z\u00e1vorek v AS3 P-k\u00f3du
config.description.useOldStyleLookupSwitchAs3PCode = Pou\u017e\u00edvat star\u00fd styl lookupswitch z FFDec 12.x a star\u0161\u00edho