diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Graph.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Graph.java index 695a221e8..60aee5a2c 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Graph.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Graph.java @@ -1915,17 +1915,42 @@ public class Graph { if (leftSide instanceof DuplicateItem) { isIf = false; - stack.push(new OrItem(null, localData.lineStartInstruction, prevExpr, rightSide)); + if (prevExpr.getNotCoercedNoDup() instanceof FalseItem) { + stack.push(rightSide); + } else if (rightSide.getNotCoercedNoDup() instanceof FalseItem) { + stack.push(prevExpr); + } else { + stack.push(new OrItem(null, localData.lineStartInstruction, prevExpr, rightSide)); + } } else if (leftSide.invert(null).getNotCoercedNoDup() instanceof DuplicateItem) { isIf = false; - stack.push(new AndItem(null, localData.lineStartInstruction, prevExpr, rightSide)); + if (prevExpr.getNotCoercedNoDup() instanceof TrueItem) { + stack.push(rightSide); + } else if (rightSide.getNotCoercedNoDup() instanceof TrueItem) { + stack.push(prevExpr); + } else { + stack.push(new AndItem(null, localData.lineStartInstruction, prevExpr, rightSide)); + } } else if (prevExpr instanceof FalseItem) { isIf = false; leftSide = leftSide.invert(null); - stack.push(new AndItem(null, localData.lineStartInstruction, leftSide, rightSide)); + + if (leftSide.getNotCoercedNoDup() instanceof TrueItem) { + stack.push(rightSide); + } else if (rightSide.getNotCoercedNoDup() instanceof TrueItem) { + stack.push(leftSide); + } else { + stack.push(new AndItem(null, localData.lineStartInstruction, leftSide, rightSide)); + } } else if (prevExpr instanceof TrueItem) { isIf = false; - stack.push(new OrItem(null, localData.lineStartInstruction, leftSide, rightSide)); + if (leftSide.getNotCoercedNoDup() instanceof FalseItem) { + stack.push(rightSide); + } else if (rightSide.getNotCoercedNoDup() instanceof FalseItem) { + stack.push(leftSide); + } else { + stack.push(new OrItem(null, localData.lineStartInstruction, leftSide, rightSide)); + } } else { stack.push(prevExpr); //push it back //Still unstructured diff --git a/libsrc/ffdec_lib/testdata/as3_new/bin/as3_new.air.swf b/libsrc/ffdec_lib/testdata/as3_new/bin/as3_new.air.swf index e18d5d092..c8dcdcf4f 100644 Binary files a/libsrc/ffdec_lib/testdata/as3_new/bin/as3_new.air.swf and b/libsrc/ffdec_lib/testdata/as3_new/bin/as3_new.air.swf differ diff --git a/libsrc/ffdec_lib/testdata/as3_new/bin/as3_new.flex.swf b/libsrc/ffdec_lib/testdata/as3_new/bin/as3_new.flex.swf index fcc5ea768..363a9db55 100644 Binary files a/libsrc/ffdec_lib/testdata/as3_new/bin/as3_new.flex.swf and b/libsrc/ffdec_lib/testdata/as3_new/bin/as3_new.flex.swf differ diff --git a/libsrc/ffdec_lib/testdata/as3_new/src/Main.as b/libsrc/ffdec_lib/testdata/as3_new/src/Main.as index 9d00886d3..0201af5c5 100644 --- a/libsrc/ffdec_lib/testdata/as3_new/src/Main.as +++ b/libsrc/ffdec_lib/testdata/as3_new/src/Main.as @@ -50,6 +50,7 @@ package TestIf; TestIfElse; TestIfInIf; + TestIgnoreAndOr; TestInc2; TestIncDec; TestInlineFunctions; diff --git a/libsrc/ffdec_lib/testdata/as3_new/src/tests/TestDeobfuscation.as b/libsrc/ffdec_lib/testdata/as3_new/src/tests/TestDeobfuscation.as index 4ebd55c99..ad4388932 100644 --- a/libsrc/ffdec_lib/testdata/as3_new/src/tests/TestDeobfuscation.as +++ b/libsrc/ffdec_lib/testdata/as3_new/src/tests/TestDeobfuscation.as @@ -6,13 +6,35 @@ package tests public function run():* { var r:int = Math.random(); + var t:Boolean = true; var f:Boolean = false; - if(r > 5 || f) - { - return "okay"; - } - return "after"; + if (r > 5 && t) + { + trace("A"); + } + if (r > 10 || f) + { + trace("B"); + } + if (t && r > 15) + { + trace("C"); + } + if (f || r > 20) + { + trace("D"); + } + + if (f) + { + trace("trash1"); + } + + if (!t) + { + trace("trash2"); + } } } } diff --git a/libsrc/ffdec_lib/testdata/as3_new/src/tests/TestIgnoreAndOr.as b/libsrc/ffdec_lib/testdata/as3_new/src/tests/TestIgnoreAndOr.as new file mode 100644 index 000000000..db53a8ed8 --- /dev/null +++ b/libsrc/ffdec_lib/testdata/as3_new/src/tests/TestIgnoreAndOr.as @@ -0,0 +1,27 @@ +package tests +{ + + public class TestIgnoreAndOr + { + public function run():* + { + var k:int = Math.random(); + if (k > 5 && true) + { + trace("A"); + } + if (k > 10 || false) + { + trace("B"); + } + if (true && k > 15) + { + trace("C"); + } + if (false || k > 20) + { + trace("D"); + } + } + } +}