Search in sources :

Example 6 with Expression

use of org.evosuite.symbolic.expr.Expression in project evosuite by EvoSuite.

the class SymbolicHeap method array_load.

public StringValue array_load(ReferenceExpression symb_array, int conc_index, String conc_value) {
    Map<Integer, Expression<?>> symb_array_contents = getOrCreateSymbolicArray(symb_array);
    StringValue symb_value = (StringValue) symb_array_contents.get(conc_index);
    if (symb_value == null || !((String) symb_value.getConcreteValue()).equals(conc_value)) {
        symb_value = ExpressionFactory.buildNewStringConstant(conc_value);
        symb_array_contents.remove(conc_index);
    }
    return symb_value;
}
Also used : Expression(org.evosuite.symbolic.expr.Expression) ReferenceExpression(org.evosuite.symbolic.expr.ref.ReferenceExpression) StringValue(org.evosuite.symbolic.expr.str.StringValue)

Example 7 with Expression

use of org.evosuite.symbolic.expr.Expression in project evosuite by EvoSuite.

the class SymbolicHeap method array_load.

public RealValue array_load(ReferenceExpression symb_array, int conc_index, double conc_value) {
    Map<Integer, Expression<?>> symb_array_contents = getOrCreateSymbolicArray(symb_array);
    RealValue symb_value = (RealValue) symb_array_contents.get(conc_index);
    if (symb_value == null || ((Double) symb_value.getConcreteValue()).doubleValue() != conc_value) {
        symb_value = ExpressionFactory.buildNewRealConstant(conc_value);
        symb_array_contents.remove(conc_index);
    }
    return symb_value;
}
Also used : RealValue(org.evosuite.symbolic.expr.fp.RealValue) Expression(org.evosuite.symbolic.expr.Expression) ReferenceExpression(org.evosuite.symbolic.expr.ref.ReferenceExpression)

Example 8 with Expression

use of org.evosuite.symbolic.expr.Expression in project evosuite by EvoSuite.

the class SymbolicHeap method getField.

/**
 * @param className
 * @param fieldName
 * @param conc_receiver
 * @param symb_receiver
 * @param conc_value
 * @return
 */
public RealValue getField(String className, String fieldName, Object conc_receiver, ReferenceExpression symb_receiver, double conc_value) {
    Map<ReferenceExpression, Expression<?>> symb_field = getOrCreateSymbolicField(className, fieldName);
    RealValue symb_value = (RealValue) symb_field.get(symb_receiver);
    if (symb_value == null || ((Double) symb_value.getConcreteValue()).doubleValue() != conc_value) {
        symb_value = ExpressionFactory.buildNewRealConstant(conc_value);
        symb_field.remove(symb_receiver);
    }
    return symb_value;
}
Also used : RealValue(org.evosuite.symbolic.expr.fp.RealValue) Expression(org.evosuite.symbolic.expr.Expression) ReferenceExpression(org.evosuite.symbolic.expr.ref.ReferenceExpression) ReferenceExpression(org.evosuite.symbolic.expr.ref.ReferenceExpression)

Example 9 with Expression

use of org.evosuite.symbolic.expr.Expression in project evosuite by EvoSuite.

the class RegionMatches5 method executeFunction.

@Override
public Object executeFunction() {
    ReferenceConstant symb_receiver = (ReferenceConstant) this.getSymbReceiver();
    String conc_receiver = (String) this.getConcReceiver();
    StringValue stringReceiverExpr = env.heap.getField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_receiver, symb_receiver, conc_receiver);
    IntegerValue ignoreCaseExpr = new IntegerConstant(0);
    IntegerValue toffsetExpr = this.getSymbIntegerArgument(0);
    ReferenceConstant symb_other = (ReferenceConstant) this.getSymbArgument(1);
    String conc_other = (String) this.getConcArgument(1);
    StringValue otherExpr = env.heap.getField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_other, symb_other, conc_other);
    IntegerValue ooffsetExpr = this.getSymbIntegerArgument(2);
    IntegerValue lenExpr = this.getSymbIntegerArgument(3);
    boolean res = this.getConcBooleanRetVal();
    if (stringReceiverExpr.containsSymbolicVariable() || ignoreCaseExpr.containsSymbolicVariable() || toffsetExpr.containsSymbolicVariable() || otherExpr.containsSymbolicVariable() || ooffsetExpr.containsSymbolicVariable() || lenExpr.containsSymbolicVariable()) {
        ArrayList<Expression<?>> other = new ArrayList<Expression<?>>();
        other.add(toffsetExpr);
        other.add(ooffsetExpr);
        other.add(lenExpr);
        other.add(ignoreCaseExpr);
        int conV = res ? 1 : 0;
        StringMultipleComparison strComp = new StringMultipleComparison(stringReceiverExpr, Operator.REGIONMATCHES, otherExpr, other, (long) conV);
        return strComp;
    }
    return this.getSymbIntegerRetVal();
}
Also used : ReferenceConstant(org.evosuite.symbolic.expr.ref.ReferenceConstant) StringMultipleComparison(org.evosuite.symbolic.expr.bv.StringMultipleComparison) Expression(org.evosuite.symbolic.expr.Expression) IntegerValue(org.evosuite.symbolic.expr.bv.IntegerValue) ArrayList(java.util.ArrayList) StringValue(org.evosuite.symbolic.expr.str.StringValue) IntegerConstant(org.evosuite.symbolic.expr.bv.IntegerConstant)

Example 10 with Expression

use of org.evosuite.symbolic.expr.Expression in project evosuite by EvoSuite.

the class RegionMatches method executeFunction.

@Override
public Object executeFunction() {
    ReferenceConstant symb_receiver = (ReferenceConstant) this.getSymbReceiver();
    String conc_receiver = (String) this.getConcReceiver();
    StringValue stringReceiverExpr = env.heap.getField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_receiver, symb_receiver, conc_receiver);
    IntegerValue ignoreCaseExpr = this.getSymbIntegerArgument(0);
    IntegerValue toffsetExpr = this.getSymbIntegerArgument(1);
    ReferenceConstant symb_other = (ReferenceConstant) this.getSymbArgument(2);
    String conc_other = (String) this.getConcArgument(2);
    StringValue otherExpr = env.heap.getField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_other, symb_other, conc_other);
    IntegerValue ooffsetExpr = this.getSymbIntegerArgument(3);
    IntegerValue lenExpr = this.getSymbIntegerArgument(4);
    boolean res = this.getConcBooleanRetVal();
    if (stringReceiverExpr.containsSymbolicVariable() || ignoreCaseExpr.containsSymbolicVariable() || toffsetExpr.containsSymbolicVariable() || otherExpr.containsSymbolicVariable() || ooffsetExpr.containsSymbolicVariable() || lenExpr.containsSymbolicVariable()) {
        ArrayList<Expression<?>> other = new ArrayList<Expression<?>>();
        other.add(toffsetExpr);
        other.add(ooffsetExpr);
        other.add(lenExpr);
        other.add(ignoreCaseExpr);
        int conV = res ? 1 : 0;
        StringMultipleComparison strComp = new StringMultipleComparison(stringReceiverExpr, Operator.REGIONMATCHES, otherExpr, other, (long) conV);
        return strComp;
    }
    return this.getSymbIntegerRetVal();
}
Also used : ReferenceConstant(org.evosuite.symbolic.expr.ref.ReferenceConstant) StringMultipleComparison(org.evosuite.symbolic.expr.bv.StringMultipleComparison) Expression(org.evosuite.symbolic.expr.Expression) IntegerValue(org.evosuite.symbolic.expr.bv.IntegerValue) ArrayList(java.util.ArrayList) StringValue(org.evosuite.symbolic.expr.str.StringValue)

Aggregations

Expression (org.evosuite.symbolic.expr.Expression)24 ReferenceExpression (org.evosuite.symbolic.expr.ref.ReferenceExpression)13 StringValue (org.evosuite.symbolic.expr.str.StringValue)10 ReferenceConstant (org.evosuite.symbolic.expr.ref.ReferenceConstant)9 IntegerValue (org.evosuite.symbolic.expr.bv.IntegerValue)8 StringBinaryToIntegerExpression (org.evosuite.symbolic.expr.bv.StringBinaryToIntegerExpression)8 StringUnaryExpression (org.evosuite.symbolic.expr.str.StringUnaryExpression)8 ArrayList (java.util.ArrayList)6 IntegerConstant (org.evosuite.symbolic.expr.bv.IntegerConstant)6 StringMultipleComparison (org.evosuite.symbolic.expr.bv.StringMultipleComparison)6 RealValue (org.evosuite.symbolic.expr.fp.RealValue)6 StringMultipleExpression (org.evosuite.symbolic.expr.str.StringMultipleExpression)6 StringConstraint (org.evosuite.symbolic.expr.StringConstraint)5 PrimitiveExpression (org.evosuite.testcase.statements.PrimitiveExpression)5 LinkedList (java.util.LinkedList)4 Constraint (org.evosuite.symbolic.expr.Constraint)4 IntegerConstraint (org.evosuite.symbolic.expr.IntegerConstraint)4 Operator (org.evosuite.symbolic.expr.Operator)4 IntegerBinaryExpression (org.evosuite.symbolic.expr.bv.IntegerBinaryExpression)4 IntegerUnaryExpression (org.evosuite.symbolic.expr.bv.IntegerUnaryExpression)4