From 60df54d7e183cf540648478e760aac0af6e39da2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=F8=EDk?= Date: Fri, 21 Jun 2013 20:14:27 +0200 Subject: [PATCH] Issue #149 Empty If branches are inverted --- .../jpexs/decompiler/flash/graph/IfItem.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/trunk/src/com/jpexs/decompiler/flash/graph/IfItem.java b/trunk/src/com/jpexs/decompiler/flash/graph/IfItem.java index 6b121d48f..98a303f9b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/graph/IfItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/graph/IfItem.java @@ -48,8 +48,20 @@ public class IfItem extends GraphTargetItem implements Block { @Override public String toString(List localData) { String ret; - ret = hilight("if(") + expression.toString(localData) + hilight(")") + "\r\n{\r\n"; - for (GraphTargetItem ti : onTrue) { + GraphTargetItem expr = expression; + List ifBranch = onTrue; + List elseBranch = onFalse; + if (onTrue.isEmpty()) { + if (expr instanceof LogicalOpItem) { + expr = ((LogicalOpItem) expr).invert(); + } else { + expr = new NotItem(null, expr); + } + ifBranch = onFalse; + elseBranch = onTrue; + } + ret = hilight("if(") + expr.toString(localData) + hilight(")") + "\r\n{\r\n"; + for (GraphTargetItem ti : ifBranch) { if (!ti.isEmpty()) { ret += ti.toStringSemicoloned(localData) + "\r\n"; } @@ -57,7 +69,7 @@ public class IfItem extends GraphTargetItem implements Block { ret += hilight("}"); if (onFalse.size() > 0) { ret += "\r\n" + hilight("else") + "\r\n" + hilight("{") + "\r\n"; - for (GraphTargetItem ti : onFalse) { + for (GraphTargetItem ti : elseBranch) { if (!ti.isEmpty()) { ret += ti.toStringSemicoloned(localData) + "\r\n"; }