Example #1
0
  /**
   * Given an abstract dispatch to an object of type c and a method m, gives a list of possible
   * receiver methods.
   */
  public List resolveAbstractDispatch(SootClass c, SootMethod m) {
    c.checkLevel(SootClass.HIERARCHY);
    m.getDeclaringClass().checkLevel(SootClass.HIERARCHY);
    checkState();

    Iterator<SootClass> classesIt = null;

    if (c.isInterface()) {
      classesIt = getImplementersOf(c).iterator();
      HashSet<SootClass> classes = new HashSet<SootClass>();
      while (classesIt.hasNext()) classes.addAll(getSubclassesOfIncluding(classesIt.next()));
      classesIt = classes.iterator();
    } else classesIt = getSubclassesOfIncluding(c).iterator();

    ArraySet s = new ArraySet();

    while (classesIt.hasNext()) {
      SootClass cl = classesIt.next();
      if (Modifier.isAbstract(cl.getModifiers())) continue;
      s.add(resolveConcreteDispatch(cl, m));
    }

    List l = new ArrayList();
    l.addAll(s);
    return Collections.unmodifiableList(l);
  }
Example #2
0
  /** Returns a list of possible targets for the given method and set of receiver types. */
  public List resolveAbstractDispatch(List classes, SootMethod m) {
    m.getDeclaringClass().checkLevel(SootClass.HIERARCHY);
    ArraySet s = new ArraySet();
    Iterator classesIt = classes.iterator();

    while (classesIt.hasNext()) s.addAll(resolveAbstractDispatch((SootClass) classesIt.next(), m));

    List l = new ArrayList();
    l.addAll(s);
    return Collections.unmodifiableList(l);
  }
Example #3
0
  /** Given a set of definite receiver types, returns a list of possible targets. */
  public List resolveConcreteDispatch(List classes, SootMethod m) {
    m.getDeclaringClass().checkLevel(SootClass.HIERARCHY);
    checkState();

    ArraySet s = new ArraySet();
    Iterator classesIt = classes.iterator();

    while (classesIt.hasNext()) {
      Object cls = classesIt.next();
      if (cls instanceof RefType) s.add(resolveConcreteDispatch(((RefType) cls).getSootClass(), m));
      else if (cls instanceof ArrayType) {
        s.add(resolveConcreteDispatch((RefType.v("java.lang.Object")).getSootClass(), m));
      } else throw new RuntimeException("Unable to resolve concrete dispatch of type " + cls);
    }

    List l = new ArrayList();
    l.addAll(s);
    return Collections.unmodifiableList(l);
  }
Example #4
0
  /** Returns a list of implementers of c, excluding itself. */
  public List<SootClass> getImplementersOf(SootClass i) {
    i.checkLevel(SootClass.HIERARCHY);
    if (!i.isInterface()) throw new RuntimeException("interface needed; got " + i);

    checkState();

    Iterator<SootClass> it = getSubinterfacesOfIncluding(i).iterator();
    ArraySet set = new ArraySet();

    while (it.hasNext()) {
      SootClass c = it.next();

      set.addAll(getDirectImplementersOf(c));
    }

    ArrayList l = new ArrayList();
    l.addAll(set);

    return Collections.unmodifiableList(l);
  }
Example #5
0
 /**
  * Report the facet opposite vertex.
  *
  * @param vertex a vertex of this Triangle
  * @return the facet opposite vertex
  * @throws IllegalArgumentException if the vertex is not in triangle
  */
 public ArraySet<Pnt> facetOpposite(Pnt vertex) {
   ArraySet<Pnt> facet = new ArraySet<Pnt>(this);
   if (!facet.remove(vertex)) throw new IllegalArgumentException("Vertex not in triangle");
   return facet;
 }