public Object next() { Edge e = (Edge) edges.next(); return e.srcUnit(); }
public boolean hasNext() { if (position.srcUnit() != u) { return false; } if (position.kind() == Kind.INVALID) { return false; } return true; }
@Override public Collection<Unit> load(SootMethod m) throws Exception { ArrayList<Unit> res = new ArrayList<Unit>(); // only retain callers that are explicit call sites or // Thread.start() Iterator<Edge> edgeIter = new EdgeFilter().wrap(cg.edgesInto(m)); while (edgeIter.hasNext()) { Edge edge = edgeIter.next(); res.add(edge.srcUnit()); } res.trimToSize(); return res; } };
/** * Find the specific call edge that is going out from the callsite u and the call target is callee. Without advanced data * structure, we can only sequentially search for the match. Fortunately, the number of outgoing edges for a unit is not * too large. * * @param u * @param callee * @return */ public Edge findEdge(Unit u, SootMethod callee) { Edge e = srcUnitToEdge.get(u); while (e.srcUnit() == u && e.kind() != Kind.INVALID) { if (e.tgt() == callee) { return e; } e = e.nextByUnit(); } return null; }
private void processNewMethodContext(MethodOrMethodContext momc) { SootMethod m = momc.method(); Iterator<Edge> it = cicg.edgesOutOf(m); while (it.hasNext()) { Edge e = it.next(); cm.addStaticEdge(momc, e.srcUnit(), e.tgt(), e.kind()); } }
/** * Used to add an edge to the call graph. Returns true iff the edge was not already present. */ public boolean addEdge(Edge e) { if (!edges.add(e)) { return false; } stream.add(e); Edge position = null; position = srcUnitToEdge.get(e.srcUnit()); if (position == null) { srcUnitToEdge.put(e.srcUnit(), e); position = dummy; } e.insertAfterByUnit(position); position = srcMethodToEdge.get(e.getSrc()); if (position == null) { srcMethodToEdge.put(e.getSrc(), e); position = dummy; } e.insertAfterBySrc(position); position = tgtToEdge.get(e.getTgt()); if (position == null) { tgtToEdge.put(e.getTgt(), e); position = dummy; } e.insertAfterByTgt(position); return true; }
/** * Removes the edge e from the call graph. Returns true iff the edge was originally present in the call graph. */ public boolean removeEdge(Edge e) { if (!edges.remove(e)) { return false; } srcMap.remove(e.getSrc(), e); tgtMap.remove(e.getTgt(), e); unitMap.remove(e.srcUnit(), e); return true; }
/** * Used to add an edge to the call graph. Returns true iff the edge was not already present. */ public boolean addEdge(Edge e) { if (!edges.add(e)) { return false; } stream.add(e); srcMap.put(e.getSrc(), e); tgtMap.put(e.getTgt(), e); unitMap.put(e.srcUnit(), e); return true; }
/** * Removes all outgoing edges that start at the given unit * * @param u * The unit from which to remove all outgoing edges * @return True if at least one edge has been removed, otherwise false */ public boolean removeAllEdgesOutOf(Unit u) { boolean hasRemoved = false; for (QueueReader<Edge> edgeRdr = listener(); edgeRdr.hasNext();) { Edge e = edgeRdr.next(); if (e.srcUnit() == u) { removeEdge(e); hasRemoved = true; } } return hasRemoved; }
/** * Swaps an invocation statement. All edges that previously went from the given statement to some callee now go from the * new statement to the same callee. This method is intended to be used when a Jimple statement is replaced, but the * replacement does not semantically affect the edges. * * @param out * The old statement * @param in * The new statement * @return True if at least one edge was affected by this operation */ public boolean swapEdgesOutOf(Stmt out, Stmt in) { boolean hasSwapped = false; for (QueueReader<Edge> edgeRdr = listener(); edgeRdr.hasNext();) { Edge e = edgeRdr.next(); if (e.srcUnit() == out) { removeEdge(e); addEdge(new Edge(e.getSrc(), in, e.getTgt())); hasSwapped = true; } } return hasSwapped; }
addCallTarget(srcmpag, tgtmpag, (Stmt) e.srcUnit(), e.srcCtxt(), e.tgtCtxt(), e); } else if (e.kind() == Kind.EXECUTOR) { InvokeExpr ie = e.srcStmt().getInvokeExpr(); callToMethod.put(ie, srcmpag.getMethod()); if (e.srcUnit() instanceof AssignStmt) { AssignStmt as = (AssignStmt) e.srcUnit(); pval = addInterproceduralAssignment(srcThis, tgtThis, e); } else if (e.kind() == Kind.NEWINSTANCE) { Stmt s = (Stmt) e.srcUnit(); InstanceInvokeExpr iie = (InstanceInvokeExpr) s.getInvokeExpr(); if (e.srcUnit() instanceof AssignStmt && (tgt.getReturnType() instanceof RefLikeType)) { AssignStmt as = (AssignStmt) e.srcUnit(); Stmt s = (Stmt) e.srcUnit(); InstanceInvokeExpr iie = (InstanceInvokeExpr) s.getInvokeExpr();
public Object next() { Edge e = (Edge) edges.next(); return e.srcUnit(); } public void remove() { throw new UnsupportedOperationException(); }
public boolean hasNext() { if( position.srcUnit() != u ) return false; if( position.kind() == Kind.INVALID ) return false; return true; } public Edge next() {
public boolean hasNext() { if( position.srcUnit() != u ) return false; if( position.kind() == Kind.INVALID ) return false; return true; } public Edge next() {
private void processNewMethodContext( MethodOrMethodContext momc ) { SootMethod m = momc.method(); Object ctxt = momc.context(); Iterator it = cicg.edgesOutOf(m); while( it.hasNext() ) { Edge e = (Edge) it.next(); cm.addStaticEdge( momc, e.srcUnit(), e.tgt(), e.kind() ); } }
private void processNewMethodContext( MethodOrMethodContext momc ) { SootMethod m = momc.method(); Object ctxt = momc.context(); Iterator it = cicg.edgesOutOf(m); while( it.hasNext() ) { Edge e = (Edge) it.next(); cm.addStaticEdge( momc, e.srcUnit(), e.tgt(), e.kind() ); } }
/** Removes the edge e from the call graph. Returns true iff the edge * was originally present in the call graph. */ public boolean removeEdge( Edge e ) { if( !edges.remove( e ) ) return false; srcMap.remove(e.getSrc(), e); tgtMap.remove(e.getTgt(), e); unitMap.remove(e.srcUnit(), e); return true; }
/** Removes the edge e from the call graph. Returns true iff the edge * was originally present in the call graph. */ public boolean removeEdge( Edge e ) { if( !edges.remove( e ) ) return false; srcMap.remove(e.getSrc(), e); tgtMap.remove(e.getTgt(), e); unitMap.remove(e.srcUnit(), e); return true; }