public MethodOrMethodContext next() { Edge e = edges.next(); return e.getTgt(); }
public boolean hasNext() { if (position.getTgt() != m) { return false; } if (position.kind() == Kind.INVALID) { return false; } return true; }
private Iterator<MethodOrMethodContext> iterator(Set<MethodOrMethodContext> s, ArrayList<MethodOrMethodContext> worklist) { for (int i = 0; i < worklist.size(); i++) { MethodOrMethodContext method = worklist.get(i); Iterator<Edge> it = cg.edgesOutOf(method); if (filter != null) { it = filter.wrap(it); } while (it.hasNext()) { Edge e = (Edge) it.next(); if (s.add(e.getTgt())) { worklist.add(e.getTgt()); } } } return worklist.iterator(); } }
public Iterator<MethodOrMethodContext> iterator(Unit u) { ArrayList<MethodOrMethodContext> methods = new ArrayList<MethodOrMethodContext>(); Iterator<Edge> it = cg.edgesOutOf(u); if (filter != null) { it = filter.wrap(it); } while (it.hasNext()) { Edge e = (Edge) it.next(); methods.add(e.getTgt()); } return iterator(methods.iterator()); }
public Iterator<MethodOrMethodContext> iterator(MethodOrMethodContext momc) { ArrayList<MethodOrMethodContext> methods = new ArrayList<MethodOrMethodContext>(); Iterator<Edge> it = cg.edgesOutOf(momc); if (filter != null) { it = filter.wrap(it); } while (it.hasNext()) { Edge e = (Edge) it.next(); methods.add(e.getTgt()); } return iterator(methods.iterator()); }
@Override public Collection<SootMethod> load(Unit u) throws Exception { ArrayList<SootMethod> res = null; // only retain callers that are explicit call sites or // Thread.start() Iterator<Edge> edgeIter = new EdgeFilter().wrap(cg.edgesOutOf(u)); while (edgeIter.hasNext()) { Edge edge = edgeIter.next(); SootMethod m = edge.getTgt().method(); if (includePhantomCallees || m.hasActiveBody()) { if (res == null) { res = new ArrayList<SootMethod>(); } res.add(m); } else if (IDESolver.DEBUG) { logger.error(String.format("Method %s is referenced but has no body!", m.getSignature(), new Exception())); } } if (res != null) { res.trimToSize(); return res; } else { return Collections.emptySet(); } } };
/** * 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; }
/** * Causes the QueueReader objects to be filled up with any methods that have become reachable since the last call. */ public void update() { while (edgeSource.hasNext()) { Edge e = edgeSource.next(); if (set.contains(e.getSrc())) { addMethod(e.getTgt()); } } while (unprocessedMethods.hasNext()) { MethodOrMethodContext m = unprocessedMethods.next(); Iterator<Edge> targets = cg.edgesOutOf(m); if (filter != null) { targets = filter.wrap(targets); } addMethods(new Targets(targets)); } }
Edge e = (Edge) edges.next(); SootMethod m = e.tgt(); s.addTag(new LinkTag("CallGraph: Type: " + e.kind() + " Target Method/Context: " + e.getTgt().toString(), m, m.getDeclaringClass().getName(), "Call Graph"));
for (Iterator<Edge> edges = cg.edgesOutOf(is); edges.hasNext();) { Edge e = edges.next(); SootMethod target = e.getTgt().method();
/** * 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; }
if (e.getTgt().method().getDeclaringClass().isConcrete()) { if (e.tgt().isConcrete() || e.tgt().isNative()) { MethodPAG.v(pag, e.tgt()).addToPAG(null);
public MethodOrMethodContext next() { Edge e = edges.next(); return e.getTgt(); } public void remove() { throw new UnsupportedOperationException(); }
public boolean hasNext() { if( position.getTgt() != m ) return false; if( position.kind() == Kind.INVALID ) return false; return true; } public Edge next() {
/** 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; }