Search in sources :

Example 6 with IntegerValue

use of org.evosuite.symbolic.expr.bv.IntegerValue in project evosuite by EvoSuite.

the class SymbolicFunctionVM method CALL_RESULT.

@Override
public void CALL_RESULT(int conc_ret_val, String owner, String name, String desc) {
    if (functionUnderExecution != null) {
        if (!functionUnderExecution.getOwner().equals(owner) || !functionUnderExecution.getName().equals(name) || !functionUnderExecution.getDesc().equals(desc)) {
            functionUnderExecution = null;
        }
    }
    if (functionUnderExecution != null) {
        IntegerValue symb_ret_val = this.env.topFrame().operandStack.peekBv32();
        functionUnderExecution.setReturnValue(conc_ret_val, symb_ret_val);
        IntegerValue new_symb_ret_val = (IntegerValue) functionUnderExecution.executeFunction();
        this.replaceTopBv32(new_symb_ret_val);
    }
    functionUnderExecution = null;
}
Also used : IntegerValue(org.evosuite.symbolic.expr.bv.IntegerValue)

Example 7 with IntegerValue

use of org.evosuite.symbolic.expr.bv.IntegerValue in project evosuite by EvoSuite.

the class SymbolicFunctionVM method CALLER_STACK_PARAM.

@Override
public void CALLER_STACK_PARAM(int nr, int calleeLocalsIndex, byte conc_arg) {
    if (functionUnderExecution != null) {
        IntegerValue symb_arg = getIntegerExprFromStack(nr);
        functionUnderExecution.setParam(nr, conc_arg, symb_arg);
        beforeExecuteFunction(nr);
    }
}
Also used : IntegerValue(org.evosuite.symbolic.expr.bv.IntegerValue)

Example 8 with IntegerValue

use of org.evosuite.symbolic.expr.bv.IntegerValue in project evosuite by EvoSuite.

the class SymbolicFunctionVM method CALLER_STACK_PARAM.

@Override
public void CALLER_STACK_PARAM(int nr, int calleeLocalsIndex, short conc_arg) {
    if (functionUnderExecution != null) {
        IntegerValue symb_arg = getIntegerExprFromStack(nr);
        functionUnderExecution.setParam(nr, conc_arg, symb_arg);
        beforeExecuteFunction(nr);
    }
}
Also used : IntegerValue(org.evosuite.symbolic.expr.bv.IntegerValue)

Example 9 with IntegerValue

use of org.evosuite.symbolic.expr.bv.IntegerValue in project evosuite by EvoSuite.

the class BigInteger_DivideAndRemainder method executeFunction.

@Override
public Object executeFunction() {
    BigInteger conc_left_big_integer = (BigInteger) this.getConcReceiver();
    ReferenceConstant symb_left_big_integer = this.getSymbReceiver();
    BigInteger conc_right_big_integer = (BigInteger) this.getConcArgument(0);
    ReferenceConstant symb_right_big_integer = (ReferenceConstant) this.getSymbArgument(0);
    Object res = this.getConcRetVal();
    ReferenceExpression symb_res = this.getSymbRetVal();
    if (res != null && conc_left_big_integer != null && conc_right_big_integer != null) {
        IntegerValue left_big_integer_expr = this.env.heap.getField(Types.JAVA_MATH_BIG_INTEGER, SymbolicHeap.$BIG_INTEGER_CONTENTS, conc_left_big_integer, symb_left_big_integer, conc_left_big_integer.longValue());
        IntegerValue right_big_integer_expr = this.env.heap.getField(Types.JAVA_MATH_BIG_INTEGER, SymbolicHeap.$BIG_INTEGER_CONTENTS, conc_right_big_integer, symb_right_big_integer, conc_right_big_integer.longValue());
        if (left_big_integer_expr.containsSymbolicVariable() || right_big_integer_expr.containsSymbolicVariable()) {
            // quotient
            BigInteger conc_quotient = (BigInteger) Array.get(res, QUOTIENT_ARRAY_INDEX);
            ReferenceConstant symb_quotient = (ReferenceConstant) this.env.heap.getReference(conc_quotient);
            IntegerValue symb_div_value = ExpressionFactory.div(left_big_integer_expr, right_big_integer_expr, conc_quotient.longValue());
            this.env.heap.putField(Types.JAVA_MATH_BIG_INTEGER, SymbolicHeap.$BIG_INTEGER_CONTENTS, conc_quotient, symb_quotient, symb_div_value);
            // remainder
            BigInteger conc_remainder = (BigInteger) Array.get(res, REMAINDER_ARRAY_INDEX);
            ReferenceConstant symb_remainder = (ReferenceConstant) this.env.heap.getReference(conc_remainder);
            IntegerValue symb_rem_value = ExpressionFactory.rem(left_big_integer_expr, right_big_integer_expr, conc_remainder.longValue());
            this.env.heap.putField(Types.JAVA_MATH_BIG_INTEGER, SymbolicHeap.$BIG_INTEGER_CONTENTS, conc_remainder, symb_remainder, symb_rem_value);
        }
    }
    return symb_res;
}
Also used : ReferenceConstant(org.evosuite.symbolic.expr.ref.ReferenceConstant) IntegerValue(org.evosuite.symbolic.expr.bv.IntegerValue) BigInteger(java.math.BigInteger) ReferenceExpression(org.evosuite.symbolic.expr.ref.ReferenceExpression)

Example 10 with IntegerValue

use of org.evosuite.symbolic.expr.bv.IntegerValue 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)

Aggregations

IntegerValue (org.evosuite.symbolic.expr.bv.IntegerValue)117 IntegerConstraint (org.evosuite.symbolic.expr.IntegerConstraint)48 ReferenceConstant (org.evosuite.symbolic.expr.ref.ReferenceConstant)32 ReferenceExpression (org.evosuite.symbolic.expr.ref.ReferenceExpression)27 RealValue (org.evosuite.symbolic.expr.fp.RealValue)22 IntegerBinaryExpression (org.evosuite.symbolic.expr.bv.IntegerBinaryExpression)14 Expression (org.evosuite.symbolic.expr.Expression)8 StringValue (org.evosuite.symbolic.expr.str.StringValue)8 IntegerConstant (org.evosuite.symbolic.expr.bv.IntegerConstant)7 Type (org.objectweb.asm.Type)7 RealToIntegerCast (org.evosuite.symbolic.expr.bv.RealToIntegerCast)6 IntegerToRealCast (org.evosuite.symbolic.expr.fp.IntegerToRealCast)6 IntegerUnaryExpression (org.evosuite.symbolic.expr.bv.IntegerUnaryExpression)5 PrimitiveExpression (org.evosuite.testcase.statements.PrimitiveExpression)4 ArrayList (java.util.ArrayList)3 CodeUnderTestException (org.evosuite.testcase.execution.CodeUnderTestException)3 Field (java.lang.reflect.Field)2 BigInteger (java.math.BigInteger)2 Vector (java.util.Vector)2 Constraint (org.evosuite.symbolic.expr.Constraint)2