Search in sources :

Example 36 with IntegerValue

use of org.evosuite.symbolic.expr.bv.IntegerValue in project evosuite by EvoSuite.

the class ArithmeticVM method L2I.

@Override
public void L2I() {
    IntegerValue integerExpr = env.topFrame().operandStack.popBv64();
    env.topFrame().operandStack.pushBv32(integerExpr);
}
Also used : IntegerValue(org.evosuite.symbolic.expr.bv.IntegerValue)

Example 37 with IntegerValue

use of org.evosuite.symbolic.expr.bv.IntegerValue in project evosuite by EvoSuite.

the class ArithmeticVM method LREM.

@Override
public void LREM(long rhs) {
    IntegerValue right = env.topFrame().operandStack.popBv64();
    IntegerValue left = env.topFrame().operandStack.popBv64();
    if (zeroViolation(right, rhs))
        return;
    long left_concrete_value = ((Long) left.getConcreteValue()).longValue();
    long right_concrete_value = ((Long) right.getConcreteValue()).longValue();
    if (!left.containsSymbolicVariable()) {
        left = ExpressionFactory.buildNewIntegerConstant(left_concrete_value);
    }
    if (!right.containsSymbolicVariable()) {
        right = ExpressionFactory.buildNewIntegerConstant(right_concrete_value);
    }
    long con = left_concrete_value % right_concrete_value;
    IntegerValue intExpr = ExpressionFactory.rem(left, right, (long) con);
    env.topFrame().operandStack.pushBv64(intExpr);
}
Also used : IntegerValue(org.evosuite.symbolic.expr.bv.IntegerValue)

Example 38 with IntegerValue

use of org.evosuite.symbolic.expr.bv.IntegerValue in project evosuite by EvoSuite.

the class ArithmeticVM method LSUB.

/**
 * @see http
 *      ://java.sun.com/docs/books/jvms/second_edition/html/Instructions2
 *      .doc8.html#lsub
 */
@Override
public void LSUB() {
    IntegerValue right = env.topFrame().operandStack.popBv64();
    IntegerValue left = env.topFrame().operandStack.popBv64();
    long left_concrete_value = ((Long) left.getConcreteValue()).longValue();
    long right_concrete_value = ((Long) right.getConcreteValue()).longValue();
    if (!left.containsSymbolicVariable()) {
        left = ExpressionFactory.buildNewIntegerConstant(left_concrete_value);
    }
    if (!right.containsSymbolicVariable()) {
        right = ExpressionFactory.buildNewIntegerConstant(right_concrete_value);
    }
    long con = left_concrete_value - right_concrete_value;
    IntegerValue intExpr = new IntegerBinaryExpression(left, Operator.MINUS, right, (long) con);
    env.topFrame().operandStack.pushBv64(intExpr);
}
Also used : IntegerBinaryExpression(org.evosuite.symbolic.expr.bv.IntegerBinaryExpression) IntegerValue(org.evosuite.symbolic.expr.bv.IntegerValue)

Example 39 with IntegerValue

use of org.evosuite.symbolic.expr.bv.IntegerValue in project evosuite by EvoSuite.

the class ArithmeticVM method L2D.

@Override
public void L2D() {
    IntegerValue integerExpr = env.topFrame().operandStack.popBv64();
    long longValue = ((Long) integerExpr.getConcreteValue()).longValue();
    RealValue realExpr;
    double concreteValue = (double) longValue;
    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)

Example 40 with IntegerValue

use of org.evosuite.symbolic.expr.bv.IntegerValue in project evosuite by EvoSuite.

the class ArithmeticVM method ISHR.

/**
 * Stack=value1(int)|value2(int)
 *
 * Pops two ints off the stack. Shifts value2 left by the amount indicated
 * in the five low bits of value1. The int result is then pushed back onto
 * the stack.
 */
@Override
public void ISHR() {
    IntegerValue right_expr = (IntegerValue) env.topFrame().operandStack.popBv32();
    IntegerValue left_expr = (IntegerValue) env.topFrame().operandStack.popBv32();
    int left_concrete_value = ((Long) left_expr.getConcreteValue()).intValue();
    int right_concrete_value = ((Long) right_expr.getConcreteValue()).intValue();
    int concrete_value = left_concrete_value >> (right_concrete_value & 0x001F);
    IntegerBinaryExpression intExpr = new IntegerBinaryExpression(left_expr, Operator.SHR, right_expr, (long) concrete_value);
    env.topFrame().operandStack.pushBv32(intExpr);
}
Also used : IntegerBinaryExpression(org.evosuite.symbolic.expr.bv.IntegerBinaryExpression) IntegerValue(org.evosuite.symbolic.expr.bv.IntegerValue) IntegerConstraint(org.evosuite.symbolic.expr.IntegerConstraint)

Aggregations

IntegerValue (org.evosuite.symbolic.expr.bv.IntegerValue)117 IntegerConstraint (org.evosuite.symbolic.expr.IntegerConstraint)48 ReferenceConstant (org.evosuite.symbolic.expr.ref.ReferenceConstant)32 ReferenceExpression (org.evosuite.symbolic.expr.ref.ReferenceExpression)27 RealValue (org.evosuite.symbolic.expr.fp.RealValue)22 IntegerBinaryExpression (org.evosuite.symbolic.expr.bv.IntegerBinaryExpression)14 Expression (org.evosuite.symbolic.expr.Expression)8 StringValue (org.evosuite.symbolic.expr.str.StringValue)8 IntegerConstant (org.evosuite.symbolic.expr.bv.IntegerConstant)7 Type (org.objectweb.asm.Type)7 RealToIntegerCast (org.evosuite.symbolic.expr.bv.RealToIntegerCast)6 IntegerToRealCast (org.evosuite.symbolic.expr.fp.IntegerToRealCast)6 IntegerUnaryExpression (org.evosuite.symbolic.expr.bv.IntegerUnaryExpression)5 PrimitiveExpression (org.evosuite.testcase.statements.PrimitiveExpression)4 ArrayList (java.util.ArrayList)3 CodeUnderTestException (org.evosuite.testcase.execution.CodeUnderTestException)3 Field (java.lang.reflect.Field)2 BigInteger (java.math.BigInteger)2 Vector (java.util.Vector)2 Constraint (org.evosuite.symbolic.expr.Constraint)2