AS3 p-code more RAbcDasm like: commas in parameters list (WARNING: Breaks backward compatibility)

This commit is contained in:
Jindra Petřík
2021-01-25 19:59:39 +01:00
parent 2012ddf2e4
commit 05f7561314
4 changed files with 22 additions and 9 deletions

View File

@@ -230,6 +230,9 @@ public class AVM2Instruction implements Cloneable, GraphSourceItem {
public String getParams(AVM2ConstantPool constants, List<DottedChain> fullyQualifiedNames) {
StringBuilder s = new StringBuilder();
for (int i = 0; i < definition.operands.length; i++) {
if (i > 0) {
s.append(",");
}
switch (definition.operands[i]) {
case AVM2Code.DAT_NAMESPACE_INDEX:
if (operands[i] == 0) {
@@ -373,8 +376,11 @@ public class AVM2Instruction implements Cloneable, GraphSourceItem {
public String toStringNoAddress(AVM2ConstantPool constants, List<DottedChain> fullyQualifiedNames) {
String s = definition.instructionName;
for (int i = s.length(); i < 19; i++) {
s += " ";
}
s += getParams(constants, fullyQualifiedNames) + getComment();
return s;
return s.trim();
}
@Override

View File

@@ -854,6 +854,12 @@ public class ASM3Parser {
for (int i = 0; i < def.operands.length; i++) {
ParsedSymbol parsedOperand = lexer.lex();
if (i > 0) {
if (parsedOperand.type != ParsedSymbol.TYPE_COMMA) {
throw new AVM2ParseException("Comma (,) expected", lexer.yyline());
}
parsedOperand = lexer.lex();
}
switch (def.operands[i]) {
case AVM2Code.DAT_MULTINAME_INDEX:
lexer.pushback(parsedOperand);