/* * @see com.ibm.wala.ipa.callgraph.impl.BasicCallGraph.NodeImpl#removeTarget(com.ibm.wala.ipa.callgraph.CGNode) */ public void removeTarget(CGNode target) { allTargets.remove(getCallGraph().getNumber(target)); for (IntIterator it = targets.safeIterateIndices(); it.hasNext(); ) { int pc = it.next(); Object value = targets.get(pc); if (value instanceof CGNode) { if (value.equals(target)) { targets.remove(pc); } } else { MutableIntSet s = (MutableIntSet) value; int n = getCallGraph().getNumber(target); if (s.size() > 2) { s.remove(n); } else { assert s.size() == 2; if (s.contains(n)) { s.remove(n); int i = s.intIterator().next(); targets.set(pc, getCallGraph().getNode(i)); } } } } }
protected boolean addTarget(int pc, CGNode tNode) { allTargets.add(getCallGraph().getNumber(tNode)); Object S = targets.get(pc); if (S == null) { S = tNode; targets.set(pc, S); getCallGraph().addEdge(this, tNode); return true; } else { if (S instanceof CGNode) { if (S.equals(tNode)) { return false; } else { MutableSharedBitVectorIntSet s = new MutableSharedBitVectorIntSet(); s.add(getCallGraph().getNumber((CGNode) S)); s.add(getCallGraph().getNumber(tNode)); getCallGraph().addEdge(this, tNode); targets.set(pc, s); return true; } } else { MutableIntSet s = (MutableIntSet) S; int n = getCallGraph().getNumber(tNode); if (!s.contains(n)) { s.add(n); getCallGraph().addEdge(this, tNode); return true; } else { return false; } } } }
protected IntSet getPossibleTargetNumbers(CallSiteReference site) { Object t = targets.get(site.getProgramCounter()); if (t == null) { return null; } else if (t instanceof CGNode) { return SparseIntSet.singleton(getCallGraph().getNumber((CGNode) t)); } else { return (IntSet) t; } }
protected int getNumberOfTargets(CallSiteReference site) { Object result = targets.get(site.getProgramCounter()); if (result == null) { return 0; } else if (result instanceof CGNode) { return 1; } else { return ((IntSet) result).size(); } }
protected Set<CGNode> getPossibleTargets(CallSiteReference site) { Object result = targets.get(site.getProgramCounter()); if (result == null) { return Collections.emptySet(); } else if (result instanceof CGNode) { Set<CGNode> s = Collections.singleton((CGNode) result); return s; } else { IntSet s = (IntSet) result; HashSet<CGNode> h = HashSetFactory.make(s.size()); for (IntIterator it = s.intIterator(); it.hasNext(); ) { h.add(getCallGraph().getNode(it.next())); } return h; } }