use of org.evosuite.symbolic.expr.ref.ReferenceExpression 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);
}
use of org.evosuite.symbolic.expr.ref.ReferenceExpression in project evosuite by EvoSuite.
the class HeapVM method IALOAD.
/**
* Load an int value from an array and push it on the stack
*
* ..., arrayref, index ==> ..., value
*
* http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.
* doc6.html#iaload
*/
@Override
public void IALOAD(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;
int bv32 = Array.getInt(conc_array, conc_index);
IntegerValue c = env.heap.array_load(symb_array, conc_index, (long) bv32);
env.topFrame().operandStack.pushBv32(c);
}
use of org.evosuite.symbolic.expr.ref.ReferenceExpression in project evosuite by EvoSuite.
the class OperandStack method pushNullRef.
public void pushNullRef() {
ReferenceExpression nullExpression = ExpressionFactory.buildNewNullExpression();
this.stack.push(new ReferenceOperand(nullExpression));
}
use of org.evosuite.symbolic.expr.ref.ReferenceExpression in project evosuite by EvoSuite.
the class OperandStack method peekRef.
public ReferenceExpression peekRef() {
Operand operand = this.peekOperand();
if (!(operand instanceof ReferenceOperand)) {
throw new ClassCastException("top of stack is not a reference but an operand of type " + operand.getClass().getCanonicalName());
}
ReferenceOperand refOp = (ReferenceOperand) operand;
ReferenceExpression ref = refOp.getReference();
return ref;
}
use of org.evosuite.symbolic.expr.ref.ReferenceExpression in project evosuite by EvoSuite.
the class StringTokenizer_Init method executeFunction.
@Override
public Object executeFunction() {
// symbolic receiver (new object)
ReferenceConstant symb_str_tokenizer = (ReferenceConstant) this.getSymbReceiver();
// string argument
String conc_str = (String) this.getConcArgument(0);
ReferenceExpression symb_str = this.getSymbArgument(0);
// delim argument
String conc_delim = (String) this.getConcArgument(1);
ReferenceExpression symb_delim = this.getSymbArgument(1);
if (symb_str instanceof ReferenceConstant && symb_delim 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);
ReferenceConstant non_null_symb_delim = (ReferenceConstant) symb_delim;
assert conc_delim != null;
StringValue delimExpr = env.heap.getField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_delim, non_null_symb_delim, conc_delim);
NewTokenizerExpr newTokenizerExpr = new NewTokenizerExpr(strExpr, delimExpr);
// update symbolic heap
env.heap.putField(Types.JAVA_UTIL_STRING_TOKENIZER, SymbolicHeap.$STRING_TOKENIZER_VALUE, null, symb_str_tokenizer, newTokenizerExpr);
}
// constructor returns void
return null;
}
Aggregations