public Instruction getLastInstr() { return collinstr.getLast(); }
private static boolean isSequenceDisbandable(Statement block, Statement next) { Statement last = block.getStats().getLast(); List<StatEdge> lstSuccs = last.getAllSuccessorEdges(); if (!lstSuccs.isEmpty()) { if (lstSuccs.get(0).getDestination() != next) { return false; } } for (StatEdge edge : next.getPredecessorEdges(StatEdge.TYPE_BREAK)) { if (last != edge.getSource() && !last.containsStatementStrict(edge.getSource())) { return false; } } return true; }
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 cleanUpUnreachableBlocks(Statement stat) { boolean found; do { found = false; for (int i = 0; i < stat.getStats().size(); i++) { Statement st = stat.getStats().get(i); cleanUpUnreachableBlocks(st); if (st.type == Statement.TYPE_SEQUENCE && st.getStats().size() > 1) { Statement last = st.getStats().getLast(); Statement secondlast = st.getStats().get(st.getStats().size() - 2); if (last.getExprents() == null || !last.getExprents().isEmpty()) { if (!secondlast.hasBasicSuccEdge()) { Set<Statement> set = last.getNeighboursSet(Statement.STATEDGE_DIRECT_ALL, Statement.DIRECTION_BACKWARD); set.remove(secondlast); if (set.isEmpty()) { last.setExprents(new ArrayList<>()); found = true; break; } } } } } } while (found); }
private static Statement getNextStatement(Statement stat) { Statement parent = stat.getParent(); switch (parent.type) { case Statement.TYPE_ROOT: return ((RootStatement)parent).getDummyExit(); case Statement.TYPE_DO: return parent; case Statement.TYPE_SEQUENCE: SequenceStatement sequence = (SequenceStatement)parent; if (sequence.getStats().getLast() != stat) { for (int i = sequence.getStats().size() - 1; i >= 0; i--) { if (sequence.getStats().get(i) == stat) { return sequence.getStats().get(i + 1); } } } } return getNextStatement(parent); }
Statement last = st.getStats().getLast(); if (last.getAllSuccessorEdges().isEmpty() && i < lst.size() - 1) { last.addSuccessor(new StatEdge(StatEdge.TYPE_REGULAR, last, lst.get(i + 1)));
sequence.getStats().getLast() == stat && sequence.getStats().get(sequence_stats_number - 2).type == Statement.TYPE_IF) {
last = last.getStats().getLast();
switch (stat.type) { case Statement.TYPE_SEQUENCE: return hasDirectEndEdge(stat.getStats().getLast(), from); case Statement.TYPE_CATCHALL: case Statement.TYPE_TRYCATCH:
Statement last = parent.type == Statement.TYPE_SEQUENCE ? parent.getStats().getLast() : ifstat; noelsestat = (last == ifstat);
public Instruction getLastInstr() { return collinstr.getLast(); }
private static boolean isSequenceDisbandable(Statement block, Statement next) { Statement last = block.getStats().getLast(); List<StatEdge> lstSuccs = last.getAllSuccessorEdges(); if (!lstSuccs.isEmpty()) { if (lstSuccs.get(0).getDestination() != next) { return false; } } for (StatEdge edge : next.getPredecessorEdges(StatEdge.TYPE_BREAK)) { if (last != edge.getSource() && !last.containsStatementStrict(edge.getSource())) { return false; } } return true; }
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 cleanUpUnreachableBlocks(Statement stat) { boolean found; do { found = false; for (int i = 0; i < stat.getStats().size(); i++) { Statement st = stat.getStats().get(i); cleanUpUnreachableBlocks(st); if (st.type == Statement.TYPE_SEQUENCE && st.getStats().size() > 1) { Statement last = st.getStats().getLast(); Statement secondlast = st.getStats().get(st.getStats().size() - 2); if (last.getExprents() == null || !last.getExprents().isEmpty()) { if (!secondlast.hasBasicSuccEdge()) { Set<Statement> set = last.getNeighboursSet(Statement.STATEDGE_DIRECT_ALL, Statement.DIRECTION_BACKWARD); set.remove(secondlast); if (set.isEmpty()) { last.setExprents(new ArrayList<>()); found = true; break; } } } } } } while (found); }
private static Statement getNextStatement(Statement stat) { Statement parent = stat.getParent(); switch (parent.type) { case Statement.TYPE_ROOT: return ((RootStatement)parent).getDummyExit(); case Statement.TYPE_DO: return parent; case Statement.TYPE_SEQUENCE: SequenceStatement sequence = (SequenceStatement)parent; if (sequence.getStats().getLast() != stat) { for (int i = sequence.getStats().size() - 1; i >= 0; i--) { if (sequence.getStats().get(i) == stat) { return sequence.getStats().get(i + 1); } } } } return getNextStatement(parent); }
Statement last = st.getStats().getLast(); if (last.getAllSuccessorEdges().isEmpty() && i < lst.size() - 1) { last.addSuccessor(new StatEdge(StatEdge.TYPE_REGULAR, last, lst.get(i + 1)));
sequence.getStats().getLast() == stat && sequence.getStats().get(sequence_stats_number - 2).type == Statement.TYPE_IF) {
Statement last = closure.getStats().getLast();
last = last.getStats().getLast();
switch (stat.type) { case Statement.TYPE_SEQUENCE: return hasDirectEndEdge(stat.getStats().getLast(), from); case Statement.TYPE_CATCHALL: case Statement.TYPE_TRYCATCH: