From 55f72a1d3e09b7ac98889b572cdc1d6e3125ef5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Tue, 22 Apr 2025 23:47:00 +0200 Subject: [PATCH] Fixed: AS3 - AIR float support - ABC Explorer incorrectly calculating float usages (For clean action, etc.) --- CHANGELOG.md | 3 ++- .../flash/abc/usages/simple/ABCCleaner.java | 2 +- .../usages/simple/ABCSimpleUsageDetector.java | 26 ++++++++++++++++--- .../flash/gui/abc/ABCExplorerDialog.java | 6 ++--- 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f83a08b4..85c6e55fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,7 +35,8 @@ All notable changes to this project will be documented in this file. - [#2444] SVG importer - improper stroke width when using width/height with viewBox - [#2444] SVG importer - stroke width not respecting transforms - [#2415] AS3 direct editation - nested functions - prefer callstack variables over prototype chain -- AS3 - AIR float support incorrectly writes float values to output stream +- AS3 - AIR float support - incorrect writing float values to output stream +- AS3 - AIR float support - ABC Explorer incorrectly calculating float usages (For clean action, etc.) ## [22.0.2] - 2025-01-17 ### Added diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/simple/ABCCleaner.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/simple/ABCCleaner.java index 48283bd99..eb035fa67 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/simple/ABCCleaner.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/simple/ABCCleaner.java @@ -223,7 +223,7 @@ public class ABCCleaner { break; case AVM2Code.DAT_UINT_INDEX: ins.operands[operandIndex] = handleReplace(ABCSimpleUsageDetector.ItemKind.UINT, ins.operands[operandIndex], replaceMap); - break; + break; } int newOperand = ins.operands[operandIndex]; if (oldOperand != newOperand) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/simple/ABCSimpleUsageDetector.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/simple/ABCSimpleUsageDetector.java index d118e1295..05bf532be 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/simple/ABCSimpleUsageDetector.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/simple/ABCSimpleUsageDetector.java @@ -169,6 +169,13 @@ public class ABCSimpleUsageDetector { initUsages(ItemKind.INT, abc.constants.getIntCount()); initUsages(ItemKind.UINT, abc.constants.getUIntCount()); initUsages(ItemKind.DOUBLE, abc.constants.getDoubleCount()); + if (abc.hasFloatSupport()) { + initUsages(ItemKind.FLOAT, abc.constants.getFloatCount()); + } + if (abc.hasDecimalSupport()) { + initUsages(ItemKind.DECIMAL, abc.constants.getDecimalCount()); + } + initUsages(ItemKind.STRING, abc.constants.getStringCount()); initUsages(ItemKind.NAMESPACE, abc.constants.getNamespaceCount()); initUsages(ItemKind.NAMESPACESET, abc.constants.getNamespaceSetCount()); @@ -243,7 +250,7 @@ public class ABCSimpleUsageDetector { } if (m.flagHas_optional()) { for (int i = 0; i < m.optional.length; i++) { - handleUsageValueKind(m.optional[i].value_kind, m.optional[i].value_index, usageDescription + "/optional/op" + i); + handleUsageValueKind(abc, m.optional[i].value_kind, m.optional[i].value_index, usageDescription + "/optional/op" + i); } } @@ -298,6 +305,12 @@ public class ABCSimpleUsageDetector { case AVM2Code.DAT_UINT_INDEX: handleUsage(ItemKind.UINT, operand, operandDescription); break; + case AVM2Code.DAT_FLOAT_INDEX: + handleUsage(ItemKind.FLOAT, operand, operandDescription); + break; + case AVM2Code.DAT_DECIMAL_INDEX: + handleUsage(ItemKind.DECIMAL, operand, operandDescription); + break; } } } @@ -386,7 +399,7 @@ public class ABCSimpleUsageDetector { handleTraitMethodBase(abc, trait, scriptIndex, scriptTraitIndex, classIndex, traitIndex, walkType); } - protected void handleUsageValueKind(int value_kind, int value_index, String description) { + protected void handleUsageValueKind(ABC abc, int value_kind, int value_index, String description) { switch (value_kind) { case ValueKind.CONSTANT_Int: handleUsage(ItemKind.INT, value_index, description); @@ -400,6 +413,13 @@ public class ABCSimpleUsageDetector { case ValueKind.CONSTANT_Utf8: handleUsage(ItemKind.STRING, value_index, description); break; + case ValueKind.CONSTANT_DecimalOrFloat: + if (abc.hasFloatSupport()) { + handleUsage(ItemKind.FLOAT, value_index, description); + } else { + handleUsage(ItemKind.DECIMAL, value_index, description); + } + break; case ValueKind.CONSTANT_Namespace: case ValueKind.CONSTANT_PackageNamespace: case ValueKind.CONSTANT_PackageInternalNs: @@ -446,7 +466,7 @@ public class ABCSimpleUsageDetector { //description += " " + trait.getKindToStr(); handleUsageMultiname(trait.name_index, description + "/name"); handleUsageMultiname(trait.type_index, description + "/type"); - handleUsageValueKind(trait.value_kind, trait.value_index, description + "/value_index"); + handleUsageValueKind(abc, trait.value_kind, trait.value_index, description + "/value_index"); } @Override diff --git a/src/com/jpexs/decompiler/flash/gui/abc/ABCExplorerDialog.java b/src/com/jpexs/decompiler/flash/gui/abc/ABCExplorerDialog.java index 8b7c30ca5..68585457c 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/ABCExplorerDialog.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/ABCExplorerDialog.java @@ -1223,9 +1223,9 @@ public class ABCExplorerDialog extends AppDialog { CONSTANT_INT("Integers", "int", TreeIcon.CONSTANT_INT, ABCSimpleUsageDetector.ItemKind.INT), CONSTANT_UINT("UnsignedIntegers", "uint", TreeIcon.CONSTANT_UINT, ABCSimpleUsageDetector.ItemKind.UINT), CONSTANT_DOUBLE("Doubles", "dbl", TreeIcon.CONSTANT_DOUBLE, ABCSimpleUsageDetector.ItemKind.DOUBLE), - CONSTANT_DECIMAL("Decimals", "dc", TreeIcon.CONSTANT_DECIMAL, null), //needs ABC decimal support - CONSTANT_FLOAT("Floats", "fl", TreeIcon.CONSTANT_FLOAT, null), //needs ABC float support - CONSTANT_FLOAT_4("Floats4", "fl4", TreeIcon.CONSTANT_FLOAT_4, null), //needs ABC float support + CONSTANT_DECIMAL("Decimals", "dc", TreeIcon.CONSTANT_DECIMAL, ABCSimpleUsageDetector.ItemKind.DECIMAL), //needs ABC decimal support + CONSTANT_FLOAT("Floats", "fl", TreeIcon.CONSTANT_FLOAT, ABCSimpleUsageDetector.ItemKind.FLOAT), //needs ABC float support + CONSTANT_FLOAT_4("Floats4", "fl4", TreeIcon.CONSTANT_FLOAT_4, ABCSimpleUsageDetector.ItemKind.FLOAT4), //needs ABC float4 support CONSTANT_STRING("Strings", "str", TreeIcon.CONSTANT_STRING, ABCSimpleUsageDetector.ItemKind.STRING), CONSTANT_NAMESPACE("Namespaces", "ns", TreeIcon.CONSTANT_NAMESPACE, ABCSimpleUsageDetector.ItemKind.NAMESPACE), CONSTANT_NAMESPACE_SET("NamespaceSets", "nss", TreeIcon.CONSTANT_NAMESPACE_SET, ABCSimpleUsageDetector.ItemKind.NAMESPACESET),