use of org.evosuite.symbolic.expr.bv.RealComparison 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.bv.RealComparison in project evosuite by EvoSuite.
the class ConstraintNormalizer method createRealConstraint.
private static Constraint<?> createRealConstraint(IntegerConstraint c) {
if (c.getLeftOperand() instanceof RealComparison) {
RealComparison cmp = (RealComparison) c.getLeftOperand();
int value = ((Number) c.getRightOperand().getConcreteValue()).intValue();
Comparator op = c.getComparator();
Expression<Double> cmp_left = cmp.getLeftOperant();
Expression<Double> cmp_right = cmp.getRightOperant();
return createRealConstraint(cmp_left, op, cmp_right, value);
} else {
assert (c.getRightOperand() instanceof RealComparison);
RealComparison cmp = (RealComparison) c.getRightOperand();
Comparator op = c.getComparator();
Comparator swap_op = op.swap();
int value = ((Number) c.getLeftOperand().getConcreteValue()).intValue();
int swap_value = -value;
Expression<Double> cmp_left = cmp.getLeftOperant();
Expression<Double> cmp_right = cmp.getRightOperant();
return createRealConstraint(cmp_left, swap_op, cmp_right, swap_value);
}
}
use of org.evosuite.symbolic.expr.bv.RealComparison in project evosuite by EvoSuite.
the class ArithmeticVM method DCMPL.
/**
* http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.
* doc3.html#dcmpop
*/
@Override
public void DCMPL() {
RealValue right = env.topFrame().operandStack.popFp64();
RealValue left = env.topFrame().operandStack.popFp64();
double left_concrete_value = (Double) left.getConcreteValue();
double right_concrete_value = (Double) right.getConcreteValue();
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);
}
Aggregations