private IterableSet<AugmentedStmt> get_EntryPoint(IterableSet<AugmentedStmt> nodeList) { IterableSet<AugmentedStmt> entryPoints = new IterableSet<AugmentedStmt>(); for (AugmentedStmt as : nodeList) { for (AugmentedStmt po : as.cpreds) { if (nodeList.contains(po) == false) { entryPoints.add(as); break; } } } return entryPoints; }
private boolean verify_ESuccs(AugmentedStmt as, IterableSet ref) { IterableSet esuccs = new IterableSet(); esuccs.addAll(as.csuccs); esuccs.removeAll(as.bsuccs); // System.out.println("ESUCCS are:"+esuccs); // System.out.println("ref are:"+ref); return esuccs.equals(ref); }
public boolean isStrictSubsetOf(IterableSet<T> other) { if (other == null) { throw new IllegalArgumentException("Cannot set compare an IterableSet with \"null\"."); } if (size() >= other.size()) { return false; } return isSubsetOf(other); }
public Object clone() { IterableSet<T> s = new IterableSet<T>(); s.addAll(this); return s; }
IterableSet<ExceptionNode> enlist = new IterableSet<ExceptionNode>(); IterableSet<AugmentedStmt> tryBody = new IterableSet<AugmentedStmt>(); tryBody.add(asg.get_AugStmt((Stmt) u)); enlist.add(new ExceptionNode(tryBody, trap.getException(), asg.get_AugStmt((Stmt) trap.getHandlerUnit()))); if ((try_body.contains(pas) == false) && (ps instanceof GotoStmt)) { boolean add_it = true; if ((add_it = try_body.contains(pred)) == false) { break; ExceptionNode[] ena = new ExceptionNode[enlist.size()]; Iterator<ExceptionNode> enlit = enlist.iterator(); for (int i = 0; enlit.hasNext(); i++) { ena[i] = (ExceptionNode) enlit.next(); if ((eniTryBody.equals(enjTryBody) == false) && (eniTryBody.intersects(enjTryBody))) { if ((eniTryBody.isSupersetOf(enj.get_Body())) || (enjTryBody.isSupersetOf(eni.get_Body()))) { continue; IterableSet<AugmentedStmt> newTryBody = eniTryBody.intersection(enjTryBody); if (newTryBody.equals(enjTryBody)) { eni.splitOff_ExceptionNode(newTryBody, asg, enlist); } else {
private Map<AugmentedStmt, IterableSet> build_SynchSets() { HashMap<AugmentedStmt, IterableSet> as2synchSet = new HashMap<AugmentedStmt, IterableSet>(); Iterator mesit = monitorEnterSet.iterator(); monitorEnterLoop: while (mesit.hasNext()) { IterableSet synchSet = new IterableSet(); IterableSet worklist = new IterableSet(); worklist.add(headAs); while (worklist.isEmpty() == false) { AugmentedStmt as = (AugmentedStmt) worklist.getFirst(); worklist.removeFirst(); synchSet.add(as); if (sas.get_Dominators().contains(headAs) && (sml >= monitorLevel) && (worklist.contains(sas) == false) && (synchSet.contains(sas) == false)) { worklist.addLast(sas);
if (as.get_Dominators().isEmpty() == false) { as.get_Dominators().clear(); as.get_Dominators().addAll(aug_list); } else { as.get_Dominators().clear(); IterableSet<AugmentedStmt> worklist = new IterableSet<AugmentedStmt>(); worklist.addAll(aug_list); while (!worklist.isEmpty()) { AugmentedStmt as = worklist.getFirst(); worklist.removeFirst(); IterableSet<AugmentedStmt> pred_intersection = new IterableSet<AugmentedStmt>(); boolean first_pred = true; pred_intersection.addAll(pas.get_Dominators()); if (pred_intersection.contains(pas) == false) { pred_intersection.add(pas); Iterator<AugmentedStmt> piit = pred_intersection.snapshotIterator(); while (piit.hasNext()) { AugmentedStmt pid = piit.next(); if ((pas.get_Dominators().contains(pid) == false) && (pas != pid)) { pred_intersection.remove(pid); if (as.get_Dominators().equals(pred_intersection) == false) {
asg.calculate_Reachability(succElse, succIf, as); IterableSet fullBody = new IterableSet(), ifBody = find_Body(succIf, succElse), elseBody = find_Body(succElse, succIf); fullBody.add(as); fullBody.addAll(ifBody); fullBody.addAll(elseBody); Iterator enlit = body.get_ExceptionFacts().iterator(); while (enlit.hasNext()) { ExceptionNode en = (ExceptionNode) enlit.next(); IterableSet tryBody = en.get_TryBody(); if (tryBody.contains(as)) { Iterator fbit = fullBody.snapshotIterator(); if (tryBody.contains(fbas) == false) { fullBody.remove(fbas); if (ifBody.contains(fbas)) { ifBody.remove(fbas); if (elseBody.contains(fbas)) { elseBody.remove(fbas);
private void find_VariableIncreasing(AugmentedStmtGraph asg, HashMap local2level_template, LinkedList<AugmentedStmt> viAugStmts, HashMap<AugmentedStmt, LinkedList<Value>> as2locals) { StronglyConnectedComponentsFast scc = new StronglyConnectedComponentsFast(asg); IterableSet viSeeds = new IterableSet(); HashMap as2color = new HashMap(), as2rml = new HashMap(); IterableSet component = new IterableSet(); component.addAll(componentList); Iterator cit = component.iterator(); while (cit.hasNext()) { as2color.put(cit.next(), WHITE); AugmentedStmt seedStmt = (AugmentedStmt) component.getFirst(); IterableSet worklist = new IterableSet(); worklist.addAll(viSeeds); while (worklist.isEmpty() == false) { AugmentedStmt as = (AugmentedStmt) worklist.getFirst(); worklist.removeFirst(); HashMap local2level = (HashMap) as2rml.get(as); Iterator mlsit = monitorLocalSet.iterator(); while (mlsit.hasNext()) { Value local = (Value) mlsit.next(); if (worklist.contains(sas) == false) { worklist.addLast(sas);
if (subBody.intersects(en.get_TryBody())) { Iterator ccit = childChain.iterator(); while (ccit.hasNext()) { IterableSet childBody = child.get_Body(); if ((childBody.intersects(en.get_TryBody()) == false) || (childBody.isSubsetOf(en.get_TryBody()))) { continue; if (childBody.isSupersetOf(get_Body())) { return true; IterableSet newTryBody = childBody.intersection(en.get_TryBody()); if (newTryBody.isStrictSubsetOf(en.get_TryBody())) { en.splitOff_ExceptionNode(newTryBody, asg, davaBody.get_ExceptionFacts()); Iterator enlit = davaBody.get_ExceptionFacts().iterator(); while (enlit.hasNext()) { ((ExceptionNode) enlit.next()).refresh_CatchBody(ExceptionFinder.v()); Iterator bit = cb2clone.get(cit.next()).snapshotIterator(); while (bit.hasNext()) { AugmentedStmt as = (AugmentedStmt) bit.next(); if (childBody.contains(as) == false) { remove_AugmentedStmt(as); } else if ((child instanceof SETControlFlowNode) && ((child instanceof SETUnconditionalWhileNode) == false)) {
if (sc_component.contains(au) == false) { return entry_point; IterableSet<AugmentedStmt> candidates = new IterableSet<AugmentedStmt>(); HashMap<AugmentedStmt, AugmentedStmt> candSuccMap = new HashMap<AugmentedStmt, AugmentedStmt>(); HashSet<AugmentedStmt> blockers = new HashSet<AugmentedStmt>(); if ((sc_component.contains(pas)) && (pas.get_Stmt() instanceof IfStmt)) { if (sc_component.contains(spas) == false) { candidates.add(pas); candSuccMap.put(pas, spas); blockers.add(spas); if (candidates.isEmpty()) { return null; if (candidates.size() == 1) { return (AugmentedStmt) candidates.getFirst(); int current_reach_size = ((AugmentedStmt) candSuccMap.get(as)).get_Reachers().intersection(candidates).size(); max_Reach_Set = new IterableSet<AugmentedStmt>(); reachSize = current_reach_size; max_Reach_Set.add(as); if (candidates.size() == 1) {
IterableSet childOrdering = new IterableSet(); LinkedList worklist = new LinkedList(); List<SETBasicBlock> SETBasicBlocks = null; while (children.contains(startSETNode) == false) { startSETNode = startSETNode.get_Parent(); Iterator bit = body.iterator(); find_entry_loop: while (bit.hasNext()) { AugmentedStmt as = (AugmentedStmt) bit.next(); if (body.contains(pbit.next()) == false) { startSETNode = as.myNode; break find_entry_loop; while (children.contains(startSETNode) == false) { startSETNode = startSETNode.get_Parent(); Iterator cit = children.iterator(); while (cit.hasNext()) { SETNode child = (SETNode) cit.next(); if (child.get_Predecessors().isEmpty()) { worklist.add(SETBasicBlock.get_SETBasicBlock(child)); Iterator bit = sbb.get_Body().iterator(); while (bit.hasNext()) { childOrdering.addLast(bit.next());
public IterableSet get_NaturalExits() { IterableSet c = new IterableSet(); Iterator<IterableSet> it = subBodies.iterator(); while (it.hasNext()) { Iterator eit = ((SETNode) body2childChain.get(it.next()).getLast()).get_NaturalExits().iterator(); while (eit.hasNext()) { Object o = eit.next(); if (c.contains(o) == false) { c.add(o); } } } return c; }
private void find_OtherMethods(SootMethod startingMethod, HashMap<SootMethod, IterableSet> methodMapping, HashMap<SootClass, IterableSet> classMapping, HashSet<SootClass> applicationClasses) { IterableSet worklist = (IterableSet) classMapping.get(startingMethod.getDeclaringClass()).clone(); while (worklist.isEmpty() == false) { SootClass currentClass = (SootClass) worklist.getFirst(); worklist.removeFirst(); IterableSet otherMethods = methodMapping.get(startingMethod); if (otherMethods == null) { otherMethods = new IterableSet(); methodMapping.put(startingMethod, otherMethods); otherMethods.add(currentClass.getMethod(signature)); IterableSet otherClasses = classMapping.get(currentClass); if (otherClasses != null) { Iterator ocit = otherClasses.iterator(); while (ocit.hasNext()) { SootClass otherClass = (SootClass) ocit.next(); worklist.addLast(otherClass); touchSet.add(otherClass);
public IterableSet<T> intersection(IterableSet<T> other) { if (other == null) { throw new IllegalArgumentException("Cannot set intersect an IterableSet with \"null\"."); } IterableSet<T> c = new IterableSet<T>(); if (other.size() < size()) { for (T t : other) { if (contains(t)) { c.add(t); } } } else { for (T t : this) { if (other.contains(t)) { c.add(t); } } } return c; }
IterableSet<AugmentedStmt> node_list = new IterableSet<AugmentedStmt>(); node_list.clear(); node_list.addAll(cal); if (entry_points.size() > 1) { IterableSet<AugmentedStmt> asgScc = new IterableSet<AugmentedStmt>(); for (AugmentedStmt au : node_list) { asgScc.addLast(asg.get_AugStmt(au.get_Stmt())); AugmentedStmt entry_point = (AugmentedStmt) entry_points.getFirst(); AugmentedStmt characterizing_stmt = find_CharacterizingStmt(entry_point, node_list, wasg), succ_stmt = null; for (AugmentedStmt au : characterizing_stmt.bsuccs) { succ_stmt = au; if (node_list.contains(succ_stmt) == false) { break; if (tryBody.contains(asg.get_AugStmt(characterizing_stmt.get_Stmt()))) { for (AugmentedStmt cbas : cycle_body) { if (tryBody.contains(cbas) == false) { characterizing_stmt = null; break checkExceptionLoop; if (cycle_body.contains(asg.get_AugStmt(condition.getTarget())) == false) { condition.setCondition(ConditionFlipper.flip((ConditionExpr) condition.getCondition()));
IterableSet children = SETParent.get_Body2ChildChain().get(curBody); Iterator it = children.snapshotIterator(); if (it.hasNext()) { SETNode curNode = (SETNode) it.next(), prevNode = null; AugmentedStmt pas = (AugmentedStmt) pit.next(); if (curBody.contains(pas) == false) { continue; while (children.contains(srcNode) == false) { srcNode = srcNode.get_Parent(); IterableSet labeledBlockBody = new IterableSet(); Iterator cit = children.iterator(minNode); while (cit.hasNext()) { SETNode child = (SETNode) cit.next(); labeledBlockBody.addAll(child.get_Body()); orderNumber.put(slbn, orderNumber.get(minNode)); cit = children.snapshotIterator(minNode); while (cit.hasNext()) { SETNode child = (SETNode) cit.next();
public void splitOff_ExceptionNode(IterableSet<AugmentedStmt> newTryBody, AugmentedStmtGraph asg, IterableSet<ExceptionNode> enlist) { IterableSet<AugmentedStmt> oldTryBody = new IterableSet<AugmentedStmt>(); oldTryBody.addAll(tryBody); IterableSet<AugmentedStmt> oldBody = new IterableSet<AugmentedStmt>(); oldBody.addAll(body); if (catchBody.isSupersetOf(en.get_Body())) { IterableSet<AugmentedStmt> clonedTryBody = new IterableSet<AugmentedStmt>(); clonedTryBody.add(asg.get_CloneOf(au)); enlist.addLast(new ExceptionNode(clonedTryBody, en.exception, asg.get_CloneOf(en.handlerAugmentedStmt))); enlist.addLast(new ExceptionNode(newTryBody, exception, asg.get_CloneOf(handlerAugmentedStmt)));
Iterator it = body.iterator(); while (it.hasNext()) { AugmentedStmt as = (AugmentedStmt) it.next(); if (body.contains(sas)) { while (children.contains(srcNode) == false) { srcNode = srcNode.get_Parent(); while (children.contains(dstNode) == false) { dstNode = dstNode.get_Parent(); if (srcNode.get_Successors().contains(dstNode) == false) { srcNode.get_Successors().add(dstNode); if (dstNode.get_Predecessors().contains(srcNode) == false) { dstNode.get_Predecessors().add(srcNode); Iterator cit = children.iterator(); while (cit.hasNext()) { SETNode child = (SETNode) cit.next(); while (child.get_Predecessors().size() == 1) { SETNode prev = (SETNode) child.get_Predecessors().getFirst(); if ((SETBasicBlock.get_SETBasicBlock(prev) != null) || (prev.get_Successors().size() != 1)) { break; while (child.get_Successors().size() == 1) {
public boolean isSupersetOf( IterableSet other) { if (other == null) throw new IllegalArgumentException( "Cannot set compare an IterableSet with \"null\"."); if (size() < other.size()) return false; Iterator it = other.iterator(); while (it.hasNext()) if (contains( it.next()) == false) return false; return true; }