use of org.evosuite.symbolic.expr.bv.IntegerValue in project evosuite by EvoSuite.
the class HeapVM method IASTORE.
/**
* Store the top operand stack value into an array
*
* http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.
* doc6.html#iastore
*/
@Override
public void IASTORE(Object conc_array, int conc_index) {
// pop arguments
IntegerValue symb_value = env.topFrame().operandStack.popBv32();
IntegerValue symb_index = env.topFrame().operandStack.popBv32();
ReferenceExpression array_ref = env.topFrame().operandStack.popRef();
/* check reference initialization */
env.heap.initializeReference(conc_array, array_ref);
/* null-check */
if (nullReferenceViolation(array_ref, conc_array)) {
return;
}
/* negative index */
if (negativeIndexViolation(conc_index, symb_index)) {
return;
}
/* out of bound index */
ReferenceExpression symb_array = array_ref;
int conc_array_length = Array.getLength(conc_array);
IntegerValue symb_array_length = env.heap.getField("", ARRAY_LENGTH, conc_array, symb_array, conc_array_length);
if (indexTooBigViolation(conc_index, symb_index, conc_array_length, symb_array_length))
return;
env.heap.array_store(conc_array, symb_array, conc_index, symb_value);
}
use of org.evosuite.symbolic.expr.bv.IntegerValue in project evosuite by EvoSuite.
the class HeapVM method ARRAYLENGTH.
@Override
public void ARRAYLENGTH(Object conc_array) {
/* get symbolic arguments */
ReferenceExpression array_ref = env.topFrame().operandStack.popRef();
/* check reference initialization */
env.heap.initializeReference(conc_array, array_ref);
/* null-check */
if (nullReferenceViolation(array_ref, conc_array)) {
return;
}
int conc_array_length = Array.getLength(conc_array);
ReferenceExpression symb_array_ref = (ReferenceExpression) array_ref;
IntegerValue symb_array_length = (IntegerValue) env.heap.getField("", ARRAY_LENGTH, conc_array, symb_array_ref, conc_array_length);
env.topFrame().operandStack.pushBv32(symb_array_length);
}
use of org.evosuite.symbolic.expr.bv.IntegerValue in project evosuite by EvoSuite.
the class JumpVM method TABLESWITCH.
/* switch */
/**
* <b>switch</b> statement that has consecutively numbered cases. I.e.,
* there are no holes (missing targets) between the lowest and highest
* target. Hence the compiler does not need to translate the case values to
* offsets.
*
* <p>
* We treat the switch statement as a nested if in order lowest to highest
* index as follows.
*
* <pre>
* if (x==lowest) ..
* else
* {
* if (x==second_lowest) ..
* else
* {
* if ..
* </pre>
*
* http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.
* doc14.html#tableswitch
*/
@Override
public void TABLESWITCH(String className, String methName, int branchIndex, int goalConcrete, int min, int max) {
final IntegerValue value = env.topFrame().operandStack.popBv32();
Vector<IntegerConstraint> constraints = new Vector<IntegerConstraint>();
// process each time in the same order: lowest to highest target
for (int i = min; i <= max; i++) {
IntegerConstant literal = ExpressionFactory.buildNewIntegerConstant(i);
IntegerConstraint constraint;
if (goalConcrete == i) {
constraint = ConstraintFactory.eq(value, literal);
constraints.add(constraint);
break;
} else {
constraint = ConstraintFactory.neq(value, literal);
constraints.add(constraint);
}
}
for (int i = 0; i < constraints.size() - 1; i++) {
IntegerConstraint cnstrt = constraints.get(i);
if (cnstrt.getLeftOperand().containsSymbolicVariable() || cnstrt.getRightOperand().containsSymbolicVariable())
pc.addSupportingConstraint(cnstrt);
}
// add branch condition iif local constraint is concrete
IntegerConstraint cnstr = constraints.get(constraints.size() - 1);
if (cnstr.getLeftOperand().containsSymbolicVariable() || cnstr.getRightOperand().containsSymbolicVariable())
pc.addBranchCondition(className, methName, branchIndex, cnstr);
}
use of org.evosuite.symbolic.expr.bv.IntegerValue in project evosuite by EvoSuite.
the class SymbolicHeap method array_load.
public IntegerValue array_load(ReferenceExpression symb_array, int conc_index, long conc_value) {
Map<Integer, Expression<?>> symb_array_contents = getOrCreateSymbolicArray(symb_array);
IntegerValue symb_value = (IntegerValue) symb_array_contents.get(conc_index);
if (symb_value == null || ((Long) symb_value.getConcreteValue()).longValue() != conc_value) {
symb_value = ExpressionFactory.buildNewIntegerConstant(conc_value);
symb_array_contents.remove(conc_index);
}
return symb_value;
}
use of org.evosuite.symbolic.expr.bv.IntegerValue in project evosuite by EvoSuite.
the class SymbolicHeap method getStaticField.
public IntegerValue getStaticField(String owner, String name, long conc_value) {
FieldKey k = new FieldKey(owner, name);
IntegerValue symb_value = (IntegerValue) symb_static_fields.get(k);
if (symb_value == null || ((Long) symb_value.getConcreteValue()).longValue() != conc_value) {
symb_value = ExpressionFactory.buildNewIntegerConstant(conc_value);
symb_static_fields.remove(k);
}
return symb_value;
}
Aggregations