use of org.evosuite.symbolic.solver.smt.SmtExpr in project evosuite by EvoSuite.
the class ExprToCVC4Visitor method visit.
@Override
public SmtExpr visit(StringUnaryExpression e, Void v) {
SmtExpr operand = e.getOperand().accept(this, null);
if (operand == null) {
return null;
}
if (!operand.isSymbolic()) {
String stringValue = e.getConcreteValue();
return SmtExprBuilder.mkStringConstant(stringValue);
}
Operator op = e.getOperator();
switch(op) {
case TRIM:
case TOLOWERCASE:
case TOUPPERCASE:
{
String stringValue = e.getConcreteValue();
return SmtExprBuilder.mkStringConstant(stringValue);
}
default:
throw new IllegalArgumentException("The operation " + op + " is not a unary string operation");
}
}
use of org.evosuite.symbolic.solver.smt.SmtExpr in project evosuite by EvoSuite.
the class ExprToCVC4Visitor method visit.
@Override
public SmtExpr visit(IntegerBinaryExpression 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()) {
long longValue = e.getConcreteValue();
return SmtExprBuilder.mkIntConstant(longValue);
}
switch(e.getOperator()) {
case DIV:
{
if (rewriteNonLinearExpressions) {
if (left.isSymbolic() && right.isSymbolic()) {
long rightValue = e.getRightOperand().getConcreteValue();
SmtExpr conc_right = SmtExprBuilder.mkIntConstant(rightValue);
SmtExpr rewrite_expr = SmtExprBuilder.mkIntDiv(left, conc_right);
return rewrite_expr;
}
}
SmtExpr expr = SmtExprBuilder.mkIntDiv(left, right);
return expr;
}
case MUL:
{
if (rewriteNonLinearExpressions) {
if (left.isSymbolic() && right.isSymbolic()) {
long rightValue = e.getRightOperand().getConcreteValue();
SmtExpr conc_right = SmtExprBuilder.mkIntConstant(rightValue);
SmtExpr rewrite_expr = SmtExprBuilder.mkMul(left, conc_right);
return rewrite_expr;
}
}
SmtExpr expr = SmtExprBuilder.mkMul(left, right);
return expr;
}
case MINUS:
{
SmtExpr expr = SmtExprBuilder.mkSub(left, right);
return expr;
}
case PLUS:
{
SmtExpr expr = SmtExprBuilder.mkAdd(left, right);
return expr;
}
case REM:
{
if (rewriteNonLinearExpressions) {
if (left.isSymbolic() && right.isSymbolic()) {
long rightValue = e.getRightOperand().getConcreteValue();
SmtExpr conc_right = SmtExprBuilder.mkIntConstant(rightValue);
SmtExpr rewrite_expr = SmtExprBuilder.mkMod(left, conc_right);
return rewrite_expr;
}
}
SmtExpr mod = SmtExprBuilder.mkMod(left, right);
return mod;
}
case IOR:
{
SmtExpr bv_left = SmtExprBuilder.mkInt2BV(32, left);
SmtExpr bv_right = SmtExprBuilder.mkInt2BV(32, right);
SmtExpr bvor = SmtExprBuilder.mkBVOR(bv_left, bv_right);
SmtExpr ret_val = mkBV2Int(bvor);
return ret_val;
}
case IAND:
{
SmtExpr bv_left = SmtExprBuilder.mkInt2BV(32, left);
SmtExpr bv_right = SmtExprBuilder.mkInt2BV(32, right);
SmtExpr bv_and = SmtExprBuilder.mkBVAND(bv_left, bv_right);
SmtExpr ret_val = mkBV2Int(bv_and);
return ret_val;
}
case IXOR:
{
SmtExpr bv_left = SmtExprBuilder.mkInt2BV(32, left);
SmtExpr bv_right = SmtExprBuilder.mkInt2BV(32, right);
SmtExpr bv_xor = SmtExprBuilder.mkBVXOR(bv_left, bv_right);
SmtExpr ret_val = mkBV2Int(bv_xor);
return ret_val;
}
case SHL:
{
SmtExpr bv_left = SmtExprBuilder.mkInt2BV(32, left);
SmtExpr bv_right = SmtExprBuilder.mkInt2BV(32, right);
SmtExpr bv_shl = SmtExprBuilder.mkBVSHL(bv_left, bv_right);
SmtExpr ret_val = mkBV2Int(bv_shl);
return ret_val;
}
case SHR:
{
SmtExpr bv_left = SmtExprBuilder.mkInt2BV(32, left);
SmtExpr bv_right = SmtExprBuilder.mkInt2BV(32, right);
SmtExpr bv_shr = SmtExprBuilder.mkBVASHR(bv_left, bv_right);
SmtExpr ret_val = mkBV2Int(bv_shr);
return ret_val;
}
case USHR:
{
SmtExpr bv_left = SmtExprBuilder.mkInt2BV(32, left);
SmtExpr bv_right = SmtExprBuilder.mkInt2BV(32, right);
SmtExpr bv_shr = SmtExprBuilder.mkBVLSHR(bv_left, bv_right);
SmtExpr ret_val = mkBV2Int(bv_shr);
return ret_val;
}
case MAX:
{
SmtExpr left_gt_right = SmtExprBuilder.mkGt(left, right);
SmtExpr ite_expr = SmtExprBuilder.mkITE(left_gt_right, left, right);
return ite_expr;
}
case MIN:
{
SmtExpr left_gt_right = SmtExprBuilder.mkLt(left, right);
SmtExpr ite_expr = SmtExprBuilder.mkITE(left_gt_right, left, right);
return ite_expr;
}
default:
{
throw new UnsupportedOperationException("Not implemented yet! " + e.getOperator());
}
}
}
use of org.evosuite.symbolic.solver.smt.SmtExpr in project evosuite by EvoSuite.
the class ExprToCVC4Visitor method visit.
@Override
public SmtExpr visit(IntegerConstant e, Void v) {
long longValue = e.getConcreteValue();
SmtExpr intConst = SmtExprBuilder.mkIntConstant(longValue);
return intConst;
}
use of org.evosuite.symbolic.solver.smt.SmtExpr in project evosuite by EvoSuite.
the class ConstraintToCVC4Visitor method visit.
private SmtExpr visit(Expression<?> leftOperand, Comparator cmp, Expression<?> rightOperand) {
SmtExpr left = leftOperand.accept(exprVisitor, null);
SmtExpr right = rightOperand.accept(exprVisitor, null);
if (left == null || right == null) {
return null;
}
return mkComparison(left, cmp, right);
}
use of org.evosuite.symbolic.solver.smt.SmtExpr in project evosuite by EvoSuite.
the class RegExpToCVC4Visitor method visitRepeatMin.
@Override
public SmtExpr visitRepeatMin(RegExp e, int min) {
SmtExpr regExpr = this.visitRegExp(e);
if (regExpr == null) {
return null;
}
if (min == 1) {
SmtExpr kleeneCrossExpr = SmtExprBuilder.mkRegExpKleeCross(regExpr);
return kleeneCrossExpr;
} else {
SmtIntConstant minExpr = SmtExprBuilder.mkIntConstant(min);
SmtExpr loopExpr = SmtExprBuilder.mkLoop(regExpr, minExpr);
return loopExpr;
}
}
Aggregations