Changed AS1/2/3 P-code - format Number values with EcmaScript toString function

This commit is contained in:
Jindra Petřík
2023-03-01 23:26:01 +01:00
parent f81d1ac58d
commit 8116df7a7b
4 changed files with 14 additions and 7 deletions

View File

@@ -31,6 +31,7 @@ import com.jpexs.decompiler.flash.abc.types.Float4;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.Multiname;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.ecma.EcmaScript;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.DottedChain;
import com.jpexs.decompiler.graph.GraphSource;
@@ -327,7 +328,7 @@ public class AVM2Instruction implements Cloneable, GraphSourceItem {
} else {
s.append(" ");
try {
s.append(constants.getDouble(operands[i]));
s.append(EcmaScript.toString(constants.getDouble(operands[i])));
} catch (IndexOutOfBoundsException iob) {
s.append("Unknown(").append(operands[i]).append(")");
}
@@ -339,7 +340,7 @@ public class AVM2Instruction implements Cloneable, GraphSourceItem {
} else {
s.append(" ");
try {
s.append(constants.getFloat(operands[i]));
s.append(EcmaScript.toString(constants.getFloat(operands[i])));
} catch (IndexOutOfBoundsException iob) {
s.append("Unknown(").append(operands[i]).append(")");
}
@@ -351,10 +352,10 @@ public class AVM2Instruction implements Cloneable, GraphSourceItem {
} else {
try {
Float4 f4 = constants.getFloat4(operands[i]);
s.append(" ").append(f4.values[0]);
s.append(" ").append(f4.values[1]);
s.append(" ").append(f4.values[2]);
s.append(" ").append(f4.values[3]);
s.append(" ").append(EcmaScript.toString(f4.values[0]));
s.append(" ").append(EcmaScript.toString(f4.values[1]));
s.append(" ").append(EcmaScript.toString(f4.values[2]));
s.append(" ").append(EcmaScript.toString(f4.values[3]));
} catch (IndexOutOfBoundsException iob) {
s.append(" Unknown(").append(operands[i]).append(")");
}

View File

@@ -180,7 +180,7 @@ public class ValueKind {
ret = "UInteger(" + constants.getUInt(value_index) + ")";
break;
case CONSTANT_Double:
ret = "Double(" + constants.getDouble(value_index) + ")";
ret = "Double(" + EcmaScript.toString(constants.getDouble(value_index)) + ")";
break;
case CONSTANT_DecimalOrFloat:
ret = "Decimal(" + constants.getDecimal(value_index) + ")";

View File

@@ -32,6 +32,7 @@ import com.jpexs.decompiler.flash.action.parser.pcode.ASMParsedSymbol;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.dumpview.DumpInfo;
import com.jpexs.decompiler.flash.ecma.EcmaScript;
import com.jpexs.decompiler.flash.ecma.Null;
import com.jpexs.decompiler.flash.ecma.Undefined;
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
@@ -346,6 +347,8 @@ public class ActionPush extends Action {
ret = "\"" + Helper.escapeActionScriptString((String) value) + "\"";
} else if (value instanceof RegisterNumber) {
ret = ((RegisterNumber) value).toStringNoName();
} else if ((value instanceof Float)||(value instanceof Double)) {
ret = EcmaScript.toString(value);
} else {
ret = value.toString();
}