Search in sources :

Example 16 with IntegerBinaryExpression

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

the class ArithmeticVM method IOR.

/**
 * bitwise OR
 *
 * http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.
 * doc6.html#ior
 */
@Override
public void IOR() {
    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.IOR, 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)

Example 17 with IntegerBinaryExpression

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

the class ArithmeticVM method ISUB.

/**
 * @see http
 *      ://java.sun.com/docs/books/jvms/second_edition/html/Instructions2
 *      .doc6.html#isub
 */
@Override
public void ISUB() {
    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.MINUS, 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)

Example 18 with IntegerBinaryExpression

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

the class ArithmeticVM method LOR.

/**
 * @see http
 *      ://java.sun.com/docs/books/jvms/second_edition/html/Instructions2
 *      .doc8.html#lor
 */
@Override
public void LOR() {
    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.IOR, 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 19 with IntegerBinaryExpression

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

the class ArithmeticVM method IXOR.

/**
 * bitwise XOR
 *
 * http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.
 * doc6.html#ixor
 */
@Override
public void IXOR() {
    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.IXOR, 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)

Example 20 with IntegerBinaryExpression

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

the class TestIntegerSearch method sub.

private static IntegerValue sub(IntegerValue left, IntegerValue right) {
    int left_val = left.getConcreteValue().intValue();
    int right_val = right.getConcreteValue().intValue();
    return new IntegerBinaryExpression(left, Operator.MINUS, right, (long) left_val - right_val);
}
Also used : IntegerBinaryExpression(org.evosuite.symbolic.expr.bv.IntegerBinaryExpression) IntegerConstraint(org.evosuite.symbolic.expr.IntegerConstraint) Constraint(org.evosuite.symbolic.expr.Constraint)

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