use of soot.jimple.internal.ImmediateBox in project soot by Sable.
the class ShortcutIfGenerator method inASTStatementSequenceNode.
public void inASTStatementSequenceNode(ASTStatementSequenceNode node) {
for (AugmentedStmt as : node.getStatements()) {
Stmt s = as.get_Stmt();
if (!(s instanceof DefinitionStmt))
continue;
DefinitionStmt ds = (DefinitionStmt) s;
ValueBox rightBox = ds.getRightOpBox();
Value right = rightBox.getValue();
/*
* Going to match int i = (int) z where z is a boolean
* or int i= z i.e. without the cast
*/
// right type should contain the expected type on the left
// in the case of the cast this is the cast type else just get the left type
Type rightType = null;
ValueBox OpBox = null;
if (right instanceof CastExpr) {
rightType = ((CastExpr) right).getCastType();
OpBox = ((CastExpr) right).getOpBox();
} else {
rightType = ds.getLeftOp().getType();
OpBox = rightBox;
}
if (!(rightType instanceof IntType)) {
continue;
}
Value Op = OpBox.getValue();
if (!(Op.getType() instanceof BooleanType)) {
continue;
}
// ready for the switch
ImmediateBox trueBox = new ImmediateBox(IntConstant.v(1));
ImmediateBox falseBox = new ImmediateBox(IntConstant.v(0));
DShortcutIf shortcut = new DShortcutIf(OpBox, trueBox, falseBox);
if (DEBUG)
System.out.println("created: " + shortcut);
rightBox.setValue(shortcut);
}
}
Aggregations