use of org.evosuite.symbolic.expr.ref.ReferenceExpression in project evosuite by EvoSuite.
the class JumpVM method IF_ACMPEQ.
/* Reference equality */
/**
* (left == right). (left != right) is just (not (left == right)).
*
* http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.
* doc6.html#if_acmpcond
*/
@Override
public void IF_ACMPEQ(String className, String methName, int branchIndex, Object conc_left, Object conc_right) {
ReferenceExpression right_ref = env.topFrame().operandStack.popRef();
ReferenceExpression left_ref = env.topFrame().operandStack.popRef();
env.heap.initializeReference(conc_left, left_ref);
env.heap.initializeReference(conc_right, right_ref);
}
use of org.evosuite.symbolic.expr.ref.ReferenceExpression 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.ref.ReferenceExpression in project evosuite by EvoSuite.
the class SymbolicHeap method getField.
/**
* @param className
* @param fieldName
* @param conc_receiver
* @param symb_receiver
* @param conc_value
* @return
*/
public StringValue getField(String className, String fieldName, Object conc_receiver, ReferenceExpression symb_receiver, String conc_value) {
Map<ReferenceExpression, Expression<?>> symb_field = getOrCreateSymbolicField(className, fieldName);
StringValue symb_value = (StringValue) symb_field.get(symb_receiver);
if (symb_value == null || !((String) symb_value.getConcreteValue()).equals(conc_value)) {
symb_value = ExpressionFactory.buildNewStringConstant(conc_value);
symb_field.remove(symb_receiver);
}
return symb_value;
}
use of org.evosuite.symbolic.expr.ref.ReferenceExpression in project evosuite by EvoSuite.
the class SymbolicHeap method getReference.
/**
* Returns a <code>ReferenceConstant</code> if the concrete reference is
* null. Otherwise, it looks in the list of non-null symbolic references for
* a symbolic reference with the concrete value. If it is found, that
* symbolic reference is returned, otherwise a new reference constant is
* created (and added ot the list of non-null symbolic references)
*
* @param conc_ref
* @return
*/
public ReferenceExpression getReference(Object conc_ref) {
if (conc_ref == null) {
// null reference
ReferenceConstant nullConstant = ExpressionFactory.buildNewNullExpression();
return nullConstant;
} else {
int identityHashCode = System.identityHashCode(conc_ref);
if (nonNullRefs.containsKey(identityHashCode)) {
// already known object
ReferenceExpression symb_ref = nonNullRefs.get(identityHashCode);
return symb_ref;
} else {
// unknown object
final Type type = Type.getType(conc_ref.getClass());
ReferenceConstant ref_constant = new ReferenceConstant(type, newInstanceCount++);
ref_constant.initializeReference(conc_ref);
nonNullRefs.put(identityHashCode, ref_constant);
return ref_constant;
}
}
}
use of org.evosuite.symbolic.expr.ref.ReferenceExpression in project evosuite by EvoSuite.
the class SymbolicFunctionVM method INVOKEINTERFACE.
@Override
public void INVOKEINTERFACE(Object conc_receiver, String owner, String name, String desc) {
functionUnderExecution = getFunction(owner, name, desc);
if (functionUnderExecution != null) {
ReferenceExpression symb_receiver = getReceiverFromStack();
functionUnderExecution.setReceiver(conc_receiver, symb_receiver);
if (Type.getArgumentTypes(functionUnderExecution.getDesc()).length == 0) {
callBeforeExecution(functionUnderExecution);
}
}
}
Aggregations