use of org.evosuite.symbolic.expr.ref.ReferenceExpression in project evosuite by EvoSuite.
the class SymbolicFunctionVM method CALL_RESULT.
@Override
public void CALL_RESULT(Object conc_ret_val, String owner, String name, String desc) {
if (functionUnderExecution != null) {
if (!functionUnderExecution.getOwner().equals(owner) || !functionUnderExecution.getName().equals(name) || !functionUnderExecution.getDesc().equals(desc)) {
functionUnderExecution = null;
}
}
if (functionUnderExecution != null) {
ReferenceExpression symb_ret_val = this.env.topFrame().operandStack.peekRef();
functionUnderExecution.setReturnValue(conc_ret_val, symb_ret_val);
ReferenceExpression new_symb_ret_val = (ReferenceExpression) functionUnderExecution.executeFunction();
this.replaceTopRef(new_symb_ret_val);
}
functionUnderExecution = null;
}
use of org.evosuite.symbolic.expr.ref.ReferenceExpression in project evosuite by EvoSuite.
the class BigInteger_DivideAndRemainder method executeFunction.
@Override
public Object executeFunction() {
BigInteger conc_left_big_integer = (BigInteger) this.getConcReceiver();
ReferenceConstant symb_left_big_integer = this.getSymbReceiver();
BigInteger conc_right_big_integer = (BigInteger) this.getConcArgument(0);
ReferenceConstant symb_right_big_integer = (ReferenceConstant) this.getSymbArgument(0);
Object res = this.getConcRetVal();
ReferenceExpression symb_res = this.getSymbRetVal();
if (res != null && conc_left_big_integer != null && conc_right_big_integer != null) {
IntegerValue left_big_integer_expr = this.env.heap.getField(Types.JAVA_MATH_BIG_INTEGER, SymbolicHeap.$BIG_INTEGER_CONTENTS, conc_left_big_integer, symb_left_big_integer, conc_left_big_integer.longValue());
IntegerValue right_big_integer_expr = this.env.heap.getField(Types.JAVA_MATH_BIG_INTEGER, SymbolicHeap.$BIG_INTEGER_CONTENTS, conc_right_big_integer, symb_right_big_integer, conc_right_big_integer.longValue());
if (left_big_integer_expr.containsSymbolicVariable() || right_big_integer_expr.containsSymbolicVariable()) {
// quotient
BigInteger conc_quotient = (BigInteger) Array.get(res, QUOTIENT_ARRAY_INDEX);
ReferenceConstant symb_quotient = (ReferenceConstant) this.env.heap.getReference(conc_quotient);
IntegerValue symb_div_value = ExpressionFactory.div(left_big_integer_expr, right_big_integer_expr, conc_quotient.longValue());
this.env.heap.putField(Types.JAVA_MATH_BIG_INTEGER, SymbolicHeap.$BIG_INTEGER_CONTENTS, conc_quotient, symb_quotient, symb_div_value);
// remainder
BigInteger conc_remainder = (BigInteger) Array.get(res, REMAINDER_ARRAY_INDEX);
ReferenceConstant symb_remainder = (ReferenceConstant) this.env.heap.getReference(conc_remainder);
IntegerValue symb_rem_value = ExpressionFactory.rem(left_big_integer_expr, right_big_integer_expr, conc_remainder.longValue());
this.env.heap.putField(Types.JAVA_MATH_BIG_INTEGER, SymbolicHeap.$BIG_INTEGER_CONTENTS, conc_remainder, symb_remainder, symb_rem_value);
}
}
return symb_res;
}
use of org.evosuite.symbolic.expr.ref.ReferenceExpression in project evosuite by EvoSuite.
the class Pattern_Matcher method executeFunction.
@Override
public Object executeFunction() {
// receiver
@SuppressWarnings("unused") ReferenceConstant symb_receiver = this.getSymbReceiver();
// argument
CharSequence conc_char_seq = (CharSequence) this.getConcArgument(0);
ReferenceExpression symb_char_seq = this.getSymbArgument(0);
// return value
Matcher conc_matcher = (Matcher) this.getConcRetVal();
ReferenceConstant symb_matcher = (ReferenceConstant) this.getSymbRetVal();
if (conc_char_seq != null && conc_char_seq instanceof String) {
assert symb_char_seq instanceof ReferenceConstant;
ReferenceConstant symb_string = (ReferenceConstant) symb_char_seq;
String string = (String) conc_char_seq;
StringValue symb_input = env.heap.getField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, string, symb_string, string);
env.heap.putField(Types.JAVA_UTIL_REGEX_MATCHER, SymbolicHeap.$MATCHER_INPUT, conc_matcher, symb_matcher, symb_input);
}
return symb_matcher;
}
use of org.evosuite.symbolic.expr.ref.ReferenceExpression in project evosuite by EvoSuite.
the class EqualsIgnoreCase method executeFunction.
@Override
public Object executeFunction() {
String conc_left = (String) this.getConcReceiver();
ReferenceConstant symb_left = this.getSymbReceiver();
String conc_right = (String) this.getConcArgument(0);
ReferenceExpression symb_right = this.getSymbArgument(0);
boolean res = this.getConcBooleanRetVal();
StringValue left_expr = env.heap.getField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_left, symb_left, conc_left);
if (symb_right instanceof ReferenceConstant && conc_right != null) {
ReferenceConstant ref_constant_right = (ReferenceConstant) symb_right;
StringValue right_expr = env.heap.getField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_right, ref_constant_right, conc_right);
if (left_expr.containsSymbolicVariable() || right_expr.containsSymbolicVariable()) {
int conV = res ? 1 : 0;
StringBinaryComparison strBExpr = new StringBinaryComparison(left_expr, Operator.EQUALSIGNORECASE, right_expr, (long) conV);
return strBExpr;
}
}
return this.getSymbIntegerRetVal();
}
use of org.evosuite.symbolic.expr.ref.ReferenceExpression in project evosuite by EvoSuite.
the class ReplaceFirst method executeFunction.
@Override
public Object executeFunction() {
// receiver
ReferenceConstant symb_receiver = this.getSymbReceiver();
String conc_receiver = (String) this.getConcReceiver();
// regex argument
ReferenceExpression symb_regex = this.getSymbArgument(0);
String conc_regex = (String) this.getConcArgument(0);
// replacement argument
ReferenceExpression symb_replacement = this.getSymbArgument(1);
String conc_replacement = (String) this.getConcArgument(1);
// return value
String conc_ret_val = (String) this.getConcRetVal();
ReferenceExpression symb_ret_val = this.getSymbRetVal();
StringValue stringReceiverExpr = env.heap.getField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_receiver, symb_receiver, conc_receiver);
if (symb_regex instanceof ReferenceConstant && symb_replacement instanceof ReferenceConstant) {
ReferenceConstant non_null_symb_regex = (ReferenceConstant) symb_regex;
StringValue regexExpr = env.heap.getField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_regex, non_null_symb_regex, conc_regex);
ReferenceConstant non_null_symb_replacement = (ReferenceConstant) symb_replacement;
StringValue replacementExpr = env.heap.getField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_replacement, non_null_symb_replacement, conc_replacement);
if (symb_ret_val instanceof ReferenceConstant) {
ReferenceConstant non_null_symb_ret_val = (ReferenceConstant) symb_ret_val;
StringMultipleExpression symb_value = new StringMultipleExpression(stringReceiverExpr, Operator.REPLACEFIRST, regexExpr, new ArrayList<Expression<?>>(Collections.singletonList(replacementExpr)), conc_ret_val);
env.heap.putField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_ret_val, non_null_symb_ret_val, symb_value);
}
}
return symb_ret_val;
}
Aggregations