Search in sources :

Example 1 with StringNextTokenExpr

use of org.evosuite.symbolic.expr.token.StringNextTokenExpr in project evosuite by EvoSuite.

the class NextToken method executeFunction.

@Override
public Object executeFunction() {
    ReferenceConstant symb_receiver = this.getSymbReceiver();
    StringTokenizer conc_receiver = (StringTokenizer) this.getConcReceiver();
    TokenizerExpr tokenizerExpr = (TokenizerExpr) env.heap.getField(Types.JAVA_UTIL_STRING_TOKENIZER, SymbolicHeap.$STRING_TOKENIZER_VALUE, conc_receiver, symb_receiver);
    if (tokenizerExpr != null && tokenizerExpr.containsSymbolicVariable()) {
        ReferenceConstant symb_ret_val = (ReferenceConstant) this.getSymbRetVal();
        String conc_ret_val = (String) this.getConcRetVal();
        // create new NEXT_TOKEN string expression
        StringNextTokenExpr string_next_token_expr = new StringNextTokenExpr(tokenizerExpr, conc_ret_val);
        env.heap.putField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_ret_val, symb_ret_val, string_next_token_expr);
        // update StringTokenizer's symbolic state
        NextTokenizerExpr nextTokenizerExpr = new NextTokenizerExpr(tokenizerExpr);
        env.heap.putField(Types.JAVA_UTIL_STRING_TOKENIZER, SymbolicHeap.$STRING_TOKENIZER_VALUE, conc_receiver, symb_receiver, nextTokenizerExpr);
    }
    return this.getSymbRetVal();
}
Also used : ReferenceConstant(org.evosuite.symbolic.expr.ref.ReferenceConstant) NextTokenizerExpr(org.evosuite.symbolic.expr.token.NextTokenizerExpr) StringTokenizer(java.util.StringTokenizer) StringNextTokenExpr(org.evosuite.symbolic.expr.token.StringNextTokenExpr) NextTokenizerExpr(org.evosuite.symbolic.expr.token.NextTokenizerExpr) TokenizerExpr(org.evosuite.symbolic.expr.token.TokenizerExpr)

Aggregations

StringTokenizer (java.util.StringTokenizer)1 ReferenceConstant (org.evosuite.symbolic.expr.ref.ReferenceConstant)1 NextTokenizerExpr (org.evosuite.symbolic.expr.token.NextTokenizerExpr)1 StringNextTokenExpr (org.evosuite.symbolic.expr.token.StringNextTokenExpr)1 TokenizerExpr (org.evosuite.symbolic.expr.token.TokenizerExpr)1