From 6ca0fcf152e840d927f3f9e09fc6f6ef9f2331be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Fri, 29 Jan 2021 11:16:16 +0100 Subject: [PATCH] =?UTF-8?q?Fixed=20ASC2=20=C2=A7=C2=A7push=20of=20function?= =?UTF-8?q?=20calls=20before=20returning=20from=20a=20method?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + .../src/com/jpexs/decompiler/graph/Graph.java | 10 +++++++++- .../testdata/flashdevelop/flashdevelop.as3proj | 2 +- .../testdata/flashdevelop/obj/flashdevelopConfig.old | 2 -- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba5eabc53..67082e317 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ All notable changes to this project will be documented in this file. - AS3 docs not correctly displayed under p-code when metadata present - Improper initialization of ActiveX component when Flash not available causing FFDec not start - #1206 Switch with multiple default clauses +- ASC2 §§push of function calls before returning from a method ### Changed - AS3 test methods separated to classes diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Graph.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Graph.java index 6e37fb355..94f04e0f1 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Graph.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Graph.java @@ -2362,13 +2362,16 @@ public class Graph { protected static void makeAllCommands(List commands, TranslateStack stack) { int clen = commands.size(); + boolean isExit = false; if (clen > 0) { if (commands.get(clen - 1) instanceof ScriptEndItem) { clen--; + isExit = true; } } if (clen > 0) { if (commands.get(clen - 1) instanceof ExitItem) { + isExit = true; clen--; } } @@ -2391,7 +2394,12 @@ public class Graph { if (p instanceof FunctionActionItem) { commands.add(clen, p); } else { - commands.add(clen, new PushItem(p)); + if (isExit) { + //ASC2 leaves some function calls unpopped on stack before returning from a method + commands.add(clen, p); + } else { + commands.add(clen, new PushItem(p)); + } } } } diff --git a/libsrc/ffdec_lib/testdata/flashdevelop/flashdevelop.as3proj b/libsrc/ffdec_lib/testdata/flashdevelop/flashdevelop.as3proj index d3147a1b3..0e516e727 100644 --- a/libsrc/ffdec_lib/testdata/flashdevelop/flashdevelop.as3proj +++ b/libsrc/ffdec_lib/testdata/flashdevelop/flashdevelop.as3proj @@ -28,7 +28,7 @@