void (DoStatement stat) { // search for an if condition at the end of the loop Statement last = stat.getFirst(); while (last.type == StatementType.SEQUENCE) { last = last.getStats().getLast(); } if (last.type == StatementType.IF) { IfStatement lastif = (IfStatement)last; if (lastif.iftype == IfStatement.IFTYPE_IF && lastif.getIfstat() == null) { StatEdge ifedge = lastif.getIfEdge(); StatEdge elseedge = lastif.getAllSuccessorEdges().get(0); if ((ifedge.getType() == EdgeType.BREAK && elseedge.getType() == EdgeType.CONTINUE && elseedge.closure == stat && isDirectPath(stat, ifedge.getDestination())) || (ifedge.getType() == EdgeType.CONTINUE && elseedge.getType() == EdgeType.BREAK && ifedge.closure == stat && isDirectPath(stat, elseedge.getDestination()))) { Set<Statement> set = stat.getNeighboursSet(EdgeType.CONTINUE, EdgeDirection.BACKWARD); set.remove(last); if (!set.isEmpty()) { return; } stat.setLoopType(LoopType.DO_WHILE); IfExprent ifexpr = (IfExprent)lastif.getHeadexprent().copy(); if (ifedge.getType() == EdgeType.BREAK) { ifexpr.negateIf(); } stat.setConditionExprent(ifexpr.getCondition()); lastif.getFirst().removeSuccessor(ifedge); lastif.removeSuccessor(elseedge); // remove empty if if (lastif.getFirst().getExprents().isEmpty()) { removeLastEmptyStatement(stat, lastif); } else { lastif.setExprents(lastif.getFirst().getExprents()); StatEdge newedge = new StatEdge(EdgeType.CONTINUE, lastif, stat); lastif.addSuccessor(newedge); stat.addLabeledEdge(newedge); } if (stat.getAllSuccessorEdges().isEmpty()) { StatEdge edge = elseedge.getType() == EdgeType.CONTINUE ? ifedge : elseedge; edge.setSource(stat); if (edge.closure == stat) { edge.closure = stat.getParent(); } stat.addSuccessor(edge); } } } } }