use of org.evosuite.symbolic.expr.fp.RealValue 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.fp.RealValue 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.fp.RealValue in project evosuite by EvoSuite.
the class LocalsVM method FSTORE.
@Override
public void FSTORE(int i) {
RealValue realExpr = env.topFrame().operandStack.popFp32();
env.topFrame().localsTable.setFp32Local(i, realExpr);
}
use of org.evosuite.symbolic.expr.fp.RealValue in project evosuite by EvoSuite.
the class LocalsVM method DLOAD.
@Override
public void DLOAD(int i) {
RealValue realExpr = (RealValue) env.topFrame().localsTable.getFp64Local(i);
env.topFrame().operandStack.pushFp64(realExpr);
}
use of org.evosuite.symbolic.expr.fp.RealValue in project evosuite by EvoSuite.
the class CEIL method executeFunction.
@Override
public Object executeFunction() {
double res = this.getConcDoubleRetVal();
RealValue realExpression = this.getSymbRealArgument(0);
RealValue ceilExpr;
if (realExpression.containsSymbolicVariable()) {
Operator op = Operator.CEIL;
ceilExpr = new RealUnaryExpression(realExpression, op, res);
} else {
ceilExpr = this.getSymbRealRetVal();
}
return ceilExpr;
}
Aggregations