Search in sources :

Example 46 with RealValue

use of org.evosuite.symbolic.expr.fp.RealValue 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)

Example 47 with RealValue

use of org.evosuite.symbolic.expr.fp.RealValue in project evosuite by EvoSuite.

the class ArithmeticVM method I2D.

/**
 * http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.
 * doc6.html#i2d
 */
@Override
public void I2D() {
    IntegerValue integerExpr = env.topFrame().operandStack.popBv32();
    int integerValue = ((Long) integerExpr.getConcreteValue()).intValue();
    RealValue realExpr;
    double concreteValue = (double) integerValue;
    if (!integerExpr.containsSymbolicVariable()) {
        realExpr = ExpressionFactory.buildNewRealConstant(concreteValue);
    } else {
        realExpr = new IntegerToRealCast(integerExpr, (double) concreteValue);
    }
    env.topFrame().operandStack.pushFp64(realExpr);
}
Also used : RealValue(org.evosuite.symbolic.expr.fp.RealValue) IntegerToRealCast(org.evosuite.symbolic.expr.fp.IntegerToRealCast) IntegerValue(org.evosuite.symbolic.expr.bv.IntegerValue) IntegerConstraint(org.evosuite.symbolic.expr.IntegerConstraint)

Example 48 with RealValue

use of org.evosuite.symbolic.expr.fp.RealValue in project evosuite by EvoSuite.

the class ArithmeticVM method FMUL.

@Override
public void FMUL() {
    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.mul(left, right, (double) con);
    env.topFrame().operandStack.pushFp32(realExpr);
}
Also used : RealValue(org.evosuite.symbolic.expr.fp.RealValue)

Example 49 with RealValue

use of org.evosuite.symbolic.expr.fp.RealValue in project evosuite by EvoSuite.

the class ArithmeticVM method FREM.

@Override
public void FREM(float rhs) {
    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.rem(left, right, (double) con);
    env.topFrame().operandStack.pushFp32(realExpr);
}
Also used : RealValue(org.evosuite.symbolic.expr.fp.RealValue)

Example 50 with RealValue

use of org.evosuite.symbolic.expr.fp.RealValue in project evosuite by EvoSuite.

the class ArithmeticVM method DADD.

@Override
public void DADD() {
    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.add(left, right, con);
    env.topFrame().operandStack.pushFp64(realExpr);
}
Also used : RealValue(org.evosuite.symbolic.expr.fp.RealValue)

Aggregations

RealValue (org.evosuite.symbolic.expr.fp.RealValue)81 Operator (org.evosuite.symbolic.expr.Operator)25 RealUnaryExpression (org.evosuite.symbolic.expr.fp.RealUnaryExpression)23 IntegerValue (org.evosuite.symbolic.expr.bv.IntegerValue)22 ReferenceExpression (org.evosuite.symbolic.expr.ref.ReferenceExpression)13 IntegerConstraint (org.evosuite.symbolic.expr.IntegerConstraint)12 ReferenceConstant (org.evosuite.symbolic.expr.ref.ReferenceConstant)11 Expression (org.evosuite.symbolic.expr.Expression)6 RealToIntegerCast (org.evosuite.symbolic.expr.bv.RealToIntegerCast)6 IntegerToRealCast (org.evosuite.symbolic.expr.fp.IntegerToRealCast)6 RealBinaryExpression (org.evosuite.symbolic.expr.fp.RealBinaryExpression)6 StringValue (org.evosuite.symbolic.expr.str.StringValue)4 PrimitiveExpression (org.evosuite.testcase.statements.PrimitiveExpression)4 Type (org.objectweb.asm.Type)4 CodeUnderTestException (org.evosuite.testcase.execution.CodeUnderTestException)3 Field (java.lang.reflect.Field)2 RealComparison (org.evosuite.symbolic.expr.bv.RealComparison)2 EvosuiteError (org.evosuite.testcase.execution.EvosuiteError)2 VariableReference (org.evosuite.testcase.variable.VariableReference)2 SmtExpr (org.evosuite.symbolic.solver.smt.SmtExpr)1