From e9568e413b8d1bb68b078083f4f91d31b3c0960a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Fri, 13 Jan 2023 18:44:33 +0100 Subject: [PATCH] Fixed AS3 - local registers type declarations vs for..in clause --- CHANGELOG.md | 1 + .../com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java | 11 +++++------ .../ActionScript3ClassicDecompileTest.java | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2db0b8ef6..4ec9c28fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file. - [#1801] AS3 - AIR/Flash switching - [#1892] AS3 - internal modifier after implicit namespace - [#1888] AS3 - Coerce to string +- AS3 - local registers type declarations vs for..in clause ## [18.3.2] - 2023-01-10 ### Removed diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java index 6c90d8ea1..6a0b1b8f5 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java @@ -1776,14 +1776,13 @@ public class AVM2Code implements Cloneable { GraphTargetItem vtype = TypeItem.UNBOUNDED; if (assignment.value instanceof ConvertAVM2Item) { vtype = ((ConvertAVM2Item) assignment.value).type; - } - - if (vtype.equals(TypeItem.UNBOUNDED) && (assignment.value instanceof CoerceAVM2Item)) { + } else if (assignment.value instanceof CoerceAVM2Item) { vtype = ((CoerceAVM2Item) assignment.value).typeObj; - } - if (vtype.equals(TypeItem.UNBOUNDED) && (assignment.value instanceof SimpleValue) && ((SimpleValue) assignment.value).isSimpleValue()) { + } else if (assignment instanceof LocalRegAVM2Item) { //for..in + vtype = ((LocalRegAVM2Item)assignment).type; + } else if ((assignment.value instanceof SimpleValue) && ((SimpleValue) assignment.value).isSimpleValue()) { vtype = assignment.value.returnType(); - } + } if (declaredRegisters[reg] == null) { declaredRegisters[reg] = new DeclarationAVM2Item(assignment, vtype); diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3ClassicDecompileTest.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3ClassicDecompileTest.java index 25a8b7f3e..d8c37a363 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3ClassicDecompileTest.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3ClassicDecompileTest.java @@ -699,7 +699,7 @@ public class ActionScript3ClassicDecompileTest extends ActionScript3DecompileTes @Test public void testForInIf() { - decompileMethod("classic", "testForInIf", "var a:* = null;\r\n" + decompileMethod("classic", "testForInIf", "var a:String = null;\r\n" + "var arr:Array = [\"a\",\"b\",\"c\"];\r\n" + "var b:int = 5;\r\n" + "for(a in arr)\r\n" @@ -733,7 +733,7 @@ public class ActionScript3ClassicDecompileTest extends ActionScript3DecompileTes @Test public void testForInSwitch() { - decompileMethod("classic", "testForInSwitch", "var a:* = null;\r\n" + decompileMethod("classic", "testForInSwitch", "var a:String = null;\r\n" + "var arr:Array = [\"a\",\"b\",\"c\"];\r\n" + "for(a in arr)\r\n" + "{\r\n"