Search in sources :

Example 1 with SmtExpr

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

the class ExprToZ3Visitor method visit.

@Override
public SmtExpr visit(HasMoreTokensExpr e, Void v) {
    Long longObject = e.getConcreteValue();
    SmtExpr intConst = createIntegerConstant(longObject);
    return intConst;
}
Also used : SmtExpr(org.evosuite.symbolic.solver.smt.SmtExpr)

Example 2 with SmtExpr

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

the class ExprToZ3Visitor method visit.

@Override
public SmtExpr visit(IntegerUnaryExpression e, Void v) {
    SmtExpr intExpr = e.getOperand().accept(this, null);
    if (intExpr == null) {
        return null;
    }
    if (!intExpr.isSymbolic()) {
        long longValue = e.getConcreteValue();
        return SmtExprBuilder.mkIntConstant(longValue);
    }
    switch(e.getOperator()) {
        case NEG:
            {
                SmtExpr minus_expr = SmtExprBuilder.mkNeg(intExpr);
                return minus_expr;
            }
        case GETNUMERICVALUE:
        case ISDIGIT:
        case ISLETTER:
            {
                long longValue = e.getConcreteValue();
                return SmtExprBuilder.mkIntConstant(longValue);
            }
        case ABS:
            SmtExpr zero = SmtExprBuilder.mkIntConstant(0);
            SmtExpr gte_than_zero = SmtExprBuilder.mkGe(intExpr, zero);
            SmtExpr minus_expr = SmtExprBuilder.mkNeg(intExpr);
            SmtExpr ite_expr = SmtExprBuilder.mkITE(gte_than_zero, intExpr, minus_expr);
            return ite_expr;
        default:
            throw new UnsupportedOperationException("Not implemented yet!" + e.getOperator());
    }
}
Also used : SmtExpr(org.evosuite.symbolic.solver.smt.SmtExpr)

Example 3 with SmtExpr

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

the class ExprToZ3Visitor method visit.

@Override
public SmtExpr visit(IntegerToRealCast e, Void v) {
    SmtExpr integerExpr = e.getArgument().accept(this, null);
    if (integerExpr == null) {
        return null;
    }
    if (!integerExpr.isSymbolic()) {
        double doubleVal = e.getConcreteValue();
        return mkRepresentableRealConstant(doubleVal);
    }
    SmtExpr realExpr = SmtExprBuilder.mkInt2Real(integerExpr);
    return realExpr;
}
Also used : SmtExpr(org.evosuite.symbolic.solver.smt.SmtExpr)

Example 4 with SmtExpr

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

the class ExprToZ3Visitor method visit.

@Override
public SmtExpr visit(RealBinaryExpression 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()) {
        double doubleValue = e.getConcreteValue();
        return mkRepresentableRealConstant(doubleValue);
    }
    switch(e.getOperator()) {
        case DIV:
            {
                SmtExpr z3_div = SmtExprBuilder.mkRealDiv(left, right);
                return z3_div;
            }
        case MUL:
            {
                SmtExpr z3_mul = SmtExprBuilder.mkMul(left, right);
                return z3_mul;
            }
        case MINUS:
            {
                SmtExpr z3_sub = SmtExprBuilder.mkSub(left, right);
                return z3_sub;
            }
        case PLUS:
            {
                SmtExpr z3_add = SmtExprBuilder.mkAdd(left, right);
                return z3_add;
            }
        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;
            }
        case ATAN2:
        case COPYSIGN:
        case HYPOT:
        case NEXTAFTER:
        case POW:
        case SCALB:
        case IEEEREMAINDER:
        case REM:
            {
                double doubleValue = e.getConcreteValue();
                return mkRepresentableRealConstant(doubleValue);
            }
        default:
            {
                throw new UnsupportedOperationException("Not implemented yet! " + e.getOperator());
            }
    }
}
Also used : SmtExpr(org.evosuite.symbolic.solver.smt.SmtExpr)

Example 5 with SmtExpr

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

the class ExprToZ3Visitor method visit.

@Override
public SmtExpr visit(StringReaderExpr e, Void v) {
    Long longObject = e.getConcreteValue();
    SmtExpr intConst = createIntegerConstant(longObject);
    return intConst;
}
Also used : SmtExpr(org.evosuite.symbolic.solver.smt.SmtExpr)

Aggregations

SmtExpr (org.evosuite.symbolic.solver.smt.SmtExpr)60 Operator (org.evosuite.symbolic.expr.Operator)14 LinkedList (java.util.LinkedList)8 Comparator (org.evosuite.symbolic.expr.Comparator)6 SmtAssertion (org.evosuite.symbolic.solver.smt.SmtAssertion)6 SmtIntConstant (org.evosuite.symbolic.solver.smt.SmtIntConstant)6 SmtConstantDeclaration (org.evosuite.symbolic.solver.smt.SmtConstantDeclaration)5 Expression (org.evosuite.symbolic.expr.Expression)4 IntegerBinaryExpression (org.evosuite.symbolic.expr.bv.IntegerBinaryExpression)4 IntegerUnaryExpression (org.evosuite.symbolic.expr.bv.IntegerUnaryExpression)4 RealUnaryToIntegerExpression (org.evosuite.symbolic.expr.bv.RealUnaryToIntegerExpression)4 StringBinaryToIntegerExpression (org.evosuite.symbolic.expr.bv.StringBinaryToIntegerExpression)4 StringMultipleToIntegerExpression (org.evosuite.symbolic.expr.bv.StringMultipleToIntegerExpression)4 StringUnaryToIntegerExpression (org.evosuite.symbolic.expr.bv.StringUnaryToIntegerExpression)4 RealBinaryExpression (org.evosuite.symbolic.expr.fp.RealBinaryExpression)4 RealUnaryExpression (org.evosuite.symbolic.expr.fp.RealUnaryExpression)4 GetFieldExpression (org.evosuite.symbolic.expr.ref.GetFieldExpression)4 StringBinaryExpression (org.evosuite.symbolic.expr.str.StringBinaryExpression)4 StringMultipleExpression (org.evosuite.symbolic.expr.str.StringMultipleExpression)4 StringUnaryExpression (org.evosuite.symbolic.expr.str.StringUnaryExpression)4