use of org.evosuite.symbolic.expr.str.StringValue in project evosuite by EvoSuite.
the class BigInteger_Ctor method executeFunction.
@Override
public Object executeFunction() {
String conc_string = (String) this.getConcArgument(0);
ReferenceConstant str_ref = (ReferenceConstant) this.getSymbArgument(0);
StringValue symb_string = this.env.heap.getField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_string, str_ref, conc_string);
if (symb_string.containsSymbolicVariable()) {
ReferenceConstant symb_big_integer = (ReferenceConstant) env.topFrame().operandStack.peekRef();
BigInteger bigInteger = new BigInteger(conc_string);
long concVal = bigInteger.longValue();
StringToIntegerCast big_integer_value = new StringToIntegerCast(symb_string, concVal);
env.heap.putField(Types.JAVA_MATH_BIG_INTEGER, SymbolicHeap.$BIG_INTEGER_CONTENTS, null, /* conc_big_integer */
symb_big_integer, big_integer_value);
}
// return void
return null;
}
use of org.evosuite.symbolic.expr.str.StringValue in project evosuite by EvoSuite.
the class StringBuffer_ToString method executeFunction.
@Override
public Object executeFunction() {
ReferenceConstant symb_str_buffer = this.getSymbReceiver();
StringBuffer conc_str_buffer = (StringBuffer) this.getConcReceiver();
// retrieve symbolic value from heap
String conc_value = conc_str_buffer.toString();
StringValue symb_value = env.heap.getField(Types.JAVA_LANG_STRING_BUFFER, SymbolicHeap.$STRING_BUFFER_CONTENTS, conc_str_buffer, symb_str_buffer, conc_value);
String conc_ret_val = (String) this.getConcRetVal();
ReferenceConstant symb_ret_val = (ReferenceConstant) this.getSymbRetVal();
env.heap.putField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_ret_val, symb_ret_val, symb_value);
// return symbolic value
return symb_ret_val;
}
use of org.evosuite.symbolic.expr.str.StringValue in project evosuite by EvoSuite.
the class StringBuilder_Append method executeFunction.
@Override
public final Object executeFunction() {
// string builder
StringBuilder conc_str_builder = (StringBuilder) this.getConcReceiver();
ReferenceConstant symb_str_builder = (ReferenceConstant) this.getSymbReceiver();
// return value
StringBuilder res = (StringBuilder) this.getConcRetVal();
ReferenceConstant symb_res = (ReferenceConstant) this.getSymbRetVal();
StringValue leftExpr = this.env.heap.getField(Types.JAVA_LANG_STRING_BUILDER, SymbolicHeap.$STRING_BUILDER_CONTENTS, conc_str_builder, symb_str_builder, conc_str_builder_to_string_pre);
// append string expression
StringValue newStrExpr = appendExpression(leftExpr, res);
// store to symbolic heap
env.heap.putField(Types.JAVA_LANG_STRING_BUILDER, SymbolicHeap.$STRING_BUILDER_CONTENTS, conc_str_builder, symb_res, newStrExpr);
return symb_res;
}
use of org.evosuite.symbolic.expr.str.StringValue in project evosuite by EvoSuite.
the class StringBuilder_ToString method executeFunction.
@Override
public Object executeFunction() {
ReferenceConstant symb_str_builder = (ReferenceConstant) this.getSymbReceiver();
// receiver
StringBuilder conc_str_builder = (StringBuilder) this.getConcReceiver();
// return value
String res = (String) this.getConcRetVal();
if (res != null) {
ReferenceConstant symb_ret_val = (ReferenceConstant) this.getSymbRetVal();
StringValue symb_value = env.heap.getField(Types.JAVA_LANG_STRING_BUILDER, SymbolicHeap.$STRING_BUILDER_CONTENTS, conc_str_builder, symb_str_builder, conc_str_builder.toString());
String conc_receiver = (String) res;
env.heap.putField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_receiver, symb_ret_val, symb_value);
}
return this.getSymbRetVal();
}
use of org.evosuite.symbolic.expr.str.StringValue 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