use of org.evosuite.symbolic.expr.bv.IntegerValue in project evosuite by EvoSuite.
the class HeapVM method FALOAD.
@Override
public void FALOAD(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 = (ReferenceExpression) 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;
float fp32 = Array.getFloat(conc_array, conc_index);
RealValue c = env.heap.array_load(symb_array, conc_index, (double) fp32);
env.topFrame().operandStack.pushFp32(c);
}
use of org.evosuite.symbolic.expr.bv.IntegerValue in project evosuite by EvoSuite.
the class HeapVM method GETFIELD.
/**
* Retrieve the value of an instance field
*
* <p>
* Before actually retrieving the value, the JVM will check if the instance
* is null. If the receiver instance is null, the JVM will throw a null
* pointer exception.
*
* @see http
* ://java.sun.com/docs/books/jvms/second_edition/html/Instructions2
* .doc5.html#getfield
*/
@Override
public void GETFIELD(Object conc_receiver, String className, String fieldName, String desc) {
// consume symbolic operand
ReferenceExpression receiver_ref = env.topFrame().operandStack.popRef();
/* check reference initialization */
env.heap.initializeReference(conc_receiver, receiver_ref);
Field field = resolveField(classLoader.getClassForName(className), fieldName);
env.ensurePrepared(field.getDeclaringClass());
boolean isAccessible = field.isAccessible();
if (!isAccessible) {
field.setAccessible(true);
}
/* null-check */
if (nullReferenceViolation(receiver_ref, conc_receiver)) {
return;
}
ReferenceExpression symb_receiver = receiver_ref;
Type type = Type.getType(desc);
try {
if (type.equals(Type.INT_TYPE)) {
int value = field.getInt(conc_receiver);
IntegerValue intExpr = (IntegerValue) env.heap.getField(className, fieldName, conc_receiver, symb_receiver, (long) value);
env.topFrame().operandStack.pushBv32(intExpr);
} else if (type.equals(Type.LONG_TYPE)) {
long value = field.getLong(conc_receiver);
IntegerValue intExpr = (IntegerValue) env.heap.getField(className, fieldName, conc_receiver, symb_receiver, value);
env.topFrame().operandStack.pushBv64(intExpr);
} else if (type.equals(Type.FLOAT_TYPE)) {
float value = field.getFloat(conc_receiver);
RealValue fp32 = (RealValue) env.heap.getField(className, fieldName, conc_receiver, symb_receiver, (double) value);
env.topFrame().operandStack.pushFp32(fp32);
} else if (type.equals(Type.DOUBLE_TYPE)) {
double value = field.getDouble(conc_receiver);
RealValue fp64 = (RealValue) env.heap.getField(className, fieldName, conc_receiver, symb_receiver, value);
env.topFrame().operandStack.pushFp64(fp64);
} else if (type.equals(Type.CHAR_TYPE)) {
char value = field.getChar(conc_receiver);
IntegerValue intExpr = (IntegerValue) env.heap.getField(className, fieldName, conc_receiver, symb_receiver, (long) value);
env.topFrame().operandStack.pushBv32(intExpr);
} else if (type.equals(Type.SHORT_TYPE)) {
short value = field.getShort(conc_receiver);
IntegerValue intExpr = (IntegerValue) env.heap.getField(className, fieldName, conc_receiver, symb_receiver, (long) value);
env.topFrame().operandStack.pushBv32(intExpr);
} else if (type.equals(Type.BOOLEAN_TYPE)) {
boolean booleanValue = field.getBoolean(conc_receiver);
int value = booleanValue ? 1 : 0;
IntegerValue intExpr = (IntegerValue) env.heap.getField(className, fieldName, conc_receiver, symb_receiver, (long) value);
env.topFrame().operandStack.pushBv32(intExpr);
} else if (type.equals(Type.BYTE_TYPE)) {
byte value = field.getByte(conc_receiver);
IntegerValue intExpr = (IntegerValue) env.heap.getField(className, fieldName, conc_receiver, symb_receiver, (long) value);
env.topFrame().operandStack.pushBv32(intExpr);
} else {
Object value = field.get(conc_receiver);
ReferenceExpression ref = env.heap.getReference(value);
env.topFrame().operandStack.pushRef(ref);
}
if (!isAccessible) {
field.setAccessible(false);
}
} catch (IllegalArgumentException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
use of org.evosuite.symbolic.expr.bv.IntegerValue in project evosuite by EvoSuite.
the class HeapVM method BALOAD.
/**
* retrieve byte/boolean from array
*/
@Override
public void BALOAD(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;
Object object = Array.get(conc_array, conc_index);
int intValue;
if (object instanceof Boolean) {
boolean booleanValue = ((Boolean) object).booleanValue();
intValue = booleanValue ? 1 : 0;
} else {
assert object instanceof Byte;
intValue = ((Byte) object).shortValue();
}
IntegerValue c = env.heap.array_load(symb_array, conc_index, (long) intValue);
env.topFrame().operandStack.pushBv32(c);
}
use of org.evosuite.symbolic.expr.bv.IntegerValue in project evosuite by EvoSuite.
the class HeapVM method SALOAD.
@Override
public void SALOAD(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;
short conc_value = Array.getShort(conc_array, conc_index);
IntegerValue e = env.heap.array_load(symb_array, conc_index, (long) conc_value);
env.topFrame().operandStack.pushBv32(e);
}
use of org.evosuite.symbolic.expr.bv.IntegerValue in project evosuite by EvoSuite.
the class HeapVM method CASTORE.
@Override
public void CASTORE(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);
}
Aggregations