use of soot.jimple.IfStmt in project soot by Sable.
the class IfTestzInstruction method ifStatement.
@Override
protected IfStmt ifStatement(DexBody body) {
Instruction21t i = (Instruction21t) instruction;
BinopExpr condition = getComparisonExpr(body, i.getRegisterA());
IfStmt jif = Jimple.v().newIfStmt(condition, targetInstruction.getUnit());
// setUnit() is called in ConditionalJumpInstruction
addTags(jif);
if (IDalvikTyper.ENABLE_DVKTYPER) {
// Debug.printDbg(IDalvikTyper.DEBUG, "constraint: "+ jif);
/*
int op = instruction.getOpcode().value;
switch (op) {
case 0x38:
case 0x39:
//DalvikTyper.v().addConstraint(condition.getOp1Box(), condition.getOp2Box());
break;
case 0x3a:
case 0x3b:
case 0x3c:
case 0x3d:
DalvikTyper.v().setType(condition.getOp1Box(), BooleanType.v(), true);
break;
default:
throw new RuntimeException("error: unknown op: 0x"+ Integer.toHexString(op));
}
*/
}
return jif;
}
use of soot.jimple.IfStmt in project soot by Sable.
the class UnitThrowAnalysisTest method testJIfStmt.
@Test
public void testJIfStmt() {
IfStmt s = Jimple.v().newIfStmt(Jimple.v().newEqExpr(IntConstant.v(1), IntConstant.v(1)), (Unit) null);
// A very tight infinite loop.
s.setTarget(s);
assertTrue(ExceptionTestUtility.sameMembers(utility.VM_ERRORS, Collections.EMPTY_SET, unitAnalysis.mightThrow(s)));
assertEquals(utility.VM_ERRORS_PLUS_SUPERTYPES, utility.catchableSubset(unitAnalysis.mightThrow(s)));
}
use of soot.jimple.IfStmt in project soot by Sable.
the class UnitThrowAnalysisTest method testGIfStmt.
@Test
public void testGIfStmt() {
IfStmt s = Grimp.v().newIfStmt(Grimp.v().newEqExpr(IntConstant.v(1), IntConstant.v(1)), (Unit) null);
// A very tight infinite loop.
s.setTarget(s);
assertTrue(ExceptionTestUtility.sameMembers(utility.VM_ERRORS, Collections.EMPTY_SET, unitAnalysis.mightThrow(s)));
assertEquals(utility.VM_ERRORS_PLUS_SUPERTYPES, utility.catchableSubset(unitAnalysis.mightThrow(s)));
}
use of soot.jimple.IfStmt in project soot by Sable.
the class DexIfTransformer method getNullIfCandidates.
/**
* Collect all the if statements comparing two locals with an Eq or Ne
* expression
*
* @param body
* the body to analyze
*/
private Set<IfStmt> getNullIfCandidates(Body body) {
Set<IfStmt> candidates = new HashSet<IfStmt>();
Iterator<Unit> i = body.getUnits().iterator();
while (i.hasNext()) {
Unit u = i.next();
if (u instanceof IfStmt) {
ConditionExpr expr = (ConditionExpr) ((IfStmt) u).getCondition();
boolean isTargetIf = false;
if (((expr instanceof EqExpr) || (expr instanceof NeExpr))) {
if (expr.getOp1() instanceof Local && expr.getOp2() instanceof Local) {
isTargetIf = true;
}
}
if (isTargetIf) {
candidates.add((IfStmt) u);
}
}
}
return candidates;
}
use of soot.jimple.IfStmt in project soot by Sable.
the class DexJumpChainShortener method internalTransform.
@Override
protected void internalTransform(Body b, String phaseName, Map<String, String> options) {
for (Iterator<Unit> unitIt = b.getUnits().snapshotIterator(); unitIt.hasNext(); ) {
Unit u = unitIt.next();
if (u instanceof GotoStmt) {
GotoStmt stmt = (GotoStmt) u;
while (stmt.getTarget() instanceof GotoStmt) {
GotoStmt nextTarget = (GotoStmt) stmt.getTarget();
stmt.setTarget(nextTarget.getTarget());
}
} else if (u instanceof IfStmt) {
IfStmt stmt = (IfStmt) u;
while (stmt.getTarget() instanceof GotoStmt) {
GotoStmt nextTarget = (GotoStmt) stmt.getTarget();
stmt.setTarget(nextTarget.getTarget());
}
}
}
}
Aggregations