diff --git a/CHANGELOG.md b/CHANGELOG.md index 81402ec32..e8937390a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ All notable changes to this project will be documented in this file. - #1627 Previously decompiled scripts not cached - SWF is not garbage collected on close in some situations - AS1/2 script search does not show all results +- #1633 AS3 decompilation - return in for..in clause ### Removed - #1631 ActiveX Flash component download in windows installer diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java index 5784cb904..3a6f92677 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java @@ -1944,6 +1944,50 @@ public class AVM2Graph extends Graph { } } + List ret = list; + for (int i = 0; i < list.size(); i++) { + if (list.get(i) instanceof IfItem) { + IfItem ifi = (IfItem) list.get(i); + if (((ifi.expression instanceof HasNextAVM2Item) + || ((ifi.expression instanceof NotItem) + && (((NotItem) ifi.expression).getOriginal() instanceof HasNextAVM2Item)))) { + HasNextAVM2Item hnt; + List body = new ArrayList<>(); + List nextbody;//= new ArrayList<>(); + if (ifi.expression instanceof NotItem) { + hnt = (HasNextAVM2Item) ((NotItem) ifi.expression).getOriginal(); + body.addAll(ifi.onFalse); + for (int j = i + 1; j < list.size();) { + body.add(list.remove(i + 1)); + } + nextbody = ifi.onTrue; + } else { + hnt = (HasNextAVM2Item) ifi.expression; + body = ifi.onTrue; + nextbody = ifi.onFalse; + } + if (!body.isEmpty()) { + if (body.get(0) instanceof SetTypeAVM2Item) { + SetTypeAVM2Item sti = (SetTypeAVM2Item) body.remove(0); + GraphTargetItem gti = sti.getValue().getNotCoerced(); + GraphTargetItem repl = null; + + if (gti instanceof NextValueAVM2Item) { + repl = new ForEachInAVM2Item(ifi.getSrc(), ifi.getLineStartItem(), new Loop(0, null, null), new InAVM2Item(null, null, sti.getObject(), hnt.obj), body); + } else if (gti instanceof NextNameAVM2Item) { + repl = new ForInAVM2Item(ifi.getSrc(), ifi.getLineStartItem(), new Loop(0, null, null), new InAVM2Item(null, null, sti.getObject(), hnt.obj), body); + } + if (repl != null) { + list.remove(i); + list.add(i, repl); + list.addAll(i + 1, nextbody); + } + } + } + } + } + } + for (int i = 0; i < list.size(); i++) { if (list.get(i) instanceof WithAVM2Item) { @@ -2060,49 +2104,6 @@ public class AVM2Graph extends Graph { } } - List ret = list; - for (int i = 0; i < list.size(); i++) { - if (list.get(i) instanceof IfItem) { - IfItem ifi = (IfItem) list.get(i); - if (((ifi.expression instanceof HasNextAVM2Item) - || ((ifi.expression instanceof NotItem) - && (((NotItem) ifi.expression).getOriginal() instanceof HasNextAVM2Item)))) { - HasNextAVM2Item hnt; - List body = new ArrayList<>(); - List nextbody;//= new ArrayList<>(); - if (ifi.expression instanceof NotItem) { - hnt = (HasNextAVM2Item) ((NotItem) ifi.expression).getOriginal(); - body.addAll(ifi.onFalse); - for (int j = i + 1; j < list.size();) { - body.add(list.remove(i + 1)); - } - nextbody = ifi.onTrue; - } else { - hnt = (HasNextAVM2Item) ifi.expression; - body = ifi.onTrue; - nextbody = ifi.onFalse; - } - if (!body.isEmpty()) { - if (body.get(0) instanceof SetTypeAVM2Item) { - SetTypeAVM2Item sti = (SetTypeAVM2Item) body.remove(0); - GraphTargetItem gti = sti.getValue().getNotCoerced(); - GraphTargetItem repl = null; - - if (gti instanceof NextValueAVM2Item) { - repl = new ForEachInAVM2Item(ifi.getSrc(), ifi.getLineStartItem(), new Loop(0, null, null), new InAVM2Item(null, null, sti.getObject(), hnt.obj), body); - } else if (gti instanceof NextNameAVM2Item) { - repl = new ForInAVM2Item(ifi.getSrc(), ifi.getLineStartItem(), new Loop(0, null, null), new InAVM2Item(null, null, sti.getObject(), hnt.obj), body); - } - if (repl != null) { - list.remove(i); - list.add(i, repl); - list.addAll(i + 1, nextbody); - } - } - } - } - } - } //Handle for loops at the end: super.finalProcess(list, level, localData, path); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java index e6cb8b6f0..f185842ca 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java @@ -45,7 +45,6 @@ import com.jpexs.helpers.Helper; import com.jpexs.helpers.MemoryInputStream; import com.jpexs.helpers.stat.Statistics; import java.io.IOException; -import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.HashMap; import java.util.List;