diff --git a/CHANGELOG.md b/CHANGELOG.md index 63243631d..22fc58f42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,7 @@ All notable changes to this project will be documented in this file. - AS1/2 - direct editation - do..while - AS1/2 - newmethod proper brackets - AS1/2 - class detection with ternars +- AS1/2 - empty tellTarget ## [14.6.0] - 2021-11-22 ### Added diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionGraph.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionGraph.java index 5ed1f343f..68dbdc0c7 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionGraph.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionGraph.java @@ -275,6 +275,62 @@ public class ActionGraph extends Graph { again = true; } } while (again); + + targetStart = -1; + targetEnd = -1; + GraphTargetItem target = null; + + //process empty telltargets + for (int t = 0; t < list.size(); t++) { + GraphTargetItem it = list.get(t); + + if (it instanceof SetTargetActionItem) { + SetTargetActionItem st = (SetTargetActionItem) it; + if (st.target.isEmpty()) { + if (targetStart > -1) { + targetEnd = t; + } else { + targetStart = t; + targetStartItem = st; + target = new DirectValueActionItem(null, null, 0, st.target, new ArrayList<>()); + } + } + } + if (it instanceof SetTarget2ActionItem) { + SetTarget2ActionItem st = (SetTarget2ActionItem) it; + if ((st.target instanceof DirectValueActionItem) && st.target.getResult().equals("")) { + if (targetStart > -1) { + targetEnd = t; + } else { + targetStart = t; + targetStartItem = st; + target = st.target; + } + } + } + + if (targetStart > -1 && targetEnd > -1) { + List newlist = new ArrayList<>(); + for (int i = 0; i < targetStart; i++) { + newlist.add(list.get(i)); + } + List tellist = new ArrayList<>(); + for (int i = targetStart + 1; i < targetEnd; i++) { + tellist.add(list.get(i)); + } + newlist.add(new TellTargetActionItem(targetStartItem.getSrc(), targetStartItem.getLineStartItem(), target, tellist)); + //TODO: maybe set nested flag + for (int i = targetEnd + 1; i < list.size(); i++) { + newlist.add(list.get(i)); + } + list.clear(); + list.addAll(newlist); + targetStart = -1; + targetEnd = -1; + target = null; + t = 0; + } + } for (int t = 1/*not first*/; t < list.size(); t++) { GraphTargetItem it = list.get(t); List checkedBody = null;