Search in sources :

Example 1 with SmtStringConstant

use of org.evosuite.symbolic.solver.smt.SmtStringConstant in project evosuite by EvoSuite.

the class ExprToCVC4Visitor method visit.

@Override
public SmtExpr visit(StringBinaryExpression e, Void v) {
    SmtExpr left = e.getLeftOperand().accept(this, null);
    SmtExpr right = e.getRightOperand().accept(this, null);
    if (left == null || right == null) {
        return null;
    }
    if (!left.isSymbolic() && !right.isSymbolic()) {
        String stringValue = e.getConcreteValue();
        SmtExpr strConstant = SmtExprBuilder.mkStringConstant(stringValue);
        return strConstant;
    }
    Operator op = e.getOperator();
    switch(op) {
        case CONCAT:
            {
                SmtExpr concatExpr = SmtExprBuilder.mkStrConcat(left, right);
                return concatExpr;
            }
        case APPEND_STRING:
            {
                SmtExpr concatExpr = SmtExprBuilder.mkStrConcat(left, right);
                return concatExpr;
            }
        case APPEND_INTEGER:
            {
                SmtExpr rigthStr = SmtExprBuilder.mkIntToStr(right);
                SmtExpr concatExpr = SmtExprBuilder.mkStrConcat(left, rigthStr);
                return concatExpr;
            }
        case APPEND_BOOLEAN:
            {
                SmtIntConstant zero = SmtExprBuilder.ZERO_INT;
                SmtExpr eqZero = SmtExprBuilder.mkEq(right, zero);
                SmtStringConstant falseConstantExpr = SmtExprBuilder.mkStringConstant(String.valueOf(Boolean.FALSE));
                SmtStringConstant trueConstantExpr = SmtExprBuilder.mkStringConstant(String.valueOf(Boolean.TRUE));
                SmtExpr ite = SmtExprBuilder.mkITE(eqZero, falseConstantExpr, trueConstantExpr);
                SmtExpr concatExpr = SmtExprBuilder.mkStrConcat(left, ite);
                return concatExpr;
            }
        case APPEND_CHAR:
            {
                SmtExpr rigthStr = SmtExprBuilder.mkIntToChar(right);
                SmtExpr concatExpr = SmtExprBuilder.mkStrConcat(left, rigthStr);
                return concatExpr;
            }
        case APPEND_REAL:
            {
                String stringValue = e.getConcreteValue();
                SmtExpr strConstant = SmtExprBuilder.mkStringConstant(stringValue);
                return strConstant;
            }
        default:
            {
                throw new UnsupportedOperationException("Not implemented yet! " + op);
            }
    }
}
Also used : Operator(org.evosuite.symbolic.expr.Operator) SmtIntConstant(org.evosuite.symbolic.solver.smt.SmtIntConstant) SmtExpr(org.evosuite.symbolic.solver.smt.SmtExpr) SmtStringConstant(org.evosuite.symbolic.solver.smt.SmtStringConstant)

Example 2 with SmtStringConstant

use of org.evosuite.symbolic.solver.smt.SmtStringConstant in project evosuite by EvoSuite.

the class RegExpToCVC4Visitor method visitCharRange.

@Override
public SmtExpr visitCharRange(char from, char to) {
    String fromStr = String.valueOf(from);
    SmtStringConstant fromConstant = SmtExprBuilder.mkStringConstant(fromStr);
    String toStr = String.valueOf(to);
    SmtStringConstant toConstant = SmtExprBuilder.mkStringConstant(toStr);
    SmtExpr rangeExpr = SmtExprBuilder.mkRegExpRange(fromConstant, toConstant);
    return rangeExpr;
}
Also used : SmtExpr(org.evosuite.symbolic.solver.smt.SmtExpr) SmtStringConstant(org.evosuite.symbolic.solver.smt.SmtStringConstant)

Example 3 with SmtStringConstant

use of org.evosuite.symbolic.solver.smt.SmtStringConstant in project evosuite by EvoSuite.

the class RegExpToCVC4Visitor method visitChar.

@Override
public SmtExpr visitChar(char c) {
    String str = String.valueOf(c);
    SmtStringConstant strConstant = SmtExprBuilder.mkStringConstant(str);
    SmtExpr expr = SmtExprBuilder.mkStrToRegExp(strConstant);
    return expr;
}
Also used : SmtExpr(org.evosuite.symbolic.solver.smt.SmtExpr) SmtStringConstant(org.evosuite.symbolic.solver.smt.SmtStringConstant)

Example 4 with SmtStringConstant

use of org.evosuite.symbolic.solver.smt.SmtStringConstant in project evosuite by EvoSuite.

the class RegExpToCVC4Visitor method visitString.

@Override
public SmtExpr visitString(String s) {
    SmtStringConstant strConstant = SmtExprBuilder.mkStringConstant(s);
    SmtExpr strToRegExpr = SmtExprBuilder.mkStrToRegExp(strConstant);
    return strToRegExpr;
}
Also used : SmtExpr(org.evosuite.symbolic.solver.smt.SmtExpr) SmtStringConstant(org.evosuite.symbolic.solver.smt.SmtStringConstant)

Aggregations

SmtExpr (org.evosuite.symbolic.solver.smt.SmtExpr)4 SmtStringConstant (org.evosuite.symbolic.solver.smt.SmtStringConstant)4 Operator (org.evosuite.symbolic.expr.Operator)1 SmtIntConstant (org.evosuite.symbolic.solver.smt.SmtIntConstant)1