public boolean hasBasicSuccEdge() { // FIXME: default switch return type == TYPE_BASICBLOCK || (type == TYPE_IF && ((IfStatement)this).iftype == IfStatement.IFTYPE_IF) || (type == TYPE_DO && ((DoStatement)this).getLooptype() != DoStatement.LOOP_DO); }
private static boolean enhanceLoop(DoStatement stat) { int oldloop = stat.getLooptype(); switch (oldloop) { case DoStatement.LOOP_DO: // identify a while loop if (matchWhile(stat)) { // identify a for loop - subtype of while matchFor(stat); } else { // identify a do{}while loop matchDoWhile(stat); } break; case DoStatement.LOOP_WHILE: matchFor(stat); } return (stat.getLooptype() != oldloop); }
DoStatement loop = (DoStatement)nd.statement; if (loop.getLooptype() == DoStatement.LOOP_FOR && loop.getInitExprent() == null &&
if (dost.getLooptype() != DoStatement.LOOP_FOR && dost.getLooptype() != DoStatement.LOOP_DO) { currVars.add(dost.getConditionExprent());
if (stat.type == Statement.TYPE_DO && ((DoStatement)stat).getLooptype() == DoStatement.LOOP_DO) { next = null;
private static boolean isOnlyEdge(StatEdge edge) { Statement stat = edge.getDestination(); for (StatEdge ed : stat.getAllPredecessorEdges()) { if (ed != edge) { if (ed.getType() == StatEdge.TYPE_REGULAR) { Statement source = ed.getSource(); if (source.type == Statement.TYPE_BASICBLOCK || (source.type == Statement.TYPE_IF && ((IfStatement)source).iftype == IfStatement.IFTYPE_IF) || (source.type == Statement.TYPE_DO && ((DoStatement)source).getLooptype() != DoStatement.LOOP_DO)) { return false; } } else { return false; } } } return true; }
private static boolean extractLoop(DoStatement stat) { if (stat.getLooptype() != DoStatement.LOOP_DO) { return false; } for (StatEdge edge : stat.getLabelEdges()) { if (edge.getType() != StatEdge.TYPE_CONTINUE && edge.getDestination().type != Statement.TYPE_DUMMYEXIT) { return false; } } return extractLastIf(stat) || extractFirstIf(stat); }
public static void lowContinueLabels(Statement stat, HashSet<StatEdge> edges) { boolean ok = (stat.type != Statement.TYPE_DO); if (!ok) { DoStatement dostat = (DoStatement)stat; ok = dostat.getLooptype() == DoStatement.LOOP_DO || dostat.getLooptype() == DoStatement.LOOP_WHILE || (dostat.getLooptype() == DoStatement.LOOP_FOR && dostat.getIncExprent() == null); } if (ok) { edges.addAll(stat.getPredecessorEdges(StatEdge.TYPE_CONTINUE)); } if (ok && stat.type == Statement.TYPE_DO) { for (StatEdge edge : edges) { if (stat.containsStatementStrict(edge.getSource())) { edge.getDestination().removePredecessor(edge); edge.getSource().changeEdgeNode(Statement.DIRECTION_FORWARD, edge, stat); stat.addPredecessor(edge); stat.addLabeledEdge(edge); } } } for (Statement st : stat.getStats()) { if (st == stat.getFirst()) { lowContinueLabels(st, edges); } else { lowContinueLabels(st, new HashSet<>()); } } }
int looptype = dostat.getLooptype();
if (dstat.getLooptype() == DoStatement.LOOP_FOR) {
public boolean hasBasicSuccEdge() { // FIXME: default switch return type == TYPE_BASICBLOCK || (type == TYPE_IF && ((IfStatement)this).iftype == IfStatement.IFTYPE_IF) || (type == TYPE_DO && ((DoStatement)this).getLooptype() != DoStatement.LOOP_DO); }
private static boolean enhanceLoop(DoStatement stat) { int oldloop = stat.getLooptype(); switch (oldloop) { case DoStatement.LOOP_DO: // identify a while loop if (matchWhile(stat)) { // identify a for loop - subtype of while matchFor(stat); } else { // identify a do{}while loop matchDoWhile(stat); } break; case DoStatement.LOOP_WHILE: matchFor(stat); } return (stat.getLooptype() != oldloop); }
DoStatement loop = (DoStatement)nd.statement; if (loop.getLooptype() == DoStatement.LOOP_FOR && loop.getInitExprent() == null &&
if (dost.getLooptype() != DoStatement.LOOP_FOR && dost.getLooptype() != DoStatement.LOOP_DO) { currVars.add(dost.getConditionExprent());
if (stat.type == Statement.TYPE_DO && ((DoStatement)stat).getLooptype() == DoStatement.LOOP_DO) { next = null;
private static boolean isLoopRedundant(DoStatement loop) { if (loop.getLooptype() != DoStatement.LOOP_DO) { return false;
private static boolean isOnlyEdge(StatEdge edge) { Statement stat = edge.getDestination(); for (StatEdge ed : stat.getAllPredecessorEdges()) { if (ed != edge) { if (ed.getType() == StatEdge.TYPE_REGULAR) { Statement source = ed.getSource(); if (source.type == Statement.TYPE_BASICBLOCK || (source.type == Statement.TYPE_IF && ((IfStatement)source).iftype == IfStatement.IFTYPE_IF) || (source.type == Statement.TYPE_DO && ((DoStatement)source).getLooptype() != DoStatement.LOOP_DO)) { return false; } } else { return false; } } } return true; }
public static void lowContinueLabels(Statement stat, HashSet<StatEdge> edges) { boolean ok = (stat.type != Statement.TYPE_DO); if (!ok) { DoStatement dostat = (DoStatement)stat; ok = dostat.getLooptype() == DoStatement.LOOP_DO || dostat.getLooptype() == DoStatement.LOOP_WHILE || (dostat.getLooptype() == DoStatement.LOOP_FOR && dostat.getIncExprent() == null); } if (ok) { edges.addAll(stat.getPredecessorEdges(StatEdge.TYPE_CONTINUE)); } if (ok && stat.type == Statement.TYPE_DO) { for (StatEdge edge : edges) { if (stat.containsStatementStrict(edge.getSource())) { edge.getDestination().removePredecessor(edge); edge.getSource().changeEdgeNode(Statement.DIRECTION_FORWARD, edge, stat); stat.addPredecessor(edge); stat.addLabeledEdge(edge); } } } for (Statement st : stat.getStats()) { if (st == stat.getFirst()) { lowContinueLabels(st, edges); } else { lowContinueLabels(st, new HashSet<>()); } } }
private static boolean extractLoop(DoStatement stat) { if (stat.getLooptype() != DoStatement.LOOP_DO) { return false; } for (StatEdge edge : stat.getLabelEdges()) { if (edge.getType() != StatEdge.TYPE_CONTINUE && edge.getDestination().type != Statement.TYPE_DUMMYEXIT) { return false; } } if (!extractLastIf(stat)) { return extractFirstIf(stat); } else { return true; } }
if (dstat.getLooptype() == DoStatement.LOOP_FOR) {