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);
}
}
}
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;
}
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;
}
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;
}
Aggregations