use of org.evosuite.symbolic.expr.fp.RealValue in project evosuite by EvoSuite.
the class ArithmeticVM method FCMPL.
/**
* http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.
* doc4.html#fcmpop
*/
@Override
public void FCMPL() {
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);
}
int concrete_value;
if (new Double(left_concrete_value).isNaN() || new Double(right_concrete_value).isNaN()) {
concrete_value = 1;
} else if (left_concrete_value == right_concrete_value) {
concrete_value = 0;
} else if (left_concrete_value > right_concrete_value) {
concrete_value = 1;
} else {
assert left_concrete_value < right_concrete_value;
concrete_value = -1;
}
RealComparison ret = new RealComparison(left, right, (long) concrete_value);
env.topFrame().operandStack.pushBv32(ret);
}
use of org.evosuite.symbolic.expr.fp.RealValue in project evosuite by EvoSuite.
the class ArithmeticVM method DMUL.
@Override
public void DMUL() {
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 = ExpressionFactory.mul(left, right, con);
env.topFrame().operandStack.pushFp64(realExpr);
}
use of org.evosuite.symbolic.expr.fp.RealValue in project evosuite by EvoSuite.
the class ArithmeticVM method FADD.
/**
* http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.
* doc4.html#fadd
*/
@Override
public void FADD() {
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 = ExpressionFactory.add(left, right, (double) con);
env.topFrame().operandStack.pushFp32(realExpr);
}
use of org.evosuite.symbolic.expr.fp.RealValue in project evosuite by EvoSuite.
the class ExprToCVC4Visitor method visit.
@Override
public SmtExpr visit(RealBinaryExpression e, Void v) {
SmtExpr left = e.getLeftOperand().accept(this, null);
SmtExpr right = e.getRightOperand().accept(this, null);
if (left == null || right == null) {
return null;
}
if (!left.isSymbolic() && !right.isSymbolic()) {
double doubleValue = e.getConcreteValue();
return SmtExprBuilder.mkRealConstant(doubleValue);
}
switch(e.getOperator()) {
case DIV:
{
if (rewriteNonLinearExpressions) {
if (left.isSymbolic() && right.isSymbolic()) {
RealValue r = (RealValue) e.getRightOperand();
double rightValue = r.getConcreteValue();
SmtExpr conc_right = SmtExprBuilder.mkRealConstant(rightValue);
SmtExpr rewrite_expr = SmtExprBuilder.mkRealDiv(left, conc_right);
return rewrite_expr;
}
}
SmtExpr expr = SmtExprBuilder.mkRealDiv(left, right);
return expr;
}
case MUL:
{
if (rewriteNonLinearExpressions) {
if (left.isSymbolic() && right.isSymbolic()) {
RealValue r = (RealValue) e.getRightOperand();
double rightValue = r.getConcreteValue();
SmtExpr conc_right = SmtExprBuilder.mkRealConstant(rightValue);
SmtExpr rewrite_expr = SmtExprBuilder.mkMul(left, conc_right);
return rewrite_expr;
}
}
SmtExpr expr = SmtExprBuilder.mkMul(left, right);
return expr;
}
case MINUS:
{
SmtExpr expr = SmtExprBuilder.mkSub(left, right);
return expr;
}
case PLUS:
{
SmtExpr expr = SmtExprBuilder.mkAdd(left, right);
return expr;
}
case MAX:
{
SmtExpr left_gt_right = SmtExprBuilder.mkGt(left, right);
SmtExpr ite_expr = SmtExprBuilder.mkITE(left_gt_right, left, right);
return ite_expr;
}
case MIN:
{
SmtExpr left_gt_right = SmtExprBuilder.mkLt(left, right);
SmtExpr ite_expr = SmtExprBuilder.mkITE(left_gt_right, left, right);
return ite_expr;
}
case ATAN2:
case COPYSIGN:
case HYPOT:
case NEXTAFTER:
case POW:
case SCALB:
case IEEEREMAINDER:
case REM:
{
double concreteValue = e.getConcreteValue();
SmtExpr realConstant = createRatNumber(concreteValue);
return realConstant;
}
default:
{
throw new UnsupportedOperationException("Not implemented yet! " + e.getOperator());
}
}
}
use of org.evosuite.symbolic.expr.fp.RealValue in project evosuite by EvoSuite.
the class HeapVM method FASTORE.
@Override
public void FASTORE(Object conc_array, int conc_index) {
// get symbolic arguments
RealValue symb_value = env.topFrame().operandStack.popFp32();
IntegerValue symb_index = env.topFrame().operandStack.popBv32();
ReferenceExpression array_ref = env.topFrame().operandStack.popRef();
/* check reference initialization */
env.heap.initializeReference(conc_array, array_ref);
/* null-check */
if (nullReferenceViolation(array_ref, conc_array)) {
return;
}
/* negative index */
if (negativeIndexViolation(conc_index, symb_index)) {
return;
}
/* out of bound index */
ReferenceExpression symb_array = array_ref;
int conc_array_length = Array.getLength(conc_array);
IntegerValue symb_array_length = env.heap.getField("", ARRAY_LENGTH, conc_array, symb_array, conc_array_length);
if (indexTooBigViolation(conc_index, symb_index, conc_array_length, symb_array_length))
return;
env.heap.array_store(conc_array, symb_array, conc_index, symb_value);
}
Aggregations