Search in sources :

Example 1 with IntegerBinaryExpression

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

the class ArithmeticVM method LUSHR.

/**
 * Stack=value1(int)|value2(long)
 *
 * Pops an integer and a long integer and from the stack. Shifts value2 (the
 * long integer) right by the amount indicated in the low six bits of value1
 * (an int). The long integer result is then pushed back onto the stack. The
 * value is shifted logically (ignoring the sign extension - useful for
 * unsigned values).
 */
@Override
public void LUSHR() {
    IntegerValue right_expr = (IntegerValue) env.topFrame().operandStack.popBv32();
    IntegerValue left_expr = (IntegerValue) env.topFrame().operandStack.popBv64();
    long left_concrete_value = ((Long) left_expr.getConcreteValue()).longValue();
    int right_concrete_value = ((Long) right_expr.getConcreteValue()).intValue();
    long concrete_value = left_concrete_value >>> (right_concrete_value & 0x001F);
    IntegerBinaryExpression intExpr = new IntegerBinaryExpression(left_expr, Operator.USHR, right_expr, (long) concrete_value);
    env.topFrame().operandStack.pushBv64(intExpr);
}
Also used : IntegerBinaryExpression(org.evosuite.symbolic.expr.bv.IntegerBinaryExpression) IntegerValue(org.evosuite.symbolic.expr.bv.IntegerValue) IntegerConstraint(org.evosuite.symbolic.expr.IntegerConstraint)

Example 2 with IntegerBinaryExpression

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

the class ArithmeticVM method IUSHR.

/**
 * Stack=value1(int)|value2(int)
 *
 * Pops two ints off the operand stack. Shifts value1 right by the amount
 * indicated in the five low bits of value2. The int result is then pushed
 * back onto the stack. value1 is shifted logically (ignoring the sign
 * extension - useful for unsigned values).
 */
@Override
public void IUSHR() {
    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.USHR, 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)

Example 3 with IntegerBinaryExpression

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

the class ArithmeticVM method LSHR.

/**
 * Stack=value1(int)|value2(long)
 *
 * Pops an int and a long integer from the stack. Shifts value2 (the long
 * integer) right by the amount indicated in the low six bits of value1 (an
 * int). The long integer result is then pushed back onto the stack. The
 * value is shifted arithmetically (preserving the sign extension).
 */
@Override
public void LSHR() {
    IntegerValue right_expr = (IntegerValue) env.topFrame().operandStack.popBv32();
    IntegerValue left_expr = (IntegerValue) env.topFrame().operandStack.popBv64();
    long left_concrete_value = ((Long) left_expr.getConcreteValue()).longValue();
    int right_concrete_value = ((Long) right_expr.getConcreteValue()).intValue();
    long concrete_value = left_concrete_value >> (right_concrete_value & 0x001F);
    IntegerBinaryExpression intExpr = new IntegerBinaryExpression(left_expr, Operator.SHL, right_expr, (long) concrete_value);
    env.topFrame().operandStack.pushBv64(intExpr);
}
Also used : IntegerBinaryExpression(org.evosuite.symbolic.expr.bv.IntegerBinaryExpression) IntegerValue(org.evosuite.symbolic.expr.bv.IntegerValue) IntegerConstraint(org.evosuite.symbolic.expr.IntegerConstraint)

Example 4 with IntegerBinaryExpression

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

the class ArithmeticVM method LSHL.

/**
 * Stack=value1(int)|value2(long)
 *
 * Pops a long integer and an int from the stack. Shifts value2 (the long
 * integer) left by the amount indicated in the low six bits of value1 (an
 * int). The long integer result is then pushed back onto the stack.
 */
@Override
public void LSHL() {
    IntegerValue right_expr = (IntegerValue) env.topFrame().operandStack.popBv32();
    IntegerValue left_expr = (IntegerValue) env.topFrame().operandStack.popBv64();
    long left_concrete_value = ((Long) left_expr.getConcreteValue()).longValue();
    int right_concrete_value = ((Long) right_expr.getConcreteValue()).intValue();
    long concrete_value = left_concrete_value << (right_concrete_value & 0x001F);
    IntegerBinaryExpression intExpr = new IntegerBinaryExpression(left_expr, Operator.SHL, right_expr, (long) concrete_value);
    env.topFrame().operandStack.pushBv64(intExpr);
}
Also used : IntegerBinaryExpression(org.evosuite.symbolic.expr.bv.IntegerBinaryExpression) IntegerValue(org.evosuite.symbolic.expr.bv.IntegerValue) IntegerConstraint(org.evosuite.symbolic.expr.IntegerConstraint)

Example 5 with IntegerBinaryExpression

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

the class ArithmeticVM method IAND.

/**
 * bitwise AND
 *
 * http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.
 * doc6.html#iand
 */
@Override
public void IAND() {
    IntegerValue right = env.topFrame().operandStack.popBv32();
    IntegerValue left = env.topFrame().operandStack.popBv32();
    int left_concrete_value = ((Long) left.getConcreteValue()).intValue();
    int right_concrete_value = ((Long) right.getConcreteValue()).intValue();
    if (!left.containsSymbolicVariable()) {
        left = ExpressionFactory.buildNewIntegerConstant(left_concrete_value);
    }
    if (!right.containsSymbolicVariable()) {
        right = ExpressionFactory.buildNewIntegerConstant(right_concrete_value);
    }
    int con = left_concrete_value & right_concrete_value;
    IntegerValue intExpr = new IntegerBinaryExpression(left, Operator.IAND, right, (long) con);
    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

IntegerBinaryExpression (org.evosuite.symbolic.expr.bv.IntegerBinaryExpression)27 IntegerConstraint (org.evosuite.symbolic.expr.IntegerConstraint)22 IntegerValue (org.evosuite.symbolic.expr.bv.IntegerValue)14 Constraint (org.evosuite.symbolic.expr.Constraint)12 ArrayList (java.util.ArrayList)8 SolverTimeoutException (org.evosuite.symbolic.solver.SolverTimeoutException)8 EvoSuiteSolver (org.evosuite.symbolic.solver.avm.EvoSuiteSolver)8 Test (org.junit.Test)8 IntegerVariable (org.evosuite.symbolic.expr.bv.IntegerVariable)7 SolverResult (org.evosuite.symbolic.solver.SolverResult)7 IntegerConstant (org.evosuite.symbolic.expr.bv.IntegerConstant)3 StringBinaryToIntegerExpression (org.evosuite.symbolic.expr.bv.StringBinaryToIntegerExpression)1 StringUnaryToIntegerExpression (org.evosuite.symbolic.expr.bv.StringUnaryToIntegerExpression)1 StringVariable (org.evosuite.symbolic.expr.str.StringVariable)1