From 16a5edc8415aee10fc8f5110d3da8b3d64a9e52a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sun, 15 Jan 2023 21:07:21 +0100 Subject: [PATCH] Fixed #1938 AS3 - coercion call type --- CHANGELOG.md | 1 + .../abc/avm2/instructions/other/GetPropertyIns.java | 2 +- .../com/jpexs/decompiler/graph/model/TernarOpItem.java | 10 ++++++---- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index df57ed47a..d763ef7e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ All notable changes to this project will be documented in this file. - [#1938] AS3 Direct editation - local registers coerce/convert - [#1938] AS3 Direct editation - setting default values for slots - AS3 Direct editation - using local classes as types +- [#1938] AS3 - coercion call type ## [18.3.2] - 2023-01-10 ### Removed diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetPropertyIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetPropertyIns.java index 620832a91..627117d8f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetPropertyIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetPropertyIns.java @@ -180,7 +180,7 @@ public class GetPropertyIns extends InstructionDefinition { GraphTargetItem ti = AbcIndexing.multinameToType(multiname.multinameIndex, localData.abc.constants);//new TypeItem(localData.abc.constants.getMultiname(multiname.multinameIndex).getNameWithNamespace(localData.abc.constants, true)); if (localData.abcIndex.findClass(ti, localData.abc, localData.scriptIndex) != null) { type.setVal(ti); - callType.setVal(TypeItem.UNBOUNDED); + callType.setVal(ti); //coercion i = int(xx); isStatic.setVal(true); return; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/model/TernarOpItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/model/TernarOpItem.java index 3057de619..6b4e0f521 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/model/TernarOpItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/model/TernarOpItem.java @@ -95,11 +95,13 @@ public class TernarOpItem extends GraphTargetItem { @Override public GraphTargetItem returnType() { - if (onTrue.returnType().equals(onFalse.returnType())) { - return onTrue.returnType(); + GraphTargetItem onTrueType = onTrue.returnType(); + GraphTargetItem onFalseType = onFalse.returnType(); + if (onTrueType.equals(onFalseType)) { + return onTrueType; } - if ((onTrue.returnType().equals(TypeItem.NUMBER) || onTrue.returnType().equals(TypeItem.INT) || onTrue.returnType().equals(TypeItem.UINT)) - && (onFalse.returnType().equals(TypeItem.NUMBER) || onFalse.returnType().equals(TypeItem.INT) || onFalse.returnType().equals(TypeItem.UINT))) { + if ((onTrueType.equals(TypeItem.NUMBER) || onTrueType.equals(TypeItem.INT) || onTrueType.equals(TypeItem.UINT)) + && (onFalseType.equals(TypeItem.NUMBER) || onFalseType.equals(TypeItem.INT) || onFalseType.equals(TypeItem.UINT))) { return TypeItem.NUMBER; } return TypeItem.UNKNOWN;