Search in sources :

Example 66 with SootClass

use of soot.SootClass in project soot by Sable.

the class JavaTranslator method getTargetsOf.

public List<SootMethod> getTargetsOf(Value v, SootMethod m) {
    SootClass rc;
    Type t = v.getType();
    if (t instanceof ArrayType) {
        rc = Scene.v().getSootClass("java.lang.Object");
    } else {
        rc = ((RefType) v.getType()).getSootClass();
    }
    List<SootMethod> targets = h.resolveAbstractDispatch(rc, m);
    return targets;
}
Also used : ArrayType(soot.ArrayType) RefType(soot.RefType) ArrayType(soot.ArrayType) Type(soot.Type) SootMethod(soot.SootMethod) SootClass(soot.SootClass)

Example 67 with SootClass

use of soot.SootClass in project soot by Sable.

the class JavaTranslator method makeMethods.

void makeMethods() {
    Collection<SootClass> app = Scene.v().getApplicationClasses();
    for (SootClass ac : app) {
        List<SootMethod> sootMethods = ac.getMethods();
        for (SootMethod sm : sootMethods) {
            List<Variable> vars = new LinkedList<Variable>();
            List<Type> params = sm.getParameterTypes();
            for (Type pt : params) {
                Variable v = makeVariable(pt);
                vars.add(v);
            }
            Variable[] var_array = (Variable[]) vars.toArray(new Variable[0]);
            Method m = new Method(sm.getName(), var_array);
            methods.add(m);
            methodsignaturToMethod.put(sm.getSignature(), m);
        }
    }
}
Also used : RefType(soot.RefType) ArrayType(soot.ArrayType) Type(soot.Type) Variable(dk.brics.soot.intermediate.representation.Variable) SootMethod(soot.SootMethod) Method(dk.brics.soot.intermediate.representation.Method) SootMethod(soot.SootMethod) SootClass(soot.SootClass) LinkedList(java.util.LinkedList)

Example 68 with SootClass

use of soot.SootClass in project soot by Sable.

the class PointsToAnalysis method main.

public static void main(String[] args) {
    loadClass("Item", false);
    loadClass("Container", false);
    SootClass c = loadClass(args[1], true);
    soot.Scene.v().loadNecessaryClasses();
    soot.Scene.v().setEntryPoints(EntryPoints.v().all());
    if (args[0].equals("paddle"))
        setPaddlePointsToAnalysis();
    else if (args[0].equals("spark"))
        setSparkPointsToAnalysis();
    SootField f = getField("Container", "item");
    Map /*<Local>*/
    ls = getLocals(c, args[2], "Container");
    printLocalIntersects(ls);
    printFieldIntersects(ls, f);
}
Also used : SootField(soot.SootField) SootClass(soot.SootClass) HashMap(java.util.HashMap) Map(java.util.Map)

Example 69 with SootClass

use of soot.SootClass in project soot by Sable.

the class ExprTranslator method handleSpecialCall.

// any type
boolean handleSpecialCall(InstanceInvokeExpr expr, SootMethod target) {
    String mn = target.getName();
    int np = target.getParameterCount();
    SootClass dc = target.getDeclaringClass();
    // Is it a method in a Foo object?
    if (isFoo(dc)) {
        if (mn.equals("foo") && np == 1) {
            Variable lvar = new Variable(Variable.Type.FOO);
            Method foo = new Method("foo", new Variable[0]);
            FooMethodCall fmc = new FooMethodCall(foo);
            fmc.setAssignmentTarget(lvar);
            st.addStatement(fmc);
            return true;
        }
        // Unknown Foo method
        return false;
    }
    // Not a special call
    return false;
}
Also used : Variable(dk.brics.soot.intermediate.representation.Variable) FooMethodCall(dk.brics.soot.intermediate.representation.FooMethodCall) SootMethod(soot.SootMethod) Method(dk.brics.soot.intermediate.representation.Method) SootClass(soot.SootClass)

Example 70 with SootClass

use of soot.SootClass in project soot by Sable.

the class ExprTranslator method caseSpecialInvokeExpr.

public void caseSpecialInvokeExpr(SpecialInvokeExpr expr) {
    // Constructor calls, maybe
    Variable bvar = st.getLocalVariable((Local) expr.getBase());
    SootMethod m = expr.getMethod();
    if (m.getName().equals("<init>")) {
        SootClass dc = m.getDeclaringClass();
        if (isFoo(dc)) {
            FooInit fi = new FooInit();
            fi.setAssignmentTarget(bvar);
            st.addStatement(fi);
            return;
        }
    }
    handleCall(expr, expr.getMethod());
}
Also used : Variable(dk.brics.soot.intermediate.representation.Variable) SootMethod(soot.SootMethod) FooInit(dk.brics.soot.intermediate.representation.FooInit) SootClass(soot.SootClass)

Aggregations

SootClass (soot.SootClass)194 SootMethod (soot.SootMethod)99 RefType (soot.RefType)69 ArrayList (java.util.ArrayList)60 Type (soot.Type)57 VoidType (soot.VoidType)33 ArrayType (soot.ArrayType)32 Iterator (java.util.Iterator)29 BooleanType (soot.BooleanType)29 DoubleType (soot.DoubleType)29 LongType (soot.LongType)29 Value (soot.Value)29 FloatType (soot.FloatType)28 Local (soot.Local)27 SootField (soot.SootField)27 List (java.util.List)26 CharType (soot.CharType)26 IntType (soot.IntType)26 ByteType (soot.ByteType)25 PrimType (soot.PrimType)23