IfStatement ifchild = (IfStatement)ifbranch.value; if (ifchild.getFirst().getExprents().isEmpty()) { ifparent.getFirst().removeSuccessor(ifparent.getIfEdge()); ifchild.getFirst().removeSuccessor(ifchild.getIfEdge()); ifparent.getStats().removeWithKey(ifchild.id); ifedge.setSource(ifparent.getFirst()); ifparent.getFirst().addSuccessor(ifedge);
Statement ifinner = ifbranch.succs.get(0).value; if (ifchild.getFirst().getExprents().isEmpty()) { ifparent.getFirst().removeSuccessor(ifparent.getIfEdge()); ifchild.removeSuccessor(ifchild.getAllSuccessorEdges().get(0)); ifparent.getStats().removeWithKey(ifchild.id); ifchild.getFirst().removeSuccessor(ifedge); ifedge.setSource(ifparent.getFirst()); ifparent.getFirst().addSuccessor(ifedge); ifchild.getFirst().removeSuccessor(ifchild.getIfEdge()); StatEdge ifedge = new StatEdge(StatEdge.TYPE_REGULAR, ifparent.getFirst(), ifinner); ifparent.getFirst().addSuccessor(ifedge); ifparent.setIfEdge(ifedge); ifparent.setIfstat(ifinner);
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; }
Statement parent = firstif.getParent(); if (secondif.getFirst().getExprents().isEmpty()) { firstif.getFirst().removeSuccessor(firstif.getIfEdge()); .setCondition(new FunctionExprent(path == 1 ? FunctionExprent.FUNCTION_COR : FunctionExprent.FUNCTION_CADD, lstOperands, null)); if (secondif.getFirst().getExprents().isEmpty() && !firstif.getFirst().getExprents().isEmpty()) { secondif.replaceStatement(secondif.getFirst(), firstif.getFirst()); firstif.getFirst().removeSuccessor(ifedge); StatEdge newifedge = new StatEdge(StatEdge.TYPE_REGULAR, firstif.getFirst(), second); firstif.getFirst().addSuccessor(newifedge); firstif.setIfstat(second);
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(); } }
processEdgesWithNext(ifstat.getFirst(), mapEdges, null);
ifparent.getFirst().removeSuccessor(ifedge); ifparent.getFirst().removeSuccessor(elseedge); if (!ifparent.getFirst().getExprents().isEmpty()) { elsebranch.getExprents().addAll(0, ifparent.getFirst().getExprents()); if (!ifstat.getFirst().getExprents().isEmpty()) { stat.getExprents().addAll(0, ifstat.getFirst().getExprents());
ifelsestat.getFirst().removeSuccessor(ifelsestat.getIfEdge());
newstat.setExprents(Arrays.asList(new Exprent[]{asexpr})); Statement first = stat.getFirst();
StatEdge elseedge = new StatEdge(StatEdge.TYPE_REGULAR, ifstat.getFirst(), stelse); ifstat.getFirst().addSuccessor(elseedge); ifstat.setElsestat(stelse); ifstat.setElseEdge(elseedge); ifstat.getFirst().removeSuccessor(ifedge); ifstat.removeSuccessor(elseedge); elseedge.setSource(ifstat.getFirst()); ifstat.getFirst().addSuccessor(elseedge); ifstat.getFirst().removeSuccessor(ifedge); ifstat.getStats().removeWithKey(ifbranch.id); ifstat.setIfstat(null); elseedge.setSource(ifstat.getFirst()); ifstat.getFirst().addSuccessor(elseedge); ifstat.getFirst().removeSuccessor(ifedge); ifedge.setSource(ifstat); ifstat.addSuccessor(ifedge); ifstat.getFirst().removeSuccessor(ifstat.getIfEdge()); ifstat.getStats().removeWithKey(ifbranch.id); StatEdge newifedge = new StatEdge(StatEdge.TYPE_REGULAR, ifstat.getFirst(), stelse); ifstat.getFirst().addSuccessor(newifedge); ifstat.setIfstat(stelse);
IfStatement ifchild = (IfStatement)ifbranch.value; if (ifchild.getFirst().getExprents().isEmpty()) { ifparent.getFirst().removeSuccessor(ifparent.getIfEdge()); ifchild.getFirst().removeSuccessor(ifchild.getIfEdge()); ifparent.getStats().removeWithKey(ifchild.id); ifedge.setSource(ifparent.getFirst()); ifparent.getFirst().addSuccessor(ifedge);
Statement ifinner = ifbranch.succs.get(0).value; if (ifchild.getFirst().getExprents().isEmpty()) { ifparent.getFirst().removeSuccessor(ifparent.getIfEdge()); ifchild.removeSuccessor(ifchild.getAllSuccessorEdges().get(0)); ifparent.getStats().removeWithKey(ifchild.id); ifchild.getFirst().removeSuccessor(ifedge); ifedge.setSource(ifparent.getFirst()); ifparent.getFirst().addSuccessor(ifedge); ifchild.getFirst().removeSuccessor(ifchild.getIfEdge()); StatEdge ifedge = new StatEdge(StatEdge.TYPE_REGULAR, ifparent.getFirst(), ifinner); ifparent.getFirst().addSuccessor(ifedge); ifparent.setIfEdge(ifedge); ifparent.setIfstat(ifinner);
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 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(); } }
ifelsestat.getFirst().removeSuccessor(ifelsestat.getIfEdge());