Search in sources :

Example 76 with RealValue

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

the class IEEEremainder method executeFunction.

@Override
public Object executeFunction() {
    double res = this.getConcDoubleRetVal();
    RealValue left = this.getSymbRealArgument(0);
    RealValue right = this.getSymbRealArgument(1);
    RealValue ieeeRemainderExpr;
    if (left.containsSymbolicVariable() || right.containsSymbolicVariable()) {
        Operator op = Operator.IEEEREMAINDER;
        ieeeRemainderExpr = new RealBinaryExpression(left, op, right, res);
    } else {
        ieeeRemainderExpr = this.getSymbRealRetVal();
    }
    return ieeeRemainderExpr;
}
Also used : RealValue(org.evosuite.symbolic.expr.fp.RealValue) Operator(org.evosuite.symbolic.expr.Operator) RealBinaryExpression(org.evosuite.symbolic.expr.fp.RealBinaryExpression)

Example 77 with RealValue

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

the class POW method executeFunction.

@Override
public Object executeFunction() {
    double res = this.getConcDoubleRetVal();
    RealValue left = this.getSymbRealArgument(0);
    RealValue right = this.getSymbRealArgument(1);
    RealValue powExpr;
    if (left.containsSymbolicVariable() || right.containsSymbolicVariable()) {
        Operator op = Operator.POW;
        powExpr = new RealBinaryExpression(left, op, right, res);
    } else {
        powExpr = this.getSymbRealRetVal();
    }
    return powExpr;
}
Also used : RealValue(org.evosuite.symbolic.expr.fp.RealValue) Operator(org.evosuite.symbolic.expr.Operator) RealBinaryExpression(org.evosuite.symbolic.expr.fp.RealBinaryExpression)

Example 78 with RealValue

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

the class SymbolicObserver method pushDummyValue.

private void pushDummyValue(Type argType) {
    if (isBv32(argType)) {
        IntegerValue integerExpr = ExpressionFactory.buildNewIntegerConstant(0);
        env.topFrame().operandStack.pushBv32(integerExpr);
    } else if (isBv64(argType)) {
        IntegerValue integerExpr = ExpressionFactory.buildNewIntegerConstant(0);
        env.topFrame().operandStack.pushBv64(integerExpr);
    } else if (isFp32(argType)) {
        RealValue realExpr = ExpressionFactory.buildNewRealConstant(0);
        env.topFrame().operandStack.pushFp32(realExpr);
    } else if (isFp64(argType)) {
        RealValue realExpr = ExpressionFactory.buildNewRealConstant(0);
        env.topFrame().operandStack.pushFp64(realExpr);
    } else {
        throw new EvosuiteError(argType.toString() + " is not a value type!");
    }
}
Also used : RealValue(org.evosuite.symbolic.expr.fp.RealValue) EvosuiteError(org.evosuite.testcase.execution.EvosuiteError) IntegerValue(org.evosuite.symbolic.expr.bv.IntegerValue)

Example 79 with RealValue

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

the class SymbolicObserver method pushValue.

private void pushValue(Type argType, Expression<?> symb_expr) {
    if (isBv32(argType)) {
        IntegerValue booleanExpr = (IntegerValue) symb_expr;
        env.topFrame().operandStack.pushBv32(booleanExpr);
    } else if (isBv64(argType)) {
        IntegerValue longExpr = (IntegerValue) symb_expr;
        env.topFrame().operandStack.pushBv64(longExpr);
    } else if (isFp32(argType)) {
        RealValue realExpr = (RealValue) symb_expr;
        env.topFrame().operandStack.pushFp32(realExpr);
    } else if (isFp64(argType)) {
        RealValue realExpr = (RealValue) symb_expr;
        env.topFrame().operandStack.pushFp64(realExpr);
    } else {
        throw new EvosuiteError(argType.toString() + " is not a value type!");
    }
}
Also used : RealValue(org.evosuite.symbolic.expr.fp.RealValue) EvosuiteError(org.evosuite.testcase.execution.EvosuiteError) IntegerValue(org.evosuite.symbolic.expr.bv.IntegerValue)

Example 80 with RealValue

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

the class SymbolicObserver method readInstanceField.

private ReferenceExpressionPair readInstanceField(VariableReference source, Field field, Scope scope) {
    String owner = field.getDeclaringClass().getName().replace('.', '/');
    String name = field.getName();
    Class<?> fieldClazz = field.getType();
    String source_name = source.getName();
    ReferenceConstant symb_receiver = (ReferenceConstant) symb_references.get(source_name);
    try {
        Object conc_receiver = source.getObject(scope);
        if (fieldClazz.equals(int.class)) {
            int conc_value = field.getInt(conc_receiver);
            IntegerValue expr = env.heap.getField(owner, name, conc_receiver, symb_receiver, conc_value);
            ReferenceConstant newIntegerRef = newIntegerReference(conc_value, expr);
            return new ReferenceExpressionPair(newIntegerRef, expr);
        } else if (fieldClazz.equals(char.class)) {
            char conc_value = field.getChar(conc_receiver);
            IntegerValue expr = env.heap.getField(owner, name, conc_receiver, symb_receiver, conc_value);
            ReferenceConstant newCharacterRef = newCharacterReference(conc_value, expr);
            return new ReferenceExpressionPair(newCharacterRef, expr);
        } else if (fieldClazz.equals(long.class)) {
            long conc_value = field.getLong(conc_receiver);
            IntegerValue expr = env.heap.getField(owner, name, conc_receiver, symb_receiver, conc_value);
            ReferenceConstant newLongRef = newLongReference(conc_value, expr);
            return new ReferenceExpressionPair(newLongRef, expr);
        } else if (fieldClazz.equals(short.class)) {
            short conc_value = field.getShort(conc_receiver);
            IntegerValue expr = env.heap.getField(owner, name, conc_receiver, symb_receiver, conc_value);
            ReferenceConstant newShortRef = newShortReference(conc_value, expr);
            return new ReferenceExpressionPair(newShortRef, expr);
        } else if (fieldClazz.equals(byte.class)) {
            byte conc_value = field.getByte(conc_receiver);
            IntegerValue expr = env.heap.getField(owner, name, conc_receiver, symb_receiver, conc_value);
            ReferenceConstant newByteRef = newByteReference(conc_value, expr);
            return new ReferenceExpressionPair(newByteRef, expr);
        } else if (fieldClazz.equals(boolean.class)) {
            boolean conc_value = field.getBoolean(conc_receiver);
            IntegerValue expr = env.heap.getField(owner, name, conc_receiver, symb_receiver, conc_value ? 1 : 0);
            ReferenceConstant newBooleanRef = newBooleanReference(conc_value, expr);
            return new ReferenceExpressionPair(newBooleanRef, expr);
        } else if (fieldClazz.equals(float.class)) {
            float conc_value = field.getFloat(conc_receiver);
            RealValue expr = env.heap.getField(owner, name, conc_receiver, symb_receiver, conc_value);
            ReferenceConstant newFloatRef = newFloatReference(conc_value, expr);
            return new ReferenceExpressionPair(newFloatRef, expr);
        } else if (fieldClazz.equals(double.class)) {
            double conc_value = field.getDouble(conc_receiver);
            RealValue expr = env.heap.getField(owner, name, conc_receiver, symb_receiver, conc_value);
            ReferenceConstant newDoubleRef = newDoubleReference(conc_value, expr);
            return new ReferenceExpressionPair(newDoubleRef, expr);
        } else {
            Object conc_value = field.get(conc_receiver);
            if (conc_value instanceof String) {
                String string = (String) conc_value;
                StringValue expr = env.heap.getField(owner, name, conc_receiver, symb_receiver, string);
                ReferenceConstant newStringRef = newStringReference(string, expr);
                return new ReferenceExpressionPair(newStringRef, expr);
            } else {
                ReferenceExpression ref = env.heap.getReference(conc_value);
                if (conc_value != null && isWrapper(conc_value)) {
                    ReferenceConstant nonNullRef = (ReferenceConstant) ref;
                    Expression<?> expr = findOrCreate(conc_value, nonNullRef);
                    return new ReferenceExpressionPair(ref, expr);
                } else {
                    return new ReferenceExpressionPair(ref, null);
                }
            }
        }
    } catch (IllegalArgumentException e) {
        throw new RuntimeException(e);
    } catch (IllegalAccessException e) {
        throw new RuntimeException(e);
    } catch (CodeUnderTestException e) {
        throw new RuntimeException(e);
    }
}
Also used : RealValue(org.evosuite.symbolic.expr.fp.RealValue) IntegerValue(org.evosuite.symbolic.expr.bv.IntegerValue) CodeUnderTestException(org.evosuite.testcase.execution.CodeUnderTestException) ReferenceConstant(org.evosuite.symbolic.expr.ref.ReferenceConstant) ReferenceExpression(org.evosuite.symbolic.expr.ref.ReferenceExpression) PrimitiveExpression(org.evosuite.testcase.statements.PrimitiveExpression) Expression(org.evosuite.symbolic.expr.Expression) ReferenceExpression(org.evosuite.symbolic.expr.ref.ReferenceExpression) StringValue(org.evosuite.symbolic.expr.str.StringValue)

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