use of soot.dava.internal.javaRep.DIncrementStmt in project soot by Sable.
the class DecrementIncrementStmtCreation method caseASTStatementSequenceNode.
public void caseASTStatementSequenceNode(ASTStatementSequenceNode node) {
for (AugmentedStmt as : node.getStatements()) {
// System.out.println(temp);
Stmt s = as.get_Stmt();
if (!(s instanceof DefinitionStmt))
continue;
// check if its i= i+1
Value left = ((DefinitionStmt) s).getLeftOp();
Value right = ((DefinitionStmt) s).getRightOp();
if (right instanceof SubExpr) {
Value op1 = ((SubExpr) right).getOp1();
Value op2 = ((SubExpr) right).getOp2();
if (left.toString().compareTo(op1.toString()) != 0) {
// not the same
continue;
}
// check if op2 is a constant with value 1 or -1
if (op2 instanceof IntConstant) {
if (((IntConstant) op2).value == 1) {
// this is i = i-1
DDecrementStmt newStmt = new DDecrementStmt(left, right);
as.set_Stmt(newStmt);
} else if (((IntConstant) op2).value == -1) {
// this is i = i+1
DIncrementStmt newStmt = new DIncrementStmt(left, right);
as.set_Stmt(newStmt);
}
}
} else if (right instanceof AddExpr) {
Value op1 = ((AddExpr) right).getOp1();
Value op2 = ((AddExpr) right).getOp2();
if (left.toString().compareTo(op1.toString()) != 0) {
continue;
}
// check if op2 is a constant with value 1 or -1
if (op2 instanceof IntConstant) {
if (((IntConstant) op2).value == 1) {
// this is i = i+1
DIncrementStmt newStmt = new DIncrementStmt(left, right);
as.set_Stmt(newStmt);
} else if (((IntConstant) op2).value == -1) {
// this is i = i-1
DDecrementStmt newStmt = new DDecrementStmt(left, right);
as.set_Stmt(newStmt);
}
}
}
// right expr was addExpr
}
// going through statements
}
Aggregations