Search in sources :

Example 6 with Instruction23x

use of org.jf.dexlib2.iface.instruction.formats.Instruction23x in project soot by Sable.

the class AputInstruction method getTargetType.

@Override
protected Type getTargetType(DexBody body) {
    Instruction23x aPutInstr = (Instruction23x) instruction;
    Type t = body.getRegisterLocal(aPutInstr.getRegisterB()).getType();
    if (t instanceof ArrayType)
        return ((ArrayType) t).getElementType();
    else
        return UnknownType.v();
}
Also used : ArrayType(soot.ArrayType) UnknownType(soot.UnknownType) ArrayType(soot.ArrayType) IntType(soot.IntType) Type(soot.Type) Instruction23x(org.jf.dexlib2.iface.instruction.formats.Instruction23x)

Example 7 with Instruction23x

use of org.jf.dexlib2.iface.instruction.formats.Instruction23x in project soot by Sable.

the class CmpInstruction method jimplify.

@Override
public void jimplify(DexBody body) {
    if (!(instruction instanceof Instruction23x))
        throw new IllegalArgumentException("Expected Instruction23x but got: " + instruction.getClass());
    Instruction23x cmpInstr = (Instruction23x) instruction;
    int dest = cmpInstr.getRegisterA();
    Local first = body.getRegisterLocal(cmpInstr.getRegisterB());
    Local second = body.getRegisterLocal(cmpInstr.getRegisterC());
    // Expr cmpExpr;
    // Type type = null
    Opcode opcode = instruction.getOpcode();
    Expr cmpExpr = null;
    Type type = null;
    switch(opcode) {
        case CMPL_DOUBLE:
            setTag(new DoubleOpTag());
            type = DoubleType.v();
            cmpExpr = Jimple.v().newCmplExpr(first, second);
            break;
        case CMPL_FLOAT:
            setTag(new FloatOpTag());
            type = FloatType.v();
            cmpExpr = Jimple.v().newCmplExpr(first, second);
            break;
        case CMPG_DOUBLE:
            setTag(new DoubleOpTag());
            type = DoubleType.v();
            cmpExpr = Jimple.v().newCmpgExpr(first, second);
            break;
        case CMPG_FLOAT:
            setTag(new FloatOpTag());
            type = FloatType.v();
            cmpExpr = Jimple.v().newCmpgExpr(first, second);
            break;
        case CMP_LONG:
            setTag(new LongOpTag());
            type = LongType.v();
            cmpExpr = Jimple.v().newCmpExpr(first, second);
            break;
        default:
            throw new RuntimeException("no opcode for CMP: " + opcode);
    }
    AssignStmt assign = Jimple.v().newAssignStmt(body.getRegisterLocal(dest), cmpExpr);
    assign.addTag(getTag());
    setUnit(assign);
    addTags(assign);
    body.add(assign);
    if (IDalvikTyper.ENABLE_DVKTYPER) {
        getTag().getName();
        BinopExpr bexpr = (BinopExpr) cmpExpr;
        DalvikTyper.v().setType(bexpr.getOp1Box(), type, true);
        DalvikTyper.v().setType(bexpr.getOp2Box(), type, true);
        DalvikTyper.v().setType(((JAssignStmt) assign).leftBox, IntType.v(), false);
    }
}
Also used : JAssignStmt(soot.jimple.internal.JAssignStmt) AssignStmt(soot.jimple.AssignStmt) Local(soot.Local) Opcode(org.jf.dexlib2.Opcode) LongOpTag(soot.dexpler.tags.LongOpTag) FloatOpTag(soot.dexpler.tags.FloatOpTag) DoubleOpTag(soot.dexpler.tags.DoubleOpTag) DoubleType(soot.DoubleType) FloatType(soot.FloatType) IntType(soot.IntType) Type(soot.Type) LongType(soot.LongType) Expr(soot.jimple.Expr) BinopExpr(soot.jimple.BinopExpr) Instruction23x(org.jf.dexlib2.iface.instruction.formats.Instruction23x) BinopExpr(soot.jimple.BinopExpr)

Aggregations

Instruction23x (org.jf.dexlib2.iface.instruction.formats.Instruction23x)5 Local (soot.Local)4 AssignStmt (soot.jimple.AssignStmt)4 IntType (soot.IntType)2 Type (soot.Type)2 ObjectOpTag (soot.dexpler.tags.ObjectOpTag)2 ArrayRef (soot.jimple.ArrayRef)2 Opcode (org.jf.dexlib2.Opcode)1 ExceptionHandler (org.jf.dexlib2.iface.ExceptionHandler)1 MethodImplementation (org.jf.dexlib2.iface.MethodImplementation)1 Instruction (org.jf.dexlib2.iface.instruction.Instruction)1 OneRegisterInstruction (org.jf.dexlib2.iface.instruction.OneRegisterInstruction)1 ReferenceInstruction (org.jf.dexlib2.iface.instruction.ReferenceInstruction)1 StringReference (org.jf.dexlib2.iface.reference.StringReference)1 SmaliClass (org.jf.smalidea.psi.impl.SmaliClass)1 SmaliFile (org.jf.smalidea.psi.impl.SmaliFile)1 SmaliMethod (org.jf.smalidea.psi.impl.SmaliMethod)1 ExceptionWithContext (org.jf.util.ExceptionWithContext)1 ArrayType (soot.ArrayType)1 DoubleType (soot.DoubleType)1