Example #1
0
 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;
       }
     }
   }
 }
Example #2
0
 /*
  * @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));
         }
       }
     }
   }
 }
Example #3
0
 public void clearAllTargets() {
   targets.clear();
   allTargets.clear();
 }