use of org.evosuite.symbolic.expr.bv.IntegerValue in project evosuite by EvoSuite.
the class HeapVM method FASTORE.
@Override
public void FASTORE(Object conc_array, int conc_index) {
// get symbolic arguments
RealValue symb_value = env.topFrame().operandStack.popFp32();
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 MULTIANEWARRAY.
/**
* MULTIANEWARRAY
*
* <pre>
* boolean[] b1 = new boolean[1]; // NEWARRAY T_BOOLEAN
* Boolean[] B1 = new Boolean[1]; // ANEWARRAY java/lang/Boolean
* boolean[][] b2 = new boolean[1][2]; // MULTIANEWARRAY [[Z 2
* Boolean[][] B2 = new Boolean[1][2]; // MULTIANEWARRAY [[Ljava/lang/Boolean; 2
* </pre>
*/
@Override
public void MULTIANEWARRAY(String arrayTypeDesc, int nrDimensions) {
// push negartive length constraints
for (int i = 0; i < nrDimensions; i++) {
IntegerValue symb_length = env.topFrame().operandStack.popBv32();
int conc_length = ((Long) symb_length.getConcreteValue()).intValue();
if (negativeArrayLengthViolation(conc_length, symb_length)) {
return;
}
}
Type multiArrayType = Type.getType(arrayTypeDesc);
// push delayed object
ReferenceConstant newMultiArray = this.env.heap.buildNewReferenceConstant(// @FIXME
multiArrayType);
env.topFrame().operandStack.pushRef(newMultiArray);
}
use of org.evosuite.symbolic.expr.bv.IntegerValue in project evosuite by EvoSuite.
the class HeapVM method NEWARRAY.
/* Arrays */
/**
* Create a (one-dimensional) array of primitive componenet type, e.g., new
* int[3]
*
* Allocate space on the heap and push a reference ref to it onto the stack.
*
* http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.
* doc10.html#newarray
*/
@Override
public void NEWARRAY(int conc_array_length, Class<?> componentType) {
/**
* Since this callback is invoked before the actual array creation, we
* can only add negative index constraints.
*
* PRE: int (length)
*
* POST: arrayref (delayed)
*/
// discard symbolic arguments
IntegerValue symb_array_length = env.topFrame().operandStack.popBv32();
/* negative index */
if (negativeArrayLengthViolation(conc_array_length, symb_array_length))
return;
// create array class
int[] lenghts = new int[] { 0 };
Class<?> array_class = Array.newInstance(componentType, lenghts).getClass();
Type arrayType = Type.getType(array_class);
ReferenceConstant symb_array_ref = this.env.heap.buildNewReferenceConstant(arrayType);
env.heap.putField("", ARRAY_LENGTH, null, symb_array_ref, symb_array_length);
env.topFrame().operandStack.pushRef(symb_array_ref);
}
use of org.evosuite.symbolic.expr.bv.IntegerValue in project evosuite by EvoSuite.
the class HeapVM method ANEWARRAY.
/**
* http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc
* .html#anewarray
*/
@Override
public void ANEWARRAY(int conc_array_length, String componentTypeName) {
/**
* Since this callback is invoked before the actual array creation, we
* can only add negative index constraints.
*
* PRE: int (length)
*
* POST: arrayref (delayed)
*/
// discard symbolic arguments
IntegerValue symb_array_length = env.topFrame().operandStack.popBv32();
/* negative index */
if (negativeArrayLengthViolation(conc_array_length, symb_array_length))
return;
// create array class
Type componentType = Type.getType(componentTypeName.replace('/', '.'));
Class<?> componentClass = classLoader.getClassForType(componentType);
int[] lenghts = new int[] { 0 };
Class<?> array_class = Array.newInstance(componentClass, lenghts).getClass();
Type arrayType = Type.getType(array_class);
ReferenceConstant symb_array_ref = env.heap.buildNewReferenceConstant(arrayType);
env.heap.putField("", ARRAY_LENGTH, null, symb_array_ref, symb_array_length);
env.topFrame().operandStack.pushRef(symb_array_ref);
}
use of org.evosuite.symbolic.expr.bv.IntegerValue in project evosuite by EvoSuite.
the class HeapVM method CALOAD.
@Override
public void CALOAD(Object conc_array, int conc_index) {
// pop symbolic arguments
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;
char bv32 = Array.getChar(conc_array, conc_index);
IntegerValue c = env.heap.array_load(symb_array, conc_index, (long) bv32);
env.topFrame().operandStack.pushBv32(c);
}
Aggregations