Search in sources :

Example 1 with Insn31t

use of soot.toDex.instructions.Insn31t in project soot by Sable.

the class StmtVisitor method buildSwitchInsn.

private Insn buildSwitchInsn(Opcode opc, Value key, Stmt defaultTarget, SwitchPayload payload, Stmt stmt) {
    Register keyReg = regAlloc.asImmediate(key, constantV);
    Insn31t switchInsn = new Insn31t(opc, keyReg);
    switchInsn.setPayload(payload);
    payload.setSwitchInsn(switchInsn);
    addInsn(switchInsn, stmt);
    // switch instruction
    return buildGotoInsn(defaultTarget);
}
Also used : Insn31t(soot.toDex.instructions.Insn31t)

Example 2 with Insn31t

use of soot.toDex.instructions.Insn31t in project soot by Sable.

the class StmtVisitor method buildArrayFillInsn.

private Insn buildArrayFillInsn(ArrayRef destRef, List<Value> values) {
    Local array = (Local) destRef.getBase();
    Register arrayReg = regAlloc.asLocal(array);
    // Convert the list of values into a list of numbers
    int elementSize = 0;
    List<Number> numbers = new ArrayList<Number>(values.size());
    for (Value val : values) {
        if (val instanceof IntConstant) {
            elementSize = Math.max(elementSize, 4);
            numbers.add(((IntConstant) val).value);
        } else if (val instanceof LongConstant) {
            elementSize = Math.max(elementSize, 8);
            numbers.add(((LongConstant) val).value);
        } else if (val instanceof FloatConstant) {
            elementSize = Math.max(elementSize, 4);
            numbers.add(((FloatConstant) val).value);
        } else if (val instanceof DoubleConstant) {
            elementSize = Math.max(elementSize, 8);
            numbers.add(((DoubleConstant) val).value);
        } else
            return null;
    }
    // For some local types, we know the size upfront
    if (destRef.getType() instanceof BooleanType)
        elementSize = 1;
    else if (destRef.getType() instanceof ByteType)
        elementSize = 1;
    else if (destRef.getType() instanceof CharType)
        elementSize = 2;
    else if (destRef.getType() instanceof ShortType)
        elementSize = 2;
    else if (destRef.getType() instanceof IntType)
        elementSize = 4;
    else if (destRef.getType() instanceof FloatType)
        elementSize = 4;
    else if (destRef.getType() instanceof LongType)
        elementSize = 8;
    else if (destRef.getType() instanceof DoubleType)
        elementSize = 8;
    ArrayDataPayload payload = new ArrayDataPayload(elementSize, numbers);
    payloads.add(payload);
    Insn31t insn = new Insn31t(Opcode.FILL_ARRAY_DATA, arrayReg);
    insn.setPayload(payload);
    return insn;
}
Also used : LongConstant(soot.jimple.LongConstant) DoubleConstant(soot.jimple.DoubleConstant) LongType(soot.LongType) FloatConstant(soot.jimple.FloatConstant) ShortType(soot.ShortType) ArrayList(java.util.ArrayList) BooleanType(soot.BooleanType) Local(soot.Local) ByteType(soot.ByteType) IntType(soot.IntType) FloatType(soot.FloatType) ArrayDataPayload(soot.toDex.instructions.ArrayDataPayload) Insn31t(soot.toDex.instructions.Insn31t) DoubleType(soot.DoubleType) Value(soot.Value) IntConstant(soot.jimple.IntConstant) CharType(soot.CharType)

Aggregations

Insn31t (soot.toDex.instructions.Insn31t)2 ArrayList (java.util.ArrayList)1 BooleanType (soot.BooleanType)1 ByteType (soot.ByteType)1 CharType (soot.CharType)1 DoubleType (soot.DoubleType)1 FloatType (soot.FloatType)1 IntType (soot.IntType)1 Local (soot.Local)1 LongType (soot.LongType)1 ShortType (soot.ShortType)1 Value (soot.Value)1 DoubleConstant (soot.jimple.DoubleConstant)1 FloatConstant (soot.jimple.FloatConstant)1 IntConstant (soot.jimple.IntConstant)1 LongConstant (soot.jimple.LongConstant)1 ArrayDataPayload (soot.toDex.instructions.ArrayDataPayload)1