From 125e8d29cd72e0ba1b02a60c4c339ec042a0408f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sun, 15 Jan 2023 17:10:23 +0100 Subject: [PATCH] =?UTF-8?q?Fixed=20#1842=20AS=20-=20Do=20not=20display=20?= =?UTF-8?q?=C2=A7=C2=A7dup=20when=20the=20value=20has=20no=20sideeffect?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + .../src/com/jpexs/decompiler/graph/model/DuplicateItem.java | 2 +- .../src/com/jpexs/decompiler/graph/model/PopItem.java | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 38e34efd5..e2ffb735c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ All notable changes to this project will be documented in this file. - [#1458] Quick find bar overlaying horizontal scrollbar - [#1842] AS1/2 Better handling obfuscated code, for..in - [#1842] AS1/2 use parenthesis when initObject has nonstring keys +- [#1842] AS - Do not display §§dup when the value has no sideeffect ## [18.3.2] - 2023-01-10 ### Removed diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/model/DuplicateItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/model/DuplicateItem.java index 909764c22..327ab918d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/model/DuplicateItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/model/DuplicateItem.java @@ -49,7 +49,7 @@ public class DuplicateItem extends GraphTargetItem implements SimpleValue { @Override public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException { - if (((value instanceof SimpleValue) && (((SimpleValue) value).isSimpleValue())) || !Configuration.displayDupInstructions.get()) { + if (!value.hasSideEffect() || !Configuration.displayDupInstructions.get()) { return value.appendTry(writer, localData); } writer.append("§§dup("); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/model/PopItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/model/PopItem.java index d82127f95..c997384c2 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/model/PopItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/model/PopItem.java @@ -62,4 +62,9 @@ public class PopItem extends GraphTargetItem { public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { return generator.generate(localData, this); } + + @Override + public boolean hasSideEffect() { + return true; //? + } }