private static boolean extractFirstIf(DoStatement stat) { // search for an if condition at the entrance of the loop Statement first = stat.getFirst(); while (first.type == Statement.TYPE_SEQUENCE) { first = first.getFirst(); } // found an if statement if (first.type == Statement.TYPE_IF) { IfStatement firstif = (IfStatement)first; if (firstif.getFirst().getExprents().isEmpty()) { if (firstif.iftype == IfStatement.IFTYPE_IF && firstif.getIfstat() != null) { Statement ifstat = firstif.getIfstat(); if (isExternStatement(stat, ifstat, ifstat)) { extractIfBlock(stat, firstif); return true; } } } } return false; }
private static boolean extractLastIf(DoStatement stat) { // search for an if condition at the end of the loop Statement last = stat.getFirst(); while (last.type == Statement.TYPE_SEQUENCE) { last = last.getStats().getLast(); } if (last.type == Statement.TYPE_IF) { IfStatement lastif = (IfStatement)last; if (lastif.iftype == IfStatement.IFTYPE_IF && lastif.getIfstat() != null) { Statement ifstat = lastif.getIfstat(); StatEdge elseedge = lastif.getAllSuccessorEdges().get(0); if (elseedge.getType() == StatEdge.TYPE_CONTINUE && elseedge.closure == stat) { Set<Statement> set = stat.getNeighboursSet(StatEdge.TYPE_CONTINUE, Statement.DIRECTION_BACKWARD); set.remove(last); if (set.isEmpty()) { // no direct continues in a do{}while loop if (isExternStatement(stat, ifstat, ifstat)) { extractIfBlock(stat, lastif); return true; } } } } } return false; }
Statement ifbranch = ifstat.getIfstat();
Statement ifchild = stat.getIfstat(); if (ifchild == null) { StatEdge edge = stat.getIfEdge(); if (ifchild.type == Statement.TYPE_IF && ((IfStatement)ifchild).iftype == IfStatement.IFTYPE_IF) { IfStatement stat2 = (IfStatement)ifchild; Statement ifchild2 = stat2.getIfstat(); if (ifchild2 == null) { StatEdge edge = stat2.getIfEdge(); if (elsechild.type == Statement.TYPE_IF && ((IfStatement)elsechild).iftype == IfStatement.IFTYPE_IF) { IfStatement stat2 = (IfStatement)elsechild; Statement ifchild2 = stat2.getIfstat(); if (ifchild2 == null) { elsenode.addChild(new IfNode(stat2.getIfEdge().getDestination()), 1);
Statement ifstat = ifelsestat.getIfstat();
private static void removeParameterCheck(Statement stat) { Statement st = stat.getFirst(); while (st.type == Statement.TYPE_SEQUENCE) { st = st.getFirst(); } IfStatement ifstat = (IfStatement)st; if (ifstat.getElsestat() != null) { // if - else StatEdge ifedge = ifstat.getIfEdge(); StatEdge elseedge = ifstat.getElseEdge(); Statement ifbranch = ifstat.getIfstat(); Statement elsebranch = ifstat.getElsestat(); ifstat.getFirst().removeSuccessor(ifedge); ifstat.getFirst().removeSuccessor(elseedge); ifstat.getStats().removeWithKey(ifbranch.id); ifstat.getStats().removeWithKey(elsebranch.id); if (!ifbranch.getAllSuccessorEdges().isEmpty()) { ifbranch.removeSuccessor(ifbranch.getAllSuccessorEdges().get(0)); } ifstat.getParent().replaceStatement(ifstat, elsebranch); ifstat.getParent().setAllParent(); } }
Statement ifStatement = statement.getIfstat(); Statement elseStatement = statement.getElsestat();
private static void extractIfBlock(DoStatement loop, IfStatement ifstat) { Statement target = ifstat.getIfstat(); StatEdge ifedge = ifstat.getIfEdge();
if (lastif.iftype == IfStatement.IFTYPE_IF && lastif.getIfstat() == null) { StatEdge ifedge = lastif.getIfEdge(); StatEdge elseedge = lastif.getAllSuccessorEdges().get(0);
if (ifstat.getIfstat() == null) { noifstat = true; List<StatEdge> lstSuccs = ifstat.getIfstat().getAllSuccessorEdges(); ifdirect = !lstSuccs.isEmpty() && lstSuccs.get(0).getType() == StatEdge.TYPE_FINALLYEXIT || hasDirectEndEdge(ifstat.getIfstat(), from); Statement ifbranch = ifstat.getIfstat(); SequenceStatement newseq = new SequenceStatement(Arrays.asList(ifstat, ifbranch)); Statement ifbranch = ifstat.getIfstat();
if (firstif.getIfstat() == null) { StatEdge ifedge = firstif.getIfEdge(); if (isDirectPath(stat, ifedge.getDestination())) { if (firstif.getIfstat() == null) { BasicBlockStatement bstat = new BasicBlockStatement(new BasicBlock( DecompilerContext.getCounterContainer().getCounterAndIncrement(CounterContainer.STATEMENT_COUNTER))); first.getParent().replaceStatement(first, firstif.getIfstat());
IfStatement ifstat = (IfStatement)stat; if (ifstat.iftype == IfStatement.IFTYPE_IFELSE) { return hasDirectEndEdge(ifstat.getIfstat(), from) || hasDirectEndEdge(ifstat.getElsestat(), from);
if (ifst.getIfstat() == null) { StatEdge ifedge = ifst.getIfEdge(); dest = isExitEdge(ifedge);
private static boolean extractFirstIf(DoStatement stat) { // search for an if condition at the entrance of the loop Statement first = stat.getFirst(); while (first.type == Statement.TYPE_SEQUENCE) { first = first.getFirst(); } // found an if statement if (first.type == Statement.TYPE_IF) { IfStatement firstif = (IfStatement)first; if (firstif.getFirst().getExprents().isEmpty()) { if (firstif.iftype == IfStatement.IFTYPE_IF && firstif.getIfstat() != null) { Statement ifstat = firstif.getIfstat(); if (isExternStatement(stat, ifstat, ifstat)) { extractIfBlock(stat, firstif); return true; } } } } return false; }
private static boolean extractLastIf(DoStatement stat) { // search for an if condition at the end of the loop Statement last = stat.getFirst(); while (last.type == Statement.TYPE_SEQUENCE) { last = last.getStats().getLast(); } if (last.type == Statement.TYPE_IF) { IfStatement lastif = (IfStatement)last; if (lastif.iftype == IfStatement.IFTYPE_IF && lastif.getIfstat() != null) { Statement ifstat = lastif.getIfstat(); StatEdge elseedge = lastif.getAllSuccessorEdges().get(0); if (elseedge.getType() == StatEdge.TYPE_CONTINUE && elseedge.closure == stat) { Set<Statement> set = stat.getNeighboursSet(StatEdge.TYPE_CONTINUE, Statement.DIRECTION_BACKWARD); set.remove(last); if (set.isEmpty()) { // no direct continues in a do{}while loop if (isExternStatement(stat, ifstat, ifstat)) { extractIfBlock(stat, lastif); return true; } } } } } return false; }
private static void removeParameterCheck(Statement stat, StructMethod mt) { Statement st = stat.getFirst(); while (st.type == Statement.TYPE_SEQUENCE) { st = st.getFirst(); } IfStatement ifstat = (IfStatement)st; if (ifstat.getElsestat() == null) { // if // TODO: } else { // if - else StatEdge ifedge = ifstat.getIfEdge(); StatEdge elseedge = ifstat.getElseEdge(); Statement ifbranch = ifstat.getIfstat(); Statement elsebranch = ifstat.getElsestat(); ifstat.getFirst().removeSuccessor(ifedge); ifstat.getFirst().removeSuccessor(elseedge); ifstat.getStats().removeWithKey(ifbranch.id); ifstat.getStats().removeWithKey(elsebranch.id); if (!ifbranch.getAllSuccessorEdges().isEmpty()) { ifbranch.removeSuccessor(ifbranch.getAllSuccessorEdges().get(0)); } ifstat.getParent().replaceStatement(ifstat, elsebranch); ifstat.getParent().setAllParent(); } }
private static void extractIfBlock(DoStatement loop, IfStatement ifstat) { Statement target = ifstat.getIfstat(); StatEdge ifedge = ifstat.getIfEdge();