use of org.evosuite.symbolic.expr.fp.RealBinaryExpression in project evosuite by EvoSuite.
the class ATAN2 method executeFunction.
@Override
public Object executeFunction() {
double res = this.getConcDoubleRetVal();
RealValue left = this.getSymbRealArgument(0);
RealValue right = this.getSymbRealArgument(1);
RealValue atan2Expr;
if (left.containsSymbolicVariable() || right.containsSymbolicVariable()) {
Operator op = Operator.ATAN2;
atan2Expr = new RealBinaryExpression(left, op, right, res);
} else {
atan2Expr = this.getSymbRealRetVal();
}
return atan2Expr;
}
use of org.evosuite.symbolic.expr.fp.RealBinaryExpression in project evosuite by EvoSuite.
the class HYPOT method executeFunction.
@Override
public Object executeFunction() {
double res = this.getConcDoubleRetVal();
RealValue left = this.getSymbRealArgument(0);
RealValue right = this.getSymbRealArgument(1);
RealValue hypotExpr;
if (left.containsSymbolicVariable() || right.containsSymbolicVariable()) {
Operator op = Operator.HYPOT;
hypotExpr = new RealBinaryExpression(left, op, right, res);
} else {
hypotExpr = this.getSymbRealRetVal();
}
return hypotExpr;
}
use of org.evosuite.symbolic.expr.fp.RealBinaryExpression in project evosuite by EvoSuite.
the class ArithmeticVM method FSUB.
/**
*/
@Override
public void FSUB() {
RealValue right = env.topFrame().operandStack.popFp32();
RealValue left = env.topFrame().operandStack.popFp32();
float left_concrete_value = ((Double) left.getConcreteValue()).floatValue();
float right_concrete_value = ((Double) right.getConcreteValue()).floatValue();
if (!left.containsSymbolicVariable()) {
left = ExpressionFactory.buildNewRealConstant(left_concrete_value);
}
if (!right.containsSymbolicVariable()) {
right = ExpressionFactory.buildNewRealConstant(right_concrete_value);
}
float con = left_concrete_value - right_concrete_value;
RealValue realExpr = new RealBinaryExpression(left, Operator.MINUS, right, (double) con);
env.topFrame().operandStack.pushFp32(realExpr);
}
use of org.evosuite.symbolic.expr.fp.RealBinaryExpression in project evosuite by EvoSuite.
the class ExpressionFactory method buildAddNormalized.
private static RealValue buildAddNormalized(RealValue right, RealValue left, double con) {
// can only optimize if left is a literal
if (!(left instanceof RealConstant))
return new RealBinaryExpression(left, Operator.PLUS, right, con);
/*
* (add 0 x) --> x
*/
if (((RealConstant) left).getConcreteValue() == 0) {
return right;
}
/*
* (add a b) --> result of a+b
*/
if (right instanceof RealConstant) {
double a = left.getConcreteValue();
double b = right.getConcreteValue();
return buildNewRealConstant(a + b);
}
/*
* (add a (add b x)) --> (add (a+b) x)
*/
if (right instanceof RealBinaryExpression && ((RealBinaryExpression) right).getOperator() == Operator.PLUS) {
RealBinaryExpression add = (RealBinaryExpression) right;
if (add.getLeftOperand() instanceof RealConstant) {
double a = left.getConcreteValue();
double b = add.getLeftOperand().getConcreteValue();
RealConstant a_plus_b = buildNewRealConstant(a + b);
return new RealBinaryExpression(a_plus_b, Operator.PLUS, add.getRightOperand(), con);
}
}
return new RealBinaryExpression(left, Operator.PLUS, right, con);
}
use of org.evosuite.symbolic.expr.fp.RealBinaryExpression in project evosuite by EvoSuite.
the class ArithmeticVM method DSUB.
@Override
public void DSUB() {
RealValue right = env.topFrame().operandStack.popFp64();
RealValue left = env.topFrame().operandStack.popFp64();
double left_concrete_value = ((Double) left.getConcreteValue()).doubleValue();
double right_concrete_value = ((Double) right.getConcreteValue()).doubleValue();
if (!left.containsSymbolicVariable()) {
left = ExpressionFactory.buildNewRealConstant(left_concrete_value);
}
if (!right.containsSymbolicVariable()) {
right = ExpressionFactory.buildNewRealConstant(right_concrete_value);
}
double con = left_concrete_value - right_concrete_value;
RealValue realExpr = new RealBinaryExpression(left, Operator.MINUS, right, con);
env.topFrame().operandStack.pushFp64(realExpr);
}
Aggregations