diff --git a/CHANGELOG.md b/CHANGELOG.md index 5bc748fa0..f55c3af50 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file. ### Fixed - [#1761] AS3 - try..finally inside another structure like if - [#1762] AS call on integer numbers parenthesis +- [#1762] AS3 - Auto adding returnvoid/return undefined ## [15.0.0] - 2021-11-29 ### Added diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java index 1d64d239d..b371d0477 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java @@ -1916,8 +1916,13 @@ public class AVM2SourceGenerator implements SourceGenerator { declarations.add(d); } } + boolean addRet = false; if (body != null) { body.addAll(0, declarations); + if (body.isEmpty() || (!((body.get(body.size() - 1) instanceof ReturnValueAVM2Item) + || (body.get(body.size() - 1) instanceof ReturnVoidAVM2Item)))) { + addRet = true; + } } localData.exceptions = new ArrayList<>(); @@ -2002,15 +2007,14 @@ public class AVM2SourceGenerator implements SourceGenerator { mbodyCode.add(0, new AVM2Instruction(0, AVM2Instructions.GetLocal0, null)); mbodyCode.add(1, new AVM2Instruction(0, AVM2Instructions.PushScope, null)); } - boolean addRet = false; - if (!mbodyCode.isEmpty()) { + /*if (!mbodyCode.isEmpty()) { InstructionDefinition lastDef = mbodyCode.get(mbodyCode.size() - 1).definition; if (!((lastDef instanceof ReturnVoidIns) || (lastDef instanceof ReturnValueIns))) { addRet = true; } } else { addRet = true; - } + }*/ if (addRet) { if (retType.toString().equals("*") || retType.toString().equals("void") || constructor) { mbodyCode.add(new AVM2Instruction(0, AVM2Instructions.ReturnVoid, null));