Use Iterator2Iterable helper to convert more loops to for-each
This commit is contained in:
parent
bf6698edf5
commit
0286c2b048
|
@ -425,10 +425,8 @@ public abstract class JDTJava2CAstTranslator<T extends Position> {
|
|||
ArrayList<ASTNode> staticInits = new ArrayList<>();
|
||||
|
||||
if (enumConstants != null) {
|
||||
for (Object decl : enumConstants) {
|
||||
EnumConstantDeclaration ecd = (EnumConstantDeclaration) decl;
|
||||
staticInits.add(ecd); // always (implicitly) static,final (actually, no modifiers allowed)
|
||||
}
|
||||
// always (implicitly) static,final (actually, no modifiers allowed)
|
||||
staticInits.addAll(enumConstants);
|
||||
}
|
||||
|
||||
for (BodyDeclaration decl : bodyDecls) {
|
||||
|
|
|
@ -53,6 +53,7 @@ import com.ibm.wala.types.TypeReference;
|
|||
import com.ibm.wala.types.annotations.Annotation;
|
||||
import com.ibm.wala.util.CancelException;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.collections.Pair;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
import com.ibm.wala.util.strings.Atom;
|
||||
|
@ -190,9 +191,7 @@ public abstract class IRTests {
|
|||
CGNode tgtNode = tgtNodes.iterator().next();
|
||||
|
||||
boolean found = false;
|
||||
for (Iterator<? extends CGNode> succIter = callGraph.getSuccNodes(srcNode); succIter.hasNext();) {
|
||||
CGNode succ = succIter.next();
|
||||
|
||||
for (CGNode succ : Iterator2Iterable.make(callGraph.getSuccNodes(srcNode))) {
|
||||
if (tgtNode == succ) {
|
||||
found = true;
|
||||
break;
|
||||
|
@ -378,8 +377,7 @@ public abstract class IRTests {
|
|||
Set<IMethod> unreachable = HashSetFactory.make();
|
||||
IClassHierarchy cha = cg.getClassHierarchy();
|
||||
IClassLoader sourceLoader = cha.getLoader(JavaSourceAnalysisScope.SOURCE);
|
||||
for (Iterator<IClass> iter = sourceLoader.iterateAllClasses(); iter.hasNext();) {
|
||||
IClass clazz = iter.next();
|
||||
for (IClass clazz : Iterator2Iterable.make(sourceLoader.iterateAllClasses())) {
|
||||
|
||||
System.err.println(clazz);
|
||||
if (clazz.isInterface())
|
||||
|
|
|
@ -93,9 +93,7 @@ public abstract class JavaIRTests extends IRTests {
|
|||
/*
|
||||
Assert.assertEquals("Expected two classes.", iClass.getClassLoader().getNumberOfClasses(), 2);
|
||||
|
||||
for (Iterator<IClass> it = iClass.getClassLoader().iterateAllClasses(); it.hasNext();) {
|
||||
IClass cls = it.next();
|
||||
|
||||
for (IClass cls : Iterator2Iterable.make(iClass.getClassLoader().iterateAllClasses())) {
|
||||
Assert.assertTrue("Expected class to be either " + typeStr + " or " + "Bar", cls.getName().getClassName().toString()
|
||||
.equals(typeStr)
|
||||
|| cls.getName().getClassName().toString().equals("Bar"));
|
||||
|
|
|
@ -1696,8 +1696,8 @@ public class RhinoToAstTranslator implements TranslatorToCAst {
|
|||
if (finallyNode != null) {
|
||||
int i = 0;
|
||||
CAstNode[] finallyAsts = new CAstNode[finallyList.size()];
|
||||
for (Iterator<Node> fns = finallyList.iterator(); fns.hasNext();) {
|
||||
finallyAsts[i++] = walkNodes(fns.next(), context);
|
||||
for (Node fn : finallyList) {
|
||||
finallyAsts[i++] = walkNodes(fn, context);
|
||||
}
|
||||
finallyBlock = Ast.makeNode(CAstNode.BLOCK_STMT, finallyAsts);
|
||||
}
|
||||
|
@ -1707,8 +1707,8 @@ public class RhinoToAstTranslator implements TranslatorToCAst {
|
|||
int i = 0;
|
||||
WalkContext catchChild = new CatchBlockContext(context);
|
||||
CAstNode[] catchAsts = new CAstNode[catchList.size()];
|
||||
for (Iterator<Node> cns = catchList.iterator(); cns.hasNext();) {
|
||||
catchAsts[i++] = walkNodes(cns.next(), catchChild);
|
||||
for (Node cn : catchList.iterator()) {
|
||||
catchAsts[i++] = walkNodes(cn, catchChild);
|
||||
}
|
||||
CAstNode catchBlock = Ast.makeNode(CAstNode.CATCH, Ast.makeConstant(catchChild.getCatchVar()),
|
||||
Ast.makeNode(CAstNode.BLOCK_STMT, catchAsts));
|
||||
|
@ -1717,8 +1717,8 @@ public class RhinoToAstTranslator implements TranslatorToCAst {
|
|||
i = 0;
|
||||
WalkContext tryChild = new TryBlockContext(context, catchBlock);
|
||||
CAstNode[] tryAsts = new CAstNode[tryList.size()];
|
||||
for (Iterator<Node> tns = tryList.iterator(); tns.hasNext();) {
|
||||
tryAsts[i++] = walkNodes(tns.next(), tryChild);
|
||||
for (Node tn : tryList) {
|
||||
tryAsts[i++] = walkNodes(tn, tryChild);
|
||||
}
|
||||
CAstNode tryBlock = Ast.makeNode(CAstNode.BLOCK_STMT, tryAsts);
|
||||
|
||||
|
@ -1732,8 +1732,8 @@ public class RhinoToAstTranslator implements TranslatorToCAst {
|
|||
} else {
|
||||
int i = 0;
|
||||
CAstNode[] tryAsts = new CAstNode[tryList.size()];
|
||||
for (Iterator<Node> tns = tryList.iterator(); tns.hasNext();) {
|
||||
tryAsts[i++] = walkNodes(tns.next(), context);
|
||||
for (Node tn : tryList) {
|
||||
tryAsts[i++] = walkNodes(tn, context);
|
||||
}
|
||||
CAstNode tryBlock = Ast.makeNode(CAstNode.BLOCK_STMT, tryAsts);
|
||||
|
||||
|
|
|
@ -12,8 +12,6 @@ package com.ibm.wala.cast.js.test;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -33,6 +31,7 @@ import com.ibm.wala.ipa.slicer.Statement;
|
|||
import com.ibm.wala.util.CancelException;
|
||||
import com.ibm.wala.util.WalaException;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
|
||||
public abstract class TestJavaScriptSlicer extends TestJSCallGraphShape {
|
||||
|
||||
|
@ -85,10 +84,9 @@ public abstract class TestJavaScriptSlicer extends TestJSCallGraphShape {
|
|||
private Collection<Statement> findTargetStatement(CallGraph CG) {
|
||||
final Collection<Statement> ss = HashSetFactory.make();
|
||||
for(CGNode n : getNodes(CG, "suffix:_slice_target_fn")) {
|
||||
for(Iterator<CGNode> callers = CG.getPredNodes(n); callers.hasNext(); ) {
|
||||
final CGNode caller = callers.next();
|
||||
for(Iterator<CallSiteReference> sites = CG.getPossibleSites(caller, n); sites.hasNext(); ) {
|
||||
caller.getIR().getCallInstructionIndices(sites.next()).foreach(x -> ss.add(new NormalStatement(caller, x)));
|
||||
for(CGNode caller : Iterator2Iterable.make(CG.getPredNodes(n))) {
|
||||
for(CallSiteReference site : Iterator2Iterable.make(CG.getPossibleSites(caller, n))) {
|
||||
caller.getIR().getCallInstructionIndices(site).foreach(x -> ss.add(new NormalStatement(caller, x)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@ import com.ibm.wala.util.NullProgressMonitor;
|
|||
import com.ibm.wala.util.WalaException;
|
||||
import com.ibm.wala.util.collections.EmptyIterator;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.collections.MapIterator;
|
||||
import com.ibm.wala.util.collections.Pair;
|
||||
import com.ibm.wala.util.intset.OrdinalSet;
|
||||
|
@ -132,8 +133,8 @@ public abstract class TestPointerAnalyses {
|
|||
OrdinalSet<? extends InstanceKey> pointers = pa.getPointsToSet(l);
|
||||
if (pointers != null) {
|
||||
for(InstanceKey k : pointers) {
|
||||
for(Iterator<Pair<CGNode, NewSiteReference>> css = k.getCreationSites(CG); css.hasNext(); ) {
|
||||
result.add(css.next());
|
||||
for(Pair<CGNode, NewSiteReference> cs : Iterator2Iterable.make(k.getCreationSites(CG))) {
|
||||
result.add(cs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -302,8 +303,8 @@ public abstract class TestPointerAnalyses {
|
|||
System.err.println("empty " + f + " for " + k + "(" + k.getConcreteType() + ")");
|
||||
}
|
||||
if (dump) {
|
||||
for(Iterator<Pair<CGNode, NewSiteReference>> css = k.getCreationSites(fbCG); css.hasNext(); ) {
|
||||
System.err.println(css.next());
|
||||
for(Pair<CGNode, NewSiteReference> cs : Iterator2Iterable.make(k.getCreationSites(fbCG))) {
|
||||
System.err.println(cs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -319,9 +320,9 @@ public abstract class TestPointerAnalyses {
|
|||
PointerKey fbKey = fbPA.getHeapModel().getPointerKeyForLocal(node, vn);
|
||||
OrdinalSet<T> fbPointsTo = fbPA.getPointsToSet(fbKey);
|
||||
for(T o : fbPointsTo) {
|
||||
for(Iterator<T> ps = proto.apply(o); ps.hasNext(); ) {
|
||||
for(Iterator<Pair<CGNode, NewSiteReference>> css = ps.next().getCreationSites(CG); css.hasNext(); ) {
|
||||
fbProtos.add(css.next());
|
||||
for(T p : Iterator2Iterable.make(proto.apply(o))) {
|
||||
for(Pair<CGNode, NewSiteReference> cs : Iterator2Iterable.make(p.getCreationSites(CG))) {
|
||||
fbProtos.add(cs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
*****************************************************************************/
|
||||
package com.ibm.wala.cast.js.callgraph.fieldbased;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.ibm.wala.cast.js.callgraph.fieldbased.flowgraph.FlowGraph;
|
||||
import com.ibm.wala.cast.js.callgraph.fieldbased.flowgraph.vertices.FuncVertex;
|
||||
import com.ibm.wala.cast.js.callgraph.fieldbased.flowgraph.vertices.VertexFactory;
|
||||
|
@ -30,6 +28,7 @@ import com.ibm.wala.ssa.SSAInstruction;
|
|||
import com.ibm.wala.ssa.SymbolTable;
|
||||
import com.ibm.wala.types.TypeReference;
|
||||
import com.ibm.wala.util.MonitorUtil.IProgressMonitor;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
|
||||
/**
|
||||
* Call graph builder for building pessimistic call graphs, where inter-procedural flows are not
|
||||
|
@ -103,8 +102,7 @@ public class PessimisticCallGraphBuilder extends FieldBasedCallGraphBuilder {
|
|||
FuncVertex callee = factory.makeFuncVertex(fnClass);
|
||||
|
||||
// look at all uses
|
||||
for(Iterator<SSAInstruction> uses = du.getUses(defn);uses.hasNext();) {
|
||||
SSAInstruction use = uses.next();
|
||||
for(SSAInstruction use : Iterator2Iterable.make(du.getUses(defn))) {
|
||||
|
||||
// check whether this is a local call
|
||||
if(use instanceof JavaScriptInvoke && ((JavaScriptInvoke)use).getFunction() == defn) {
|
||||
|
|
|
@ -60,6 +60,7 @@ import com.ibm.wala.util.MonitorUtil.IProgressMonitor;
|
|||
import com.ibm.wala.util.collections.CompoundIterator;
|
||||
import com.ibm.wala.util.collections.HashMapFactory;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.collections.Pair;
|
||||
import com.ibm.wala.util.graph.Graph;
|
||||
import com.ibm.wala.util.graph.GraphReachability;
|
||||
|
@ -194,14 +195,12 @@ public class FlowGraph implements Iterable<Vertex> {
|
|||
{
|
||||
PropVertex proto = factory.makePropVertex("prototype");
|
||||
if (graph.containsNode(proto)) {
|
||||
for(Iterator<Vertex> ps = graph.getPredNodes(proto); ps.hasNext(); ) {
|
||||
Vertex p = ps.next();
|
||||
for(Vertex p : Iterator2Iterable.make(graph.getPredNodes(proto))) {
|
||||
if (p instanceof VarVertex) {
|
||||
int rval = ((VarVertex) p).getValueNumber();
|
||||
FuncVertex func = ((VarVertex) p).getFunction();
|
||||
DefUse du = cache.getDefUse(getIR(cache, func));
|
||||
for(Iterator<SSAInstruction> insts = du.getUses(rval); insts.hasNext(); ) {
|
||||
SSAInstruction inst = insts.next();
|
||||
for(SSAInstruction inst : Iterator2Iterable.make(du.getUses(rval))) {
|
||||
if (inst instanceof JavaScriptPropertyWrite) {
|
||||
int obj = ((JavaScriptPropertyWrite) inst).getObjectRef();
|
||||
VarVertex object = factory.makeVarVertex(func, obj);
|
||||
|
@ -452,14 +451,12 @@ public class FlowGraph implements Iterable<Vertex> {
|
|||
for(PropVertex property : factory.getPropVertices()) {
|
||||
|
||||
// edges from objects to properties assigned to them
|
||||
for(Iterator<Vertex> ps = dataflow.getPredNodes(property); ps.hasNext(); ) {
|
||||
Vertex p = ps.next();
|
||||
for(Vertex p : Iterator2Iterable.make(dataflow.getPredNodes(property))) {
|
||||
if (p instanceof VarVertex) {
|
||||
int rval = ((VarVertex) p).getValueNumber();
|
||||
FuncVertex func = ((VarVertex) p).getFunction();
|
||||
DefUse du = cache.getDefUse(getIR(cache, func));
|
||||
for(Iterator<SSAInstruction> insts = du.getUses(rval); insts.hasNext(); ) {
|
||||
SSAInstruction inst = insts.next();
|
||||
for(SSAInstruction inst : Iterator2Iterable.make(du.getUses(rval))) {
|
||||
if (inst instanceof JavaScriptPropertyWrite) {
|
||||
int obj = ((JavaScriptPropertyWrite) inst).getObjectRef();
|
||||
VarVertex object = factory.makeVarVertex(func, obj);
|
||||
|
@ -502,8 +499,7 @@ public class FlowGraph implements Iterable<Vertex> {
|
|||
// prototype dataflow for object creations
|
||||
for(CreationSiteVertex cs : factory.creationSites()) {
|
||||
if (cg.getNode(cs.getMethod(), Everywhere.EVERYWHERE) != null) {
|
||||
for(Iterator<Pair<CGNode, NewSiteReference>> sites = cs.getCreationSites(cg); sites.hasNext(); ) {
|
||||
Pair<CGNode, NewSiteReference> site = sites.next();
|
||||
for(Pair<CGNode, NewSiteReference> site : Iterator2Iterable.make(cs.getCreationSites(cg))) {
|
||||
IR ir = site.fst.getIR();
|
||||
SSAInstruction creation = ir.getInstructions()[ site.snd.getProgramCounter() ];
|
||||
if (creation instanceof JavaScriptInvoke) {
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
*****************************************************************************/
|
||||
package com.ibm.wala.cast.js.callgraph.fieldbased.flowgraph;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.ibm.wala.cast.ir.ssa.AstGlobalRead;
|
||||
import com.ibm.wala.cast.ir.ssa.AstGlobalWrite;
|
||||
import com.ibm.wala.cast.ir.ssa.AstLexicalAccess.Access;
|
||||
|
@ -50,6 +48,7 @@ import com.ibm.wala.ssa.SSAPutInstruction;
|
|||
import com.ibm.wala.ssa.SSAReturnInstruction;
|
||||
import com.ibm.wala.ssa.SSAThrowInstruction;
|
||||
import com.ibm.wala.types.TypeReference;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.intset.EmptyIntSet;
|
||||
import com.ibm.wala.util.intset.IntSet;
|
||||
|
||||
|
@ -117,11 +116,11 @@ public class FlowGraphBuilder {
|
|||
|
||||
// now visit phis and catches
|
||||
visitor.instructionIndex = -1;
|
||||
for(Iterator<? extends SSAInstruction> iter=ir.iteratePhis();iter.hasNext();)
|
||||
iter.next().visit(visitor);
|
||||
for(SSAInstruction inst : Iterator2Iterable.make(ir.iteratePhis()))
|
||||
inst.visit(visitor);
|
||||
|
||||
for(Iterator<SSAInstruction> iter=ir.iterateCatchInstructions();iter.hasNext();)
|
||||
iter.next().visit(visitor);
|
||||
for(SSAInstruction inst : Iterator2Iterable.make(ir.iterateCatchInstructions()))
|
||||
inst.visit(visitor);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ import com.ibm.wala.cast.tree.rewrite.CAstRewriter.Rewrite;
|
|||
import com.ibm.wala.util.collections.EmptyIterator;
|
||||
import com.ibm.wala.util.collections.HashMapFactory;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
|
||||
/**
|
||||
* A simple implementation of {@link CAstEntity} used by the {@link ClosureExtractor}.
|
||||
|
@ -120,8 +121,7 @@ class ExtractedFunction implements CAstEntity {
|
|||
}
|
||||
}
|
||||
// now, add all new entities which arise from extracted nested for-in loops
|
||||
for(Iterator<ExtractionPos> iter=pos.getNestedLoops(); iter.hasNext();) {
|
||||
ExtractionPos nested_loop = iter.next();
|
||||
for(ExtractionPos nested_loop : Iterator2Iterable.make(pos.getNestedLoops())) {
|
||||
CAstNode callsite = nested_loop.getCallSite();
|
||||
CAstEntity scoped_entity = nested_loop.getExtractedEntity();
|
||||
Collection<CAstEntity> c = scopedEntities.get(callsite);
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
package com.ibm.wala.cast.js.ipa.modref;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.ibm.wala.cast.ipa.callgraph.AstHeapModel;
|
||||
import com.ibm.wala.cast.ipa.modref.AstModRef;
|
||||
import com.ibm.wala.cast.js.ssa.JSInstructionVisitor;
|
||||
|
@ -31,6 +29,7 @@ import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
|
|||
import com.ibm.wala.ipa.callgraph.propagation.PointerAnalysis;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.PointerKey;
|
||||
import com.ibm.wala.ipa.modref.ExtendedHeapModel;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
|
||||
public class JavaScriptModRef<T extends InstanceKey> extends AstModRef<T> {
|
||||
|
||||
|
@ -56,8 +55,7 @@ public class JavaScriptModRef<T extends InstanceKey> extends AstModRef<T> {
|
|||
PointerKey prop = h.getPointerKeyForLocal(n, instruction.getMemberRef());
|
||||
for(InstanceKey o : pa.getPointsToSet(obj)) {
|
||||
for(InstanceKey p : pa.getPointsToSet(prop)) {
|
||||
for(Iterator<PointerKey> keys = h.getPointerKeysForReflectedFieldRead(o, p); keys.hasNext(); ) {
|
||||
PointerKey x = keys.next();
|
||||
for(PointerKey x : Iterator2Iterable.make(h.getPointerKeysForReflectedFieldRead(o, p))) {
|
||||
assert x != null : instruction;
|
||||
result.add(x);
|
||||
}
|
||||
|
@ -130,8 +128,7 @@ public class JavaScriptModRef<T extends InstanceKey> extends AstModRef<T> {
|
|||
PointerKey prop = h.getPointerKeyForLocal(n, instruction.getMemberRef());
|
||||
for(T o : pa.getPointsToSet(obj)) {
|
||||
for(T p : pa.getPointsToSet(prop)) {
|
||||
for(Iterator<PointerKey> keys = h.getPointerKeysForReflectedFieldWrite(o, p); keys.hasNext(); ) {
|
||||
PointerKey x = keys.next();
|
||||
for(PointerKey x : Iterator2Iterable.make(h.getPointerKeysForReflectedFieldWrite(o, p))) {
|
||||
assert x != null : instruction;
|
||||
result.add(x);
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
*****************************************************************************/
|
||||
package com.ibm.wala.cast.js.util;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -24,6 +23,7 @@ import com.ibm.wala.classLoader.IMethod;
|
|||
import com.ibm.wala.ipa.callgraph.CGNode;
|
||||
import com.ibm.wala.ipa.callgraph.CallGraph;
|
||||
import com.ibm.wala.util.collections.HashMapFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.collections.MapUtil;
|
||||
import com.ibm.wala.util.collections.Util;
|
||||
|
||||
|
@ -72,8 +72,7 @@ public class CallGraph2JSON {
|
|||
continue;
|
||||
AstMethod method = (AstMethod)nd.getMethod();
|
||||
|
||||
for(Iterator<CallSiteReference> iter = nd.iterateCallSites(); iter.hasNext();) {
|
||||
CallSiteReference callsite = iter.next();
|
||||
for(CallSiteReference callsite : Iterator2Iterable.make(nd.iterateCallSites())) {
|
||||
Set<IMethod> targets = Util.mapToSet(cg.getPossibleTargets(nd, callsite), CGNode::getMethod);
|
||||
serializeCallSite(method, callsite, targets, edges);
|
||||
}
|
||||
|
|
|
@ -10,13 +10,12 @@
|
|||
*******************************************************************************/
|
||||
package com.ibm.wala.cast.js.util;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.ibm.wala.cast.js.ssa.PrototypeLookup;
|
||||
import com.ibm.wala.ssa.DefUse;
|
||||
import com.ibm.wala.ssa.IR;
|
||||
import com.ibm.wala.ssa.SSAInstruction;
|
||||
import com.ibm.wala.ssa.SSAPhiInstruction;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.intset.IntSet;
|
||||
import com.ibm.wala.util.intset.IntSetUtil;
|
||||
import com.ibm.wala.util.intset.MutableIntSet;
|
||||
|
@ -35,8 +34,7 @@ public class Util {
|
|||
do {
|
||||
size = result.size();
|
||||
result.foreach(vn -> {
|
||||
for(Iterator<SSAInstruction> insts = du.getUses(vn); insts.hasNext(); ) {
|
||||
SSAInstruction inst = insts.next();
|
||||
for(SSAInstruction inst : Iterator2Iterable.make(du.getUses(vn))) {
|
||||
if (inst instanceof PrototypeLookup || inst instanceof SSAPhiInstruction) {
|
||||
result.add(inst.getDef());
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import com.ibm.wala.ipa.callgraph.CallGraph;
|
|||
import com.ibm.wala.ssa.IR;
|
||||
import com.ibm.wala.ssa.SSACFG;
|
||||
import com.ibm.wala.ssa.SSAInstruction;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.collections.NonNullSingletonIterator;
|
||||
|
||||
public abstract class TestCallGraphShape extends WalaTestCase {
|
||||
|
@ -149,8 +150,7 @@ public abstract class TestCallGraphShape extends WalaTestCase {
|
|||
|
||||
while (srcs.hasNext()) {
|
||||
CGNode src = srcs.next();
|
||||
for (Iterator<CallSiteReference> sites = src.iterateCallSites(); sites.hasNext();) {
|
||||
CallSiteReference sr = sites.next();
|
||||
for (CallSiteReference sr : Iterator2Iterable.make(src.iterateCallSites())) {
|
||||
|
||||
Iterator<CGNode> dsts = getNodes(CG, targetName).iterator();
|
||||
if (! checkAbsence) {
|
||||
|
@ -194,8 +194,8 @@ public abstract class TestCallGraphShape extends WalaTestCase {
|
|||
Collection<CGNode> dests = getNodes(CG, destDescription);
|
||||
for (Object source : sources) {
|
||||
for (Object dest : dests) {
|
||||
for (Iterator<CGNode> i = CG.getSuccNodes((CGNode) source); i.hasNext();) {
|
||||
if (i.next().equals(dest)) {
|
||||
for (CGNode n : Iterator2Iterable.make(CG.getSuccNodes((CGNode) source))) {
|
||||
if (n.equals(dest)) {
|
||||
Assert.fail("Found a link from " + source + " to " + dest);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
package com.ibm.wala.cast.ipa.callgraph;
|
||||
|
||||
import java.util.ConcurrentModificationException;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
||||
|
@ -36,6 +35,7 @@ import com.ibm.wala.types.MethodReference;
|
|||
import com.ibm.wala.types.TypeReference;
|
||||
import com.ibm.wala.util.CancelException;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
|
||||
public class AstCallGraph extends ExplicitCallGraph {
|
||||
public AstCallGraph(IClassHierarchy cha, AnalysisOptions options, IAnalysisCacheView cache) {
|
||||
|
@ -118,8 +118,8 @@ public class AstCallGraph extends ExplicitCallGraph {
|
|||
|
||||
callbacks.add(callback);
|
||||
|
||||
for (Iterator<CGNode> ps = getCallGraph().getPredNodes(this); ps.hasNext();) {
|
||||
((AstCGNode) ps.next()).addCallback(callback);
|
||||
for (CGNode p : Iterator2Iterable.make(getCallGraph().getPredNodes(this))) {
|
||||
((AstCGNode) p).addCallback(callback);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -132,8 +132,8 @@ public class AstCallGraph extends ExplicitCallGraph {
|
|||
|
||||
callbacks.addAll(callback);
|
||||
|
||||
for (Iterator<CGNode> ps = getCallGraph().getPredNodes(this); ps.hasNext();) {
|
||||
((AstCGNode) ps.next()).addAllCallbacks(callback);
|
||||
for (CGNode p : Iterator2Iterable.make(getCallGraph().getPredNodes(this))) {
|
||||
((AstCGNode) p).addAllCallbacks(callback);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,6 +66,7 @@ import com.ibm.wala.ssa.IRView;
|
|||
import com.ibm.wala.ssa.SSAPutInstruction;
|
||||
import com.ibm.wala.ssa.SymbolTable;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.collections.Pair;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
import com.ibm.wala.util.intset.IntSet;
|
||||
|
@ -960,9 +961,9 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
|
|||
fields.getValue().foreach(fptr -> {
|
||||
if (!doneField.contains(fptr) || !doneReceiver.contains(rptr)) {
|
||||
InstanceKey field = system.getInstanceKey(fptr);
|
||||
for (Iterator<PointerKey> keys = isLoadOperation ? getPointerKeysForReflectedFieldRead(receiver, field)
|
||||
: getPointerKeysForReflectedFieldWrite(receiver, field); keys.hasNext();) {
|
||||
AbstractFieldPointerKey key = (AbstractFieldPointerKey) keys.next();
|
||||
for (PointerKey pkey : Iterator2Iterable.make(isLoadOperation ? getPointerKeysForReflectedFieldRead(receiver, field)
|
||||
: getPointerKeysForReflectedFieldWrite(receiver, field))) {
|
||||
AbstractFieldPointerKey key = (AbstractFieldPointerKey) pkey;
|
||||
if (DEBUG_PROPERTIES)
|
||||
action.dump(key, false, false);
|
||||
action.action(key);
|
||||
|
@ -1006,8 +1007,8 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
|
|||
PointerKey objCatalog = getPointerKeyForObjectCatalog(object);
|
||||
for (InstanceKey fieldsKey : fieldsKeys) {
|
||||
if (isLoadOperation) {
|
||||
for (Iterator<PointerKey> keys = getPointerKeysForReflectedFieldRead(object, fieldsKey); keys.hasNext();) {
|
||||
AbstractFieldPointerKey key = (AbstractFieldPointerKey) keys.next();
|
||||
for (PointerKey pkey : Iterator2Iterable.make(getPointerKeysForReflectedFieldRead(object, fieldsKey))) {
|
||||
AbstractFieldPointerKey key = (AbstractFieldPointerKey) pkey;
|
||||
if (DEBUG_PROPERTIES)
|
||||
action.dump(key, true, false);
|
||||
action.action(key);
|
||||
|
@ -1016,8 +1017,8 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
|
|||
if (objCatalog != null) {
|
||||
system.newConstraint(objCatalog, fieldsKey);
|
||||
}
|
||||
for (Iterator<PointerKey> keys = getPointerKeysForReflectedFieldWrite(object, fieldsKey); keys.hasNext();) {
|
||||
AbstractFieldPointerKey key = (AbstractFieldPointerKey) keys.next();
|
||||
for (PointerKey pkey : Iterator2Iterable.make(getPointerKeysForReflectedFieldWrite(object, fieldsKey))) {
|
||||
AbstractFieldPointerKey key = (AbstractFieldPointerKey) pkey;
|
||||
if (DEBUG_PROPERTIES)
|
||||
action.dump(key, true, false);
|
||||
action.action(key);
|
||||
|
@ -1065,9 +1066,9 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
|
|||
fields.getValue().foreach(fptr -> {
|
||||
InstanceKey field = system.getInstanceKey(fptr);
|
||||
for (InstanceKey objKey : objKeys) {
|
||||
for (Iterator<PointerKey> keys = isLoadOperation ? getPointerKeysForReflectedFieldRead(objKey, field)
|
||||
: getPointerKeysForReflectedFieldWrite(objKey, field); keys.hasNext();) {
|
||||
AbstractFieldPointerKey key = (AbstractFieldPointerKey) keys.next();
|
||||
for (PointerKey pkey : Iterator2Iterable.make(isLoadOperation ? getPointerKeysForReflectedFieldRead(objKey, field)
|
||||
: getPointerKeysForReflectedFieldWrite(objKey, field))) {
|
||||
AbstractFieldPointerKey key = (AbstractFieldPointerKey) pkey;
|
||||
if (DEBUG_PROPERTIES)
|
||||
action.dump(key, false, true);
|
||||
action.action(key);
|
||||
|
@ -1101,8 +1102,8 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
|
|||
PointerKey objCatalog = getPointerKeyForObjectCatalog(objKey);
|
||||
for (InstanceKey fieldsKey : fieldsKeys) {
|
||||
if (isLoadOperation) {
|
||||
for (Iterator<PointerKey> keys = getPointerKeysForReflectedFieldRead(objKey, fieldsKey); keys.hasNext();) {
|
||||
AbstractFieldPointerKey key = (AbstractFieldPointerKey) keys.next();
|
||||
for (PointerKey pkey : Iterator2Iterable.make(getPointerKeysForReflectedFieldRead(objKey, fieldsKey))) {
|
||||
AbstractFieldPointerKey key = (AbstractFieldPointerKey) pkey;
|
||||
if (DEBUG_PROPERTIES)
|
||||
action.dump(key, true, true);
|
||||
action.action(key);
|
||||
|
@ -1111,8 +1112,8 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
|
|||
if (objCatalog != null) {
|
||||
system.newConstraint(objCatalog, fieldsKey);
|
||||
}
|
||||
for (Iterator<PointerKey> keys = getPointerKeysForReflectedFieldWrite(objKey, fieldsKey); keys.hasNext();) {
|
||||
AbstractFieldPointerKey key = (AbstractFieldPointerKey) keys.next();
|
||||
for (PointerKey pkey : Iterator2Iterable.make(getPointerKeysForReflectedFieldWrite(objKey, fieldsKey))) {
|
||||
AbstractFieldPointerKey key = (AbstractFieldPointerKey) pkey;
|
||||
if (DEBUG_PROPERTIES)
|
||||
action.dump(key, true, true);
|
||||
action.action(key);
|
||||
|
|
|
@ -16,8 +16,6 @@ import java.io.InputStream;
|
|||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.commons.io.ByteOrderMark;
|
||||
import org.apache.commons.io.input.BOMInputStream;
|
||||
|
||||
|
@ -37,6 +35,7 @@ import com.ibm.wala.ipa.callgraph.propagation.PointerKey;
|
|||
import com.ibm.wala.ipa.callgraph.propagation.SSAContextInterpreter;
|
||||
import com.ibm.wala.ssa.IRFactory;
|
||||
import com.ibm.wala.ssa.IRView;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
|
||||
public class CAstCallGraphUtil {
|
||||
|
@ -126,12 +125,12 @@ public class CAstCallGraphUtil {
|
|||
for (CGNode N : CG) {
|
||||
System.err.print("callees of node " + getShortName(N) + " : [");
|
||||
boolean fst = true;
|
||||
for (Iterator<? extends CGNode> ns = CG.getSuccNodes(N); ns.hasNext();) {
|
||||
for (CGNode n : Iterator2Iterable.make(CG.getSuccNodes(N))) {
|
||||
if (fst)
|
||||
fst = false;
|
||||
else
|
||||
System.err.print(", ");
|
||||
System.err.print(getShortName(ns.next()));
|
||||
System.err.print(getShortName(n));
|
||||
}
|
||||
System.err.println("]");
|
||||
System.err.println("\nIR of node " + N.getGraphNodeId() + ", context " + N.getContext());
|
||||
|
|
|
@ -10,19 +10,20 @@
|
|||
*****************************************************************************/
|
||||
package com.ibm.wala.cast.ir.cfg;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.ibm.wala.cfg.ControlFlowGraph;
|
||||
import com.ibm.wala.cfg.IBasicBlock;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
|
||||
public class Util {
|
||||
|
||||
public static <I, T extends IBasicBlock<I>> int whichPred(ControlFlowGraph<I, T> CFG, T Y, T X) {
|
||||
int i = 0;
|
||||
for (Iterator<?> N = CFG.getPredNodes(Y); N.hasNext(); i++)
|
||||
if (N.next() == X)
|
||||
for (Object N : Iterator2Iterable.make(CFG.getPredNodes(Y))) {
|
||||
if (N == X)
|
||||
return i;
|
||||
++i;
|
||||
}
|
||||
|
||||
Assertions.UNREACHABLE();
|
||||
return -1;
|
||||
|
|
|
@ -26,6 +26,7 @@ import com.ibm.wala.ssa.SSAPhiInstruction;
|
|||
import com.ibm.wala.ssa.SymbolTable;
|
||||
import com.ibm.wala.util.collections.ArrayIterator;
|
||||
import com.ibm.wala.util.collections.IntStack;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.graph.Graph;
|
||||
import com.ibm.wala.util.graph.dominators.DominanceFrontiers;
|
||||
|
||||
|
@ -211,8 +212,8 @@ public abstract class AbstractSSAConversion {
|
|||
while (!W.isEmpty()) {
|
||||
SSACFG.BasicBlock X = W.iterator().next();
|
||||
W.remove(X);
|
||||
for (Iterator<ISSABasicBlock> YS = DF.getDominanceFrontier(X); YS.hasNext();) {
|
||||
SSACFG.BasicBlock Y = (SSACFG.BasicBlock) YS.next();
|
||||
for (ISSABasicBlock IY : Iterator2Iterable.make(DF.getDominanceFrontier(X))) {
|
||||
SSACFG.BasicBlock Y = (SSACFG.BasicBlock) IY;
|
||||
if (getHasAlready(Y) < IterCount) {
|
||||
if (isLive(Y, V)) {
|
||||
placeNewPhiAt(V, Y);
|
||||
|
@ -353,8 +354,8 @@ public abstract class AbstractSSAConversion {
|
|||
repairExit();
|
||||
}
|
||||
|
||||
for (Iterator<ISSABasicBlock> YS = CFG.getSuccNodes(X); YS.hasNext();) {
|
||||
SSACFG.BasicBlock Y = (SSACFG.BasicBlock) YS.next();
|
||||
for (ISSABasicBlock IY : Iterator2Iterable.make(CFG.getSuccNodes(X))) {
|
||||
SSACFG.BasicBlock Y = (SSACFG.BasicBlock) IY;
|
||||
int Y_id = Y.getGraphNodeId();
|
||||
int j = com.ibm.wala.cast.ir.cfg.Util.whichPred(CFG, Y, X);
|
||||
for (int i = 0; i < phiCounts[Y_id]; i++) {
|
||||
|
|
|
@ -13,7 +13,6 @@ package com.ibm.wala.cast.ir.ssa;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -29,6 +28,7 @@ import com.ibm.wala.ssa.SSAPhiInstruction;
|
|||
import com.ibm.wala.ssa.SymbolTable;
|
||||
import com.ibm.wala.util.collections.HashMapFactory;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.IteratorUtil;
|
||||
import com.ibm.wala.util.intset.BitVector;
|
||||
import com.ibm.wala.util.intset.BitVectorIntSet;
|
||||
import com.ibm.wala.util.intset.IntSet;
|
||||
|
@ -532,10 +532,7 @@ public class SSAConversion extends AbstractSSAConversion {
|
|||
for (int i = 0; i < CFG.getNumberOfNodes(); i++) {
|
||||
SSACFG.BasicBlock bb = CFG.getNode(i);
|
||||
if (bb.hasPhi()) {
|
||||
int n = 0;
|
||||
for (Iterator<SSAPhiInstruction> X = bb.iteratePhis(); X.hasNext(); n++)
|
||||
X.next();
|
||||
phiCounts[i] = n;
|
||||
phiCounts[i] = IteratorUtil.count(bb.iteratePhis());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
*****************************************************************************/
|
||||
package com.ibm.wala.cast.ir.ssa.analysis;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.ibm.wala.cfg.ControlFlowGraph;
|
||||
import com.ibm.wala.dataflow.graph.AbstractMeetOperator;
|
||||
import com.ibm.wala.dataflow.graph.BitVectorSolver;
|
||||
|
@ -27,6 +25,7 @@ import com.ibm.wala.ssa.SSAPhiInstruction;
|
|||
import com.ibm.wala.ssa.SymbolTable;
|
||||
import com.ibm.wala.util.CancelException;
|
||||
import com.ibm.wala.util.CancelRuntimeException;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
import com.ibm.wala.util.graph.Graph;
|
||||
import com.ibm.wala.util.graph.impl.GraphInverter;
|
||||
|
@ -173,12 +172,11 @@ public class LiveAnalysis {
|
|||
bits.addAll(s);
|
||||
}
|
||||
// Include all uses generated by the current basic block into the successor's Phi instructions todo: rephrase
|
||||
for (Iterator<? extends ISSABasicBlock> succBBs = cfg.getSuccNodes(block); succBBs.hasNext();) {
|
||||
ISSABasicBlock succBB = succBBs.next();
|
||||
for (ISSABasicBlock succBB : Iterator2Iterable.make(cfg.getSuccNodes(block))) {
|
||||
|
||||
int rval = com.ibm.wala.cast.ir.cfg.Util.whichPred(cfg, succBB, block);
|
||||
for (Iterator<SSAPhiInstruction> sphis = succBB.iteratePhis(); sphis.hasNext();) {
|
||||
bits.add(sphis.next().getUse(rval));
|
||||
for (SSAPhiInstruction sphi : Iterator2Iterable.make(succBB.iteratePhis())) {
|
||||
bits.add(sphi.getUse(rval));
|
||||
}
|
||||
}
|
||||
// For all instructions, in reverse order, 'kill' variables written to and 'gen' variables read.
|
||||
|
@ -190,8 +188,8 @@ public class LiveAnalysis {
|
|||
}
|
||||
}
|
||||
// 'kill' the variables defined by the Phi instructions in the current block.
|
||||
for (Iterator<? extends SSAInstruction> SS = block.iteratePhis(); SS.hasNext();) {
|
||||
processDefs(SS.next(), bits.getBitVector());
|
||||
for (SSAInstruction S : Iterator2Iterable.make(block.iteratePhis())) {
|
||||
processDefs(S, bits.getBitVector());
|
||||
}
|
||||
|
||||
BitVectorVariable U = new BitVectorVariable();
|
||||
|
|
|
@ -81,6 +81,7 @@ import com.ibm.wala.types.TypeName;
|
|||
import com.ibm.wala.types.TypeReference;
|
||||
import com.ibm.wala.util.collections.HashMapFactory;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.collections.MapUtil;
|
||||
import com.ibm.wala.util.collections.Pair;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
|
@ -922,8 +923,8 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
void makeExitBlock(PreBasicBlock bb) {
|
||||
bb.makeExitBlock();
|
||||
|
||||
for (Iterator<? extends PreBasicBlock> ps = getPredNodes(bb); ps.hasNext();)
|
||||
normalToExit.add(ps.next());
|
||||
for (PreBasicBlock p : Iterator2Iterable.make(getPredNodes(bb)))
|
||||
normalToExit.add(p);
|
||||
|
||||
// now that we have created the exit block, add the delayed edges to the
|
||||
// exit
|
||||
|
@ -1143,8 +1144,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
EdgeOperation normal,
|
||||
EdgeOperation except) {
|
||||
for (PreBasicBlock src : blocks) {
|
||||
for (Iterator<PreBasicBlock> j = icfg.getSuccNodes(src); j.hasNext();) {
|
||||
PreBasicBlock dst = j.next();
|
||||
for (PreBasicBlock dst : Iterator2Iterable.make(icfg.getSuccNodes(src))) {
|
||||
if (isCatchBlock(dst.getNumber()) || (dst.isExitBlock() && icfg.exceptionalToExit.contains(src))) {
|
||||
except.act(src, dst);
|
||||
}
|
||||
|
@ -1352,8 +1352,8 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
PreBasicBlock bb = getNode(i);
|
||||
s.append(bb).append("\n");
|
||||
|
||||
for (Iterator<PreBasicBlock> ss = getSuccNodes(bb); ss.hasNext();)
|
||||
s.append(" -->" + ss.next() + "\n");
|
||||
for (PreBasicBlock pbb : Iterator2Iterable.make(getSuccNodes(bb)))
|
||||
s.append(" -->" + pbb + "\n");
|
||||
|
||||
for (int j = bb.getFirstInstructionIndex(); j <= bb.getLastInstructionIndex(); j++)
|
||||
if (insts[j] != null)
|
||||
|
@ -3102,8 +3102,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
}
|
||||
|
||||
for (Scope scope : scopes) {
|
||||
for (Iterator<String> I = scope.getAllNames(); I.hasNext();) {
|
||||
String nm = I.next();
|
||||
for (String nm : Iterator2Iterable.make(scope.getAllNames())) {
|
||||
|
||||
if (ignoreName(nm)) {
|
||||
continue;
|
||||
|
|
|
@ -15,7 +15,6 @@ import java.io.File;
|
|||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
@ -33,6 +32,7 @@ import com.ibm.wala.classLoader.SourceFileModule;
|
|||
import com.ibm.wala.classLoader.SourceModule;
|
||||
import com.ibm.wala.ipa.cha.IClassHierarchy;
|
||||
import com.ibm.wala.types.TypeName;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.collections.Pair;
|
||||
import com.ibm.wala.util.io.TemporaryFile;
|
||||
import com.ibm.wala.util.warnings.Warning;
|
||||
|
@ -174,8 +174,8 @@ public abstract class CAstAbstractModuleLoader extends CAstAbstractLoader {
|
|||
* in topLevelEntities
|
||||
*/
|
||||
private void translateModuleToCAst(Module module, CAst ast, Set<Pair<CAstEntity, ModuleEntry>> topLevelEntities) {
|
||||
for (Iterator<? extends ModuleEntry> mes = module.getEntries(); mes.hasNext();) {
|
||||
translateModuleEntryToCAst(mes.next(), ast, topLevelEntities);
|
||||
for (ModuleEntry me : Iterator2Iterable.make(module.getEntries())) {
|
||||
translateModuleEntryToCAst(me, ast, topLevelEntities);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.util.Iterator;
|
|||
import com.ibm.wala.cast.tree.CAstNode;
|
||||
import com.ibm.wala.cast.tree.CAstSourcePositionMap;
|
||||
import com.ibm.wala.util.collections.HashMapFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
|
||||
public class CAstSourcePositionRecorder implements CAstSourcePositionMap {
|
||||
|
||||
|
@ -98,8 +99,7 @@ public class CAstSourcePositionRecorder implements CAstSourcePositionMap {
|
|||
}
|
||||
|
||||
public void addAll(CAstSourcePositionMap other) {
|
||||
for(Iterator<CAstNode> nodes = other.getMappedNodes(); nodes.hasNext(); ) {
|
||||
CAstNode node = nodes.next();
|
||||
for(CAstNode node : Iterator2Iterable.make(other.getMappedNodes())) {
|
||||
setPosition(node, other.getPosition(node));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ package com.ibm.wala.core.tests.basic;
|
|||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -23,6 +22,7 @@ import com.ibm.wala.core.tests.util.WalaTestCase;
|
|||
import com.ibm.wala.util.collections.BimodalMap;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Collection;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.collections.SmallMap;
|
||||
import com.ibm.wala.util.graph.Graph;
|
||||
import com.ibm.wala.util.graph.NumberedGraph;
|
||||
|
@ -761,13 +761,12 @@ public class PrimitivesTest extends WalaTestCase {
|
|||
// Assert.assertions
|
||||
int i = 0;
|
||||
Object[] desired4 = new Object[] { nodes[4], nodes[7], nodes[8], nodes[5], nodes[10] };
|
||||
for (Iterator<Object> d4 = D.dominators(nodes[4]); d4.hasNext();)
|
||||
Assert.assertTrue(d4.next() == desired4[i++]);
|
||||
for (Object d4 : Iterator2Iterable.make(D.dominators(nodes[4])))
|
||||
Assert.assertTrue(d4 == desired4[i++]);
|
||||
|
||||
int j = 0;
|
||||
Object[] desired5 = new Object[] { nodes[8] };
|
||||
for (Iterator<? extends Object> t4 = D.dominatorTree().getSuccNodes(nodes[5]); t4.hasNext();) {
|
||||
Object o4 = t4.next();
|
||||
for (Object o4 : Iterator2Iterable.make(D.dominatorTree().getSuccNodes(nodes[5]))) {
|
||||
Object d = desired5[j++];
|
||||
boolean ok = (o4.equals(d));
|
||||
if (!ok) {
|
||||
|
|
|
@ -10,13 +10,13 @@
|
|||
*******************************************************************************/
|
||||
package com.ibm.wala.core.tests.basic;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.ibm.wala.util.collections.HashMapFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.graph.Graph;
|
||||
import com.ibm.wala.util.graph.NumberedGraph;
|
||||
import com.ibm.wala.util.graph.impl.DelegatingNumberedGraph;
|
||||
|
@ -28,15 +28,13 @@ public class WelshPowellTest {
|
|||
|
||||
public static <T> void assertColoring(Graph<T> G, Map<T,Integer> colors, boolean fullColor) {
|
||||
for(T n : G) {
|
||||
for(Iterator<T> ss = G.getSuccNodes(n); ss.hasNext(); ) {
|
||||
T succ = ss.next();
|
||||
for(T succ : Iterator2Iterable.make(G.getSuccNodes(n))) {
|
||||
if (!fullColor && (!colors.containsKey(n) || !colors.containsKey(succ)) ) {
|
||||
continue;
|
||||
}
|
||||
Assert.assertTrue(n + " and succ: " + succ + " have same color: " + colors.get(n).intValue(), colors.get(n).intValue() != colors.get(succ).intValue());
|
||||
}
|
||||
for(Iterator<T> ps = G.getPredNodes(n); ps.hasNext(); ) {
|
||||
T pred = ps.next();
|
||||
for(T pred : Iterator2Iterable.make(G.getPredNodes(n))) {
|
||||
if (!fullColor && (!colors.containsKey(n) || !colors.containsKey(pred)) ) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -52,6 +52,7 @@ import com.ibm.wala.types.MethodReference;
|
|||
import com.ibm.wala.util.CancelException;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.collections.IteratorUtil;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
import com.ibm.wala.util.graph.Graph;
|
||||
import com.ibm.wala.util.graph.GraphIntegrity;
|
||||
|
@ -503,8 +504,8 @@ public class CallGraphTest extends WalaTestCase {
|
|||
Set<MethodReference> pred = HashSetFactory.make(10);
|
||||
MethodReference methodReference = N;
|
||||
for (CGNode cgNode : cg.getNodes(methodReference))
|
||||
for (Iterator<? extends CGNode> ps = cg.getPredNodes(cgNode); ps.hasNext();)
|
||||
pred.add(((CGNode) ps.next()).getMethod().getReference());
|
||||
for (CGNode p : Iterator2Iterable.make(cg.getPredNodes(cgNode)))
|
||||
pred.add(p.getMethod().getReference());
|
||||
|
||||
return pred.iterator();
|
||||
}
|
||||
|
@ -514,10 +515,7 @@ public class CallGraphTest extends WalaTestCase {
|
|||
*/
|
||||
@Override
|
||||
public int getPredNodeCount(MethodReference N) {
|
||||
int count = 0;
|
||||
for (Iterator<? extends MethodReference> ps = getPredNodes(N); ps.hasNext(); count++, ps.next())
|
||||
;
|
||||
return count;
|
||||
return IteratorUtil.count(getPredNodes(N));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -528,8 +526,8 @@ public class CallGraphTest extends WalaTestCase {
|
|||
Set<MethodReference> succ = HashSetFactory.make(10);
|
||||
MethodReference methodReference = N;
|
||||
for (CGNode node : cg.getNodes(methodReference))
|
||||
for (Iterator<? extends CGNode> ps = cg.getSuccNodes(node); ps.hasNext();)
|
||||
succ.add(((CGNode) ps.next()).getMethod().getReference());
|
||||
for (CGNode p : Iterator2Iterable.make(cg.getSuccNodes(node)))
|
||||
succ.add(p.getMethod().getReference());
|
||||
|
||||
return succ.iterator();
|
||||
}
|
||||
|
@ -539,10 +537,7 @@ public class CallGraphTest extends WalaTestCase {
|
|||
*/
|
||||
@Override
|
||||
public int getSuccNodeCount(MethodReference N) {
|
||||
int count = 0;
|
||||
for (Iterator<MethodReference> ps = getSuccNodes(N); ps.hasNext(); count++, ps.next())
|
||||
;
|
||||
return count;
|
||||
return IteratorUtil.count(getSuccNodes(N));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -606,8 +601,8 @@ public class CallGraphTest extends WalaTestCase {
|
|||
|
||||
@Override
|
||||
public boolean hasEdge(MethodReference src, MethodReference dst) {
|
||||
for (Iterator<MethodReference> succNodes = getSuccNodes(src); succNodes.hasNext();) {
|
||||
if (dst.equals(succNodes.next())) {
|
||||
for (MethodReference succ : Iterator2Iterable.make(getSuccNodes(src))) {
|
||||
if (dst.equals(succ)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
package com.ibm.wala.core.tests.callGraph;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
@ -34,6 +33,7 @@ import com.ibm.wala.types.ClassLoaderReference;
|
|||
import com.ibm.wala.types.MethodReference;
|
||||
import com.ibm.wala.types.TypeReference;
|
||||
import com.ibm.wala.util.CancelException;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
|
||||
/**
|
||||
* Check properties of a call to clone() in RTA
|
||||
|
@ -56,8 +56,7 @@ public class CloneTest extends WalaTestCase {
|
|||
|
||||
// Check there's exactly one target for each super call in
|
||||
// MessageFormat.clone()
|
||||
for (Iterator<CallSiteReference> i = node.iterateCallSites(); i.hasNext();) {
|
||||
CallSiteReference site = i.next();
|
||||
for (CallSiteReference site : Iterator2Iterable.make(node.iterateCallSites())) {
|
||||
if (site.isSpecial()) {
|
||||
if (site.getDeclaredTarget().getDeclaringClass().equals(TypeReference.JavaLangObject)) {
|
||||
Set<CGNode> targets = cg.getPossibleTargets(node, site);
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
package com.ibm.wala.core.tests.callGraph;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
@ -34,6 +33,7 @@ import com.ibm.wala.types.Descriptor;
|
|||
import com.ibm.wala.types.MethodReference;
|
||||
import com.ibm.wala.types.TypeReference;
|
||||
import com.ibm.wala.util.CancelException;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.strings.Atom;
|
||||
|
||||
/**
|
||||
|
@ -103,8 +103,8 @@ public class LambdaTest extends WalaTestCase {
|
|||
// caller of id1 is dynamic from sortForward, and has 1 compareTo
|
||||
CGNode sfnode = cg.getPredNodes(id1node).next();
|
||||
int count = 0;
|
||||
for(Iterator<CallSiteReference> sites = sfnode.iterateCallSites(); sites.hasNext(); ) {
|
||||
if (ctnodes.containsAll(cg.getPossibleTargets(sfnode, sites.next()))) {
|
||||
for(CallSiteReference site : Iterator2Iterable.make(sfnode.iterateCallSites())) {
|
||||
if (ctnodes.containsAll(cg.getPossibleTargets(sfnode, site))) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
package com.ibm.wala.core.tests.callGraph;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
@ -40,6 +39,7 @@ import com.ibm.wala.types.TypeName;
|
|||
import com.ibm.wala.types.TypeReference;
|
||||
import com.ibm.wala.util.CancelException;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.strings.Atom;
|
||||
|
||||
/**
|
||||
|
@ -95,8 +95,7 @@ public class PiNodeCallGraphTest extends WalaTestCase {
|
|||
assert callerNodes.size() == 2;
|
||||
|
||||
for (CGNode n : callerNodes) {
|
||||
for (Iterator<CallSiteReference> sites = n.iterateCallSites(); sites.hasNext();) {
|
||||
CallSiteReference csRef = sites.next();
|
||||
for (CallSiteReference csRef : Iterator2Iterable.make(n.iterateCallSites())) {
|
||||
if (csRef.getDeclaredTarget().equals(unary2Ref)) {
|
||||
numberOfCalls++;
|
||||
assert cg.getNumberOfTargets(n, csRef) == desiredNumberOfTargets;
|
||||
|
|
|
@ -43,6 +43,7 @@ import com.ibm.wala.types.TypeReference;
|
|||
import com.ibm.wala.util.CancelException;
|
||||
import com.ibm.wala.util.WalaException;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.warnings.Warning;
|
||||
import com.ibm.wala.util.warnings.Warnings;
|
||||
|
||||
|
@ -94,8 +95,7 @@ public class ReflectionTest extends WalaTestCase {
|
|||
|
||||
Warnings.clear();
|
||||
CallGraphTest.doCallGraphs(options, new AnalysisCacheImpl(), cha, scope);
|
||||
for (Iterator<Warning> it = Warnings.iterator(); it.hasNext();) {
|
||||
Warning w = it.next();
|
||||
for (Warning w : Iterator2Iterable.make(Warnings.iterator())) {
|
||||
if (w.toString().indexOf("com/ibm/jvm") > 0) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
package com.ibm.wala.core.tests.cfg.exc.intra;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
|
@ -42,6 +40,7 @@ import com.ibm.wala.ssa.analysis.IExplodedBasicBlock;
|
|||
import com.ibm.wala.types.MethodReference;
|
||||
import com.ibm.wala.util.CancelException;
|
||||
import com.ibm.wala.util.NullProgressMonitor;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.config.AnalysisScopeReader;
|
||||
import com.ibm.wala.util.graph.GraphIntegrity.UnsoundGraphException;
|
||||
import com.ibm.wala.util.io.FileProvider;
|
||||
|
@ -732,8 +731,7 @@ public class NullPointerExceptionIntraTest extends WalaTestCase {
|
|||
|
||||
public static IExplodedBasicBlock returnNodeExploded(ISSABasicBlock returnNode, ControlFlowGraph<SSAInstruction, IExplodedBasicBlock> explodedCfg) {
|
||||
final IExplodedBasicBlock exit = explodedCfg.exit();
|
||||
for (Iterator<IExplodedBasicBlock> it = explodedCfg.getPredNodes(exit); it.hasNext();) {
|
||||
IExplodedBasicBlock candidate = it.next();
|
||||
for (IExplodedBasicBlock candidate : Iterator2Iterable.make(explodedCfg.getPredNodes(exit))) {
|
||||
if (candidate.getInstruction() == returnNode.getLastInstruction()) {
|
||||
return candidate;
|
||||
}
|
||||
|
|
|
@ -39,8 +39,6 @@ package com.ibm.wala.core.tests.demandpa;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Assert;
|
||||
|
||||
|
@ -105,8 +103,7 @@ public abstract class AbstractPtrTest {
|
|||
public static CGNode findMainMethod(CallGraph cg) {
|
||||
Descriptor d = Descriptor.findOrCreateUTF8("([Ljava/lang/String;)V");
|
||||
Atom name = Atom.findOrCreateUnicodeAtom("main");
|
||||
for (Iterator<? extends CGNode> it = cg.getSuccNodes(cg.getFakeRootNode()); it.hasNext();) {
|
||||
CGNode n = it.next();
|
||||
for (CGNode n : Iterator2Iterable.make(cg.getSuccNodes(cg.getFakeRootNode()))) {
|
||||
if (n.getMethod().getName().equals(name) && n.getMethod().getDescriptor().equals(d)) {
|
||||
return n;
|
||||
}
|
||||
|
@ -142,8 +139,7 @@ public abstract class AbstractPtrTest {
|
|||
|
||||
public static PointerKey getParam(CGNode n, String methodName, HeapModel heapModel) {
|
||||
IR ir = n.getIR();
|
||||
for (Iterator<SSAInstruction> it = ir.iterateAllInstructions(); it.hasNext();) {
|
||||
SSAInstruction s = it.next();
|
||||
for (SSAInstruction s : Iterator2Iterable.make(ir.iterateAllInstructions())) {
|
||||
if (s instanceof SSAInvokeInstruction) {
|
||||
SSAInvokeInstruction call = (SSAInvokeInstruction) s;
|
||||
if (call.getCallSite().getDeclaredTarget().getName().toString().equals(methodName)) {
|
||||
|
|
|
@ -18,8 +18,6 @@ import java.io.IOException;
|
|||
import java.io.PrintWriter;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
@ -68,6 +66,7 @@ import com.ibm.wala.ssa.SSAReturnInstruction;
|
|||
import com.ibm.wala.types.ClassLoaderReference;
|
||||
import com.ibm.wala.types.Descriptor;
|
||||
import com.ibm.wala.util.CancelException;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.config.AnalysisScopeReader;
|
||||
import com.ibm.wala.util.config.FileOfClasses;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
|
@ -1072,8 +1071,7 @@ public class SlicerTest {
|
|||
* @return
|
||||
*/
|
||||
private static CGNode findMethod(CallGraph cg, Descriptor d, Atom name) {
|
||||
for (Iterator<? extends CGNode> it = cg.getSuccNodes(cg.getFakeRootNode()); it.hasNext();) {
|
||||
CGNode n = it.next();
|
||||
for (CGNode n : Iterator2Iterable.make(cg.getSuccNodes(cg.getFakeRootNode()))) {
|
||||
if (n.getMethod().getName().equals(name) && n.getMethod().getDescriptor().equals(d)) {
|
||||
return n;
|
||||
}
|
||||
|
@ -1102,8 +1100,7 @@ public class SlicerTest {
|
|||
|
||||
public static Statement findCallTo(CGNode n, String methodName) {
|
||||
IR ir = n.getIR();
|
||||
for (Iterator<SSAInstruction> it = ir.iterateAllInstructions(); it.hasNext();) {
|
||||
SSAInstruction s = it.next();
|
||||
for (SSAInstruction s : Iterator2Iterable.make(ir.iterateAllInstructions())) {
|
||||
if (s instanceof SSAInvokeInstruction) {
|
||||
SSAInvokeInstruction call = (SSAInvokeInstruction) s;
|
||||
if (call.getCallSite().getDeclaredTarget().getName().toString().equals(methodName)) {
|
||||
|
|
|
@ -27,6 +27,7 @@ import com.ibm.wala.types.TypeReference;
|
|||
import com.ibm.wala.util.collections.CompoundIterator;
|
||||
import com.ibm.wala.util.collections.EmptyIterator;
|
||||
import com.ibm.wala.util.collections.IntMapIterator;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
import com.ibm.wala.util.debug.UnimplementedError;
|
||||
import com.ibm.wala.util.graph.AbstractNumberedGraph;
|
||||
|
@ -506,8 +507,7 @@ public class BasicHeapGraph<T extends InstanceKey> extends HeapGraphImpl<T> {
|
|||
Object node = getNode(i);
|
||||
if (node != null) {
|
||||
result.append(i).append(" -> ");
|
||||
for (Iterator<Object> it = getSuccNodes(node); it.hasNext();) {
|
||||
Object s = it.next();
|
||||
for (Object s : Iterator2Iterable.make(getSuccNodes(node))) {
|
||||
result.append(getNumber(s)).append(" ");
|
||||
}
|
||||
result.append("\n");
|
||||
|
|
|
@ -57,6 +57,7 @@ import com.ibm.wala.types.MethodReference;
|
|||
import com.ibm.wala.types.TypeReference;
|
||||
import com.ibm.wala.util.collections.HashMapFactory;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
import com.ibm.wala.util.warnings.Warnings;
|
||||
|
||||
|
@ -535,8 +536,7 @@ public class FactoryBypassInterpreter extends AbstractReflectionInterpreter {
|
|||
allInstructions.add(r);
|
||||
}
|
||||
|
||||
for (; it.hasNext();) {
|
||||
IClass klass = it.next();
|
||||
for (IClass klass : Iterator2Iterable.make(it)) {
|
||||
TypeReference T = klass.getReference();
|
||||
if (klass.isAbstract() || klass.isInterface() || typesAllocated.contains(T)) {
|
||||
continue;
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
*******************************************************************************/
|
||||
package com.ibm.wala.analysis.stackMachine;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.ibm.wala.cfg.ShrikeCFG;
|
||||
import com.ibm.wala.cfg.ShrikeCFG.BasicBlock;
|
||||
import com.ibm.wala.dataflow.graph.AbstractMeetOperator;
|
||||
|
@ -54,6 +52,7 @@ import com.ibm.wala.types.ClassLoaderReference;
|
|||
import com.ibm.wala.types.TypeReference;
|
||||
import com.ibm.wala.util.CancelException;
|
||||
import com.ibm.wala.util.CancelRuntimeException;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.graph.INodeWithNumber;
|
||||
import com.ibm.wala.util.shrike.ShrikeUtil;
|
||||
|
||||
|
@ -216,9 +215,8 @@ public abstract class AbstractIntStackMachine implements FixedPointConstants {
|
|||
/*
|
||||
* Add only the entry variable to the work list.
|
||||
*/
|
||||
for (Iterator<? extends INodeWithNumber> it = getFixedPointSystem().getStatementsThatUse(entry); it.hasNext();) {
|
||||
AbstractStatement s = (AbstractStatement) it.next();
|
||||
addToWorkList(s);
|
||||
for (INodeWithNumber s : Iterator2Iterable.make(getFixedPointSystem().getStatementsThatUse(entry))) {
|
||||
addToWorkList((AbstractStatement) s);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@ import com.ibm.wala.types.TypeReference;
|
|||
import com.ibm.wala.util.CancelException;
|
||||
import com.ibm.wala.util.CancelRuntimeException;
|
||||
import com.ibm.wala.util.MonitorUtil.IProgressMonitor;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
|
||||
/**
|
||||
|
@ -178,8 +179,7 @@ public class TypeInference extends SSAInference<TypeVariable> implements FixedPo
|
|||
}
|
||||
}
|
||||
|
||||
for (Iterator<SSAInstruction> it = ir.iterateNormalInstructions(); it.hasNext();) {
|
||||
SSAInstruction s = it.next();
|
||||
for (SSAInstruction s : Iterator2Iterable.make(ir.iterateNormalInstructions())) {
|
||||
if (s instanceof SSAAbstractInvokeInstruction) {
|
||||
SSAAbstractInvokeInstruction call = (SSAAbstractInvokeInstruction) s;
|
||||
TypeVariable v = getVariable(call.getException());
|
||||
|
|
|
@ -23,6 +23,7 @@ import com.ibm.wala.util.collections.EmptyIterator;
|
|||
import com.ibm.wala.util.collections.FilterIterator;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Collection;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.collections.IteratorPlusOne;
|
||||
import com.ibm.wala.util.collections.IteratorPlusTwo;
|
||||
import com.ibm.wala.util.collections.NonNullSingletonIterator;
|
||||
|
@ -592,8 +593,8 @@ public abstract class AbstractCFG<I, T extends IBasicBlock<I>> implements Contro
|
|||
throw new IllegalArgumentException("b is null");
|
||||
}
|
||||
List<T> result = new ArrayList<>();
|
||||
for (Iterator<T> it = iterateExceptionalSuccessors(b.getNumber()); it.hasNext();) {
|
||||
result.add(it.next());
|
||||
for (T s : Iterator2Iterable.make(iterateExceptionalSuccessors(b.getNumber()))) {
|
||||
result.add(s);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import com.ibm.wala.ssa.SSAReturnInstruction;
|
|||
import com.ibm.wala.ssa.SSAThrowInstruction;
|
||||
import com.ibm.wala.types.TypeReference;
|
||||
import com.ibm.wala.util.WalaException;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
import com.ibm.wala.util.graph.Graph;
|
||||
import com.ibm.wala.util.graph.impl.SlowSparseNumberedGraph;
|
||||
|
@ -54,9 +55,7 @@ public class CFGSanitizer {
|
|||
|
||||
// add all edges to the graph, except those that go to exit
|
||||
for (ISSABasicBlock b : cfg) {
|
||||
for (Iterator<ISSABasicBlock> it2 = cfg.getSuccNodes(b); it2.hasNext();) {
|
||||
ISSABasicBlock b2 = it2.next();
|
||||
|
||||
for (ISSABasicBlock b2 : Iterator2Iterable.make(cfg.getSuccNodes(b))) {
|
||||
if (!b2.isExitBlock()) {
|
||||
g.addEdge(b, b2);
|
||||
}
|
||||
|
@ -66,9 +65,8 @@ public class CFGSanitizer {
|
|||
// now add edges to exit, ignoring undeclared exceptions
|
||||
ISSABasicBlock exit = cfg.exit();
|
||||
|
||||
for (Iterator<ISSABasicBlock> it = cfg.getPredNodes(exit); it.hasNext();) {
|
||||
for (ISSABasicBlock b : Iterator2Iterable.make(cfg.getPredNodes(exit))) {
|
||||
// for each predecessor of exit ...
|
||||
ISSABasicBlock b = it.next();
|
||||
|
||||
SSAInstruction s = ir.getInstructions()[b.getLastInstructionIndex()];
|
||||
if (s == null) {
|
||||
|
@ -89,14 +87,12 @@ public class CFGSanitizer {
|
|||
Assertions.UNREACHABLE();
|
||||
}
|
||||
// remove any exceptions that are caught by catch blocks
|
||||
for (Iterator<ISSABasicBlock> it2 = cfg.getSuccNodes(b); it2.hasNext();) {
|
||||
IBasicBlock c = it2.next();
|
||||
for (ISSABasicBlock c : Iterator2Iterable.make(cfg.getSuccNodes(b))) {
|
||||
|
||||
if (c.isCatchBlock()) {
|
||||
SSACFG.ExceptionHandlerBasicBlock cb = (ExceptionHandlerBasicBlock) c;
|
||||
|
||||
for (Iterator<TypeReference> it3 = cb.getCaughtExceptionTypes(); it3.hasNext();) {
|
||||
TypeReference ex = it3.next();
|
||||
for (TypeReference ex : Iterator2Iterable.make(cb.getCaughtExceptionTypes())) {
|
||||
IClass exClass = cha.lookupClass(ex);
|
||||
if (exClass == null) {
|
||||
throw new WalaException("failed to find " + ex);
|
||||
|
|
|
@ -10,13 +10,12 @@
|
|||
*******************************************************************************/
|
||||
package com.ibm.wala.cfg;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.ibm.wala.shrikeBT.ConditionalBranchInstruction;
|
||||
import com.ibm.wala.ssa.SSAConditionalBranchInstruction;
|
||||
import com.ibm.wala.ssa.SSAInstruction;
|
||||
import com.ibm.wala.ssa.SSASwitchInstruction;
|
||||
import com.ibm.wala.ssa.SymbolTable;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
|
||||
/**
|
||||
|
@ -90,8 +89,7 @@ public class Util {
|
|||
throw new IllegalArgumentException(b.toString() + " does not end with a conditional branch");
|
||||
}
|
||||
T fs = getNotTakenSuccessor(G, b);
|
||||
for (Iterator<? extends T> ss = G.getSuccNodes(b); ss.hasNext();) {
|
||||
T s = ss.next();
|
||||
for (T s : Iterator2Iterable.make(G.getSuccNodes(b))) {
|
||||
if (s != fs)
|
||||
return s;
|
||||
}
|
||||
|
@ -214,8 +212,8 @@ public class Util {
|
|||
throw new IllegalArgumentException("b is null");
|
||||
}
|
||||
int i = 0;
|
||||
for (Iterator<T> it = cfg.getPredNodes(b); it.hasNext();) {
|
||||
if (it.next().equals(a)) {
|
||||
for (T p : Iterator2Iterable.make(cfg.getPredNodes(b))) {
|
||||
if (p.equals(a)) {
|
||||
return i;
|
||||
}
|
||||
i++;
|
||||
|
|
|
@ -19,6 +19,7 @@ import com.ibm.wala.cfg.MinimalCFG;
|
|||
import com.ibm.wala.util.collections.EmptyIterator;
|
||||
import com.ibm.wala.util.collections.HashMapFactory;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.collections.Pair;
|
||||
import com.ibm.wala.util.graph.AbstractNumberedGraph;
|
||||
import com.ibm.wala.util.graph.NumberedEdgeManager;
|
||||
|
@ -72,14 +73,12 @@ public class ControlDependenceGraph<T> extends AbstractNumberedGraph<T> {
|
|||
}
|
||||
|
||||
for (T y : cfg) {
|
||||
for (Iterator<T> ns2 = RDF.getDominanceFrontier(y); ns2.hasNext();) {
|
||||
T x = ns2.next();
|
||||
for (T x : Iterator2Iterable.make(RDF.getDominanceFrontier(y))) {
|
||||
controlDependence.get(x).add(y);
|
||||
if (wantEdgeLabels) {
|
||||
HashSet<Object> labels = HashSetFactory.make();
|
||||
edgeLabels.put(Pair.make(x, y), labels);
|
||||
for (Iterator<? extends T> ss = cfg.getSuccNodes(x); ss.hasNext();) {
|
||||
T s = ss.next();
|
||||
for (T s : Iterator2Iterable.make(cfg.getSuccNodes(x))) {
|
||||
if (RDF.isDominatedBy(s, y)) {
|
||||
labels.add(makeEdgeLabel(x, y, s));
|
||||
}
|
||||
|
@ -206,8 +205,7 @@ public class ControlDependenceGraph<T> extends AbstractNumberedGraph<T> {
|
|||
StringBuffer sb = new StringBuffer();
|
||||
for (T n : this) {
|
||||
sb.append(n.toString()).append("\n");
|
||||
for (Iterator<T> ss = getSuccNodes(n); ss.hasNext();) {
|
||||
Object s = ss.next();
|
||||
for (T s : Iterator2Iterable.make(getSuccNodes(n))) {
|
||||
sb.append(" --> ").append(s);
|
||||
if (edgeLabels != null)
|
||||
for (Object name : edgeLabels.get(Pair.make(n, s)))
|
||||
|
@ -265,8 +263,8 @@ public class ControlDependenceGraph<T> extends AbstractNumberedGraph<T> {
|
|||
return false;
|
||||
}
|
||||
|
||||
for (Iterator<? extends T> pbs1 = getPredNodes(bb1); pbs1.hasNext();) {
|
||||
if (!hasEdge(pbs1.next(), bb2)) {
|
||||
for (T pb : Iterator2Iterable.make(getPredNodes(bb1))) {
|
||||
if (!hasEdge(pb, bb2)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
package com.ibm.wala.cfg.exc.intra;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.ibm.wala.cfg.ControlFlowGraph;
|
||||
import com.ibm.wala.cfg.Util;
|
||||
import com.ibm.wala.dataflow.graph.AbstractMeetOperator;
|
||||
|
@ -50,6 +48,7 @@ import com.ibm.wala.ssa.SSAThrowInstruction;
|
|||
import com.ibm.wala.ssa.SSAUnaryOpInstruction;
|
||||
import com.ibm.wala.ssa.SymbolTable;
|
||||
import com.ibm.wala.ssa.analysis.IExplodedBasicBlock;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
|
||||
/**
|
||||
* @author Juergen Graf <graf@kit.edu>
|
||||
|
@ -139,8 +138,7 @@ class NullPointerTransferFunctionProvider<T extends ISSABasicBlock> implements I
|
|||
@Override
|
||||
public UnaryOperator<NullPointerState> getNodeTransferFunction(final T node) {
|
||||
final ArrayList<UnaryOperator<NullPointerState>> phiTransferFunctions = new ArrayList<>(1);
|
||||
for (final Iterator<SSAPhiInstruction> phiIterator = node.iteratePhis(); phiIterator.hasNext(); ) {
|
||||
final SSAPhiInstruction phi = phiIterator.next();
|
||||
for (SSAPhiInstruction phi : Iterator2Iterable.make(node.iteratePhis())) {
|
||||
int[] uses = new int[phi.getNumberOfUses()];
|
||||
for (int i = 0; i < uses.length; i++) {
|
||||
uses[i] = phi.getUse(i);
|
||||
|
|
|
@ -125,8 +125,7 @@ public class ClassLoaderImpl implements IClassLoader {
|
|||
System.err.println("Get source files for " + M);
|
||||
}
|
||||
HashSet<ModuleEntry> result = HashSetFactory.make();
|
||||
for (Iterator<? extends ModuleEntry> it = M.getEntries(); it.hasNext();) {
|
||||
ModuleEntry entry = it.next();
|
||||
for (ModuleEntry entry : Iterator2Iterable.make(M.getEntries())) {
|
||||
if (DEBUG_LEVEL > 0) {
|
||||
System.err.println("consider entry for source information: " + entry);
|
||||
}
|
||||
|
@ -155,8 +154,7 @@ public class ClassLoaderImpl implements IClassLoader {
|
|||
System.err.println("Get class files for " + M);
|
||||
}
|
||||
HashSet<ModuleEntry> result = HashSetFactory.make();
|
||||
for (Iterator<? extends ModuleEntry> it = M.getEntries(); it.hasNext();) {
|
||||
ModuleEntry entry = it.next();
|
||||
for (ModuleEntry entry : Iterator2Iterable.make(M.getEntries())) {
|
||||
if (DEBUG_LEVEL > 0) {
|
||||
System.err.println("ClassLoaderImpl.getClassFiles:Got entry: " + entry);
|
||||
}
|
||||
|
@ -649,8 +647,7 @@ public class ClassLoaderImpl implements IClassLoader {
|
|||
@Override
|
||||
public int getNumberOfMethods() {
|
||||
int result = 0;
|
||||
for (Iterator<IClass> it = iterateAllClasses(); it.hasNext();) {
|
||||
IClass klass = it.next();
|
||||
for (IClass klass : Iterator2Iterable.make(iterateAllClasses())) {
|
||||
result += klass.getDeclaredMethods().size();
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -31,6 +31,7 @@ import com.ibm.wala.ssa.SSAPutInstruction;
|
|||
import com.ibm.wala.types.FieldReference;
|
||||
import com.ibm.wala.types.TypeReference;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
|
||||
/**
|
||||
* Simple utilities to scan {@link IMethod}s to gather information without building an IR.
|
||||
|
@ -182,8 +183,7 @@ public class CodeScanner {
|
|||
}
|
||||
|
||||
private static boolean hasShrikeBTObjectArrayStore(ShrikeCTMethod M) throws InvalidClassFileException {
|
||||
for (Iterator<TypeReference> it = M.getArraysWritten(); it.hasNext();) {
|
||||
TypeReference t = it.next();
|
||||
for (TypeReference t : Iterator2Iterable.make(M.getArraysWritten())) {
|
||||
if (t.isReferenceType()) {
|
||||
return true;
|
||||
}
|
||||
|
@ -207,8 +207,8 @@ public class CodeScanner {
|
|||
private static List<FieldReference> getFieldsReadFromShrikeBT(ShrikeCTMethod M) throws InvalidClassFileException {
|
||||
// TODO move the logic here from ShrikeCTMethodWrapper
|
||||
LinkedList<FieldReference> result = new LinkedList<>();
|
||||
for (Iterator<FieldReference> it = M.getFieldsRead(); it.hasNext();) {
|
||||
result.add(it.next());
|
||||
for (FieldReference fr : Iterator2Iterable.make(M.getFieldsRead())) {
|
||||
result.add(fr);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -216,8 +216,8 @@ public class CodeScanner {
|
|||
private static List<FieldReference> getFieldsWrittenFromShrikeBT(ShrikeCTMethod M) throws InvalidClassFileException {
|
||||
// TODO move the logic here from ShrikeCTMethodWrapper
|
||||
LinkedList<FieldReference> result = new LinkedList<>();
|
||||
for (Iterator<FieldReference> it = M.getFieldsWritten(); it.hasNext();) {
|
||||
result.add(it.next());
|
||||
for (FieldReference fr : Iterator2Iterable.make(M.getFieldsWritten())) {
|
||||
result.add(fr);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -225,16 +225,15 @@ public class CodeScanner {
|
|||
private static List<TypeReference> getArraysWrittenFromShrikeBT(ShrikeCTMethod M) throws InvalidClassFileException {
|
||||
// TODO move the logic here from ShrikeCTMethodWrapper
|
||||
List<TypeReference> result = new LinkedList<>();
|
||||
for (Iterator<TypeReference> it = M.getArraysWritten(); it.hasNext();) {
|
||||
result.add(it.next());
|
||||
for (TypeReference tr : Iterator2Iterable.make(M.getArraysWritten())) {
|
||||
result.add(tr);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static boolean hasShrikeBTObjectArrayLoad(ShrikeCTMethod M) throws InvalidClassFileException {
|
||||
for (Iterator<TypeReference> it = M.getArraysRead(); it.hasNext();) {
|
||||
TypeReference t = it.next();
|
||||
if (t.isReferenceType()) {
|
||||
for (TypeReference tr : Iterator2Iterable.make(M.getArraysRead())) {
|
||||
if (tr.isReferenceType()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,10 +11,9 @@
|
|||
package com.ibm.wala.dataflow.IFDS;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.ibm.wala.util.MonitorUtil.IProgressMonitor;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.collections.Pair;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
import com.ibm.wala.util.intset.IntIterator;
|
||||
|
@ -46,8 +45,7 @@ public class PartiallyBalancedTabulationSolver<T, P, F> extends TabulationSolver
|
|||
if (result && wasUsedAsUnbalancedSeed(s_p, i) && supergraph.isExit(n)) {
|
||||
// j was reached from an entry seed. if there are any facts which are reachable from j, even without
|
||||
// balanced parentheses, we can use these as new seeds.
|
||||
for (Iterator<? extends T> it2 = supergraph.getSuccNodes(n); it2.hasNext();) {
|
||||
T retSite = it2.next();
|
||||
for (T retSite : Iterator2Iterable.make(supergraph.getSuccNodes(n))) {
|
||||
PartiallyBalancedTabulationProblem<T, P, F> problem = (PartiallyBalancedTabulationProblem<T, P, F>) getProblem();
|
||||
IFlowFunction f = problem.getFunctionMap().getUnbalancedReturnFlowFunction(n, retSite);
|
||||
// for each fact that can be reached by the return flow ...
|
||||
|
|
|
@ -14,7 +14,6 @@ import java.util.Arrays;
|
|||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
@ -30,6 +29,7 @@ import com.ibm.wala.util.collections.HashMapFactory;
|
|||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Heap;
|
||||
import com.ibm.wala.util.collections.Iterator2Collection;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.collections.MapUtil;
|
||||
import com.ibm.wala.util.collections.ToStringComparator;
|
||||
import com.ibm.wala.util.heapTrace.HeapTracer;
|
||||
|
@ -332,8 +332,7 @@ public class TabulationSolver<T, P, F> {
|
|||
if (DEBUG_LEVEL > 0) {
|
||||
System.err.println("process normal: " + edge);
|
||||
}
|
||||
for (Iterator<? extends T> it = supergraph.getSuccNodes(edge.target); it.hasNext();) {
|
||||
final T m = it.next();
|
||||
for (T m : Iterator2Iterable.make(supergraph.getSuccNodes(edge.target))) {
|
||||
if (DEBUG_LEVEL > 0) {
|
||||
System.err.println("normal successor: " + m);
|
||||
}
|
||||
|
@ -409,8 +408,7 @@ public class TabulationSolver<T, P, F> {
|
|||
// note that we might have different summary edges for each
|
||||
// potential return site, and different flow functions from this
|
||||
// exit block to each return site.
|
||||
for (Iterator<? extends T> retSites = supergraph.getReturnSites(c, supergraph.getProcOf(edge.target)); retSites.hasNext();) {
|
||||
final T retSite = retSites.next();
|
||||
for (T retSite : Iterator2Iterable.make(supergraph.getReturnSites(c, supergraph.getProcOf(edge.target)))) {
|
||||
if (DEBUG_LEVEL > 1) {
|
||||
System.err.println("candidate return site: " + retSite + " " + supergraph.getNumber(retSite));
|
||||
}
|
||||
|
@ -537,20 +535,18 @@ public class TabulationSolver<T, P, F> {
|
|||
|
||||
Collection<T> allReturnSites = HashSetFactory.make();
|
||||
// populate allReturnSites with return sites for missing calls.
|
||||
for (Iterator<? extends T> it = supergraph.getReturnSites(edge.target, null); it.hasNext();) {
|
||||
allReturnSites.add(it.next());
|
||||
for (T retSite : Iterator2Iterable.make(supergraph.getReturnSites(edge.target, null))) {
|
||||
allReturnSites.add(retSite);
|
||||
}
|
||||
// [14 - 16]
|
||||
boolean hasCallee = false;
|
||||
for (Iterator<? extends T> it = supergraph.getCalledNodes(edge.target); it.hasNext();) {
|
||||
for (T callee : Iterator2Iterable.make(supergraph.getCalledNodes(edge.target))) {
|
||||
hasCallee = true;
|
||||
final T callee = it.next();
|
||||
processParticularCallee(edge, c, allReturnSites, callee);
|
||||
}
|
||||
// special logic: in backwards problems, a "call" node can have
|
||||
// "normal" successors as well. deal with these.
|
||||
for (Iterator<? extends T> it = supergraph.getNormalSuccessors(edge.target); it.hasNext();) {
|
||||
final T m = it.next();
|
||||
for (T m : Iterator2Iterable.make(supergraph.getNormalSuccessors(edge.target))) {
|
||||
if (DEBUG_LEVEL > 0) {
|
||||
System.err.println("normal successor: " + m);
|
||||
}
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
|
||||
package com.ibm.wala.dataflow.ssa;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.ibm.wala.analysis.typeInference.TypeInference;
|
||||
import com.ibm.wala.fixedpoint.impl.DefaultFixedPointSolver;
|
||||
import com.ibm.wala.fixedpoint.impl.NullaryOperator;
|
||||
|
@ -21,6 +19,7 @@ import com.ibm.wala.fixpoint.IVariable;
|
|||
import com.ibm.wala.ssa.IR;
|
||||
import com.ibm.wala.ssa.SSAInstruction;
|
||||
import com.ibm.wala.ssa.SymbolTable;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
|
||||
/**
|
||||
* This class performs intra-procedural propagation over an SSA form.
|
||||
|
@ -85,16 +84,13 @@ public abstract class SSAInference<T extends IVariable<T>> extends DefaultFixedP
|
|||
for (SSAInstruction s : instructions) {
|
||||
makeEquationForInstruction(opFactory, s);
|
||||
}
|
||||
for (Iterator<? extends SSAInstruction> it = ir.iteratePhis(); it.hasNext();) {
|
||||
SSAInstruction s = it.next();
|
||||
for (SSAInstruction s : Iterator2Iterable.make(ir.iteratePhis())) {
|
||||
makeEquationForInstruction(opFactory, s);
|
||||
}
|
||||
for (Iterator<? extends SSAInstruction> it = ir.iteratePis(); it.hasNext();) {
|
||||
SSAInstruction s = it.next();
|
||||
for (SSAInstruction s : Iterator2Iterable.make(ir.iteratePis())) {
|
||||
makeEquationForInstruction(opFactory, s);
|
||||
}
|
||||
for (Iterator<? extends SSAInstruction> it = ir.iterateCatchInstructions(); it.hasNext();) {
|
||||
SSAInstruction s = it.next();
|
||||
for (SSAInstruction s : Iterator2Iterable.make(ir.iterateCatchInstructions())) {
|
||||
makeEquationForInstruction(opFactory, s);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -178,10 +178,8 @@ public class DemandRefinementPointsTo extends AbstractDemandPointsTo {
|
|||
private void sanityCheckCG() {
|
||||
if (PARANOID) {
|
||||
for (CGNode callee : cg) {
|
||||
for (Iterator<? extends CGNode> predNodes = cg.getPredNodes(callee); predNodes.hasNext();) {
|
||||
CGNode caller = predNodes.next();
|
||||
for (Iterator<CallSiteReference> iterator = cg.getPossibleSites(caller, callee); iterator.hasNext();) {
|
||||
CallSiteReference site = iterator.next();
|
||||
for (CGNode caller : Iterator2Iterable.make(cg.getPredNodes(callee))) {
|
||||
for (CallSiteReference site : Iterator2Iterable.make(cg.getPossibleSites(caller, callee))) {
|
||||
try {
|
||||
caller.getIR().getCalls(site);
|
||||
} catch (IllegalArgumentException e) {
|
||||
|
@ -1132,8 +1130,7 @@ public class DemandRefinementPointsTo extends AbstractDemandPointsTo {
|
|||
repropCallArg(exc, new PointerKeyAndState(excRet, excRetState), returnLabel.bar());
|
||||
return null;
|
||||
});
|
||||
for (Iterator<Integer> iter = new PointerParamValueNumIterator(targetForCall); iter.hasNext();) {
|
||||
final int formalNum = iter.next();
|
||||
for (int formalNum : Iterator2Iterable.make(new PointerParamValueNumIterator(targetForCall))) {
|
||||
final int actualNum = formalNum - 1;
|
||||
final ParamBarLabel paramBarLabel = ParamBarLabel.make(new CallerSiteContext(caller, call));
|
||||
doTransition(receiverState, paramBarLabel, formalState -> {
|
||||
|
@ -1390,8 +1387,8 @@ public class DemandRefinementPointsTo extends AbstractDemandPointsTo {
|
|||
}
|
||||
|
||||
private void addPredsOfIKeyAndStateToTrackedPointsTo(InstanceKeyAndState ikAndState) throws UnimplementedError {
|
||||
for (Iterator<? extends Object> iter = g.getPredNodes(ikAndState.getInstanceKey(), NewLabel.v()); iter.hasNext();) {
|
||||
PointerKey ikPred = (PointerKey) iter.next();
|
||||
for (Object o : Iterator2Iterable.make(g.getPredNodes(ikAndState.getInstanceKey(), NewLabel.v()))) {
|
||||
PointerKey ikPred = (PointerKey) o;
|
||||
PointerKeyAndState ikPredAndState = new PointerKeyAndState(ikPred, ikAndState.getState());
|
||||
int mappedIndex = ikAndStates.getMappedIndex(ikAndState);
|
||||
assert mappedIndex != -1;
|
||||
|
@ -1614,8 +1611,7 @@ public class DemandRefinementPointsTo extends AbstractDemandPointsTo {
|
|||
LocalPointerKey localPk = (LocalPointerKey) curPk;
|
||||
CGNode caller = localPk.getNode();
|
||||
// from actual parameter to callee
|
||||
for (Iterator<SSAAbstractInvokeInstruction> iter = g.getInstrsPassingParam(localPk); iter.hasNext();) {
|
||||
SSAAbstractInvokeInstruction callInstr = iter.next();
|
||||
for (SSAAbstractInvokeInstruction callInstr : Iterator2Iterable.make(g.getInstrsPassingParam(localPk))) {
|
||||
for (int i = 0; i < callInstr.getNumberOfUses(); i++) {
|
||||
if (localPk.getValueNumber() != callInstr.getUse(i))
|
||||
continue;
|
||||
|
@ -1718,8 +1714,8 @@ public class DemandRefinementPointsTo extends AbstractDemandPointsTo {
|
|||
|
||||
@Override
|
||||
public void visitAssignGlobal(final AssignGlobalLabel label, Object dst) {
|
||||
for (Iterator<? extends Object> readIter = g.getReadsOfStaticField((StaticFieldKey) dst); readIter.hasNext();) {
|
||||
final PointerKey predPk = (PointerKey) readIter.next();
|
||||
for (Object o : Iterator2Iterable.make(g.getReadsOfStaticField((StaticFieldKey) dst))) {
|
||||
final PointerKey predPk = (PointerKey) o;
|
||||
doTransition(curState, AssignGlobalBarLabel.v(), predPkState -> {
|
||||
PointerKeyAndState predPkAndState = new PointerKeyAndState(predPk, predPkState);
|
||||
handleTrackedPred(trackedSet, predPkAndState, AssignGlobalBarLabel.v());
|
||||
|
@ -1745,8 +1741,7 @@ public class DemandRefinementPointsTo extends AbstractDemandPointsTo {
|
|||
}
|
||||
} else {
|
||||
// send to all getfield sources
|
||||
for (Iterator<PointerKey> readIter = g.getReadsOfInstanceField(storeBase, field); readIter.hasNext();) {
|
||||
final PointerKey predPk = readIter.next();
|
||||
for (final PointerKey predPk : Iterator2Iterable.make(g.getReadsOfInstanceField(storeBase, field))) {
|
||||
doTransition(curState, MatchBarLabel.v(), predPkState -> {
|
||||
PointerKeyAndState predPkAndState = new PointerKeyAndState(predPk, predPkState);
|
||||
handleTrackedPred(trackedSet, predPkAndState, MatchBarLabel.v());
|
||||
|
@ -2263,9 +2258,7 @@ public class DemandRefinementPointsTo extends AbstractDemandPointsTo {
|
|||
}
|
||||
}
|
||||
} else { // use match edges
|
||||
for (Iterator<PointerKey> writesToInstanceField = g.getWritesToInstanceField(loadBase, field); writesToInstanceField
|
||||
.hasNext();) {
|
||||
final PointerKey writtenPk = writesToInstanceField.next();
|
||||
for (final PointerKey writtenPk : Iterator2Iterable.make(g.getWritesToInstanceField(loadBase, field))) {
|
||||
doTransition(curState, MatchLabel.v(), nextState -> {
|
||||
h.propagate(new PointerKeyAndState(writtenPk, nextState));
|
||||
return null;
|
||||
|
@ -2316,9 +2309,8 @@ public class DemandRefinementPointsTo extends AbstractDemandPointsTo {
|
|||
|
||||
@Override
|
||||
public void visitAssignGlobal(AssignGlobalLabel label, Object dst) {
|
||||
for (Iterator<? extends Object> writesToStaticField = g.getWritesToStaticField((StaticFieldKey) dst); writesToStaticField
|
||||
.hasNext();) {
|
||||
final PointerKey writtenPk = (PointerKey) writesToStaticField.next();
|
||||
for (Object writeToStaticField : Iterator2Iterable.make(g.getWritesToStaticField((StaticFieldKey) dst))) {
|
||||
final PointerKey writtenPk = (PointerKey) writeToStaticField;
|
||||
doTransition(curState, label, nextState -> {
|
||||
h.propagate(new PointerKeyAndState(writtenPk, nextState));
|
||||
return null;
|
||||
|
|
|
@ -64,6 +64,7 @@ import com.ibm.wala.ssa.SSAPhiInstruction;
|
|||
import com.ibm.wala.util.collections.EmptyIterator;
|
||||
import com.ibm.wala.util.collections.HashMapFactory;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.intset.BitVectorIntSet;
|
||||
import com.ibm.wala.util.ref.ReferenceCleanser;
|
||||
|
||||
|
@ -130,8 +131,7 @@ public abstract class AbstractDemandFlowGraph extends AbstractFlowGraph {
|
|||
// as the argument
|
||||
addSubgraphForNode(caller);
|
||||
IR ir = caller.getIR();
|
||||
for (Iterator<CallSiteReference> iterator = ir.iterateCallSites(); iterator.hasNext();) {
|
||||
CallSiteReference call = iterator.next();
|
||||
for (CallSiteReference call : Iterator2Iterable.make(ir.iterateCallSites())) {
|
||||
if (cg.getPossibleTargets(caller, call).contains(cgNode)) {
|
||||
SSAAbstractInvokeInstruction[] callInstrs = ir.getCalls(call);
|
||||
for (SSAAbstractInvokeInstruction callInstr : callInstrs) {
|
||||
|
@ -219,8 +219,7 @@ public abstract class AbstractDemandFlowGraph extends AbstractFlowGraph {
|
|||
// as the argument
|
||||
addSubgraphForNode(caller);
|
||||
IR ir = caller.getIR();
|
||||
for (Iterator<CallSiteReference> iterator = ir.iterateCallSites(); iterator.hasNext();) {
|
||||
CallSiteReference call = iterator.next();
|
||||
for (CallSiteReference call : Iterator2Iterable.make(ir.iterateCallSites())) {
|
||||
if (cg.getPossibleTargets(caller, call).contains(cgNode)) {
|
||||
SSAAbstractInvokeInstruction[] callInstrs = ir.getCalls(call);
|
||||
for (SSAAbstractInvokeInstruction callInstr : callInstrs) {
|
||||
|
@ -294,8 +293,8 @@ public abstract class AbstractDemandFlowGraph extends AbstractFlowGraph {
|
|||
private void addPhiConstraints(CGNode node, ControlFlowGraph<SSAInstruction, ISSABasicBlock> cfg, ISSABasicBlock b) {
|
||||
|
||||
// visit each phi instruction in each successor block
|
||||
for (Iterator<? extends IBasicBlock> iter = cfg.getSuccNodes(b); iter.hasNext();) {
|
||||
ISSABasicBlock sb = (ISSABasicBlock) iter.next();
|
||||
for (IBasicBlock ibb : Iterator2Iterable.make(cfg.getSuccNodes(b))) {
|
||||
ISSABasicBlock sb = (ISSABasicBlock) ibb;
|
||||
if (sb.isExitBlock()) {
|
||||
// an optimization based on invariant that exit blocks should
|
||||
// have no
|
||||
|
@ -304,15 +303,15 @@ public abstract class AbstractDemandFlowGraph extends AbstractFlowGraph {
|
|||
}
|
||||
int n = 0;
|
||||
// set n to be whichPred(this, sb);
|
||||
for (Iterator<? extends IBasicBlock> back = cfg.getPredNodes(sb); back.hasNext(); n++) {
|
||||
if (back.next() == b) {
|
||||
for (IBasicBlock back : Iterator2Iterable.make(cfg.getPredNodes(sb))) {
|
||||
if (back == b) {
|
||||
break;
|
||||
}
|
||||
++n;
|
||||
}
|
||||
assert n < cfg.getPredNodeCount(sb);
|
||||
for (Iterator<SSAPhiInstruction> phis = sb.iteratePhis(); phis.hasNext();) {
|
||||
for (SSAPhiInstruction phi : Iterator2Iterable.make(sb.iteratePhis())) {
|
||||
// Assertions.UNREACHABLE();
|
||||
SSAPhiInstruction phi = phis.next();
|
||||
if (phi == null) {
|
||||
continue;
|
||||
}
|
||||
|
@ -361,10 +360,8 @@ public abstract class AbstractDemandFlowGraph extends AbstractFlowGraph {
|
|||
Set<CallerSiteContext> ret = callerCache.get(callee);
|
||||
if (ret == null) {
|
||||
ret = HashSetFactory.make();
|
||||
for (Iterator<? extends CGNode> predNodes = cg.getPredNodes(callee); predNodes.hasNext();) {
|
||||
CGNode caller = predNodes.next();
|
||||
for (Iterator<CallSiteReference> iterator = cg.getPossibleSites(caller, callee); iterator.hasNext();) {
|
||||
CallSiteReference call = iterator.next();
|
||||
for (CGNode caller : Iterator2Iterable.make(cg.getPredNodes(callee))) {
|
||||
for (CallSiteReference call : Iterator2Iterable.make(cg.getPossibleSites(caller, callee))) {
|
||||
ret.add(new CallerSiteContext(caller, call));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,6 +82,7 @@ import com.ibm.wala.ssa.SymbolTable;
|
|||
import com.ibm.wala.types.TypeReference;
|
||||
import com.ibm.wala.util.collections.EmptyIterator;
|
||||
import com.ibm.wala.util.collections.HashMapFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.collections.MapUtil;
|
||||
import com.ibm.wala.util.collections.Pair;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
|
@ -159,10 +160,9 @@ public abstract class AbstractFlowGraph extends SlowSparseNumberedLabeledGraph<O
|
|||
*/
|
||||
@Override
|
||||
public void visitSuccs(Object node, IFlowLabelVisitor v) {
|
||||
for (Iterator<? extends IFlowLabel> succLabelIter = getSuccLabels(node); succLabelIter.hasNext();) {
|
||||
final IFlowLabel label = succLabelIter.next();
|
||||
for (Iterator<? extends Object> succNodeIter = getSuccNodes(node, label); succNodeIter.hasNext();) {
|
||||
label.visit(v, succNodeIter.next());
|
||||
for (final IFlowLabel label : Iterator2Iterable.make(getSuccLabels(node))) {
|
||||
for (Object succNode : Iterator2Iterable.make(getSuccNodes(node, label))) {
|
||||
label.visit(v, succNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -173,10 +173,9 @@ public abstract class AbstractFlowGraph extends SlowSparseNumberedLabeledGraph<O
|
|||
*/
|
||||
@Override
|
||||
public void visitPreds(Object node, IFlowLabelVisitor v) {
|
||||
for (Iterator<? extends IFlowLabel> predLabelIter = getPredLabels(node); predLabelIter.hasNext();) {
|
||||
final IFlowLabel label = predLabelIter.next();
|
||||
for (Iterator<? extends Object> predNodeIter = getPredNodes(node, label); predNodeIter.hasNext();) {
|
||||
label.visit(v, predNodeIter.next());
|
||||
for (final IFlowLabel label : Iterator2Iterable.make(getPredLabels(node))) {
|
||||
for (Object predNode : Iterator2Iterable.make(getPredNodes(node, label))) {
|
||||
label.visit(v, predNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -187,8 +186,7 @@ public abstract class AbstractFlowGraph extends SlowSparseNumberedLabeledGraph<O
|
|||
* @param node
|
||||
*/
|
||||
protected void addNodesForInvocations(CGNode node, IR ir) {
|
||||
for (Iterator<CallSiteReference> iter = ir.iterateCallSites(); iter.hasNext();) {
|
||||
CallSiteReference site = iter.next();
|
||||
for (CallSiteReference site : Iterator2Iterable.make(ir.iterateCallSites())) {
|
||||
SSAAbstractInvokeInstruction[] calls = ir.getCalls(site);
|
||||
for (SSAAbstractInvokeInstruction invokeInstr : calls) {
|
||||
for (int i = 0; i < invokeInstr.getNumberOfUses(); i++) {
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
package com.ibm.wala.demandpa.flowgraph;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -81,6 +80,7 @@ import com.ibm.wala.ssa.SymbolTable;
|
|||
import com.ibm.wala.types.FieldReference;
|
||||
import com.ibm.wala.types.TypeReference;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.collections.Pair;
|
||||
|
||||
/**
|
||||
|
@ -98,8 +98,7 @@ public class DemandPointerFlowGraph extends AbstractDemandFlowGraph implements I
|
|||
*/
|
||||
@Override
|
||||
protected void addNodesForParameters(CGNode node, IR ir) {
|
||||
for (Iterator<Integer> iter = new PointerParamValueNumIterator(node); iter.hasNext();) {
|
||||
int parameter = iter.next();
|
||||
for (int parameter : Iterator2Iterable.make(new PointerParamValueNumIterator(node))) {
|
||||
PointerKey paramPk = heapModel.getPointerKeyForLocal(node, parameter);
|
||||
addNode(paramPk);
|
||||
params.put(paramPk, node);
|
||||
|
|
|
@ -65,6 +65,7 @@ import com.ibm.wala.types.FieldReference;
|
|||
import com.ibm.wala.types.TypeReference;
|
||||
import com.ibm.wala.util.collections.HashMapFactory;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
import com.ibm.wala.util.debug.UnimplementedError;
|
||||
import com.ibm.wala.util.graph.impl.SlowSparseNumberedGraph;
|
||||
|
@ -301,8 +302,7 @@ public class SimpleDemandPointerFlowGraph extends SlowSparseNumberedGraph<Object
|
|||
// as the argument
|
||||
addSubgraphForNode(caller);
|
||||
IR ir = caller.getIR();
|
||||
for (Iterator<CallSiteReference> iterator = ir.iterateCallSites(); iterator.hasNext();) {
|
||||
CallSiteReference call = iterator.next();
|
||||
for (CallSiteReference call : Iterator2Iterable.make(ir.iterateCallSites())) {
|
||||
if (cg.getPossibleTargets(caller, call).contains(node)) {
|
||||
SSAAbstractInvokeInstruction[] callInstrs = ir.getCalls(call);
|
||||
for (SSAAbstractInvokeInstruction callInstr : callInstrs) {
|
||||
|
@ -494,8 +494,7 @@ public class SimpleDemandPointerFlowGraph extends SlowSparseNumberedGraph<Object
|
|||
private void addPhiConstraints(CGNode node, ControlFlowGraph<SSAInstruction, ISSABasicBlock> cfg, ISSABasicBlock b) {
|
||||
|
||||
// visit each phi instruction in each successor block
|
||||
for (Iterator<? extends IBasicBlock> sbs = cfg.getSuccNodes(b); sbs.hasNext();) {
|
||||
ISSABasicBlock sb = (ISSABasicBlock) sbs.next();
|
||||
for (ISSABasicBlock sb : Iterator2Iterable.make(cfg.getSuccNodes(b))) {
|
||||
if (sb.isExitBlock()) {
|
||||
// an optimization based on invariant that exit blocks should have no
|
||||
// phis.
|
||||
|
@ -503,14 +502,14 @@ public class SimpleDemandPointerFlowGraph extends SlowSparseNumberedGraph<Object
|
|||
}
|
||||
int n = 0;
|
||||
// set n to be whichPred(this, sb);
|
||||
for (Iterator<? extends IBasicBlock> back = cfg.getPredNodes(sb); back.hasNext(); n++) {
|
||||
if (back.next() == b) {
|
||||
for (IBasicBlock back : Iterator2Iterable.make(cfg.getPredNodes(sb))) {
|
||||
if (back == b) {
|
||||
break;
|
||||
}
|
||||
++n;
|
||||
}
|
||||
assert n < cfg.getPredNodeCount(sb);
|
||||
for (Iterator<SSAPhiInstruction> phis = sb.iteratePhis(); phis.hasNext();) {
|
||||
SSAPhiInstruction phi = phis.next();
|
||||
for (SSAPhiInstruction phi : Iterator2Iterable.make(sb.iteratePhis())) {
|
||||
if (phi == null) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
package com.ibm.wala.escape;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -29,6 +28,7 @@ import com.ibm.wala.ssa.IR;
|
|||
import com.ibm.wala.util.WalaException;
|
||||
import com.ibm.wala.util.collections.HashMapFactory;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
import com.ibm.wala.util.graph.impl.GraphInverter;
|
||||
import com.ibm.wala.util.graph.traverse.DFS;
|
||||
|
@ -125,8 +125,7 @@ public class FILiveObjectAnalysis implements ILiveObjectAnalysis {
|
|||
}
|
||||
|
||||
private boolean mayBeLiveInSomeCaller(InstanceKey ik, CGNode m) {
|
||||
for (Iterator<CGNode> it = callGraph.getPredNodes(m); it.hasNext();) {
|
||||
CGNode n = it.next();
|
||||
for (CGNode n : Iterator2Iterable.make(callGraph.getPredNodes(m))) {
|
||||
if (mayBeLive(ik, n, -1)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -144,8 +143,7 @@ public class FILiveObjectAnalysis implements ILiveObjectAnalysis {
|
|||
IR ir = m.getIR();
|
||||
DefUse du = m.getDU();
|
||||
|
||||
for (Iterator<Object> it = DFS.iterateDiscoverTime(GraphInverter.invert(heapGraph), ik); it.hasNext();) {
|
||||
Object p = it.next();
|
||||
for (Object p : Iterator2Iterable.make(DFS.iterateDiscoverTime(GraphInverter.invert(heapGraph), ik))) {
|
||||
if (p instanceof LocalPointerKey) {
|
||||
LocalPointerKey lpk = (LocalPointerKey) p;
|
||||
if (lpk.getNode().equals(m)) {
|
||||
|
@ -164,8 +162,7 @@ public class FILiveObjectAnalysis implements ILiveObjectAnalysis {
|
|||
*/
|
||||
private Set<CGNode> computeLiveNodes(InstanceKey ik) {
|
||||
Set<CGNode> localRootNodes = HashSetFactory.make();
|
||||
for (Iterator<Object> it = DFS.iterateDiscoverTime(GraphInverter.invert(heapGraph), ik); it.hasNext();) {
|
||||
Object node = it.next();
|
||||
for (Object node : Iterator2Iterable.make(DFS.iterateDiscoverTime(GraphInverter.invert(heapGraph), ik))) {
|
||||
if (node instanceof StaticFieldKey) {
|
||||
liveEverywhere.add(ik);
|
||||
return Collections.emptySet();
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
package com.ibm.wala.escape;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import com.ibm.wala.analysis.pointers.HeapGraph;
|
||||
|
@ -25,6 +24,7 @@ import com.ibm.wala.ipa.callgraph.propagation.ReturnValueKey;
|
|||
import com.ibm.wala.types.MethodReference;
|
||||
import com.ibm.wala.util.WalaException;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
|
||||
/**
|
||||
* Trivial method-level escape analysis.
|
||||
|
@ -102,8 +102,8 @@ public class TrivialMethodEscape implements IMethodEscapeAnalysis, INodeEscapeAn
|
|||
}
|
||||
|
||||
for (InstanceKey ik : instances) {
|
||||
for (Iterator<Object> it2 = hg.getPredNodes(ik); it2.hasNext();) {
|
||||
PointerKey p = (PointerKey) it2.next();
|
||||
for (Object o : Iterator2Iterable.make(hg.getPredNodes(ik))) {
|
||||
PointerKey p = (PointerKey) o;
|
||||
if (!(p instanceof AbstractLocalPointerKey)) {
|
||||
// a pointer from the heap. give up.
|
||||
return true;
|
||||
|
@ -134,8 +134,7 @@ public class TrivialMethodEscape implements IMethodEscapeAnalysis, INodeEscapeAn
|
|||
if (n == null) {
|
||||
throw new IllegalArgumentException("null n");
|
||||
}
|
||||
for (Iterator<NewSiteReference> it = n.iterateNewSites(); it.hasNext();) {
|
||||
NewSiteReference site = it.next();
|
||||
for (NewSiteReference site : Iterator2Iterable.make(n.iterateNewSites())) {
|
||||
if (site.getProgramCounter() == allocPC) {
|
||||
return site;
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ import com.ibm.wala.util.collections.FilterIterator;
|
|||
import com.ibm.wala.util.collections.HashMapFactory;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Collection;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.collections.IteratorUtil;
|
||||
import com.ibm.wala.util.collections.MapIterator;
|
||||
import com.ibm.wala.util.graph.NumberedEdgeManager;
|
||||
|
@ -242,8 +243,8 @@ public class CHACallGraph extends BasicCallGraph<CHAContextInterpreter> {
|
|||
private void closure() throws CancelException {
|
||||
while (! newNodes.isEmpty()) {
|
||||
CGNode n = newNodes.pop();
|
||||
for(Iterator<CallSiteReference> sites = n.iterateCallSites(); sites.hasNext(); ) {
|
||||
Iterator<IMethod> methods = getPossibleTargets(sites.next());
|
||||
for(CallSiteReference site : Iterator2Iterable.make(n.iterateCallSites())) {
|
||||
Iterator<IMethod> methods = getPossibleTargets(site);
|
||||
while (methods.hasNext()) {
|
||||
IMethod target = methods.next();
|
||||
if (isRelevantMethod(target)) {
|
||||
|
@ -364,8 +365,8 @@ public class CHACallGraph extends BasicCallGraph<CHAContextInterpreter> {
|
|||
@Override
|
||||
public IntSet getSuccNodeNumbers(CGNode node) {
|
||||
MutableIntSet result = IntSetUtil.make();
|
||||
for(Iterator<CGNode> ss = getSuccNodes(node); ss.hasNext(); ) {
|
||||
result.add(ss.next().getGraphNodeId());
|
||||
for(CGNode s : Iterator2Iterable.make(getSuccNodes(node))) {
|
||||
result.add(s.getGraphNodeId());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -373,8 +374,8 @@ public class CHACallGraph extends BasicCallGraph<CHAContextInterpreter> {
|
|||
@Override
|
||||
public IntSet getPredNodeNumbers(CGNode node) {
|
||||
MutableIntSet result = IntSetUtil.make();
|
||||
for(Iterator<CGNode> ss = getPredNodes(node); ss.hasNext(); ) {
|
||||
result.add(ss.next().getGraphNodeId());
|
||||
for(CGNode s : Iterator2Iterable.make(getPredNodes(node))) {
|
||||
result.add(s.getGraphNodeId());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import com.ibm.wala.types.MethodReference;
|
|||
import com.ibm.wala.util.CancelException;
|
||||
import com.ibm.wala.util.collections.HashMapFactory;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.collections.NonNullSingletonIterator;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
import com.ibm.wala.util.debug.UnimplementedError;
|
||||
|
@ -231,8 +232,7 @@ public abstract class BasicCallGraph<T> extends AbstractNumberedGraph<CGNode> im
|
|||
@Override
|
||||
public String toString() {
|
||||
StringBuffer result = new StringBuffer("");
|
||||
for (Iterator<CGNode> i = DFS.iterateDiscoverTime(this, new NonNullSingletonIterator<>(getFakeRootNode())); i.hasNext();) {
|
||||
CGNode n = i.next();
|
||||
for (CGNode n : Iterator2Iterable.make(DFS.iterateDiscoverTime(this, new NonNullSingletonIterator<>(getFakeRootNode())))) {
|
||||
result.append(nodeToString(this, n) + "\n");
|
||||
}
|
||||
return result.toString();
|
||||
|
@ -241,14 +241,12 @@ public abstract class BasicCallGraph<T> extends AbstractNumberedGraph<CGNode> im
|
|||
public static String nodeToString(CallGraph CG, CGNode n) {
|
||||
StringBuffer result = new StringBuffer(n.toString() + "\n");
|
||||
if (n.getMethod() != null) {
|
||||
for (Iterator<CallSiteReference> sites = n.iterateCallSites(); sites.hasNext();) {
|
||||
CallSiteReference site = sites.next();
|
||||
for (CallSiteReference site : Iterator2Iterable.make(n.iterateCallSites())) {
|
||||
Iterator<CGNode> targets = CG.getPossibleTargets(n, site).iterator();
|
||||
if (targets.hasNext()) {
|
||||
result.append(" - " + site + "\n");
|
||||
}
|
||||
for (; targets.hasNext();) {
|
||||
CGNode target = targets.next();
|
||||
for (CGNode target : Iterator2Iterable.make(targets)) {
|
||||
result.append(" -> " + target + "\n");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import com.ibm.wala.ipa.cha.IClassHierarchy;
|
|||
import com.ibm.wala.types.MethodReference;
|
||||
import com.ibm.wala.util.collections.FilterIterator;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.graph.Graph;
|
||||
import com.ibm.wala.util.graph.GraphSlicer;
|
||||
import com.ibm.wala.util.graph.impl.DelegatingGraph;
|
||||
|
@ -135,8 +136,7 @@ public class PartialCallGraph extends DelegatingGraph<CGNode> implements CallGra
|
|||
public IntSet getSuccNodeNumbers(CGNode node) {
|
||||
assert containsNode(node);
|
||||
MutableIntSet x = IntSetUtil.make();
|
||||
for (Iterator<CGNode> ns = getSuccNodes(node); ns.hasNext();) {
|
||||
CGNode succ = ns.next();
|
||||
for (CGNode succ : Iterator2Iterable.make(getSuccNodes(node))) {
|
||||
if (containsNode(succ)) {
|
||||
x.add(getNumber(succ));
|
||||
}
|
||||
|
@ -149,8 +149,7 @@ public class PartialCallGraph extends DelegatingGraph<CGNode> implements CallGra
|
|||
public IntSet getPredNodeNumbers(CGNode node) {
|
||||
assert containsNode(node);
|
||||
MutableIntSet x = IntSetUtil.make();
|
||||
for (Iterator<CGNode> ns = getPredNodes(node); ns.hasNext();) {
|
||||
CGNode pred = ns.next();
|
||||
for (CGNode pred : Iterator2Iterable.make(getPredNodes(node))) {
|
||||
if (containsNode(pred)) {
|
||||
x.add(getNumber(pred));
|
||||
}
|
||||
|
|
|
@ -89,8 +89,7 @@ public class PointerAnalysisImpl extends AbstractPointerAnalysis {
|
|||
@Override
|
||||
public String toString() {
|
||||
StringBuffer result = new StringBuffer("PointerAnalysis:\n");
|
||||
for (Iterator<PointerKey> it = pointsToMap.iterateKeys(); it.hasNext();) {
|
||||
PointerKey p = it.next();
|
||||
for (PointerKey p : Iterator2Iterable.make(pointsToMap.iterateKeys())) {
|
||||
OrdinalSet<InstanceKey> O = getPointsToSet(p);
|
||||
result.append(" ").append(p).append(" ->\n");
|
||||
for (InstanceKey instanceKey : O) {
|
||||
|
|
|
@ -14,6 +14,7 @@ import java.util.Iterator;
|
|||
|
||||
import com.ibm.wala.util.collections.FilterIterator;
|
||||
import com.ibm.wala.util.collections.IVector;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.collections.SimpleVector;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
import com.ibm.wala.util.intset.BitVector;
|
||||
|
@ -187,8 +188,7 @@ public class PointsToMap {
|
|||
* Wipe out the cached transitive closure information
|
||||
*/
|
||||
public void revertToPreTransitive() {
|
||||
for (Iterator<PointerKey> it = iterateKeys(); it.hasNext();) {
|
||||
PointerKey key = it.next();
|
||||
for (PointerKey key : Iterator2Iterable.make(iterateKeys())) {
|
||||
if (!isTransitiveRoot(key) && !isImplicit(key) && !isUnified(key)) {
|
||||
PointsToSetVariable v = getPointsToSet(key);
|
||||
v.removeAll();
|
||||
|
|
|
@ -547,8 +547,7 @@ public class PropagationGraph implements IFixedPointSystem<PointsToSetVariable>
|
|||
public int getPredNodeCount(INodeWithNumber N) {
|
||||
PointsToSetVariable v = (PointsToSetVariable) N;
|
||||
int result = 0;
|
||||
for (Iterator<AbstractStatement> eqs = getStatementsThatDef(v); eqs.hasNext();) {
|
||||
AbstractStatement eq = eqs.next();
|
||||
for (AbstractStatement eq : Iterator2Iterable.make(getStatementsThatDef(v))) {
|
||||
if (useImplicitRepresentation(eq)) {
|
||||
result++;
|
||||
} else {
|
||||
|
@ -604,8 +603,7 @@ public class PropagationGraph implements IFixedPointSystem<PointsToSetVariable>
|
|||
@Override
|
||||
public int getSuccNodeCount(PointsToSetVariable v) {
|
||||
int result = 0;
|
||||
for (Iterator<AbstractStatement> eqs = getStatementsThatUse(v); eqs.hasNext();) {
|
||||
AbstractStatement eq = eqs.next();
|
||||
for (AbstractStatement eq : Iterator2Iterable.make(getStatementsThatUse(v))) {
|
||||
IVariable lhs = eq.getLHS();
|
||||
if (lhs != null) {
|
||||
result++;
|
||||
|
@ -978,8 +976,7 @@ public class PropagationGraph implements IFixedPointSystem<PointsToSetVariable>
|
|||
@Override
|
||||
public int getPredNodeCount(PointsToSetVariable v) {
|
||||
int result = 0;
|
||||
for (Iterator<AbstractStatement> eqs = getStatementsThatDef(v); eqs.hasNext();) {
|
||||
AbstractStatement eq = eqs.next();
|
||||
for (AbstractStatement eq : Iterator2Iterable.make(getStatementsThatDef(v))) {
|
||||
if (isInteresting(eq)) {
|
||||
result++;
|
||||
}
|
||||
|
@ -1035,8 +1032,7 @@ public class PropagationGraph implements IFixedPointSystem<PointsToSetVariable>
|
|||
@Override
|
||||
public int getSuccNodeCount(PointsToSetVariable v) {
|
||||
int result = 0;
|
||||
for (Iterator<AbstractStatement> eqs = getStatementsThatUse(v); eqs.hasNext();) {
|
||||
AbstractStatement eq = eqs.next();
|
||||
for (AbstractStatement eq : Iterator2Iterable.make(getStatementsThatUse(v))) {
|
||||
if (isInteresting(eq)) {
|
||||
result++;
|
||||
}
|
||||
|
@ -1090,12 +1086,7 @@ public class PropagationGraph implements IFixedPointSystem<PointsToSetVariable>
|
|||
}
|
||||
|
||||
private int countImplicitEdges() {
|
||||
int result = 0;
|
||||
for (Iterator<AbstractStatement> it = new GlobalImplicitIterator(); it.hasNext();) {
|
||||
it.next();
|
||||
result++;
|
||||
}
|
||||
return result;
|
||||
return IteratorUtil.count(new GlobalImplicitIterator());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -77,6 +77,7 @@ import com.ibm.wala.util.CancelException;
|
|||
import com.ibm.wala.util.MonitorUtil;
|
||||
import com.ibm.wala.util.MonitorUtil.IProgressMonitor;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
import com.ibm.wala.util.debug.UnimplementedError;
|
||||
import com.ibm.wala.util.intset.IntIterator;
|
||||
|
@ -256,8 +257,8 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
|
|||
ConstraintVisitor v = makeVisitor(node);
|
||||
|
||||
IRView ir = v.ir;
|
||||
for (Iterator<ISSABasicBlock> x = ir.getBlocks(); x.hasNext();) {
|
||||
BasicBlock b = (BasicBlock) x.next();
|
||||
for (ISSABasicBlock sbb : Iterator2Iterable.make(ir.getBlocks())) {
|
||||
BasicBlock b = (BasicBlock) sbb;
|
||||
addBlockInstructionConstraints(node, ir, b, v, monitor);
|
||||
if (wasChanged(node)) {
|
||||
return;
|
||||
|
@ -300,20 +301,21 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
|
|||
private void addPhiConstraints(CGNode node, ControlFlowGraph<SSAInstruction, ISSABasicBlock> controlFlowGraph, BasicBlock b,
|
||||
ConstraintVisitor v) {
|
||||
// visit each phi instruction in each successor block
|
||||
for (Iterator<ISSABasicBlock> sbs = controlFlowGraph.getSuccNodes(b); sbs.hasNext();) {
|
||||
BasicBlock sb = (BasicBlock) sbs.next();
|
||||
for (ISSABasicBlock isb : Iterator2Iterable.make(controlFlowGraph.getSuccNodes(b))) {
|
||||
BasicBlock sb = (BasicBlock) isb;
|
||||
if (!sb.hasPhi()) {
|
||||
continue;
|
||||
}
|
||||
int n = 0;
|
||||
for (Iterator<? extends IBasicBlock> back = controlFlowGraph.getPredNodes(sb); back.hasNext(); n++) {
|
||||
if (back.next() == b) {
|
||||
for (IBasicBlock back : Iterator2Iterable.make(controlFlowGraph.getPredNodes(sb))) {
|
||||
if (back == b) {
|
||||
break;
|
||||
}
|
||||
++n;
|
||||
}
|
||||
assert n < controlFlowGraph.getPredNodeCount(sb);
|
||||
for (Iterator<? extends SSAInstruction> phis = sb.iteratePhis(); phis.hasNext();) {
|
||||
SSAPhiInstruction phi = (SSAPhiInstruction) phis.next();
|
||||
for (SSAInstruction inst : Iterator2Iterable.make(sb.iteratePhis())) {
|
||||
SSAPhiInstruction phi = (SSAPhiInstruction) inst;
|
||||
if (phi == null) {
|
||||
continue;
|
||||
}
|
||||
|
@ -484,8 +486,8 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
|
|||
}
|
||||
ControlFlowGraph<SSAInstruction, ISSABasicBlock> g = ir.getControlFlowGraph();
|
||||
List<ProgramCounter> result = new ArrayList<>(g.getPredNodeCount(bb));
|
||||
for (Iterator<ISSABasicBlock> it = g.getPredNodes(bb); it.hasNext();) {
|
||||
BasicBlock pred = (BasicBlock) it.next();
|
||||
for (ISSABasicBlock sbb : Iterator2Iterable.make(g.getPredNodes(bb))) {
|
||||
BasicBlock pred = (BasicBlock) sbb;
|
||||
if (DEBUG) {
|
||||
System.err.println("pred: " + pred);
|
||||
}
|
||||
|
@ -2039,8 +2041,7 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
|
|||
// todo: enhance this by solving a dead-code elimination
|
||||
// problem.
|
||||
InterestingVisitor v = makeInterestingVisitor(node, vn);
|
||||
for (Iterator<SSAInstruction> it = du.getUses(v.vn); it.hasNext();) {
|
||||
SSAInstruction s = it.next();
|
||||
for (SSAInstruction s : Iterator2Iterable.make(du.getUses(v.vn))) {
|
||||
s.visit(v);
|
||||
if (v.bingo) {
|
||||
return false;
|
||||
|
@ -2397,8 +2398,8 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
|
|||
Iterator<TypeReference> exceptionTypes = ((ExceptionHandlerBasicBlock) ir.getControlFlowGraph().getNode(
|
||||
instruction.getBasicBlockNumber())).getCaughtExceptionTypes();
|
||||
HashSet<IClass> types = HashSetFactory.make(10);
|
||||
for (; exceptionTypes.hasNext();) {
|
||||
IClass c = ir.getMethod().getClassHierarchy().lookupClass(exceptionTypes.next());
|
||||
for (TypeReference tr : Iterator2Iterable.make(exceptionTypes)) {
|
||||
IClass c = ir.getMethod().getClassHierarchy().lookupClass(tr);
|
||||
if (c != null) {
|
||||
types.add(c);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ package com.ibm.wala.ipa.callgraph.propagation.cfa;
|
|||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -35,6 +34,7 @@ import com.ibm.wala.types.TypeName;
|
|||
import com.ibm.wala.types.TypeReference;
|
||||
import com.ibm.wala.util.collections.HashMapFactory;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
|
||||
/**
|
||||
* Flexible class to create {@link InstanceKey}s depending on various policies ranging from class-based (i.e. 0-CFA) to
|
||||
|
@ -231,8 +231,7 @@ public class ZeroXInstanceKeys implements InstanceKeyFactory {
|
|||
*/
|
||||
private Map<IClass, Integer> countAllocsByType(CGNode node) {
|
||||
Map<IClass, Integer> count = HashMapFactory.make();
|
||||
for (Iterator<NewSiteReference> it = contextInterpreter.iterateNewSites(node); it.hasNext();) {
|
||||
NewSiteReference n = it.next();
|
||||
for (NewSiteReference n : Iterator2Iterable.make(contextInterpreter.iterateNewSites(node))) {
|
||||
IClass alloc = cha.lookupClass(n.getDeclaredType());
|
||||
if (alloc != null) {
|
||||
Integer old = count.get(alloc);
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
package com.ibm.wala.ipa.callgraph.propagation.rta;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import com.ibm.wala.analysis.reflection.ReflectionContextInterpreter;
|
||||
|
@ -54,6 +53,7 @@ import com.ibm.wala.types.TypeReference;
|
|||
import com.ibm.wala.util.CancelException;
|
||||
import com.ibm.wala.util.MonitorUtil.IProgressMonitor;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
|
||||
/**
|
||||
* Abstract superclass of various RTA flavors
|
||||
|
@ -136,8 +136,7 @@ public abstract class AbstractRTABuilder extends PropagationCallGraphBuilder {
|
|||
* Add a constraint for each allocate
|
||||
*/
|
||||
private void addNewConstraints(CGNode node) {
|
||||
for (Iterator<NewSiteReference> it = getRTAContextInterpreter().iterateNewSites(node); it.hasNext();) {
|
||||
NewSiteReference n = it.next();
|
||||
for (NewSiteReference n : Iterator2Iterable.make(getRTAContextInterpreter().iterateNewSites(node))) {
|
||||
visitNew(node, n);
|
||||
}
|
||||
}
|
||||
|
@ -146,8 +145,7 @@ public abstract class AbstractRTABuilder extends PropagationCallGraphBuilder {
|
|||
* Add a constraint for each invoke
|
||||
*/
|
||||
private void addCallConstraints(CGNode node) {
|
||||
for (Iterator<CallSiteReference> it = getRTAContextInterpreter().iterateCallSites(node); it.hasNext();) {
|
||||
CallSiteReference c = it.next();
|
||||
for (CallSiteReference c : Iterator2Iterable.make(getRTAContextInterpreter().iterateCallSites(node))) {
|
||||
visitInvoke(node, c);
|
||||
}
|
||||
}
|
||||
|
@ -156,12 +154,10 @@ public abstract class AbstractRTABuilder extends PropagationCallGraphBuilder {
|
|||
* Handle accesses to static fields
|
||||
*/
|
||||
private void addFieldConstraints(CGNode node) {
|
||||
for (Iterator<FieldReference> it = getRTAContextInterpreter().iterateFieldsRead(node); it.hasNext();) {
|
||||
FieldReference f = it.next();
|
||||
for (FieldReference f : Iterator2Iterable.make(getRTAContextInterpreter().iterateFieldsRead(node))) {
|
||||
processFieldAccess(f);
|
||||
}
|
||||
for (Iterator<FieldReference> it = getRTAContextInterpreter().iterateFieldsWritten(node); it.hasNext();) {
|
||||
FieldReference f = it.next();
|
||||
for (FieldReference f : Iterator2Iterable.make(getRTAContextInterpreter().iterateFieldsWritten(node))) {
|
||||
processFieldAccess(f);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import com.ibm.wala.ssa.SSAAbstractInvokeInstruction;
|
|||
import com.ibm.wala.ssa.SSAInstruction;
|
||||
import com.ibm.wala.util.collections.FilterIterator;
|
||||
import com.ibm.wala.util.collections.IndiscriminateFilter;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.collections.MapIterator;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
import com.ibm.wala.util.debug.UnimplementedError;
|
||||
|
@ -182,8 +183,7 @@ public abstract class AbstractInterproceduralCFG<T extends ISSABasicBlock> imple
|
|||
System.err.println("nPred: " + cfg.getPredNodeCount(bb));
|
||||
}
|
||||
|
||||
for (Iterator<? extends T> ps = cfg.getPredNodes(bb); ps.hasNext();) {
|
||||
T pb = ps.next();
|
||||
for (T pb : Iterator2Iterable.make(cfg.getPredNodes(bb))) {
|
||||
if (DEBUG_LEVEL > 1) {
|
||||
System.err.println("Consider previous block: " + pb);
|
||||
}
|
||||
|
@ -289,8 +289,7 @@ public abstract class AbstractInterproceduralCFG<T extends ISSABasicBlock> imple
|
|||
System.err.println("addInterproceduralEdgesForEntryAndExitBlocks " + n);
|
||||
}
|
||||
|
||||
for (Iterator<CGNode> callers = cg.getPredNodes(n); callers.hasNext();) {
|
||||
CGNode caller = callers.next();
|
||||
for (CGNode caller : Iterator2Iterable.make(cg.getPredNodes(n))) {
|
||||
if (DEBUG_LEVEL > 1) {
|
||||
System.err.println("got caller " + caller);
|
||||
}
|
||||
|
@ -331,8 +330,7 @@ public abstract class AbstractInterproceduralCFG<T extends ISSABasicBlock> imple
|
|||
BasicBlockInContext<T> b2 = new BasicBlockInContext<>(n, entryBlock);
|
||||
g.addEdge(b1, b2);
|
||||
// also add edges from exit node to all return nodes (successor of call bb)
|
||||
for (Iterator<? extends T> succIter = ccfg.getSuccNodes(callerBB); succIter.hasNext();) {
|
||||
T returnBB = succIter.next();
|
||||
for (T returnBB : Iterator2Iterable.make(ccfg.getSuccNodes(callerBB))) {
|
||||
BasicBlockInContext<T> b3 = new BasicBlockInContext<>(n, exitBlock);
|
||||
BasicBlockInContext<T> b4 = new BasicBlockInContext<>(caller, returnBB);
|
||||
addNodeForBasicBlockIfNeeded(b4);
|
||||
|
@ -882,8 +880,7 @@ public abstract class AbstractInterproceduralCFG<T extends ISSABasicBlock> imple
|
|||
throw new IllegalArgumentException("bb == null");
|
||||
}
|
||||
ControlFlowGraph<SSAInstruction, T> cfg = getCFG(bb);
|
||||
for (Iterator<? extends T> it = cfg.getPredNodes(bb.getDelegate()); it.hasNext();) {
|
||||
T b = it.next();
|
||||
for (T b : Iterator2Iterable.make(cfg.getPredNodes(bb.getDelegate()))) {
|
||||
if (hasCall(new BasicBlockInContext<>(bb.getNode(), b))) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import com.ibm.wala.cfg.IBasicBlock;
|
|||
import com.ibm.wala.classLoader.IMethod;
|
||||
import com.ibm.wala.util.collections.FilterIterator;
|
||||
import com.ibm.wala.util.collections.Iterator2Collection;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.graph.AbstractNumberedGraph;
|
||||
import com.ibm.wala.util.graph.Graph;
|
||||
import com.ibm.wala.util.graph.NumberedEdgeManager;
|
||||
|
@ -96,8 +97,8 @@ public class PrunedCFG<I, T extends IBasicBlock<I>> extends AbstractNumberedGrap
|
|||
@Override
|
||||
public IntSet getSuccNodeNumbers(T N) {
|
||||
MutableIntSet bits = IntSetUtil.make();
|
||||
for (Iterator<T> EE = getSuccNodes(N); EE.hasNext();) {
|
||||
bits.add(EE.next().getNumber());
|
||||
for (T EE : Iterator2Iterable.make(getSuccNodes(N))) {
|
||||
bits.add(EE.getNumber());
|
||||
}
|
||||
|
||||
return bits;
|
||||
|
@ -116,8 +117,8 @@ public class PrunedCFG<I, T extends IBasicBlock<I>> extends AbstractNumberedGrap
|
|||
@Override
|
||||
public IntSet getPredNodeNumbers(T N) {
|
||||
MutableIntSet bits = IntSetUtil.make();
|
||||
for (Iterator<T> EE = getPredNodes(N); EE.hasNext();) {
|
||||
bits.add(EE.next().getNumber());
|
||||
for (T EE : Iterator2Iterable.make(getPredNodes(N))) {
|
||||
bits.add(EE.getNumber());
|
||||
}
|
||||
|
||||
return bits;
|
||||
|
@ -125,8 +126,8 @@ public class PrunedCFG<I, T extends IBasicBlock<I>> extends AbstractNumberedGrap
|
|||
|
||||
@Override
|
||||
public boolean hasEdge(T src, T dst) {
|
||||
for (Iterator<T> EE = getSuccNodes(src); EE.hasNext();) {
|
||||
if (EE.next().equals(dst)) {
|
||||
for (T EE : Iterator2Iterable.make(getSuccNodes(src))) {
|
||||
if (EE.equals(dst)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -279,8 +280,8 @@ public class PrunedCFG<I, T extends IBasicBlock<I>> extends AbstractNumberedGrap
|
|||
@Override
|
||||
public List<T> getExceptionalSuccessors(final T N) {
|
||||
ArrayList<T> result = new ArrayList<>();
|
||||
for (Iterator<T> it = edges.getExceptionalSuccessors(N); it.hasNext();) {
|
||||
result.add(it.next());
|
||||
for (T s : Iterator2Iterable.make(edges.getExceptionalSuccessors(N))) {
|
||||
result.add(s);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -350,10 +351,11 @@ public class PrunedCFG<I, T extends IBasicBlock<I>> extends AbstractNumberedGrap
|
|||
|
||||
int i = 0;
|
||||
MutableIntSet valid = IntSetUtil.make();
|
||||
for (Iterator<? extends T> pbs = cfg.getPredNodes(bb); pbs.hasNext(); i++) {
|
||||
if (nodes.containsNode(pbs.next())) {
|
||||
for (T pb : Iterator2Iterable.make(cfg.getPredNodes(bb))) {
|
||||
if (nodes.containsNode(pb)) {
|
||||
valid.add(i);
|
||||
}
|
||||
++i;
|
||||
}
|
||||
|
||||
return valid;
|
||||
|
|
|
@ -40,6 +40,7 @@ import com.ibm.wala.util.MonitorUtil.IProgressMonitor;
|
|||
import com.ibm.wala.util.collections.HashMapFactory;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Collection;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.collections.MapIterator;
|
||||
import com.ibm.wala.util.collections.MapUtil;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
|
@ -273,13 +274,12 @@ public class ClassHierarchy implements IClassHierarchy {
|
|||
System.err.println(("Add all classes from loader " + loader));
|
||||
}
|
||||
Collection<IClass> toRemove = HashSetFactory.make();
|
||||
for (Iterator<IClass> it = loader.iterateAllClasses(); it.hasNext();) {
|
||||
for (IClass klass : Iterator2Iterable.make(loader.iterateAllClasses())) {
|
||||
if (progressMonitor != null) {
|
||||
if (progressMonitor.isCanceled()) {
|
||||
throw new CancelCHAConstructionException();
|
||||
}
|
||||
}
|
||||
IClass klass = it.next();
|
||||
boolean added = addClass(klass);
|
||||
if (!added) {
|
||||
toRemove.add(klass);
|
||||
|
@ -606,9 +606,7 @@ public class ClassHierarchy implements IClassHierarchy {
|
|||
*/
|
||||
private Set<IMethod> computeOverriders(Node node, Selector selector) {
|
||||
HashSet<IMethod> result = HashSetFactory.make(3);
|
||||
for (Iterator<Node> it = node.getChildren(); it.hasNext();) {
|
||||
|
||||
Node child = it.next();
|
||||
for (Node child : Iterator2Iterable.make(node.getChildren())) {
|
||||
IMethod m = findMethod(child.getJavaClass(), selector);
|
||||
if (m != null) {
|
||||
result.add(m);
|
||||
|
@ -640,8 +638,7 @@ public class ClassHierarchy implements IClassHierarchy {
|
|||
|
||||
private void recursiveStringify(Node n, StringBuffer buffer) {
|
||||
buffer.append(n.toString()).append("\n");
|
||||
for (Iterator<Node> it = n.getChildren(); it.hasNext();) {
|
||||
Node child = it.next();
|
||||
for (Node child : Iterator2Iterable.make(n.getChildren())) {
|
||||
recursiveStringify(child, buffer);
|
||||
}
|
||||
}
|
||||
|
@ -1048,8 +1045,7 @@ public class ClassHierarchy implements IClassHierarchy {
|
|||
assert node != null : "null node for class " + T;
|
||||
HashSet<IClass> result = HashSetFactory.make(3);
|
||||
result.add(T);
|
||||
for (Iterator<Node> it = node.getChildren(); it.hasNext();) {
|
||||
Node child = it.next();
|
||||
for (Node child : Iterator2Iterable.make(node.getChildren())) {
|
||||
result.addAll(computeSubClasses(child.klass.getReference()));
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
package com.ibm.wala.ipa.modref;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -33,6 +32,7 @@ import com.ibm.wala.ssa.SSAInstruction;
|
|||
import com.ibm.wala.ssa.SSANewInstruction;
|
||||
import com.ibm.wala.ssa.SSAPutInstruction;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.intset.OrdinalSet;
|
||||
|
||||
/**
|
||||
|
@ -130,8 +130,8 @@ public class ModRef<T extends InstanceKey> {
|
|||
SSAInstruction.Visitor v = makeModVisitor(n, result, pa, h);
|
||||
IR ir = n.getIR();
|
||||
if (ir != null) {
|
||||
for (Iterator<SSAInstruction> it = ir.iterateNormalInstructions(); it.hasNext();) {
|
||||
it.next().visit(v);
|
||||
for (SSAInstruction inst : Iterator2Iterable.make(ir.iterateNormalInstructions())) {
|
||||
inst.visit(v);
|
||||
assert ! result.contains(null);
|
||||
}
|
||||
}
|
||||
|
@ -151,8 +151,7 @@ public class ModRef<T extends InstanceKey> {
|
|||
SSAInstruction.Visitor v = makeRefVisitor(n, result, pa, h);
|
||||
IR ir = n.getIR();
|
||||
if (ir != null) {
|
||||
for (Iterator<SSAInstruction> it = ir.iterateNormalInstructions(); it.hasNext();) {
|
||||
SSAInstruction x = it.next();
|
||||
for (SSAInstruction x : Iterator2Iterable.make(ir.iterateNormalInstructions())) {
|
||||
x.visit(v);
|
||||
assert ! result.contains(null) : x;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@ package com.ibm.wala.ipa.modref;
|
|||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -28,6 +27,7 @@ import com.ibm.wala.ssa.SSAGetInstruction;
|
|||
import com.ibm.wala.ssa.SSAInstruction;
|
||||
import com.ibm.wala.ssa.SSAPutInstruction;
|
||||
import com.ibm.wala.types.FieldReference;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
|
||||
/**
|
||||
* Computes interprocedural field accesses for a given method.
|
||||
|
@ -119,8 +119,7 @@ public final class ModRefFieldAccess {
|
|||
continue;
|
||||
}
|
||||
|
||||
for (Iterator<SSAInstruction> it = ir.iterateNormalInstructions(); it.hasNext();) {
|
||||
SSAInstruction instr = it.next();
|
||||
for (SSAInstruction instr : Iterator2Iterable.make(ir.iterateNormalInstructions())) {
|
||||
if (instr instanceof SSAGetInstruction) {
|
||||
SSAGetInstruction get = (SSAGetInstruction) instr;
|
||||
FieldReference fref = get.getDeclaredField();
|
||||
|
@ -165,8 +164,7 @@ public final class ModRefFieldAccess {
|
|||
|
||||
final IR ir = node.getIR();
|
||||
if (ir != null) {
|
||||
for (Iterator<SSAInstruction> it = ir.iterateNormalInstructions(); it.hasNext();) {
|
||||
SSAInstruction instr = it.next();
|
||||
for (SSAInstruction instr : Iterator2Iterable.make(ir.iterateNormalInstructions())) {
|
||||
if (instr instanceof SSAGetInstruction) {
|
||||
SSAGetInstruction get = (SSAGetInstruction) instr;
|
||||
FieldReference fref = get.getDeclaredField();
|
||||
|
@ -197,8 +195,7 @@ public final class ModRefFieldAccess {
|
|||
}
|
||||
}
|
||||
|
||||
for (Iterator<CGNode> it = cg.getSuccNodes(node); it.hasNext();) {
|
||||
CGNode n = it.next();
|
||||
for (CGNode n : Iterator2Iterable.make(cg.getSuccNodes(node))) {
|
||||
if (!done.contains(n)) {
|
||||
done.add(n);
|
||||
TwoMaps t = recAdd(n);
|
||||
|
|
|
@ -286,8 +286,7 @@ public class PDG<T extends InstanceKey> implements NumberedGraph<Statement> {
|
|||
// any
|
||||
// control-dependent successors
|
||||
if (src != null) {
|
||||
for (Iterator<? extends ISSABasicBlock> succ = cdg.getSuccNodes(bb); succ.hasNext();) {
|
||||
ISSABasicBlock bb2 = succ.next();
|
||||
for (ISSABasicBlock bb2 : Iterator2Iterable.make(cdg.getSuccNodes(bb))) {
|
||||
for (SSAInstruction st : bb2) {
|
||||
if (st != null) {
|
||||
Statement dest = ssaInstruction2Statement(st, ir, instructionIndices);
|
||||
|
@ -333,12 +332,10 @@ public class PDG<T extends InstanceKey> implements NumberedGraph<Statement> {
|
|||
*/
|
||||
if (!dOptions.equals(DataDependenceOptions.NONE)) {
|
||||
for (ISSABasicBlock bb : cdg) {
|
||||
for (Iterator<SSAPhiInstruction> ps = bb.iteratePhis(); ps.hasNext();) {
|
||||
SSAPhiInstruction phi = ps.next();
|
||||
for (SSAPhiInstruction phi : Iterator2Iterable.make(bb.iteratePhis())) {
|
||||
Statement phiSt = ssaInstruction2Statement(phi, ir, instructionIndices);
|
||||
int phiUseIndex = 0;
|
||||
for (Iterator<? extends ISSABasicBlock> preds = controlFlowGraph.getPredNodes(bb); preds.hasNext();) {
|
||||
ISSABasicBlock pb = preds.next();
|
||||
for (ISSABasicBlock pb : Iterator2Iterable.make(controlFlowGraph.getPredNodes(bb))) {
|
||||
int use = phi.getUse(phiUseIndex);
|
||||
if (use == AbstractIntStackMachine.TOP) {
|
||||
// the predecessor is part of some infeasible bytecode. we probably don't want slices to include such code, so ignore.
|
||||
|
@ -358,8 +355,7 @@ public class PDG<T extends InstanceKey> implements NumberedGraph<Statement> {
|
|||
delegate.addEdge(pst, phiSt, Dependency.CONTROL_DEP);
|
||||
/** END Custom change: control deps */
|
||||
} else {
|
||||
for (Iterator<? extends ISSABasicBlock> cdps = cdg.getPredNodes(pb); cdps.hasNext();) {
|
||||
ISSABasicBlock cpb = cdps.next();
|
||||
for (ISSABasicBlock cpb : Iterator2Iterable.make(cdg.getPredNodes(pb))) {
|
||||
/** BEGIN Custom change: control deps */
|
||||
if (cpb.getLastInstructionIndex() < 0) {
|
||||
continue;
|
||||
|
@ -451,8 +447,7 @@ public class PDG<T extends InstanceKey> implements NumberedGraph<Statement> {
|
|||
// statement
|
||||
for (int i = 0; i < statement.getNumberOfDefs(); i++) {
|
||||
int def = statement.getDef(i);
|
||||
for (Iterator<SSAInstruction> it2 = DU.getUses(def); it2.hasNext();) {
|
||||
SSAInstruction use = it2.next();
|
||||
for (SSAInstruction use : Iterator2Iterable.make(DU.getUses(def))) {
|
||||
if (dOptions.isIgnoreBasePtrs()) {
|
||||
if (use instanceof SSANewInstruction) {
|
||||
// cut out array length parameters
|
||||
|
@ -488,8 +483,7 @@ public class PDG<T extends InstanceKey> implements NumberedGraph<Statement> {
|
|||
}
|
||||
|
||||
ValueNumberCarrier a = (ValueNumberCarrier) s;
|
||||
for (Iterator<SSAInstruction> it2 = DU.getUses(a.getValueNumber()); it2.hasNext();) {
|
||||
SSAInstruction use = it2.next();
|
||||
for (SSAInstruction use : Iterator2Iterable.make(DU.getUses(a.getValueNumber()))) {
|
||||
if (dOptions.isIgnoreBasePtrs()) {
|
||||
if (use instanceof SSANewInstruction) {
|
||||
// cut out array length parameters
|
||||
|
@ -952,8 +946,7 @@ public class PDG<T extends InstanceKey> implements NumberedGraph<Statement> {
|
|||
*/
|
||||
private void createSpecialStatements(IR ir) {
|
||||
// create a node for instructions which do not correspond to bytecode
|
||||
for (Iterator<SSAInstruction> it = ir.iterateAllInstructions(); it.hasNext();) {
|
||||
SSAInstruction s = it.next();
|
||||
for (SSAInstruction s : Iterator2Iterable.make(ir.iterateAllInstructions())) {
|
||||
if (s instanceof SSAPhiInstruction) {
|
||||
delegate.addNode(new PhiStatement(node, (SSAPhiInstruction) s));
|
||||
} else if (s instanceof SSAGetCaughtExceptionInstruction) {
|
||||
|
|
|
@ -35,6 +35,7 @@ import com.ibm.wala.util.collections.EmptyIterator;
|
|||
import com.ibm.wala.util.collections.HashMapFactory;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Collection;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.collections.IteratorUtil;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
import com.ibm.wala.util.graph.AbstractNumberedGraph;
|
||||
|
@ -371,10 +372,8 @@ public class SDG<T extends InstanceKey> extends AbstractNumberedGraph<Statement>
|
|||
}
|
||||
|
||||
// data dependence predecessors
|
||||
for (Iterator<? extends CGNode> it = cg.getPredNodes(N.getNode()); it.hasNext();) {
|
||||
CGNode caller = it.next();
|
||||
for (Iterator<CallSiteReference> it2 = cg.getPossibleSites(caller, N.getNode()); it2.hasNext();) {
|
||||
CallSiteReference site = it2.next();
|
||||
for (CGNode caller : Iterator2Iterable.make(cg.getPredNodes(N.getNode()))) {
|
||||
for (CallSiteReference site : Iterator2Iterable.make(cg.getPossibleSites(caller, N.getNode()))) {
|
||||
IR ir = caller.getIR();
|
||||
IntSet indices = ir.getCallInstructionIndices(site);
|
||||
for (IntIterator ii = indices.intIterator(); ii.hasNext();) {
|
||||
|
@ -402,10 +401,8 @@ public class SDG<T extends InstanceKey> extends AbstractNumberedGraph<Statement>
|
|||
Collection<Statement> result = HashSetFactory.make(5);
|
||||
if (!dOptions.equals(DataDependenceOptions.NONE)) {
|
||||
// data dependence predecessors
|
||||
for (Iterator<? extends CGNode> it = cg.getPredNodes(N.getNode()); it.hasNext();) {
|
||||
CGNode caller = it.next();
|
||||
for (Iterator<CallSiteReference> it2 = cg.getPossibleSites(caller, N.getNode()); it2.hasNext();) {
|
||||
CallSiteReference site = it2.next();
|
||||
for (CGNode caller : Iterator2Iterable.make(cg.getPredNodes(N.getNode()))) {
|
||||
for (CallSiteReference site : Iterator2Iterable.make(cg.getPossibleSites(caller, N.getNode()))) {
|
||||
IR ir = caller.getIR();
|
||||
IntSet indices = ir.getCallInstructionIndices(site);
|
||||
for (IntIterator ii = indices.intIterator(); ii.hasNext();) {
|
||||
|
@ -427,10 +424,8 @@ public class SDG<T extends InstanceKey> extends AbstractNumberedGraph<Statement>
|
|||
case METHOD_ENTRY:
|
||||
Collection<Statement> result = HashSetFactory.make(5);
|
||||
if (!cOptions.isIgnoreInterproc()) {
|
||||
for (Iterator<? extends CGNode> it = cg.getPredNodes(N.getNode()); it.hasNext();) {
|
||||
CGNode caller = it.next();
|
||||
for (Iterator<CallSiteReference> it2 = cg.getPossibleSites(caller, N.getNode()); it2.hasNext();) {
|
||||
CallSiteReference site = it2.next();
|
||||
for (CGNode caller : Iterator2Iterable.make(cg.getPredNodes(N.getNode()))) {
|
||||
for (CallSiteReference site : Iterator2Iterable.make(cg.getPossibleSites(caller, N.getNode()))) {
|
||||
IR ir = caller.getIR();
|
||||
IntSet indices = ir.getCallInstructionIndices(site);
|
||||
for (IntIterator ii = indices.intIterator(); ii.hasNext();) {
|
||||
|
@ -494,10 +489,8 @@ public class SDG<T extends InstanceKey> extends AbstractNumberedGraph<Statement>
|
|||
Collection<Statement> result = HashSetFactory.make(5);
|
||||
if (!dOptions.equals(DataDependenceOptions.NONE)) {
|
||||
// data dependence predecessors
|
||||
for (Iterator<? extends CGNode> it = cg.getPredNodes(N.getNode()); it.hasNext();) {
|
||||
CGNode caller = it.next();
|
||||
for (Iterator<CallSiteReference> it2 = cg.getPossibleSites(caller, N.getNode()); it2.hasNext();) {
|
||||
CallSiteReference site = it2.next();
|
||||
for (CGNode caller : Iterator2Iterable.make(cg.getPredNodes(N.getNode()))) {
|
||||
for (CallSiteReference site : Iterator2Iterable.make(cg.getPossibleSites(caller, N.getNode()))) {
|
||||
IR ir = caller.getIR();
|
||||
IntSet indices = ir.getCallInstructionIndices(site);
|
||||
for (IntIterator ii = indices.intIterator(); ii.hasNext();) {
|
||||
|
@ -515,10 +508,8 @@ public class SDG<T extends InstanceKey> extends AbstractNumberedGraph<Statement>
|
|||
Collection<Statement> result = HashSetFactory.make(5);
|
||||
if (!dOptions.equals(DataDependenceOptions.NONE)) {
|
||||
// data dependence predecessors
|
||||
for (Iterator<? extends CGNode> it = cg.getPredNodes(N.getNode()); it.hasNext();) {
|
||||
CGNode caller = it.next();
|
||||
for (Iterator<CallSiteReference> it2 = cg.getPossibleSites(caller, N.getNode()); it2.hasNext();) {
|
||||
CallSiteReference site = it2.next();
|
||||
for (CGNode caller : Iterator2Iterable.make(cg.getPredNodes(N.getNode()))) {
|
||||
for (CallSiteReference site : Iterator2Iterable.make(cg.getPossibleSites(caller, N.getNode()))) {
|
||||
IR ir = caller.getIR();
|
||||
IntSet indices = ir.getCallInstructionIndices(site);
|
||||
for (IntIterator ii = indices.intIterator(); ii.hasNext();) {
|
||||
|
@ -537,10 +528,8 @@ public class SDG<T extends InstanceKey> extends AbstractNumberedGraph<Statement>
|
|||
Collection<Statement> result = HashSetFactory.make(5);
|
||||
if (!dOptions.equals(DataDependenceOptions.NONE)) {
|
||||
// data dependence predecessors
|
||||
for (Iterator<? extends CGNode> it = cg.getPredNodes(N.getNode()); it.hasNext();) {
|
||||
CGNode caller = it.next();
|
||||
for (Iterator<CallSiteReference> it2 = cg.getPossibleSites(caller, N.getNode()); it2.hasNext();) {
|
||||
CallSiteReference site = it2.next();
|
||||
for (CGNode caller : Iterator2Iterable.make(cg.getPredNodes(N.getNode()))) {
|
||||
for (CallSiteReference site : Iterator2Iterable.make(cg.getPossibleSites(caller, N.getNode()))) {
|
||||
IR ir = caller.getIR();
|
||||
IntSet indices = ir.getCallInstructionIndices(site);
|
||||
for (IntIterator ii = indices.intIterator(); ii.hasNext();) {
|
||||
|
@ -766,8 +755,7 @@ public class SDG<T extends InstanceKey> extends AbstractNumberedGraph<Statement>
|
|||
public IntSet getPredNodeNumbers(Statement node) {
|
||||
// TODO: optimize me.
|
||||
MutableSparseIntSet result = MutableSparseIntSet.makeEmpty();
|
||||
for (Iterator<? extends Statement> it = getPredNodes(node); it.hasNext();) {
|
||||
Statement s = it.next();
|
||||
for (Statement s : Iterator2Iterable.make(getPredNodes(node))) {
|
||||
result.add(getNumber(s));
|
||||
}
|
||||
return result;
|
||||
|
@ -777,8 +765,7 @@ public class SDG<T extends InstanceKey> extends AbstractNumberedGraph<Statement>
|
|||
public IntSet getSuccNodeNumbers(Statement node) {
|
||||
// TODO: optimize me.
|
||||
MutableSparseIntSet result = MutableSparseIntSet.makeEmpty();
|
||||
for (Iterator<? extends Statement> it = getSuccNodes(node); it.hasNext();) {
|
||||
Statement s = it.next();
|
||||
for (Statement s : Iterator2Iterable.make(getSuccNodes(node))) {
|
||||
result.add(getNumber(s));
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -14,6 +14,7 @@ import java.util.ArrayList;
|
|||
import java.util.Iterator;
|
||||
|
||||
import com.ibm.wala.util.collections.EmptyIterator;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
import com.ibm.wala.util.intset.IntIterator;
|
||||
import com.ibm.wala.util.intset.IntSet;
|
||||
|
@ -99,8 +100,8 @@ public class DefUse {
|
|||
* Initialize the allInstructions field with every {@link SSAInstruction} in the ir.
|
||||
*/
|
||||
protected void initAllInstructions() {
|
||||
for (Iterator<SSAInstruction> it = ir.iterateAllInstructions(); it.hasNext();) {
|
||||
allInstructions.add(it.next());
|
||||
for (SSAInstruction inst : Iterator2Iterable.make(ir.iterateAllInstructions())) {
|
||||
allInstructions.add(inst);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ import com.ibm.wala.types.TypeReference;
|
|||
import com.ibm.wala.util.collections.CompoundIterator;
|
||||
import com.ibm.wala.util.collections.HashMapFactory;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
import com.ibm.wala.util.intset.BasicNaturalRelation;
|
||||
import com.ibm.wala.util.intset.IntIterator;
|
||||
|
@ -167,8 +168,7 @@ public abstract class IR implements IRView {
|
|||
result.append(")");
|
||||
}
|
||||
result.append("\n");
|
||||
for (Iterator<SSAPhiInstruction> it = bb.iteratePhis(); it.hasNext();) {
|
||||
SSAPhiInstruction phi = it.next();
|
||||
for (SSAPhiInstruction phi : Iterator2Iterable.make(bb.iteratePhis())) {
|
||||
if (phi != null) {
|
||||
result.append(" " + phi.toString(symbolTable)).append("\n");
|
||||
}
|
||||
|
@ -234,8 +234,7 @@ public abstract class IR implements IRView {
|
|||
}
|
||||
}
|
||||
}
|
||||
for (Iterator<SSAPiInstruction> it = bb.iteratePis(); it.hasNext();) {
|
||||
SSAPiInstruction pi = it.next();
|
||||
for (SSAPiInstruction pi : Iterator2Iterable.make(bb.iteratePis())) {
|
||||
if (pi != null) {
|
||||
result.append(" " + pi.toString(symbolTable)).append("\n");
|
||||
}
|
||||
|
@ -464,8 +463,8 @@ public abstract class IR implements IRView {
|
|||
* visit each normal (non-phi, non-pi, non-catch) instruction in this IR
|
||||
*/
|
||||
public void visitNormalInstructions(SSAInstruction.Visitor v) {
|
||||
for (Iterator<SSAInstruction> i = iterateNormalInstructions(); i.hasNext();) {
|
||||
i.next().visit(v);
|
||||
for (SSAInstruction inst : Iterator2Iterable.make(iterateNormalInstructions())) {
|
||||
inst.visit(v);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -473,8 +472,8 @@ public abstract class IR implements IRView {
|
|||
* visit each instruction in this IR
|
||||
*/
|
||||
public void visitAllInstructions(SSAInstruction.Visitor v) {
|
||||
for (Iterator<SSAInstruction> i = iterateAllInstructions(); i.hasNext();) {
|
||||
i.next().visit(v);
|
||||
for (SSAInstruction inst : Iterator2Iterable.make(iterateAllInstructions())) {
|
||||
inst.visit(v);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ import com.ibm.wala.types.TypeReference;
|
|||
import com.ibm.wala.util.collections.EmptyIterator;
|
||||
import com.ibm.wala.util.collections.HashMapFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Collection;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.collections.MapIterator;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
import com.ibm.wala.util.debug.UnimplementedError;
|
||||
|
@ -509,8 +510,8 @@ public class SSACFG implements ControlFlowGraph<SSAInstruction, ISSABasicBlock>,
|
|||
compressPhis();
|
||||
|
||||
ArrayList<SSAInstruction> result = new ArrayList<>();
|
||||
for (Iterator<? extends SSAInstruction> it = iteratePhis(); it.hasNext();) {
|
||||
result.add(it.next());
|
||||
for (SSAInstruction inst : Iterator2Iterable.make(iteratePhis())) {
|
||||
result.add(inst);
|
||||
}
|
||||
|
||||
for (int i = getFirstInstructionIndex(); i <= getLastInstructionIndex(); i++) {
|
||||
|
@ -520,8 +521,8 @@ public class SSACFG implements ControlFlowGraph<SSAInstruction, ISSABasicBlock>,
|
|||
}
|
||||
}
|
||||
|
||||
for (Iterator<? extends SSAInstruction> it = iteratePis(); it.hasNext();) {
|
||||
result.add(it.next());
|
||||
for (SSAInstruction inst : Iterator2Iterable.make(iteratePis())) {
|
||||
result.add(inst);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -1013,10 +1014,9 @@ public class SSACFG implements ControlFlowGraph<SSAInstruction, ISSABasicBlock>,
|
|||
throw new IllegalArgumentException("b is null");
|
||||
}
|
||||
final IBasicBlock<IInstruction> n = delegate.getNode(b.getNumber());
|
||||
final Iterator<IBasicBlock<IInstruction>> i = delegate.getExceptionalSuccessors(n).iterator();
|
||||
final Collection<IBasicBlock<IInstruction>> ss = delegate.getExceptionalSuccessors(n);
|
||||
final List<ISSABasicBlock> c = new ArrayList<>(getSuccNodeCount(b));
|
||||
for (; i.hasNext();) {
|
||||
final IBasicBlock<IInstruction> s = i.next();
|
||||
for (final IBasicBlock<IInstruction> s : ss) {
|
||||
c.add(basicBlocks[delegate.getNumber(s)]);
|
||||
}
|
||||
return c;
|
||||
|
@ -1081,10 +1081,9 @@ public class SSACFG implements ControlFlowGraph<SSAInstruction, ISSABasicBlock>,
|
|||
throw new IllegalArgumentException("b is null");
|
||||
}
|
||||
IBasicBlock<IInstruction> n = delegate.getNode(b.getNumber());
|
||||
final Iterator<IBasicBlock<IInstruction>> i = delegate.getNormalSuccessors(n).iterator();
|
||||
final Collection<IBasicBlock<IInstruction>> ss = delegate.getNormalSuccessors(n);
|
||||
Collection<ISSABasicBlock> c = new ArrayList<>(getSuccNodeCount(b));
|
||||
for (; i.hasNext();) {
|
||||
IBasicBlock<IInstruction> s = i.next();
|
||||
for (IBasicBlock<IInstruction> s : ss) {
|
||||
c.add(basicBlocks[delegate.getNumber(s)]);
|
||||
}
|
||||
return c;
|
||||
|
@ -1099,10 +1098,9 @@ public class SSACFG implements ControlFlowGraph<SSAInstruction, ISSABasicBlock>,
|
|||
throw new IllegalArgumentException("b is null");
|
||||
}
|
||||
IBasicBlock<IInstruction> n = delegate.getNode(b.getNumber());
|
||||
final Iterator<IBasicBlock<IInstruction>> i = delegate.getNormalPredecessors(n).iterator();
|
||||
final Collection<IBasicBlock<IInstruction>> ss = delegate.getNormalPredecessors(n);
|
||||
Collection<ISSABasicBlock> c = new ArrayList<>(getPredNodeCount(b));
|
||||
for (; i.hasNext();) {
|
||||
IBasicBlock<IInstruction> s = i.next();
|
||||
for (IBasicBlock<IInstruction> s : ss) {
|
||||
c.add(basicBlocks[delegate.getNumber(s)]);
|
||||
}
|
||||
return c;
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
package com.ibm.wala.ssa.analysis;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
|
@ -25,6 +24,7 @@ import com.ibm.wala.util.CancelException;
|
|||
import com.ibm.wala.util.CancelRuntimeException;
|
||||
import com.ibm.wala.util.collections.HashMapFactory;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
|
||||
/**
|
||||
* Eliminate dead assignments (phis) from an SSA IR.
|
||||
|
@ -65,8 +65,7 @@ public class DeadAssignmentElimination {
|
|||
}
|
||||
if (b.hasPhi()) {
|
||||
HashSet<SSAPhiInstruction> toRemove = HashSetFactory.make(5);
|
||||
for (Iterator<SSAPhiInstruction> it = b.iteratePhis(); it.hasNext();) {
|
||||
SSAPhiInstruction phi = it.next();
|
||||
for (SSAPhiInstruction phi : Iterator2Iterable.make(b.iteratePhis())) {
|
||||
if (phi != null) {
|
||||
int def = phi.getDef();
|
||||
if (solution.isDead(def)) {
|
||||
|
@ -103,8 +102,8 @@ public class DeadAssignmentElimination {
|
|||
*/
|
||||
DeadValueSystem(IR ir, DefUse DU) {
|
||||
// create a variable for each potentially dead phi instruction.
|
||||
for (Iterator<? extends SSAInstruction> it = ir.iteratePhis(); it.hasNext();) {
|
||||
SSAPhiInstruction phi = (SSAPhiInstruction) it.next();
|
||||
for (SSAInstruction inst : Iterator2Iterable.make(ir.iteratePhis())) {
|
||||
SSAPhiInstruction phi = (SSAPhiInstruction) inst;
|
||||
if (phi == null) {
|
||||
continue;
|
||||
}
|
||||
|
@ -114,8 +113,7 @@ public class DeadAssignmentElimination {
|
|||
trivialDead.add(new Integer(def));
|
||||
} else {
|
||||
boolean maybeDead = true;
|
||||
for (Iterator<SSAInstruction> uses = DU.getUses(def); uses.hasNext();) {
|
||||
SSAInstruction u = uses.next();
|
||||
for (SSAInstruction u : Iterator2Iterable.make(DU.getUses(def))) {
|
||||
if (!(u instanceof SSAPhiInstruction)) {
|
||||
// certainly not dead
|
||||
maybeDead = false;
|
||||
|
@ -134,8 +132,8 @@ public class DeadAssignmentElimination {
|
|||
for (Entry<Integer, BooleanVariable> E : vars.entrySet()) {
|
||||
Integer def = E.getKey();
|
||||
BooleanVariable B = E.getValue();
|
||||
for (Iterator<SSAInstruction> uses = DU.getUses(def.intValue()); uses.hasNext();) {
|
||||
SSAPhiInstruction u = (SSAPhiInstruction) uses.next();
|
||||
for (SSAInstruction use : Iterator2Iterable.make(DU.getUses(def.intValue()))) {
|
||||
SSAPhiInstruction u = (SSAPhiInstruction) use;
|
||||
Integer ud = new Integer(u.getDef());
|
||||
if (trivialDead.contains(ud)) {
|
||||
// do nothing ... u will not keep def live
|
||||
|
|
|
@ -30,6 +30,7 @@ import com.ibm.wala.types.TypeReference;
|
|||
import com.ibm.wala.util.collections.EmptyIterator;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Collection;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.collections.NonNullSingletonIterator;
|
||||
import com.ibm.wala.util.collections.SimpleVector;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
|
@ -313,8 +314,7 @@ public class ExplodedControlFlowGraph implements ControlFlowGraph<SSAInstruction
|
|||
if (eb.original != null && eb.original.isEntryBlock()) {
|
||||
result.add(entry);
|
||||
}
|
||||
for (Iterator<ISSABasicBlock> it = ir.getControlFlowGraph().getPredNodes(original); it.hasNext();) {
|
||||
ISSABasicBlock s = it.next();
|
||||
for (ISSABasicBlock s : Iterator2Iterable.make(ir.getControlFlowGraph().getPredNodes(original))) {
|
||||
if (s.isEntryBlock()) {
|
||||
// it's possible for an entry block to have instructions; in this case, add
|
||||
// the exploded basic block for the last instruction in the entry block
|
||||
|
@ -356,8 +356,7 @@ public class ExplodedControlFlowGraph implements ControlFlowGraph<SSAInstruction
|
|||
}
|
||||
if (eb.instructionIndex == eb.original.getLastInstructionIndex()) {
|
||||
List<IExplodedBasicBlock> result = new ArrayList<>();
|
||||
for (Iterator<ISSABasicBlock> it = ir.getControlFlowGraph().getSuccNodes(eb.original); it.hasNext();) {
|
||||
ISSABasicBlock s = it.next();
|
||||
for (ISSABasicBlock s : Iterator2Iterable.make(ir.getControlFlowGraph().getSuccNodes(eb.original))) {
|
||||
if (s.equals(ir.getControlFlowGraph().exit())) {
|
||||
result.add(exit());
|
||||
} else {
|
||||
|
@ -379,8 +378,7 @@ public class ExplodedControlFlowGraph implements ControlFlowGraph<SSAInstruction
|
|||
|
||||
@Override
|
||||
public boolean hasEdge(IExplodedBasicBlock src, IExplodedBasicBlock dst) throws UnimplementedError {
|
||||
for (Iterator<IExplodedBasicBlock> it = getSuccNodes(src); it.hasNext();) {
|
||||
IExplodedBasicBlock succ = it.next();
|
||||
for (IExplodedBasicBlock succ : Iterator2Iterable.make(getSuccNodes(src))) {
|
||||
if (succ == dst) {
|
||||
return true;
|
||||
}
|
||||
|
@ -443,8 +441,8 @@ public class ExplodedControlFlowGraph implements ControlFlowGraph<SSAInstruction
|
|||
@Override
|
||||
public IntSet getPredNodeNumbers(IExplodedBasicBlock node) {
|
||||
MutableSparseIntSet result = MutableSparseIntSet.makeEmpty();
|
||||
for (Iterator<? extends IExplodedBasicBlock> it = getPredNodes(node); it.hasNext();) {
|
||||
result.add(getNumber(it.next()));
|
||||
for (IExplodedBasicBlock ebb : Iterator2Iterable.make(getPredNodes(node))) {
|
||||
result.add(getNumber(ebb));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
package com.ibm.wala.viz;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.ibm.wala.cfg.CFGSanitizer;
|
||||
import com.ibm.wala.ipa.cha.IClassHierarchy;
|
||||
import com.ibm.wala.ssa.IR;
|
||||
|
@ -26,6 +24,7 @@ import com.ibm.wala.ssa.SSAPhiInstruction;
|
|||
import com.ibm.wala.ssa.SSAPiInstruction;
|
||||
import com.ibm.wala.util.WalaException;
|
||||
import com.ibm.wala.util.collections.HashMapFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.graph.Graph;
|
||||
import com.ibm.wala.util.strings.StringStuff;
|
||||
|
||||
|
@ -120,8 +119,7 @@ public class PDFViewUtil {
|
|||
result.append("<Handler>");
|
||||
}
|
||||
result.append("\\n");
|
||||
for (Iterator<SSAPhiInstruction> it = bb.iteratePhis(); it.hasNext();) {
|
||||
SSAPhiInstruction phi = it.next();
|
||||
for (SSAPhiInstruction phi : Iterator2Iterable.make(bb.iteratePhis())) {
|
||||
if (phi != null) {
|
||||
result.append(" " + phi.toString(ir.getSymbolTable())).append("\\l");
|
||||
}
|
||||
|
@ -144,8 +142,7 @@ public class PDFViewUtil {
|
|||
result.append("\\l");
|
||||
}
|
||||
}
|
||||
for (Iterator<SSAPiInstruction> it = bb.iteratePis(); it.hasNext();) {
|
||||
SSAPiInstruction pi = it.next();
|
||||
for (SSAPiInstruction pi : Iterator2Iterable.make(bb.iteratePis())) {
|
||||
if (pi != null) {
|
||||
result.append(" " + pi.toString(ir.getSymbolTable())).append("\\l");
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
package com.ibm.wala.viz.viewer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -29,6 +28,7 @@ import com.ibm.wala.classLoader.CallSiteReference;
|
|||
import com.ibm.wala.ipa.callgraph.CGNode;
|
||||
import com.ibm.wala.ipa.callgraph.CallGraph;
|
||||
import com.ibm.wala.ssa.IR;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
|
||||
public class CgPanel extends JSplitPane{
|
||||
|
||||
|
@ -111,8 +111,7 @@ public class CgPanel extends JSplitPane{
|
|||
Object userObject = treeNode.getUserObject();
|
||||
if (userObject instanceof CGNode) {
|
||||
CGNode cgNode = (CGNode) userObject;
|
||||
for (Iterator<CallSiteReference> iter = cgNode.iterateCallSites(); iter.hasNext();) {
|
||||
CallSiteReference csr = iter.next();
|
||||
for (CallSiteReference csr : Iterator2Iterable.make(cgNode.iterateCallSites())) {
|
||||
newChilds.add(new DefaultMutableTreeNode(csr));
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -16,7 +16,6 @@ import java.io.File;
|
|||
import java.net.URI;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -37,6 +36,7 @@ import com.ibm.wala.types.TypeReference;
|
|||
import com.ibm.wala.util.NullProgressMonitor;
|
||||
import com.ibm.wala.util.collections.HashMapFactory;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.collections.Pair;
|
||||
import com.ibm.wala.util.io.FileUtil;
|
||||
|
||||
|
@ -80,10 +80,8 @@ public abstract class DroidBenchCGTest extends DalvikCallGraphTestBase {
|
|||
|
||||
public static Set<IMethod> assertUserCodeReachable(CallGraph cg, Set<MethodReference> uncalled) {
|
||||
Set<IMethod> result = HashSetFactory.make();
|
||||
for(Iterator<IClass> clss = cg.getClassHierarchy().getLoader(ClassLoaderReference.Application).iterateAllClasses();
|
||||
clss.hasNext(); )
|
||||
for(IClass cls : Iterator2Iterable.make(cg.getClassHierarchy().getLoader(ClassLoaderReference.Application).iterateAllClasses()))
|
||||
{
|
||||
IClass cls = clss.next();
|
||||
if (cls.isInterface()) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -50,7 +50,6 @@ package com.ibm.wala.dalvik.classLoader;
|
|||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -63,6 +62,7 @@ import com.ibm.wala.ipa.cha.IClassHierarchy;
|
|||
import com.ibm.wala.types.ClassLoaderReference;
|
||||
import com.ibm.wala.types.TypeName;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.config.SetOfClasses;
|
||||
import com.ibm.wala.util.warnings.Warning;
|
||||
import com.ibm.wala.util.warnings.Warnings;
|
||||
|
@ -133,8 +133,7 @@ public class WDexClassLoaderImpl extends ClassLoaderImpl {
|
|||
|
||||
private static Set<ModuleEntry> getDexFiles(Module M) {
|
||||
HashSet<ModuleEntry> result = HashSetFactory.make();
|
||||
for (Iterator<? extends ModuleEntry> it = M.getEntries(); it.hasNext();) {
|
||||
ModuleEntry entry = it.next();
|
||||
for (ModuleEntry entry : Iterator2Iterable.make(M.getEntries())) {
|
||||
if (entry instanceof DexModuleEntry) {
|
||||
result.add(entry);
|
||||
}
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
*******************************************************************************/
|
||||
package com.ibm.wala.dalvik.ssa;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.ibm.wala.dalvik.classLoader.DexCFG;
|
||||
import com.ibm.wala.dalvik.classLoader.DexCFG.BasicBlock;
|
||||
import com.ibm.wala.dalvik.classLoader.DexConstants;
|
||||
|
@ -59,6 +57,7 @@ import com.ibm.wala.shrikeBT.SwitchInstruction;
|
|||
import com.ibm.wala.shrikeBT.ThrowInstruction;
|
||||
import com.ibm.wala.util.CancelException;
|
||||
import com.ibm.wala.util.CancelRuntimeException;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.debug.UnimplementedError;
|
||||
import com.ibm.wala.util.graph.INodeWithNumber;
|
||||
|
||||
|
@ -233,8 +232,8 @@ public abstract class AbstractIntRegisterMachine implements FixedPointConstants
|
|||
/*
|
||||
* Add only the entry variable to the work list.
|
||||
*/
|
||||
for (Iterator<? extends INodeWithNumber> it = getFixedPointSystem().getStatementsThatUse(entry); it.hasNext();) {
|
||||
AbstractStatement s = (AbstractStatement) it.next();
|
||||
for (INodeWithNumber inn : Iterator2Iterable.make(getFixedPointSystem().getStatementsThatUse(entry))) {
|
||||
AbstractStatement s = (AbstractStatement) inn;
|
||||
addToWorkList(s);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ import com.ibm.wala.ide.util.JavaEclipseProjectPath;
|
|||
import com.ibm.wala.ipa.callgraph.AnalysisScope;
|
||||
import com.ibm.wala.types.ClassLoaderReference;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
|
||||
/**
|
||||
|
@ -86,8 +87,7 @@ public abstract class AbstractJavaAnalysisAction implements IObjectActionDelegat
|
|||
|
||||
@Override
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
for (Iterator<Object> it = selection.iterator(); it.hasNext();) {
|
||||
Object object = it.next();
|
||||
for (Object object : Iterator2Iterable.make((Iterator<?>) selection.iterator())) {
|
||||
if (object instanceof IJavaElement) {
|
||||
IJavaElement e = (IJavaElement) object;
|
||||
IJavaProject jp = e.getJavaProject();
|
||||
|
@ -136,8 +136,7 @@ public abstract class AbstractJavaAnalysisAction implements IObjectActionDelegat
|
|||
protected Collection<IJavaProject> computeJavaProjects() {
|
||||
IStructuredSelection selection = (IStructuredSelection) currentSelection;
|
||||
Collection<IJavaProject> projects = HashSetFactory.make();
|
||||
for (Iterator<Object> it = selection.iterator(); it.hasNext();) {
|
||||
Object object = it.next();
|
||||
for (Object object : Iterator2Iterable.make((Iterator<?>) selection.iterator())) {
|
||||
if (object instanceof IJavaElement) {
|
||||
IJavaElement e = (IJavaElement) object;
|
||||
IJavaProject jp = e.getJavaProject();
|
||||
|
|
|
@ -13,7 +13,6 @@ package com.ibm.wala.ide.util;
|
|||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
@ -55,6 +54,7 @@ import com.ibm.wala.ide.util.HeadlessUtil.EclipseCompiler;
|
|||
import com.ibm.wala.ide.util.HeadlessUtil.Parser;
|
||||
import com.ibm.wala.ipa.callgraph.AnalysisScope;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.collections.Pair;
|
||||
import com.ibm.wala.util.graph.Graph;
|
||||
import com.ibm.wala.util.graph.impl.SlowSparseNumberedGraph;
|
||||
|
@ -83,8 +83,8 @@ public class JsdtUtil {
|
|||
List<Module> modules = s.getModules(JavaScriptTypes.jsLoader);
|
||||
Set<ModuleEntry> mes = HashSetFactory.make();
|
||||
for(Module m : modules) {
|
||||
for(Iterator<? extends ModuleEntry> mm = m.getEntries(); mm.hasNext(); ) {
|
||||
mes.add(mm.next());
|
||||
for(ModuleEntry entry : Iterator2Iterable.make(m.getEntries())) {
|
||||
mes.add(entry);
|
||||
}
|
||||
}
|
||||
return mes;
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
package com.ibm.wala.ide.ui;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -30,6 +29,7 @@ import org.eclipse.ui.PlatformUI;
|
|||
|
||||
import com.ibm.wala.util.PlatformUtil;
|
||||
import com.ibm.wala.util.WalaException;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
import com.ibm.wala.util.graph.Graph;
|
||||
import com.ibm.wala.viz.NodeDecorator;
|
||||
|
@ -236,8 +236,8 @@ public class SWTTreeViewer extends AbstractJFaceRunner {
|
|||
|
||||
Object[] result = new Object[graph.getSuccNodeCount(parentElement)];
|
||||
int i = 0;
|
||||
for (Iterator<Object> it = graph.getSuccNodes(parentElement); it.hasNext();) {
|
||||
result[i++] = it.next();
|
||||
for (Object o : Iterator2Iterable.make(graph.getSuccNodes(parentElement))) {
|
||||
result[i++] = o;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
*******************************************************************************/
|
||||
package com.ibm.wala.ide.ui;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import org.eclipse.jface.action.Action;
|
||||
|
@ -25,6 +24,7 @@ import com.ibm.wala.ssa.SSAInstruction;
|
|||
import com.ibm.wala.ssa.SSAPhiInstruction;
|
||||
import com.ibm.wala.ssa.analysis.IExplodedBasicBlock;
|
||||
import com.ibm.wala.util.WalaException;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
import com.ibm.wala.util.graph.Graph;
|
||||
import com.ibm.wala.util.graph.GraphSlicer;
|
||||
|
@ -117,8 +117,7 @@ public class ViewIFDSLocalAction<T, P, F> extends Action {
|
|||
if (bb.getDelegate() instanceof IExplodedBasicBlock) {
|
||||
IExplodedBasicBlock delegate = (IExplodedBasicBlock) bb.getDelegate();
|
||||
String s = delegate.getNumber() + " " + result.getResult(t) + "\\n" + stringify(delegate.getInstruction());
|
||||
for (Iterator<SSAPhiInstruction> phis = delegate.iteratePhis(); phis.hasNext();) {
|
||||
SSAPhiInstruction phi = phis.next();
|
||||
for (SSAPhiInstruction phi : Iterator2Iterable.make(delegate.iteratePhis())) {
|
||||
s += " " + phi;
|
||||
}
|
||||
if (delegate.isCatchBlock()) {
|
||||
|
|
|
@ -124,8 +124,7 @@ public class AndroidAnalysisContext {
|
|||
/*
|
||||
if (options.classHierarchyWarnings()) {
|
||||
// log ClassHierarchy warnings
|
||||
for (Iterator<Warning> wi = Warnings.iterator(); wi.hasNext();) {
|
||||
Warning w = wi.next();
|
||||
for (Warning w : Iterator2Iterable.make(Warnings.iterator())) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -157,8 +157,7 @@ public class CGAnalysisContext<E extends ISSABasicBlock> {
|
|||
/*
|
||||
if (analysisContext.getOptions().cgBuilderWarnings()) {
|
||||
// CallGraphBuilder construction warnings
|
||||
for (Iterator<Warning> wi = Warnings.iterator(); wi.hasNext();) {
|
||||
Warning w = wi.next();
|
||||
for (Warning w : Iterator2Iterable.make(Warnings.iterator())) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -189,8 +188,7 @@ public class CGAnalysisContext<E extends ISSABasicBlock> {
|
|||
|
||||
/*
|
||||
// makeCallGraph warnings
|
||||
for (Iterator<Warning> wi = Warnings.iterator(); wi.hasNext();) {
|
||||
Warning w = wi.next();
|
||||
for (Warning w : Iterator2Iterable.make(Warnings.iterator())) {
|
||||
|
||||
}
|
||||
*/
|
||||
|
@ -267,14 +265,12 @@ public class CGAnalysisContext<E extends ISSABasicBlock> {
|
|||
|
||||
/*
|
||||
if (options.stdoutCG()) {
|
||||
for (Iterator<CGNode> nodeI = cg.iterator(); nodeI.hasNext();) {
|
||||
CGNode node = nodeI.next();
|
||||
for (CGNode node : Iterator2Iterable.make(cg.iterator())) {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
for (Iterator<CGNode> nodeI = cg.iterator(); nodeI.hasNext();) {
|
||||
CGNode node = nodeI.next();
|
||||
for (CGNode node : Iterator2Iterable.make(cg.iterator())) {
|
||||
if (node.getMethod().isSynthetic()) {
|
||||
SSACFG ssaCFG = node.getIR().getControlFlowGraph();
|
||||
int totalBlocks = ssaCFG.getNumberOfNodes();
|
||||
|
|
|
@ -17,10 +17,9 @@ import java.io.File;
|
|||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.ibm.wala.util.WalaException;
|
||||
import com.ibm.wala.util.collections.Iterator2Collection;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
import com.ibm.wala.util.graph.Graph;
|
||||
import com.ibm.wala.viz.DotUtil;
|
||||
|
@ -210,8 +209,7 @@ public class DexDotUtil extends DotUtil {
|
|||
outputNodes(labels, result, dotNodes);
|
||||
|
||||
for (T n : g) {
|
||||
for (Iterator<? extends T> it2 = g.getSuccNodes(n); it2.hasNext();) {
|
||||
T s = it2.next();
|
||||
for (T s : Iterator2Iterable.make(g.getSuccNodes(n))) {
|
||||
result.append(" ");
|
||||
result.append(getPort(n, labels));
|
||||
result.append(" -> ");
|
||||
|
|
|
@ -10,13 +10,13 @@
|
|||
*******************************************************************************/
|
||||
package com.ibm.wala.dataflow.graph;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import com.ibm.wala.fixedpoint.impl.DefaultFixedPointSolver;
|
||||
import com.ibm.wala.fixpoint.IVariable;
|
||||
import com.ibm.wala.fixpoint.UnaryOperator;
|
||||
import com.ibm.wala.util.collections.HashMapFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.collections.ObjectArrayMapping;
|
||||
import com.ibm.wala.util.collections.Pair;
|
||||
import com.ibm.wala.util.graph.Graph;
|
||||
|
@ -80,8 +80,7 @@ public abstract class DataflowSolver<T, V extends IVariable<V>> extends DefaultF
|
|||
}
|
||||
|
||||
if (functions.hasEdgeTransferFunctions()) {
|
||||
for (Iterator<? extends T> it2 = G.getSuccNodes(N); it2.hasNext();) {
|
||||
T S = it2.next();
|
||||
for (T S : Iterator2Iterable.make(G.getSuccNodes(N))) {
|
||||
v = makeEdgeVariable(N, S);
|
||||
edge2Var.put(Pair.make(N, S), v);
|
||||
}
|
||||
|
@ -199,8 +198,8 @@ public abstract class DataflowSolver<T, V extends IVariable<V>> extends DefaultF
|
|||
// todo: optimize further using unary operators when possible?
|
||||
V[] rhs = makeStmtRHS(nPred);
|
||||
int i = 0;
|
||||
for (Iterator<?> it2 = G.getPredNodes(node); it2.hasNext();) {
|
||||
rhs[i++] = (functions.hasEdgeTransferFunctions()) ? getEdge(it2.next(), node) : getOut(it2.next());
|
||||
for (Object o : Iterator2Iterable.make(G.getPredNodes(node))) {
|
||||
rhs[i++] = (functions.hasEdgeTransferFunctions()) ? getEdge(o, node) : getOut(o);
|
||||
}
|
||||
newStatement(getIn(node), meet, rhs, toWorkList, eager);
|
||||
}
|
||||
|
@ -219,8 +218,7 @@ public abstract class DataflowSolver<T, V extends IVariable<V>> extends DefaultF
|
|||
// add edge transfer operations, if requested
|
||||
if (functions.hasEdgeTransferFunctions()) {
|
||||
for (T node : G) {
|
||||
for (Iterator<? extends T> it2 = G.getSuccNodes(node); it2.hasNext();) {
|
||||
T succ = it2.next();
|
||||
for (T succ : Iterator2Iterable.make(G.getSuccNodes(node))) {
|
||||
UnaryOperator<V> f = functions.getEdgeTransferFunction(node, succ);
|
||||
if (!f.isIdentity()) {
|
||||
newStatement(getEdge(node, succ), f, (functions.hasNodeTransferFunctions()) ? getOut(node) : getIn(node), toWorkList,
|
||||
|
@ -246,8 +244,7 @@ public abstract class DataflowSolver<T, V extends IVariable<V>> extends DefaultF
|
|||
|
||||
if (functions.hasEdgeTransferFunctions()) {
|
||||
for (T node : G) {
|
||||
for (Iterator<? extends T> it2 = G.getSuccNodes(node); it2.hasNext();) {
|
||||
T succ = it2.next();
|
||||
for (T succ : Iterator2Iterable.make(G.getSuccNodes(node))) {
|
||||
UnaryOperator<V> f = functions.getEdgeTransferFunction(node, succ);
|
||||
if (f.isIdentity()) {
|
||||
uf.union(getEdge(node, succ), (functions.hasNodeTransferFunctions()) ? getOut(node) : getIn(node));
|
||||
|
|
|
@ -24,6 +24,7 @@ import com.ibm.wala.fixpoint.UnaryStatement;
|
|||
import com.ibm.wala.util.CancelException;
|
||||
import com.ibm.wala.util.MonitorUtil;
|
||||
import com.ibm.wala.util.MonitorUtil.IProgressMonitor;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.debug.VerboseAction;
|
||||
import com.ibm.wala.util.graph.INodeWithNumber;
|
||||
|
||||
|
@ -216,8 +217,8 @@ public abstract class AbstractFixedPointSolver<T extends IVariable<T>> implement
|
|||
@Override
|
||||
public String toString() {
|
||||
StringBuffer result = new StringBuffer("Fixed Point System:\n");
|
||||
for (Iterator<? extends INodeWithNumber> it = getStatements(); it.hasNext();) {
|
||||
result.append(it.next()).append("\n");
|
||||
for (INodeWithNumber nwn : Iterator2Iterable.make(getStatements())) {
|
||||
result.append(nwn).append("\n");
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
@ -239,8 +240,8 @@ public abstract class AbstractFixedPointSolver<T extends IVariable<T>> implement
|
|||
* Add all to the work list.
|
||||
*/
|
||||
public void addAllStatementsToWorkList() {
|
||||
for (Iterator<? extends INodeWithNumber> i = getStatements(); i.hasNext();) {
|
||||
AbstractStatement eq = (AbstractStatement) i.next();
|
||||
for (INodeWithNumber nwn : Iterator2Iterable.make(getStatements())) {
|
||||
AbstractStatement eq = (AbstractStatement) nwn;
|
||||
addToWorkList(eq);
|
||||
}
|
||||
}
|
||||
|
@ -252,8 +253,8 @@ public abstract class AbstractFixedPointSolver<T extends IVariable<T>> implement
|
|||
* @param v the variable that has changed
|
||||
*/
|
||||
public void changedVariable(T v) {
|
||||
for (Iterator<? extends INodeWithNumber> it = getFixedPointSystem().getStatementsThatUse(v); it.hasNext();) {
|
||||
AbstractStatement s = (AbstractStatement) it.next();
|
||||
for (INodeWithNumber nwn : Iterator2Iterable.make(getFixedPointSystem().getStatementsThatUse(v))) {
|
||||
AbstractStatement s = (AbstractStatement) nwn;
|
||||
addToWorkList(s);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,8 @@ package com.ibm.wala.util.graph;
|
|||
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
|
||||
/**
|
||||
* Basic functionality for a {@link Graph} that delegates node and edge management.
|
||||
*/
|
||||
|
@ -191,8 +193,7 @@ public abstract class AbstractGraph<T> implements Graph<T> {
|
|||
StringBuffer sb = new StringBuffer();
|
||||
for (T n : this) {
|
||||
sb.append(n.toString()).append("\n");
|
||||
for (Iterator<? extends T> ss = getSuccNodes(n); ss.hasNext();) {
|
||||
T s = ss.next();
|
||||
for (T s : Iterator2Iterable.make(getSuccNodes(n))) {
|
||||
sb.append(edgeString(n, s)).append(s);
|
||||
sb.append("\n");
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import java.util.Set;
|
|||
import java.util.Stack;
|
||||
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.intset.BasicNaturalRelation;
|
||||
import com.ibm.wala.util.intset.IBinaryNaturalRelation;
|
||||
import com.ibm.wala.util.intset.IntIterator;
|
||||
|
@ -73,8 +74,7 @@ public class Acyclic {
|
|||
private static <T> void dfs(BasicNaturalRelation result, T root, NumberedGraph<T> G, Set<T> visited, Set<T> onstack) {
|
||||
visited.add(root);
|
||||
onstack.add(root);
|
||||
for (Iterator<? extends T> it = G.getSuccNodes(root); it.hasNext();) {
|
||||
T dstNode = it.next();
|
||||
for (T dstNode : Iterator2Iterable.make(G.getSuccNodes(root))) {
|
||||
if (onstack.contains(dstNode)) {
|
||||
int src = G.getNumber(root);
|
||||
int dst = G.getNumber(dstNode);
|
||||
|
|
|
@ -15,6 +15,8 @@ import java.util.HashSet;
|
|||
import java.util.Iterator;
|
||||
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.collections.IteratorUtil;
|
||||
import com.ibm.wala.util.graph.traverse.BFSIterator;
|
||||
import com.ibm.wala.util.graph.traverse.DFS;
|
||||
|
||||
|
@ -45,21 +47,13 @@ public class GraphIntegrity {
|
|||
private static <T> void checkEdgeCounts(Graph<T> G) throws UnsoundGraphException {
|
||||
for (T N : G) {
|
||||
int count1 = G.getSuccNodeCount(N);
|
||||
int count2 = 0;
|
||||
for (Iterator<T> it2 = G.getSuccNodes(N); it2.hasNext();) {
|
||||
it2.next();
|
||||
count2++;
|
||||
}
|
||||
int count2 = IteratorUtil.count(G.getSuccNodes(N));
|
||||
if (count1 != count2) {
|
||||
throw new UnsoundGraphException("getSuccNodeCount " + count1 + " is wrong for node " + N);
|
||||
}
|
||||
|
||||
int count3 = G.getPredNodeCount(N);
|
||||
int count4 = 0;
|
||||
for (Iterator<T> it2 = G.getPredNodes(N); it2.hasNext();) {
|
||||
it2.next();
|
||||
count4++;
|
||||
}
|
||||
int count4 = IteratorUtil.count(G.getPredNodes(N));
|
||||
if (count3 != count4) {
|
||||
throw new UnsoundGraphException("getPredNodeCount " + count1 + " is wrong for node " + N);
|
||||
}
|
||||
|
@ -71,13 +65,11 @@ public class GraphIntegrity {
|
|||
if (!G.containsNode(N)) {
|
||||
throw new UnsoundGraphException(N + " is not contained in the the graph " + G.containsNode(N));
|
||||
}
|
||||
PRED: for (Iterator<? extends T> p = G.getPredNodes(N); p.hasNext();) {
|
||||
T pred = p.next();
|
||||
PRED: for (T pred : Iterator2Iterable.make(G.getPredNodes(N))) {
|
||||
if (!G.containsNode(pred)) {
|
||||
throw new UnsoundGraphException(pred + " is a predecessor of " + N + " but is not contained in the graph");
|
||||
}
|
||||
for (Iterator<?> s = G.getSuccNodes(pred); s.hasNext();) {
|
||||
Object succ = s.next();
|
||||
for (Object succ : Iterator2Iterable.make(G.getSuccNodes(pred))) {
|
||||
if (succ.equals(N)) {
|
||||
continue PRED;
|
||||
}
|
||||
|
@ -87,13 +79,11 @@ public class GraphIntegrity {
|
|||
G.getSuccNodes(pred);
|
||||
throw new UnsoundGraphException(pred + " is a predecessor of " + N + " but inverse doesn't hold");
|
||||
}
|
||||
SUCC: for (Iterator<? extends T> s = G.getSuccNodes(N); s.hasNext();) {
|
||||
T succ = s.next();
|
||||
SUCC: for (T succ : Iterator2Iterable.make(G.getSuccNodes(N))) {
|
||||
if (!G.containsNode(succ)) {
|
||||
throw new UnsoundGraphException(succ + " is a successor of " + N + " but is not contained in the graph");
|
||||
}
|
||||
for (Iterator<?> p = G.getPredNodes(succ); p.hasNext();) {
|
||||
Object pred = p.next();
|
||||
for (Object pred : Iterator2Iterable.make(G.getPredNodes(succ))) {
|
||||
if (pred.equals(N)) {
|
||||
continue SUCC;
|
||||
}
|
||||
|
@ -122,21 +112,9 @@ public class GraphIntegrity {
|
|||
}
|
||||
n2++;
|
||||
}
|
||||
n3 = 0;
|
||||
for (Iterator<T> it = new BFSIterator<>(G); it.hasNext();) {
|
||||
it.next();
|
||||
n3++;
|
||||
}
|
||||
n4 = 0;
|
||||
for (Iterator<T> it = DFS.iterateDiscoverTime(G); it.hasNext();) {
|
||||
it.next();
|
||||
n4++;
|
||||
}
|
||||
n5 = 0;
|
||||
for (Iterator<T> it = DFS.iterateFinishTime(G); it.hasNext();) {
|
||||
it.next();
|
||||
n5++;
|
||||
}
|
||||
n3 = IteratorUtil.count(new BFSIterator<>(G));
|
||||
n4 = IteratorUtil.count(DFS.iterateDiscoverTime(G));
|
||||
n5 = IteratorUtil.count(DFS.iterateFinishTime(G));
|
||||
} catch (RuntimeException e) {
|
||||
e.printStackTrace();
|
||||
throw new UnsoundGraphException(e.toString());
|
||||
|
|
|
@ -10,8 +10,7 @@
|
|||
*******************************************************************************/
|
||||
package com.ibm.wala.util.graph;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.graph.impl.SlowSparseNumberedGraph;
|
||||
|
||||
/**
|
||||
|
@ -28,8 +27,7 @@ public class GraphPrint {
|
|||
sg.addNode(name);
|
||||
}
|
||||
for (T n : G) {
|
||||
for (Iterator<? extends T> it2 = G.getSuccNodes(n); it2.hasNext(); ) {
|
||||
T d = it2.next();
|
||||
for (T d : Iterator2Iterable.make(G.getSuccNodes(n))) {
|
||||
sg.addEdge(n,d);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import java.util.Set;
|
|||
|
||||
import com.ibm.wala.util.collections.HashMapFactory;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.collections.NonNullSingletonIterator;
|
||||
import com.ibm.wala.util.graph.Graph;
|
||||
import com.ibm.wala.util.graph.traverse.DFS;
|
||||
|
@ -76,18 +77,15 @@ public class DominanceFrontiers<T> {
|
|||
DF.put(X, DF_X);
|
||||
|
||||
// DF_local
|
||||
for (Iterator<? extends T> YS = G.getSuccNodes(X); YS.hasNext();) {
|
||||
T Y = YS.next();
|
||||
for (T Y : Iterator2Iterable.make(G.getSuccNodes(X))) {
|
||||
if (dom.getIdom(Y) != X) {
|
||||
DF_X.add(Y);
|
||||
}
|
||||
}
|
||||
|
||||
// DF_up
|
||||
for (Iterator<? extends T> ZS = DT.getSuccNodes(X); ZS.hasNext();) {
|
||||
T Z = ZS.next();
|
||||
for (Iterator<T> YS2 = getDominanceFrontier(Z); YS2.hasNext();) {
|
||||
T Y2 = YS2.next();
|
||||
for (T Z : Iterator2Iterable.make(DT.getSuccNodes(X))) {
|
||||
for (T Y2 : Iterator2Iterable.make(getDominanceFrontier(Z))) {
|
||||
if (dom.getIdom(Y2) != X)
|
||||
DF_X.add(Y2);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import java.util.Set;
|
|||
import com.ibm.wala.util.collections.EmptyIterator;
|
||||
import com.ibm.wala.util.collections.HashMapFactory;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.collections.NonNullSingletonIterator;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
import com.ibm.wala.util.graph.AbstractGraph;
|
||||
|
@ -586,8 +587,8 @@ public abstract class Dominators<T> {
|
|||
StringBuffer sb = new StringBuffer();
|
||||
for (T node : G) {
|
||||
sb.append("Dominators of " + node + ":\n");
|
||||
for (Iterator<T> j = dominators(node); j.hasNext();)
|
||||
sb.append(" " + j.next() + "\n");
|
||||
for (T dom : Iterator2Iterable.make(dominators(node)))
|
||||
sb.append(" " + dom + "\n");
|
||||
sb.append("\n");
|
||||
}
|
||||
return sb.toString();
|
||||
|
|
|
@ -11,8 +11,7 @@
|
|||
package com.ibm.wala.util.graph.impl;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.graph.AbstractNumberedGraph;
|
||||
import com.ibm.wala.util.graph.Graph;
|
||||
import com.ibm.wala.util.graph.NumberedEdgeManager;
|
||||
|
@ -77,8 +76,8 @@ public class SlowSparseNumberedGraph<T> extends AbstractNumberedGraph<T> impleme
|
|||
into.addNode(name);
|
||||
}
|
||||
for (T n : g) {
|
||||
for (Iterator<? extends T> it2 = g.getSuccNodes(n); it2.hasNext();) {
|
||||
into.addEdge(n, it2.next());
|
||||
for (T succ : Iterator2Iterable.make(g.getSuccNodes(n))) {
|
||||
into.addEdge(n, succ);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,8 +48,7 @@
|
|||
*/
|
||||
package com.ibm.wala.util.graph.labeled;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.graph.NumberedNodeManager;
|
||||
import com.ibm.wala.util.graph.impl.SlowNumberedNodeManager;
|
||||
|
||||
|
@ -75,8 +74,7 @@ public class SlowSparseNumberedLabeledGraph<T, U> extends AbstractNumberedLabele
|
|||
into.addNode(name);
|
||||
}
|
||||
for (T n : g) {
|
||||
for (Iterator<? extends T> it2 = g.getSuccNodes(n); it2.hasNext();) {
|
||||
T s = it2.next();
|
||||
for (T s : Iterator2Iterable.make(g.getSuccNodes(n))) {
|
||||
for(U l : g.getEdgeLabels(n, s)) {
|
||||
into.addEdge(n, s, l);
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import java.util.Iterator;
|
|||
import java.util.NoSuchElementException;
|
||||
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.collections.NonNullSingletonIterator;
|
||||
import com.ibm.wala.util.debug.UnimplementedError;
|
||||
import com.ibm.wala.util.graph.Graph;
|
||||
|
@ -105,8 +106,7 @@ public class BFSIterator<T> implements Iterator<T> {
|
|||
}
|
||||
|
||||
private void visitChildren(T N) {
|
||||
for (Iterator<? extends T> children = getConnected(N); children.hasNext();) {
|
||||
T child = children.next();
|
||||
for (T child : Iterator2Iterable.make(getConnected(N))) {
|
||||
if (!visited.contains(child)) {
|
||||
Q.add(child);
|
||||
visited.add(child);
|
||||
|
|
|
@ -16,6 +16,7 @@ import java.util.Iterator;
|
|||
import java.util.NoSuchElementException;
|
||||
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.collections.NonNullSingletonIterator;
|
||||
import com.ibm.wala.util.graph.Graph;
|
||||
|
||||
|
@ -127,8 +128,7 @@ public class BoundedBFSIterator<T> implements Iterator<T> {
|
|||
if (boundary[currentHops] == 0) {
|
||||
boundary[currentHops] = Q.size();
|
||||
}
|
||||
for (Iterator<? extends T> children = getConnected(N); children.hasNext();) {
|
||||
T child = children.next();
|
||||
for (T child : Iterator2Iterable.make(getConnected(N))) {
|
||||
if (!visited.contains(child)) {
|
||||
Q.add(child);
|
||||
visited.add(child);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue