Search in sources :

Example 1 with Variable

use of dk.brics.soot.intermediate.representation.Variable 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 2 with Variable

use of dk.brics.soot.intermediate.representation.Variable 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 3 with Variable

use of dk.brics.soot.intermediate.representation.Variable in project soot by Sable.

the class ExprTranslator method translateExpr.

// Called for any type of value
public void translateExpr(Variable var, ValueBox box) {
    Value val = box.getValue();
    Variable temp = res_var;
    res_var = var;
    val.apply(this);
    res_var = temp;
}
Also used : Variable(dk.brics.soot.intermediate.representation.Variable) Value(soot.Value)

Example 4 with Variable

use of dk.brics.soot.intermediate.representation.Variable 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)

Example 5 with Variable

use of dk.brics.soot.intermediate.representation.Variable in project soot by Sable.

the class StmtTranslator method handleAssign.

void handleAssign(DefinitionStmt stmt) {
    Value lval = stmt.getLeftOp();
    Value rval = stmt.getRightOp();
    Variable rvar;
    if (lval instanceof Local) {
        rvar = getLocalVariable((Local) lval);
    } else {
        rvar = jt.makeVariable(rval);
    }
    et.translateExpr(rvar, stmt.getRightOpBox());
    if (lval instanceof ArrayRef) {
        notSupported("We do not support arrays");
    } else if (lval instanceof FieldRef) {
        notSupported("We do not support field references");
    }
}
Also used : ArrayRef(soot.jimple.ArrayRef) Variable(dk.brics.soot.intermediate.representation.Variable) FieldRef(soot.jimple.FieldRef) Value(soot.Value) Local(soot.Local)

Aggregations

Variable (dk.brics.soot.intermediate.representation.Variable)8 SootClass (soot.SootClass)3 SootMethod (soot.SootMethod)3 Method (dk.brics.soot.intermediate.representation.Method)2 Value (soot.Value)2 FooInit (dk.brics.soot.intermediate.representation.FooInit)1 FooMethodCall (dk.brics.soot.intermediate.representation.FooMethodCall)1 Return (dk.brics.soot.intermediate.representation.Return)1 LinkedList (java.util.LinkedList)1 ArrayType (soot.ArrayType)1 Local (soot.Local)1 RefType (soot.RefType)1 Type (soot.Type)1 ArrayRef (soot.jimple.ArrayRef)1 FieldRef (soot.jimple.FieldRef)1 InvokeExpr (soot.jimple.InvokeExpr)1