use of soot.dava.internal.javaRep.DCmpgExpr in project soot by Sable.
the class SimplifyExpressions method getResult.
public NumericConstant getResult(BinopExpr binop) {
if (DEBUG)
System.out.println("Binop expr" + binop);
Value leftOp = binop.getOp1();
Value rightOp = binop.getOp2();
int op = 0;
if (binop instanceof AddExpr) {
op = 1;
} else if (binop instanceof SubExpr || binop instanceof DCmpExpr || binop instanceof DCmpgExpr || binop instanceof DCmplExpr) {
op = 2;
} else if (binop instanceof MulExpr) {
op = 3;
}
if (op == 0) {
if (DEBUG) {
System.out.println("not add sub or mult");
System.out.println(binop.getClass().getName());
}
return null;
}
NumericConstant constant = null;
if (leftOp instanceof LongConstant && rightOp instanceof LongConstant) {
if (DEBUG)
System.out.println("long constants!!");
if (op == 1)
constant = ((LongConstant) leftOp).add((LongConstant) rightOp);
else if (op == 2)
constant = ((LongConstant) leftOp).subtract((LongConstant) rightOp);
else if (op == 3)
constant = ((LongConstant) leftOp).multiply((LongConstant) rightOp);
} else if (leftOp instanceof DoubleConstant && rightOp instanceof DoubleConstant) {
if (DEBUG)
System.out.println("double constants!!");
if (op == 1)
constant = ((DoubleConstant) leftOp).add((DoubleConstant) rightOp);
else if (op == 2)
constant = ((DoubleConstant) leftOp).subtract((DoubleConstant) rightOp);
else if (op == 3)
constant = ((DoubleConstant) leftOp).multiply((DoubleConstant) rightOp);
} else if (leftOp instanceof FloatConstant && rightOp instanceof FloatConstant) {
if (DEBUG)
System.out.println("Float constants!!");
if (op == 1)
constant = ((FloatConstant) leftOp).add((FloatConstant) rightOp);
else if (op == 2)
constant = ((FloatConstant) leftOp).subtract((FloatConstant) rightOp);
else if (op == 3)
constant = ((FloatConstant) leftOp).multiply((FloatConstant) rightOp);
} else if (leftOp instanceof IntConstant && rightOp instanceof IntConstant) {
if (DEBUG)
System.out.println("Integer constants!!");
if (op == 1)
constant = ((IntConstant) leftOp).add((IntConstant) rightOp);
else if (op == 2)
constant = ((IntConstant) leftOp).subtract((IntConstant) rightOp);
else if (op == 3)
constant = ((IntConstant) leftOp).multiply((IntConstant) rightOp);
}
return constant;
}
use of soot.dava.internal.javaRep.DCmpgExpr in project soot by Sable.
the class DavaBody method javafy_binop_expr.
private void javafy_binop_expr(ValueBox vb) {
BinopExpr boe = (BinopExpr) vb.getValue();
ValueBox leftOpBox = boe.getOp1Box(), rightOpBox = boe.getOp2Box();
Value leftOp = leftOpBox.getValue(), rightOp = rightOpBox.getValue();
if (rightOp instanceof IntConstant) {
if ((leftOp instanceof IntConstant) == false) {
javafy(leftOpBox);
leftOp = leftOpBox.getValue();
if (boe instanceof ConditionExpr)
rightOpBox.setValue(DIntConstant.v(((IntConstant) rightOp).value, leftOp.getType()));
else
rightOpBox.setValue(DIntConstant.v(((IntConstant) rightOp).value, null));
}
} else if (leftOp instanceof IntConstant) {
javafy(rightOpBox);
rightOp = rightOpBox.getValue();
if (boe instanceof ConditionExpr)
leftOpBox.setValue(DIntConstant.v(((IntConstant) leftOp).value, rightOp.getType()));
else
leftOpBox.setValue(DIntConstant.v(((IntConstant) leftOp).value, null));
} else {
javafy(rightOpBox);
rightOp = rightOpBox.getValue();
javafy(leftOpBox);
leftOp = leftOpBox.getValue();
}
if (boe instanceof CmpExpr)
vb.setValue(new DCmpExpr(leftOp, rightOp));
else if (boe instanceof CmplExpr)
vb.setValue(new DCmplExpr(leftOp, rightOp));
else if (boe instanceof CmpgExpr)
vb.setValue(new DCmpgExpr(leftOp, rightOp));
}
Aggregations