Search in sources :

Example 81 with ReferenceConstant

use of org.evosuite.symbolic.expr.ref.ReferenceConstant in project evosuite by EvoSuite.

the class ReplaceAll 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.REPLACEALL, 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;
}
Also used : ReferenceConstant(org.evosuite.symbolic.expr.ref.ReferenceConstant) StringMultipleExpression(org.evosuite.symbolic.expr.str.StringMultipleExpression) Expression(org.evosuite.symbolic.expr.Expression) ReferenceExpression(org.evosuite.symbolic.expr.ref.ReferenceExpression) StringMultipleExpression(org.evosuite.symbolic.expr.str.StringMultipleExpression) ReferenceExpression(org.evosuite.symbolic.expr.ref.ReferenceExpression) StringValue(org.evosuite.symbolic.expr.str.StringValue)

Example 82 with ReferenceConstant

use of org.evosuite.symbolic.expr.ref.ReferenceConstant in project evosuite by EvoSuite.

the class ToLowerCase method executeFunction.

@Override
public Object executeFunction() {
    // object receiver
    ReferenceConstant symb_str = this.getSymbReceiver();
    String conc_str = (String) this.getConcReceiver();
    // return value
    String conc_ret_val = (String) this.getConcRetVal();
    ReferenceConstant symb_ret_val = (ReferenceConstant) this.getSymbRetVal();
    StringValue string_expr = env.heap.getField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_str, symb_str, conc_str);
    StringUnaryExpression symb_value = new StringUnaryExpression(string_expr, Operator.TOLOWERCASE, conc_ret_val);
    env.heap.putField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_ret_val, symb_ret_val, symb_value);
    return this.getSymbRetVal();
}
Also used : ReferenceConstant(org.evosuite.symbolic.expr.ref.ReferenceConstant) StringUnaryExpression(org.evosuite.symbolic.expr.str.StringUnaryExpression) StringValue(org.evosuite.symbolic.expr.str.StringValue)

Example 83 with ReferenceConstant

use of org.evosuite.symbolic.expr.ref.ReferenceConstant in project evosuite by EvoSuite.

the class D_ValueOf method executeFunction.

@Override
public Object executeFunction() {
    RealValue real_value = this.getSymbRealArgument(0);
    ReferenceConstant symb_double = (ReferenceConstant) this.getSymbRetVal();
    Double conc_double = (Double) this.getConcRetVal();
    env.heap.putField(Types.JAVA_LANG_DOUBLE, SymbolicHeap.$DOUBLE_VALUE, conc_double, symb_double, real_value);
    return symb_double;
}
Also used : RealValue(org.evosuite.symbolic.expr.fp.RealValue) ReferenceConstant(org.evosuite.symbolic.expr.ref.ReferenceConstant)

Example 84 with ReferenceConstant

use of org.evosuite.symbolic.expr.ref.ReferenceConstant in project evosuite by EvoSuite.

the class F_Init method executeFunction.

@Override
public Object executeFunction() {
    RealValue fp32 = this.getSymbRealArgument(0);
    ReferenceConstant symb_float = this.getSymbReceiver();
    env.heap.putField(Types.JAVA_LANG_FLOAT, SymbolicHeap.$FLOAT_VALUE, null, /* conc_float */
    symb_float, fp32);
    // return void
    return null;
}
Also used : RealValue(org.evosuite.symbolic.expr.fp.RealValue) ReferenceConstant(org.evosuite.symbolic.expr.ref.ReferenceConstant)

Example 85 with ReferenceConstant

use of org.evosuite.symbolic.expr.ref.ReferenceConstant in project evosuite by EvoSuite.

the class I_Init method executeFunction.

@Override
public Object executeFunction() {
    IntegerValue bv32 = this.getSymbIntegerArgument(0);
    ReferenceConstant symb_integer = this.getSymbReceiver();
    env.heap.putField(Types.JAVA_LANG_INTEGER, SymbolicHeap.$INT_VALUE, null, /* conc_integer */
    symb_integer, bv32);
    // return void
    return null;
}
Also used : ReferenceConstant(org.evosuite.symbolic.expr.ref.ReferenceConstant) IntegerValue(org.evosuite.symbolic.expr.bv.IntegerValue)

Aggregations

ReferenceConstant (org.evosuite.symbolic.expr.ref.ReferenceConstant)99 StringValue (org.evosuite.symbolic.expr.str.StringValue)39 IntegerValue (org.evosuite.symbolic.expr.bv.IntegerValue)32 ReferenceExpression (org.evosuite.symbolic.expr.ref.ReferenceExpression)18 CodeUnderTestException (org.evosuite.testcase.execution.CodeUnderTestException)16 VariableReference (org.evosuite.testcase.variable.VariableReference)14 Type (org.objectweb.asm.Type)12 RealValue (org.evosuite.symbolic.expr.fp.RealValue)11 EvosuiteError (org.evosuite.testcase.execution.EvosuiteError)11 Expression (org.evosuite.symbolic.expr.Expression)9 StringBinaryComparison (org.evosuite.symbolic.expr.bv.StringBinaryComparison)8 IntegerVariable (org.evosuite.symbolic.expr.bv.IntegerVariable)6 PrimitiveExpression (org.evosuite.testcase.statements.PrimitiveExpression)5 StringConstant (org.evosuite.symbolic.expr.str.StringConstant)4 BigInteger (java.math.BigInteger)3 ArrayList (java.util.ArrayList)3 IntegerConstraint (org.evosuite.symbolic.expr.IntegerConstraint)3 IntegerConstant (org.evosuite.symbolic.expr.bv.IntegerConstant)3 StringBinaryToIntegerExpression (org.evosuite.symbolic.expr.bv.StringBinaryToIntegerExpression)3 StringReaderExpr (org.evosuite.symbolic.expr.reader.StringReaderExpr)3