use of org.evosuite.symbolic.expr.Operator in project evosuite by EvoSuite.
the class LOG10 method executeFunction.
@Override
public Object executeFunction() {
double res = this.getConcDoubleRetVal();
RealValue realExpression = this.getSymbRealArgument(0);
RealValue log10Expr;
if (realExpression.containsSymbolicVariable()) {
Operator op = Operator.LOG10;
log10Expr = new RealUnaryExpression(realExpression, op, res);
} else {
log10Expr = this.getSymbRealRetVal();
}
return log10Expr;
}
use of org.evosuite.symbolic.expr.Operator in project evosuite by EvoSuite.
the class SQRT method executeFunction.
@Override
public Object executeFunction() {
double res = this.getConcDoubleRetVal();
RealValue realExpression = this.getSymbRealArgument(0);
RealValue sqrtExpr;
if (realExpression.containsSymbolicVariable()) {
Operator op = Operator.SQRT;
sqrtExpr = new RealUnaryExpression(realExpression, op, res);
} else {
sqrtExpr = this.getSymbRealRetVal();
}
return sqrtExpr;
}
use of org.evosuite.symbolic.expr.Operator in project evosuite by EvoSuite.
the class ExprToZ3Str2Visitor method visit.
@Override
public SmtExpr visit(StringMultipleExpression e, Void arg) {
Expression<String> leftOperand = e.getLeftOperand();
Expression<?> rightOperand = e.getRightOperand();
Operator op = e.getOperator();
ArrayList<Expression<?>> othersOperands = e.getOther();
SmtExpr left = leftOperand.accept(this, null);
SmtExpr right = rightOperand.accept(this, null);
List<SmtExpr> others = new LinkedList<SmtExpr>();
for (Expression<?> otherOperand : othersOperands) {
SmtExpr other = otherOperand.accept(this, null);
others.add(other);
}
if (left == null || right == null) {
return null;
}
for (SmtExpr expr : others) {
if (expr == null) {
return null;
}
}
if (!left.isSymbolic() && !right.isSymbolic()) {
boolean isSymbolic = false;
for (SmtExpr smtExpr : others) {
if (smtExpr.isSymbolic()) {
isSymbolic = true;
}
}
if (!isSymbolic) {
String stringValue = e.getConcreteValue();
return mkStringConstant(stringValue);
}
}
switch(op) {
case REPLACECS:
{
SmtExpr string = left;
SmtExpr target = right;
SmtExpr replacement = others.get(0);
SmtExpr substringExpr = SmtExprBuilder.mkReplace(string, target, replacement);
return substringExpr;
}
case SUBSTRING:
{
SmtExpr string = left;
SmtExpr fromExpr = right;
SmtExpr toExpr = others.get(0);
SmtExpr substringExpr = SmtExprBuilder.mkSubstring(string, fromExpr, toExpr);
return substringExpr;
}
case REPLACEC:
case REPLACEALL:
case REPLACEFIRST:
{
String stringValue = e.getConcreteValue();
return mkStringConstant(stringValue);
}
default:
throw new UnsupportedOperationException("Not implemented yet! " + op);
}
}
use of org.evosuite.symbolic.expr.Operator in project evosuite by EvoSuite.
the class ExprToZ3Str2Visitor method visit.
@Override
public SmtExpr visit(StringBinaryToIntegerExpression e, Void arg) {
Expression<String> leftOperand = e.getLeftOperand();
Operator op = e.getOperator();
Expression<?> rightOperand = e.getRightOperand();
SmtExpr left = leftOperand.accept(this, null);
SmtExpr right = rightOperand.accept(this, null);
if (left == null || right == null) {
return null;
}
if (!left.isSymbolic() && !right.isSymbolic()) {
long longValue = e.getConcreteValue();
return SmtExprBuilder.mkIntConstant(longValue);
}
switch(op) {
case INDEXOFS:
{
SmtExpr indexOfExpr = SmtExprBuilder.mkIndexOf(left, right);
return indexOfExpr;
}
case CHARAT:
{
SmtExpr startExpr = right;
SmtExpr lengthExpr = SmtExprBuilder.ONE_INT;
SmtExpr charAtExpr = SmtExprBuilder.mkSubstring(left, startExpr, lengthExpr);
SmtExpr charToInt = SmtExprBuilder.mkCharToInt(charAtExpr);
return charToInt;
}
case INDEXOFC:
case LASTINDEXOFC:
case LASTINDEXOFS:
case COMPARETO:
case COMPARETOIGNORECASE:
{
long longValue = e.getConcreteValue();
return SmtExprBuilder.mkIntConstant(longValue);
}
default:
{
throw new UnsupportedOperationException("Not implemented yet!" + e.getOperator());
}
}
}
use of org.evosuite.symbolic.expr.Operator in project evosuite by EvoSuite.
the class ExprToZ3Str2Visitor method visit.
@Override
public SmtExpr visit(StringUnaryToIntegerExpression e, Void arg) {
SmtExpr innerString = e.getOperand().accept(this, null);
if (innerString == null) {
return null;
}
if (!innerString.isSymbolic()) {
long longValue = e.getConcreteValue();
return SmtExprBuilder.mkIntConstant(longValue);
}
Operator op = e.getOperator();
switch(op) {
case LENGTH:
{
return SmtExprBuilder.mkLength(innerString);
}
case IS_INTEGER:
{
long longValue = e.getConcreteValue();
return SmtExprBuilder.mkIntConstant(longValue);
}
default:
throw new UnsupportedOperationException("Not implemented yet!");
}
}
Aggregations