Search in sources :

Example 1 with NewTokenizerExpr

use of org.evosuite.symbolic.expr.token.NewTokenizerExpr 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;
}
Also used : ReferenceConstant(org.evosuite.symbolic.expr.ref.ReferenceConstant) NewTokenizerExpr(org.evosuite.symbolic.expr.token.NewTokenizerExpr) ReferenceExpression(org.evosuite.symbolic.expr.ref.ReferenceExpression) StringValue(org.evosuite.symbolic.expr.str.StringValue)

Aggregations

ReferenceConstant (org.evosuite.symbolic.expr.ref.ReferenceConstant)1 ReferenceExpression (org.evosuite.symbolic.expr.ref.ReferenceExpression)1 StringValue (org.evosuite.symbolic.expr.str.StringValue)1 NewTokenizerExpr (org.evosuite.symbolic.expr.token.NewTokenizerExpr)1