Search in sources :

Example 11 with AnySubType

use of soot.AnySubType in project soot by Sable.

the class TypeManager method get.

public final BitVector get(Type type) {
    if (type == null)
        return null;
    while (allocNodeListener.hasNext()) {
        AllocNode n = allocNodeListener.next();
        for (final Type t : Scene.v().getTypeNumberer()) {
            if (!(t instanceof RefLikeType))
                continue;
            if (t instanceof AnySubType)
                continue;
            if (isUnresolved(t))
                continue;
            if (castNeverFails(n.getType(), t)) {
                BitVector mask = typeMask.get(t);
                if (mask == null) {
                    typeMask.put(t, mask = new BitVector());
                    for (final AllocNode an : pag.getAllocNodeNumberer()) {
                        if (castNeverFails(an.getType(), t)) {
                            mask.set(an.getNumber());
                        }
                    }
                    continue;
                }
                mask.set(n.getNumber());
            }
        }
    }
    BitVector ret = (BitVector) typeMask.get(type);
    if (ret == null && fh != null) {
        // If we have a phantom class and have no type mask, we assume that
        // it is not cast-compatible to anything
        SootClass curClass = ((RefType) type).getSootClass();
        if (type instanceof RefType && curClass.isPhantom())
            return new BitVector();
        else {
            // Scan through the hierarchy. We might have a phantom class higher up
            while (curClass.hasSuperclass()) {
                curClass = curClass.getSuperclass();
                if (type instanceof RefType && curClass.isPhantom())
                    return new BitVector();
            }
            throw new RuntimeException("Type mask not found for type " + type);
        }
    }
    return ret;
}
Also used : RefLikeType(soot.RefLikeType) RefType(soot.RefType) BitVector(soot.util.BitVector) RefType(soot.RefType) AnySubType(soot.AnySubType) NullType(soot.NullType) RefLikeType(soot.RefLikeType) ArrayType(soot.ArrayType) Type(soot.Type) AllocNode(soot.jimple.spark.pag.AllocNode) AnySubType(soot.AnySubType) SootClass(soot.SootClass)

Aggregations

AnySubType (soot.AnySubType)11 RefType (soot.RefType)10 RefLikeType (soot.RefLikeType)9 ArrayType (soot.ArrayType)5 FastHierarchy (soot.FastHierarchy)5 HashSet (java.util.HashSet)4 Type (soot.Type)4 AllocNode (soot.jimple.spark.pag.AllocNode)4 Iterator (java.util.Iterator)2 NullType (soot.NullType)2 SootClass (soot.SootClass)2 SootMethod (soot.SootMethod)2 Node (soot.jimple.spark.pag.Node)2 BitVector (soot.util.BitVector)2 Set (java.util.Set)1 Test (org.junit.Test)1 Local (soot.Local)1 ArrayRef (soot.jimple.ArrayRef)1 IfStmt (soot.jimple.IfStmt)1 Stmt (soot.jimple.Stmt)1