protected void computeEdgeAndThreadNo() { Iterator it = iterator(); int numberOfEdge = 0; while (it.hasNext()) { List succList = (List) getSuccsOf(it.next()); numberOfEdge = numberOfEdge + succList.size(); } numberOfEdge = numberOfEdge + startToThread.size(); System.err.println("**number of edges: " + numberOfEdge); System.err.println("**number of threads: " + (startToThread.size() + 1)); /* Set keySet = startToThread.keySet(); Iterator keyIt = keySet.iterator(); while (keyIt.hasNext()){ List list = (List)startToThread.get(keyIt.next()); System.out.println("********start thread:"); Iterator itit = list.iterator(); while (itit.hasNext()){ System.out.println(it.next()); } } */ }
/** * Utility method used in the construction of {@link UnitGraph}s, to be called only after the * unitToPreds and unitToSuccs maps have been built. * * <p><code>UnitGraph</code> provides an implementation of <code>buildHeadsAndTails()</code> which * defines the graph's set of heads to include the first {@link Unit} in the graph's body, * together with any other <tt>Unit</tt> which has no predecessors. It defines the graph's set of * tails to include all <tt>Unit</tt>s with no successors. Subclasses of <code>UnitGraph</code> * may override this method to change the criteria for classifying a node as a head or tail. */ protected void buildHeadsAndTails() { List tailList = new ArrayList(); List headList = new ArrayList(); for (Iterator unitIt = unitChain.iterator(); unitIt.hasNext(); ) { Unit s = (Unit) unitIt.next(); List succs = (List) unitToSuccs.get(s); if (succs.size() == 0) { tailList.add(s); } List preds = (List) unitToPreds.get(s); if (preds.size() == 0) { headList.add(s); } } // Add the first Unit, even if it is the target of // a branch. Unit entryPoint = (Unit) unitChain.getFirst(); if (!headList.contains(entryPoint)) { headList.add(entryPoint); } tails = Collections.unmodifiableList(tailList); heads = Collections.unmodifiableList(headList); }
protected void testPegChain(Chain chain) { System.out.println("******** chain********"); Iterator it = chain.iterator(); while (it.hasNext()) { /*Object o = it.next(); System.out.println(o); if (!(o instanceof JPegStmt)) System.out.println("not instanceof JPegStmt: "+o); JPegStmt s = (JPegStmt)o; */ JPegStmt stmt = (JPegStmt) it.next(); System.out.println(stmt.toString()); /*if (stmt.getName().equals("start")){ System.out.println("find start method in : " + stmt.toString() ); List list =(List)startToThread.get(stmt); Iterator chainIt = list.iterator(); while (chainIt.hasNext()){ Chain chain = (Chain)chainIt.next(); Iterator subit = chain.iterator(); while (subit.hasNext()){ System.out.println("**" + ((JPegStmt)subit.next()).toString()); } } System.out.println("$$$$$$returing to main chain"); } */ } }
protected void testStartToThread() { System.out.println("=====test startToThread "); Set maps = startToThread.entrySet(); for (Iterator iter = maps.iterator(); iter.hasNext(); ) { Map.Entry entry = (Map.Entry) iter.next(); JPegStmt key = (JPegStmt) entry.getKey(); Tag tag = (Tag) key.getTags().get(0); System.out.println("---key= " + tag + " " + key); /* List list = (List)entry.getValue(); if (list.size()>0){ System.out.println("**thread set:"); Iterator it = list.iterator(); while (it.hasNext()){ Chain chain =(Chain)it.next(); Iterator chainIt = chain.iterator(); System.out.println("the size of chain is: "+chain.size()); while (chainIt.hasNext()){ JPegStmt stmt = (JPegStmt)chainIt.next(); System.out.println(stmt); } } } */ } System.out.println("=========startToThread--ends--------"); }
protected void testList(List list) { // System.out.println("test list"); Iterator listIt = list.iterator(); while (listIt.hasNext()) { System.out.println(listIt.next()); } }
public void go() { Iterator methods = cg.sourceMethods(); while (methods.hasNext()) { SootMethod m = (SootMethod) methods.next(); dfsVisit(m); } }
protected int processModifiers(List l) { int modifier = 0; Iterator it = l.iterator(); while (it.hasNext()) { Object t = it.next(); if (t instanceof AAbstractModifier) modifier |= Modifier.ABSTRACT; else if (t instanceof AFinalModifier) modifier |= Modifier.FINAL; else if (t instanceof ANativeModifier) modifier |= Modifier.NATIVE; else if (t instanceof APublicModifier) modifier |= Modifier.PUBLIC; else if (t instanceof AProtectedModifier) modifier |= Modifier.PROTECTED; else if (t instanceof APrivateModifier) modifier |= Modifier.PRIVATE; else if (t instanceof AStaticModifier) modifier |= Modifier.STATIC; else if (t instanceof ASynchronizedModifier) modifier |= Modifier.SYNCHRONIZED; else if (t instanceof ATransientModifier) modifier |= Modifier.TRANSIENT; else if (t instanceof AVolatileModifier) modifier |= Modifier.VOLATILE; else if (t instanceof AEnumModifier) modifier |= Modifier.ENUM; else if (t instanceof AAnnotationModifier) modifier |= Modifier.ANNOTATION; else throw new RuntimeException( "Impossible: modifier unknown - Have you added a new modifier and not updated this file?"); } return modifier; }
/** * Returns a <code>ThrowableSet</code> representing the set of exceptions included in <code> * include</code> minus the set of exceptions included in <code>exclude</code>. Creates a new * <code>ThrowableSet</code> only if there was not already one whose contents correspond to * <code>include</code> - <code>exclude</code>. * * @param include A set of {@link RefLikeType} objects representing exception types included in * the result; may be <code>null</code> if there are no included types. * @param exclude A set of {@link AnySubType} objects representing exception types excluded from * the result; may be <code>null</code> if there are no excluded types. * @return a <code>ThrowableSet</code> representing the set of exceptions corresponding to * <code>include</code> - <code>exclude</code>. */ private ThrowableSet registerSetIfNew(Set include, Set exclude) { if (INSTRUMENTING) { registrationCalls++; } if (include == null) { include = Collections.EMPTY_SET; } if (exclude == null) { exclude = Collections.EMPTY_SET; } int size = include.size() + exclude.size(); Integer sizeKey = new Integer(size); List sizeList = (List) sizeToSets.get(sizeKey); if (sizeList == null) { sizeList = new LinkedList(); sizeToSets.put(sizeKey, sizeList); } for (Iterator i = sizeList.iterator(); i.hasNext(); ) { ThrowableSet set = (ThrowableSet) i.next(); if (set.exceptionsIncluded.equals(include) && set.exceptionsExcluded.equals(exclude)) { return set; } } if (INSTRUMENTING) { registeredSets++; } ThrowableSet result = new ThrowableSet(include, exclude); sizeList.add(result); return result; }
private void insertAfter(JPegStmt node, JPegStmt after) { // System.out.println("node: "+node); // System.out.println("after: "+after); // System.out.println("succs of node: "+getSuccsOf(node)); // this must be done first because the succs of node will be chanaged lately List succOfAfter = new ArrayList(); succOfAfter.addAll(getSuccsOf(node)); unitToSuccs.put(after, succOfAfter); Iterator succsIt = getSuccsOf(node).iterator(); while (succsIt.hasNext()) { Object succ = succsIt.next(); List pred = getPredsOf(succ); pred.remove(node); pred.add(after); } List succOfNode = new ArrayList(); succOfNode.add(after); unitToSuccs.put(node, succOfNode); List predOfAfter = new ArrayList(); predOfAfter.add(node); unitToPreds.put(after, predOfAfter); // buildPredecessor(Chain pegChain); }
public boolean isEmpty() { if (subsets == null) return true; for (Iterator subsetIt = subsets.iterator(); subsetIt.hasNext(); ) { final PointsToSet subset = (PointsToSet) subsetIt.next(); if (!subset.isEmpty()) return false; } return true; }
public void convertToBaf(JimpleToBafContext context, List<Unit> out) { Unit u = Baf.v().newLoadInst(getType(), context.getBafLocalOfJimpleLocal(this)); out.add(u); Iterator it = context.getCurrentUnit().getTags().iterator(); while (it.hasNext()) { u.addTag((Tag) it.next()); } }
// helper function protected void testIterator() { System.out.println("********begin test iterator*******"); Iterator testIt = iterator(); while (testIt.hasNext()) { System.out.println(testIt.next()); } System.out.println("********end test iterator*******"); System.out.println("=======size is: " + size()); }
public void convertToBaf(JimpleToBafContext context, List out) { Unit u = Baf.v().newStaticGetInst(fieldRef); out.add(u); Iterator it = context.getCurrentUnit().getTags().iterator(); while (it.hasNext()) { u.addTag((Tag) it.next()); } }
protected void testSet(Set set, String name) { System.out.println("$test set " + name); Iterator setIt = set.iterator(); while (setIt.hasNext()) { Object s = setIt.next(); // JPegStmt s = (JPegStmt)setIt.next(); // Tag tag = (Tag)s.getTags().get(0); System.out.println(s); } }
private void dfsVisit(SootMethod m) { if (visited.contains(m)) return; visited.add(m); Iterator targets = new Targets(cg.edgesOutOf(m)); while (targets.hasNext()) { SootMethod target = (SootMethod) targets.next(); dfsVisit(target); } order.add(m); }
public StronglyConnectedComponentsBV(BitVector typeVariableList, TypeResolverBV resolver) throws TypeException { this.resolver = resolver; variables = typeVariableList; black = new TreeSet(); finished = new LinkedList(); for (BitSetIterator i = variables.iterator(); i.hasNext(); ) { TypeVariableBV var = resolver.typeVariableForId(i.next()); if (!black.contains(var)) { black.add(var); dfsg_visit(var); } } black = new TreeSet(); for (Iterator i = finished.iterator(); i.hasNext(); ) { TypeVariableBV var = (TypeVariableBV) i.next(); if (!black.contains(var)) { current_tree = new LinkedList(); forest.add(current_tree); black.add(var); dfsgt_visit(var); } } for (Iterator i = forest.iterator(); i.hasNext(); ) { LinkedList list = (LinkedList) i.next(); TypeVariableBV previous = null; StringBuffer s = null; if (DEBUG) { s = new StringBuffer("scc:\n"); } for (Iterator j = list.iterator(); j.hasNext(); ) { TypeVariableBV current = (TypeVariableBV) j.next(); if (DEBUG) { s.append(" " + current + "\n"); } if (previous == null) { previous = current; } else { try { previous = previous.union(current); } catch (TypeException e) { if (DEBUG) { G.v().out.println(s); } throw e; } } } } }
protected void testSynch() { Iterator<List> it = synch.iterator(); System.out.println("========test synch======"); while (it.hasNext()) { // JPegStmt s = (JPegStmt)it.next(); // Tag tag = (Tag)s.getTags().get(0); // System.out.println(tag+" "+s); System.out.println(it.next()); } System.out.println("========end test synch======"); }
public void replaceIndex2BodyList(Map<Object, List<Object>> index2BodyList) { this.index2BodyList = index2BodyList; subBodies = new ArrayList<Object>(); Iterator<Object> it = indexList.iterator(); while (it.hasNext()) { List body = index2BodyList.get(it.next()); if (body != null) subBodies.add(body); } }
protected void testUnitToPeg(HashMap unitToPeg) { System.out.println("=====test unitToPeg "); Set maps = unitToPeg.entrySet(); for (Iterator iter = maps.iterator(); iter.hasNext(); ) { Map.Entry entry = (Map.Entry) iter.next(); System.out.println("---key= " + entry.getKey()); JPegStmt s = (JPegStmt) entry.getValue(); System.out.println("--value= " + s); } System.out.println("=========unitToPeg--ends--------"); }
public String toString() { Iterator it = unitChain.iterator(); StringBuffer buf = new StringBuffer(); while (it.hasNext()) { Unit u = (Unit) it.next(); buf.append("// preds: " + getPredsOf(u) + "\n"); buf.append(u.toString() + '\n'); buf.append("// succs " + getSuccsOf(u) + "\n"); } return buf.toString(); }
public void computeSynchNodes() { int num = 0; Set maps = monitor.entrySet(); for (Iterator iter = maps.iterator(); iter.hasNext(); ) { Map.Entry entry = (Map.Entry) iter.next(); FlowSet fs = (FlowSet) entry.getValue(); num += fs.size(); } System.err.println("synch objects: " + num); }
/** * Utility method that replaces the values of a {@link Map}, which must be instances of {@link * List}, with unmodifiable equivalents. * * @param map The map whose values are to be made unmodifiable. */ protected static void makeMappedListsUnmodifiable(Map map) { for (Iterator it = map.entrySet().iterator(); it.hasNext(); ) { Map.Entry entry = (Map.Entry) it.next(); List value = (List) entry.getValue(); if (value.size() == 0) { entry.setValue(Collections.EMPTY_LIST); } else { entry.setValue(Collections.unmodifiableList(value)); } } }
public Set possibleTypes() { if (subsets == null) { return Collections.EMPTY_SET; } HashSet ret = new HashSet(); for (Iterator subsetIt = subsets.iterator(); subsetIt.hasNext(); ) { final PointsToSet subset = (PointsToSet) subsetIt.next(); ret.addAll(subset.possibleTypes()); } return ret; }
public String toString() { StringBuffer buffer = new StringBuffer(); buffer.append("new " + getBaseType().baseType); List sizes = getSizes(); Iterator it = getSizes().iterator(); while (it.hasNext()) buffer.append("[" + it.next().toString() + "]"); for (int i = getSizeCount(); i < getBaseType().numDimensions; i++) buffer.append("[]"); return buffer.toString(); }
public boolean hasNonEmptyIntersection(PointsToSet other) { if (subsets == null) return true; for (Iterator subsetIt = subsets.iterator(); subsetIt.hasNext(); ) { final PointsToSet subset = (PointsToSet) subsetIt.next(); if (other instanceof Union) { if (other.hasNonEmptyIntersection(subset)) return true; } else { if (subset.hasNonEmptyIntersection(other)) return true; } } return false; }
private static List<Unit> searchIfStmts(Body b) { List<Unit> searchResult = new ArrayList<Unit>(); PatchingChain<Unit> statements = b.getUnits(); Iterator<Unit> unitIt = statements.iterator(); // iterate through the Units of the body while (unitIt.hasNext()) { Unit tempUnit = unitIt.next(); // if the unit is a "if statement" if (tempUnit instanceof soot.jimple.internal.JIfStmt) searchResult.add(tempUnit); } return searchResult; }
public void convertToBaf(JimpleToBafContext context, List<Unit> out) { ((ConvertToBaf) getOp()).convertToBaf(context, out); Unit u; out.add(u = Baf.v().newThrowInst()); Unit currentUnit = this; Iterator it = currentUnit.getTags().iterator(); while (it.hasNext()) { u.addTag((Tag) it.next()); } }
protected void addTag() { // add tag for each stmt Iterator it = iterator(); // int count = 0; while (it.hasNext()) { JPegStmt stmt = (JPegStmt) it.next(); int count = Counter.getTagNo(); // count++; StringTag t = new StringTag(Integer.toString(count)); stmt.addTag(t); } }
protected void testJoinStmtToThread() { System.out.println("=====test JoinStmtToThread"); Set maps = threadNameToStart.entrySet(); for (Iterator iter = maps.iterator(); iter.hasNext(); ) { Map.Entry entry = (Map.Entry) iter.next(); Object key = entry.getKey(); System.out.println("---key= " + key); System.out.println("value: " + entry.getValue()); } System.out.println("=========JoinStmtToThread--ends--------"); }
public void outADeclaration(ADeclaration node) { List localNameList = (List) mProductions.removeLast(); Type type = (Type) mProductions.removeLast(); Iterator it = localNameList.iterator(); List localList = new ArrayList(); while (it.hasNext()) { Local l = Jimple.v().newLocal((String) it.next(), type); mLocals.put(l.getName(), l); localList.add(l); } mProductions.addLast(localList); }