Search in sources :

Example 1 with Insn21t

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

the class ExprVisitor method buildComparingBinaryInsn.

private Insn buildComparingBinaryInsn(String binaryOperation, Value firstOperand, Value secondOperand) {
    constantV.setOrigStmt(origStmt);
    Value realFirstOperand = fixNullConstant(firstOperand);
    Value realSecondOperand = fixNullConstant(secondOperand);
    Register firstOpReg = regAlloc.asImmediate(realFirstOperand, constantV);
    // select fitting opcode ("if" or "if-zero")
    InsnWithOffset comparingBinaryInsn;
    String opcodeName = "IF_" + binaryOperation;
    boolean secondOpIsInt = realSecondOperand instanceof IntConstant;
    boolean secondOpIsZero = secondOpIsInt && ((IntConstant) realSecondOperand).value == 0;
    if (secondOpIsZero) {
        Opcode opc = Opcode.valueOf(opcodeName.concat("Z"));
        comparingBinaryInsn = new Insn21t(opc, firstOpReg);
        comparingBinaryInsn.setTarget(targetForOffset);
    } else {
        Opcode opc = Opcode.valueOf(opcodeName);
        Register secondOpReg = regAlloc.asImmediate(realSecondOperand, constantV);
        comparingBinaryInsn = new Insn22t(opc, firstOpReg, secondOpReg);
        comparingBinaryInsn.setTarget(targetForOffset);
    }
    return comparingBinaryInsn;
}
Also used : Insn21t(soot.toDex.instructions.Insn21t) Insn22t(soot.toDex.instructions.Insn22t) Value(soot.Value) InsnWithOffset(soot.toDex.instructions.InsnWithOffset) IntConstant(soot.jimple.IntConstant) Opcode(org.jf.dexlib2.Opcode)

Aggregations

Opcode (org.jf.dexlib2.Opcode)1 Value (soot.Value)1 IntConstant (soot.jimple.IntConstant)1 Insn21t (soot.toDex.instructions.Insn21t)1 Insn22t (soot.toDex.instructions.Insn22t)1 InsnWithOffset (soot.toDex.instructions.InsnWithOffset)1