use of org.evosuite.symbolic.expr.ref.ReferenceExpression in project evosuite by EvoSuite.
the class LocalsVM method LDC.
/**
* Class literal described in Java Spec 3rd ed, Section 15.8.2
*
* ".class" Java expression, such as for example in:
* I.class.isAssignableFrom(..)
*
* <p>
* Represent reference to Class object with symbolic function application:
* ClassRef(Type)
*
* @see http
* ://java.sun.com/docs/books/jls/third_edition/html/expressions.html
* #15.8.2
*/
@Override
public void LDC(Class<?> x) {
ReferenceExpression ref = env.heap.getReference(x);
env.topFrame().operandStack.pushRef(ref);
}
use of org.evosuite.symbolic.expr.ref.ReferenceExpression in project evosuite by EvoSuite.
the class StringBuilder_Init method executeFunction.
@Override
public Object executeFunction() {
// symbolic receiver (new object)
ReferenceConstant symb_str_builder = (ReferenceConstant) this.getSymbReceiver();
// string argument
String conc_str = (String) this.getConcArgument(0);
ReferenceExpression symb_str = this.getSymbArgument(0);
if (symb_str instanceof ReferenceConstant) {
ReferenceConstant non_null_symb_string = (ReferenceConstant) symb_str;
assert conc_str != null;
StringValue strExpr = env.heap.getField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_str, non_null_symb_string, conc_str);
// update symbolic heap
env.heap.putField(Types.JAVA_LANG_STRING_BUILDER, SymbolicHeap.$STRING_BUILDER_CONTENTS, null, symb_str_builder, strExpr);
}
// return void
return null;
}
use of org.evosuite.symbolic.expr.ref.ReferenceExpression in project evosuite by EvoSuite.
the class StringReader_Init method executeFunction.
@Override
public Object executeFunction() {
// symbolic receiver (new object)
ReferenceConstant symb_str_reader = (ReferenceConstant) this.getSymbReceiver();
// string argument
String conc_str = (String) this.getConcArgument(0);
ReferenceExpression symb_str = this.getSymbArgument(0);
if (symb_str instanceof ReferenceConstant) {
ReferenceConstant non_null_symb_string = (ReferenceConstant) symb_str;
assert conc_str != null;
StringValue strExpr = env.heap.getField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_str, non_null_symb_string, conc_str);
if (strExpr.containsSymbolicVariable()) {
int conc_string_reader_value;
if (conc_str.length() == 0) {
conc_string_reader_value = -1;
} else {
conc_string_reader_value = conc_str.charAt(0);
}
StringReaderExpr newStringReaderExpr = new StringReaderExpr((long) conc_string_reader_value, strExpr);
// update symbolic heap
env.heap.putField(Types.JAVA_IO_STRING_READER, SymbolicHeap.$STRING_READER_VALUE, null, symb_str_reader, newStringReaderExpr);
}
}
// constructor returns void
return null;
}
use of org.evosuite.symbolic.expr.ref.ReferenceExpression in project evosuite by EvoSuite.
the class CallVM method METHOD_BEGIN_PARAM.
@Override
public void METHOD_BEGIN_PARAM(int nr, int index, Object conc_ref) {
if (!env.callerFrame().weInvokedInstrumentedCode()) {
ReferenceExpression symb_ref = env.heap.getReference(conc_ref);
env.topFrame().localsTable.setRefLocal(index, symb_ref);
}
}
use of org.evosuite.symbolic.expr.ref.ReferenceExpression in project evosuite by EvoSuite.
the class CallVM method CALLER_STACK_PARAM.
@Override
public void CALLER_STACK_PARAM(int nr, int calleeLocalsIndex, Object conc_ref) {
stackParamCount++;
int operand_index = stackParamCount - 1;
Operand op = getOperand(operand_index);
ReferenceOperand ref_op = (ReferenceOperand) op;
ReferenceExpression symb_ref = ref_op.getReference();
env.heap.initializeReference(conc_ref, symb_ref);
}
Aggregations