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"; }