diff --git a/CHANGELOG.md b/CHANGELOG.md index 40f378fc8..0c1aa8e3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -79,6 +79,7 @@ All notable changes to this project will be documented in this file. - AS3 - Nullpointer in MethodBody when no ABC set - [#2148] AS2 Uninitialized class fields detector - [#2148] AS1/2 callmethod by register value +- [#2148] AS2 Do not return undefined for setters ### Changed - [#2120] Exported assets no longer take names from assigned classes if there is more than 1 assigned class diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/as2/ActionScript2ClassDetector.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/as2/ActionScript2ClassDetector.java index 601cae26f..2fd2fe090 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/as2/ActionScript2ClassDetector.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/as2/ActionScript2ClassDetector.java @@ -37,7 +37,9 @@ import com.jpexs.decompiler.flash.action.model.clauses.ClassActionItem; import com.jpexs.decompiler.flash.action.model.clauses.InterfaceActionItem; import com.jpexs.decompiler.flash.action.swf4.RegisterNumber; import com.jpexs.decompiler.flash.ecma.Null; +import com.jpexs.decompiler.flash.ecma.Undefined; import com.jpexs.decompiler.flash.helpers.collections.MyEntry; +import com.jpexs.decompiler.graph.AbstractGraphTargetVisitor; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.model.CommaExpressionItem; import com.jpexs.decompiler.graph.model.IfItem; @@ -620,6 +622,25 @@ public class ActionScript2ClassDetector { func.isSetter = true; if (FunctionActionItem.DECOMPILE_GET_SET) { + + AbstractGraphTargetVisitor visitor = new AbstractGraphTargetVisitor() { + @Override + public void visit(GraphTargetItem item) { + if (item instanceof ReturnActionItem) { + ReturnActionItem ret = (ReturnActionItem) item; + if (ret.value instanceof DirectValueActionItem) { + DirectValueActionItem dv = (DirectValueActionItem) ret.value; + if (dv.value instanceof Undefined) { + ret.value = null; + } + } + } + } + }; + for (GraphTargetItem ti : func.actions) { + ti.visitRecursively(visitor); + } + //There is return getter added at the end of every setter, gotta remove it, since it won't compile //as setter must not return a value if (!func.actions.isEmpty()) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/ReturnActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/ReturnActionItem.java index ef67a3047..2ea6e8bbe 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/ReturnActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/ReturnActionItem.java @@ -52,6 +52,9 @@ public class ReturnActionItem extends ActionItem implements ExitItem { @Override public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException { + if (value == null) { + return writer.append("return"); + } writer.append("return "); return value.toString(writer, localData); }