Search in sources :

Example 1 with RealComparison

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);
}
Also used : RealValue(org.evosuite.symbolic.expr.fp.RealValue) RealComparison(org.evosuite.symbolic.expr.bv.RealComparison) IntegerConstraint(org.evosuite.symbolic.expr.IntegerConstraint)

Example 2 with RealComparison

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);
    }
}
Also used : RealComparison(org.evosuite.symbolic.expr.bv.RealComparison) RealConstraint(org.evosuite.symbolic.expr.RealConstraint) StringConstraint(org.evosuite.symbolic.expr.StringConstraint) IntegerConstraint(org.evosuite.symbolic.expr.IntegerConstraint) Constraint(org.evosuite.symbolic.expr.Constraint) Comparator(org.evosuite.symbolic.expr.Comparator)

Example 3 with RealComparison

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);
}
Also used : RealValue(org.evosuite.symbolic.expr.fp.RealValue) RealComparison(org.evosuite.symbolic.expr.bv.RealComparison) IntegerConstraint(org.evosuite.symbolic.expr.IntegerConstraint)

Aggregations

IntegerConstraint (org.evosuite.symbolic.expr.IntegerConstraint)3 RealComparison (org.evosuite.symbolic.expr.bv.RealComparison)3 RealValue (org.evosuite.symbolic.expr.fp.RealValue)2 Comparator (org.evosuite.symbolic.expr.Comparator)1 Constraint (org.evosuite.symbolic.expr.Constraint)1 RealConstraint (org.evosuite.symbolic.expr.RealConstraint)1 StringConstraint (org.evosuite.symbolic.expr.StringConstraint)1