mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-26 08:05:34 +00:00
Fixed Float/Float4 ABC format support
This commit is contained in:
@@ -1137,7 +1137,7 @@ public class ABC implements Openable {
|
||||
output = new Utf8PrintWriter(os);
|
||||
constants.dump(output);
|
||||
for (int i = 0; i < method_info.size(); i++) {
|
||||
output.println("MethodInfo[" + i + "]:" + method_info.get(i).toString(constants, new ArrayList<>()));
|
||||
output.println("MethodInfo[" + i + "]:" + method_info.get(i).toString(this, new ArrayList<>()));
|
||||
}
|
||||
for (int i = 0; i < metadata_info.size(); i++) {
|
||||
output.println("MetadataInfo[" + i + "]:" + metadata_info.get(i).toString(constants));
|
||||
|
||||
@@ -1204,7 +1204,7 @@ public class AVM2Code implements Cloneable {
|
||||
}
|
||||
writer.newLine();
|
||||
|
||||
info.toASMSource(constants, writer);
|
||||
info.toASMSource(abc, writer);
|
||||
}
|
||||
writer.newLine();
|
||||
|
||||
|
||||
@@ -253,7 +253,7 @@ public class MethodInfo {
|
||||
return ret.toString();
|
||||
}
|
||||
|
||||
public String toString(AVM2ConstantPool constants, List<DottedChain> fullyQualifiedNames) {
|
||||
public String toString(ABC abc, List<DottedChain> fullyQualifiedNames) {
|
||||
StringBuilder optionalStr = new StringBuilder();
|
||||
optionalStr.append("[");
|
||||
if (optional != null) {
|
||||
@@ -261,7 +261,7 @@ public class MethodInfo {
|
||||
if (i > 0) {
|
||||
optionalStr.append(",");
|
||||
}
|
||||
optionalStr.append(optional[i].toString(constants));
|
||||
optionalStr.append(optional[i].toString(abc));
|
||||
}
|
||||
}
|
||||
optionalStr.append("]");
|
||||
@@ -274,7 +274,7 @@ public class MethodInfo {
|
||||
if (param_types[i] == 0) {
|
||||
param_typesStr.append("*");
|
||||
} else {
|
||||
param_typesStr.append(constants.getMultiname(param_types[i]).toString(constants, fullyQualifiedNames));
|
||||
param_typesStr.append(abc.constants.getMultiname(param_types[i]).toString(abc.constants, fullyQualifiedNames));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,17 +283,17 @@ public class MethodInfo {
|
||||
if (i > 0) {
|
||||
paramNamesStr.append(",");
|
||||
}
|
||||
paramNamesStr.append(constants.getString(paramNames[i]));
|
||||
paramNamesStr.append(abc.constants.getString(paramNames[i]));
|
||||
}
|
||||
|
||||
String ret_typeStr;
|
||||
if (ret_type == 0) {
|
||||
ret_typeStr = "*";
|
||||
} else {
|
||||
ret_typeStr = constants.getMultiname(ret_type).toString(constants, fullyQualifiedNames);
|
||||
ret_typeStr = abc.constants.getMultiname(ret_type).toString(abc.constants, fullyQualifiedNames);
|
||||
}
|
||||
|
||||
return "param_types=" + param_typesStr + " ret_type=" + ret_typeStr + " name=\"" + constants.getString(name_index) + "\" flags=" + flags + " optional=" + optionalStr + " paramNames=" + paramNamesStr;
|
||||
return "param_types=" + param_typesStr + " ret_type=" + ret_typeStr + " name=\"" + abc.constants.getString(name_index) + "\" flags=" + flags + " optional=" + optionalStr + " paramNames=" + paramNamesStr;
|
||||
}
|
||||
|
||||
public String getName(AVM2ConstantPool constants) {
|
||||
@@ -346,7 +346,7 @@ public class MethodInfo {
|
||||
if (i >= param_types.length - optional.length) {
|
||||
int optionalIndex = i - (param_types.length - optional.length);
|
||||
writer.appendNoHilight(" = ");
|
||||
writer.hilightSpecial(optional[optionalIndex].toString(constants), HighlightSpecialType.OPTIONAL, optionalIndex);
|
||||
writer.hilightSpecial(optional[optionalIndex].toString(abc), HighlightSpecialType.OPTIONAL, optionalIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -400,9 +400,9 @@ public class MethodInfo {
|
||||
return rname;
|
||||
}
|
||||
|
||||
public void toASMSource(AVM2ConstantPool constants, GraphTextWriter writer) {
|
||||
public void toASMSource(ABC abc, GraphTextWriter writer) {
|
||||
writer.appendNoHilight("name ");
|
||||
writer.hilightSpecial(name_index == 0 ? "null" : "\"" + Helper.escapeActionScriptString(getName(constants)) + "\"", HighlightSpecialType.METHOD_NAME);
|
||||
writer.hilightSpecial(name_index == 0 ? "null" : "\"" + Helper.escapeActionScriptString(getName(abc.constants)) + "\"", HighlightSpecialType.METHOD_NAME);
|
||||
writer.newLine();
|
||||
if (flagNative()) {
|
||||
writer.appendNoHilight("flag ");
|
||||
@@ -446,7 +446,7 @@ public class MethodInfo {
|
||||
}
|
||||
for (int p = 0; p < param_types.length; p++) {
|
||||
writer.appendNoHilight("param ");
|
||||
writer.hilightSpecial(constants.multinameToString(param_types[p]), HighlightSpecialType.PARAM, p);
|
||||
writer.hilightSpecial(abc.constants.multinameToString(param_types[p]), HighlightSpecialType.PARAM, p);
|
||||
writer.newLine();
|
||||
}
|
||||
if (flagHas_paramnames()) {
|
||||
@@ -456,7 +456,7 @@ public class MethodInfo {
|
||||
writer.appendNoHilight("null");
|
||||
} else {
|
||||
writer.appendNoHilight("\"");
|
||||
writer.appendNoHilight(constants.getString(n));
|
||||
writer.appendNoHilight(abc.constants.getString(n));
|
||||
writer.appendNoHilight("\"");
|
||||
}
|
||||
writer.newLine();
|
||||
@@ -466,12 +466,12 @@ public class MethodInfo {
|
||||
for (int i = 0; i < optional.length; i++) {
|
||||
ValueKind vk = optional[i];
|
||||
writer.appendNoHilight("optional ");
|
||||
writer.hilightSpecial(vk.toASMString(constants), HighlightSpecialType.OPTIONAL, i);
|
||||
writer.hilightSpecial(vk.toASMString(abc), HighlightSpecialType.OPTIONAL, i);
|
||||
writer.newLine();
|
||||
}
|
||||
}
|
||||
writer.appendNoHilight("returns ");
|
||||
writer.hilightSpecial(constants.multinameToString(ret_type), HighlightSpecialType.RETURNS);
|
||||
writer.hilightSpecial(abc.constants.multinameToString(ret_type), HighlightSpecialType.RETURNS);
|
||||
writer.newLine();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.abc.types;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.helpers.Helper;
|
||||
@@ -60,9 +61,9 @@ public class ValueKind {
|
||||
|
||||
public static final int CONSTANT_Float4 = 0x1E;// float4
|
||||
|
||||
private static final int[] optionalKinds = new int[]{0x03, 0x04, 0x06, 0x02, 0x01, 0x0B, 0x0A, 0x0C, 0x00, 0x08, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x05};
|
||||
private static final int[] optionalKinds = new int[]{0x03, 0x04, 0x06, 0x02, 0x01, 0x0B, 0x0A, 0x0C, 0x00, 0x08, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x05, 0x1E};
|
||||
|
||||
private static final String[] optionalKindNames = new String[]{"Int", "UInt", "Double", "Decimal", "Utf8", "True", "False", "Null", "Undefined", "Namespace", "PackageNamespace", "PackageInternalNs", "ProtectedNamespace", "ExplicitNamespace", "StaticProtectedNs", "PrivateNamespace"};
|
||||
private static final String[] optionalKindNames = new String[]{"Int", "UInt", "Double", "Decimal/Float", "Utf8", "True", "False", "Null", "Undefined", "Namespace", "PackageNamespace", "PackageInternalNs", "ProtectedNamespace", "ExplicitNamespace", "StaticProtectedNs", "PrivateNamespace", "Float4"};
|
||||
|
||||
public int value_index;
|
||||
|
||||
@@ -128,23 +129,34 @@ public class ValueKind {
|
||||
}
|
||||
}
|
||||
|
||||
public String toString(AVM2ConstantPool constants) {
|
||||
public String toString(ABC abc) {
|
||||
String ret = "?";
|
||||
switch (value_kind) {
|
||||
case CONSTANT_Int:
|
||||
ret = EcmaScript.toString(constants.getInt(value_index));
|
||||
ret = EcmaScript.toString(abc.constants.getInt(value_index));
|
||||
break;
|
||||
case CONSTANT_UInt:
|
||||
ret = EcmaScript.toString(constants.getUInt(value_index));
|
||||
ret = EcmaScript.toString(abc.constants.getUInt(value_index));
|
||||
break;
|
||||
case CONSTANT_Double:
|
||||
ret = EcmaScript.toString(constants.getDouble(value_index));
|
||||
ret = EcmaScript.toString(abc.constants.getDouble(value_index));
|
||||
break;
|
||||
case CONSTANT_DecimalOrFloat:
|
||||
ret = "" + constants.getDecimal(value_index);
|
||||
if (abc.hasDecimalSupport()) {
|
||||
ret = "" + abc.constants.getDecimal(value_index);
|
||||
} else {
|
||||
ret = "" + EcmaScript.toString(abc.constants.getFloat(value_index));
|
||||
}
|
||||
break;
|
||||
case CONSTANT_Float4:
|
||||
Float4 f4 = abc.constants.getFloat4(value_index);
|
||||
ret = "[" + EcmaScript.toString(f4.values[0]) + ", "
|
||||
+ EcmaScript.toString(f4.values[1]) + ", "
|
||||
+ EcmaScript.toString(f4.values[2]) + ", "
|
||||
+ EcmaScript.toString(f4.values[3]) + "]";
|
||||
break;
|
||||
case CONSTANT_Utf8:
|
||||
ret = "\"" + Helper.escapeActionScriptString(constants.getString(value_index)) + "\"";
|
||||
ret = "\"" + Helper.escapeActionScriptString(abc.constants.getString(value_index)) + "\"";
|
||||
break;
|
||||
case CONSTANT_True:
|
||||
ret = "true";
|
||||
@@ -158,35 +170,46 @@ public class ValueKind {
|
||||
case CONSTANT_Undefined:
|
||||
ret = "undefined";
|
||||
break;
|
||||
case CONSTANT_Namespace:
|
||||
case CONSTANT_Namespace:
|
||||
case CONSTANT_PackageInternalNs:
|
||||
case CONSTANT_ProtectedNamespace:
|
||||
case CONSTANT_ExplicitNamespace:
|
||||
case CONSTANT_StaticProtectedNs:
|
||||
case CONSTANT_PrivateNs:
|
||||
ret = "\"" + constants.getNamespace(value_index).getName(constants).toRawString() + "\""; //assume not null name
|
||||
ret = "\"" + abc.constants.getNamespace(value_index).getName(abc.constants).toRawString() + "\""; //assume not null name
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public String toASMString(AVM2ConstantPool constants) {
|
||||
public String toASMString(ABC abc) {
|
||||
String ret = "?";
|
||||
switch (value_kind) {
|
||||
case CONSTANT_Int:
|
||||
ret = "Integer(" + constants.getInt(value_index) + ")";
|
||||
ret = "Integer(" + abc.constants.getInt(value_index) + ")";
|
||||
break;
|
||||
case CONSTANT_UInt:
|
||||
ret = "UInteger(" + constants.getUInt(value_index) + ")";
|
||||
ret = "UInteger(" + abc.constants.getUInt(value_index) + ")";
|
||||
break;
|
||||
case CONSTANT_Double:
|
||||
ret = "Double(" + EcmaScript.toString(constants.getDouble(value_index)) + ")";
|
||||
ret = "Double(" + EcmaScript.toString(abc.constants.getDouble(value_index)) + ")";
|
||||
break;
|
||||
case CONSTANT_DecimalOrFloat:
|
||||
ret = "Decimal(" + constants.getDecimal(value_index) + ")";
|
||||
case CONSTANT_DecimalOrFloat:
|
||||
if (abc.hasDecimalSupport()) {
|
||||
ret = "Decimal(" + abc.constants.getDecimal(value_index) + ")";
|
||||
} else {
|
||||
ret = "Float(" + EcmaScript.toString(abc.constants.getFloat(value_index)) + ")";
|
||||
}
|
||||
break;
|
||||
case CONSTANT_Float4:
|
||||
Float4 f4 = abc.constants.getFloat4(value_index);
|
||||
ret = "Float4(" + EcmaScript.toString(f4.values[0]) + ", "
|
||||
+ EcmaScript.toString(f4.values[1]) + ", "
|
||||
+ EcmaScript.toString(f4.values[2]) + ", "
|
||||
+ EcmaScript.toString(f4.values[3]) + ")";
|
||||
break;
|
||||
case CONSTANT_Utf8:
|
||||
ret = "Utf8(\"" + Helper.escapePCodeString(constants.getString(value_index)) + "\")";
|
||||
ret = "Utf8(\"" + Helper.escapePCodeString(abc.constants.getString(value_index)) + "\")";
|
||||
break;
|
||||
case CONSTANT_True:
|
||||
ret = "True()";
|
||||
@@ -200,16 +223,16 @@ public class ValueKind {
|
||||
case CONSTANT_Undefined:
|
||||
ret = "Undefined()"; //"Void()" is also synonym
|
||||
break;
|
||||
case CONSTANT_Namespace:
|
||||
case CONSTANT_Namespace:
|
||||
case CONSTANT_PackageInternalNs:
|
||||
case CONSTANT_ProtectedNamespace:
|
||||
case CONSTANT_ExplicitNamespace:
|
||||
case CONSTANT_StaticProtectedNs:
|
||||
case CONSTANT_PrivateNs:
|
||||
String nsVal = constants.getNamespace(value_index).getKindStr() + "(\"" + constants.getNamespace(value_index).getName(constants).toRawString() + "\")"; //assume not null name
|
||||
|
||||
case CONSTANT_PrivateNs:
|
||||
String nsVal = abc.constants.getNamespace(value_index).getKindStr() + "(\"" + abc.constants.getNamespace(value_index).getName(abc.constants).toRawString() + "\")"; //assume not null name
|
||||
|
||||
switch (value_kind) {
|
||||
case CONSTANT_Namespace:
|
||||
case CONSTANT_Namespace:
|
||||
ret = "Namespace(" + nsVal + ")";
|
||||
break;
|
||||
case CONSTANT_PackageInternalNs:
|
||||
|
||||
@@ -77,7 +77,7 @@ public class TraitSlotConst extends Trait implements TraitWithSlot {
|
||||
if (type_index > 0) {
|
||||
typeStr = abc.constants.getMultiname(type_index).toString(abc.constants, fullyQualifiedNames);
|
||||
}
|
||||
return "0x" + Helper.formatAddress(fileOffset) + " " + Helper.byteArrToString(bytes) + " SlotConst " + abc.constants.getMultiname(name_index).toString(abc.constants, fullyQualifiedNames) + " slot=" + slot_id + " type=" + typeStr + " value=" + (new ValueKind(value_index, value_kind)).toString(abc.constants) + " metadata=" + Helper.intArrToString(metadata);
|
||||
return "0x" + Helper.formatAddress(fileOffset) + " " + Helper.byteArrToString(bytes) + " SlotConst " + abc.constants.getMultiname(name_index).toString(abc.constants, fullyQualifiedNames) + " slot=" + slot_id + " type=" + typeStr + " value=" + (new ValueKind(value_index, value_kind)).toString(abc) + " metadata=" + Helper.intArrToString(metadata);
|
||||
}
|
||||
|
||||
public String getType(AVM2ConstantPool constants, List<DottedChain> fullyQualifiedNames) {
|
||||
@@ -150,7 +150,7 @@ public class TraitSlotConst extends Trait implements TraitWithSlot {
|
||||
|
||||
if (value_kind != 0) {
|
||||
ValueKind val = new ValueKind(value_index, value_kind);
|
||||
writer.hilightSpecial(val.toString(abc.constants), HighlightSpecialType.TRAIT_VALUE);
|
||||
writer.hilightSpecial(val.toString(abc), HighlightSpecialType.TRAIT_VALUE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,7 +265,7 @@ public class TraitSlotConst extends Trait implements TraitWithSlot {
|
||||
writer.newLine();
|
||||
if (value_kind != ValueKind.CONSTANT_Undefined) {
|
||||
writer.appendNoHilight("value ");
|
||||
writer.hilightSpecial((new ValueKind(value_index, value_kind).toASMString(abc.constants)), HighlightSpecialType.TRAIT_VALUE);
|
||||
writer.hilightSpecial((new ValueKind(value_index, value_kind).toASMString(abc)), HighlightSpecialType.TRAIT_VALUE);
|
||||
writer.newLine();
|
||||
}
|
||||
return writer;
|
||||
|
||||
Reference in New Issue
Block a user