use of soot.toDex.instructions.Insn22t 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;
}
Aggregations