use of org.evosuite.symbolic.expr.bv.IntegerComparison in project evosuite by EvoSuite.
the class ArithmeticVM method LCMP.
/**
* <pre>
* (a > b) ==> 1
* (a == b) ==> 0
* (a < b) ==> -1
* </pre>
*
* http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.
* doc8.html#lcmp
*/
@Override
public void LCMP() {
IntegerValue right = env.topFrame().operandStack.popBv64();
IntegerValue left = env.topFrame().operandStack.popBv64();
long left_concrete_value = (Long) left.getConcreteValue();
long right_concrete_value = (Long) right.getConcreteValue();
if (!left.containsSymbolicVariable()) {
left = ExpressionFactory.buildNewIntegerConstant(left_concrete_value);
}
if (!right.containsSymbolicVariable()) {
right = ExpressionFactory.buildNewIntegerConstant(right_concrete_value);
}
int concrete_value = 0;
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;
}
IntegerComparison intComp = new IntegerComparison(left, right, (long) concrete_value);
env.topFrame().operandStack.pushBv32(intComp);
}
use of org.evosuite.symbolic.expr.bv.IntegerComparison in project evosuite by EvoSuite.
the class ConstraintNormalizer method normalizeIntegerConstriant.
private static Constraint<?> normalizeIntegerConstriant(IntegerConstraint c) {
if (c.getLeftOperand() instanceof IntegerComparison) {
IntegerComparison cmp = (IntegerComparison) c.getLeftOperand();
int value = ((Number) c.getRightOperand().getConcreteValue()).intValue();
Comparator op = c.getComparator();
Expression<Long> cmp_left = cmp.getLeftOperant();
Expression<Long> cmp_right = cmp.getRightOperant();
return createIntegerConstraint(cmp_left, op, cmp_right, value);
} else {
assert (c.getRightOperand() instanceof IntegerComparison);
IntegerComparison cmp = (IntegerComparison) c.getRightOperand();
int value = ((Number) c.getLeftOperand().getConcreteValue()).intValue();
Comparator op = c.getComparator();
Expression<Long> cmp_left = cmp.getLeftOperant();
Expression<Long> cmp_right = cmp.getRightOperant();
Comparator swap_op = op.swap();
int swap_value = -value;
return createIntegerConstraint(cmp_left, swap_op, cmp_right, swap_value);
}
}
Aggregations