Search in sources :

Example 41 with ReferenceExpression

use of org.evosuite.symbolic.expr.ref.ReferenceExpression in project evosuite by EvoSuite.

the class JumpVM method IF_ACMPEQ.

/* Reference equality */
/**
 * (left == right). (left != right) is just (not (left == right)).
 *
 * http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.
 * doc6.html#if_acmpcond
 */
@Override
public void IF_ACMPEQ(String className, String methName, int branchIndex, Object conc_left, Object conc_right) {
    ReferenceExpression right_ref = env.topFrame().operandStack.popRef();
    ReferenceExpression left_ref = env.topFrame().operandStack.popRef();
    env.heap.initializeReference(conc_left, left_ref);
    env.heap.initializeReference(conc_right, right_ref);
}
Also used : ReferenceExpression(org.evosuite.symbolic.expr.ref.ReferenceExpression)

Example 42 with ReferenceExpression

use of org.evosuite.symbolic.expr.ref.ReferenceExpression in project evosuite by EvoSuite.

the class SymbolicHeap method array_load.

public IntegerValue array_load(ReferenceExpression symb_array, int conc_index, long conc_value) {
    Map<Integer, Expression<?>> symb_array_contents = getOrCreateSymbolicArray(symb_array);
    IntegerValue symb_value = (IntegerValue) symb_array_contents.get(conc_index);
    if (symb_value == null || ((Long) symb_value.getConcreteValue()).longValue() != conc_value) {
        symb_value = ExpressionFactory.buildNewIntegerConstant(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) IntegerValue(org.evosuite.symbolic.expr.bv.IntegerValue)

Example 43 with ReferenceExpression

use of org.evosuite.symbolic.expr.ref.ReferenceExpression 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 StringValue getField(String className, String fieldName, Object conc_receiver, ReferenceExpression symb_receiver, String conc_value) {
    Map<ReferenceExpression, Expression<?>> symb_field = getOrCreateSymbolicField(className, fieldName);
    StringValue symb_value = (StringValue) symb_field.get(symb_receiver);
    if (symb_value == null || !((String) symb_value.getConcreteValue()).equals(conc_value)) {
        symb_value = ExpressionFactory.buildNewStringConstant(conc_value);
        symb_field.remove(symb_receiver);
    }
    return symb_value;
}
Also used : Expression(org.evosuite.symbolic.expr.Expression) ReferenceExpression(org.evosuite.symbolic.expr.ref.ReferenceExpression) ReferenceExpression(org.evosuite.symbolic.expr.ref.ReferenceExpression) StringValue(org.evosuite.symbolic.expr.str.StringValue)

Example 44 with ReferenceExpression

use of org.evosuite.symbolic.expr.ref.ReferenceExpression in project evosuite by EvoSuite.

the class SymbolicHeap method getReference.

/**
 * Returns a <code>ReferenceConstant</code> if the concrete reference is
 * null. Otherwise, it looks in the list of non-null symbolic references for
 * a symbolic reference with the concrete value. If it is found, that
 * symbolic reference is returned, otherwise a new reference constant is
 * created (and added ot the list of non-null symbolic references)
 *
 * @param conc_ref
 * @return
 */
public ReferenceExpression getReference(Object conc_ref) {
    if (conc_ref == null) {
        // null reference
        ReferenceConstant nullConstant = ExpressionFactory.buildNewNullExpression();
        return nullConstant;
    } else {
        int identityHashCode = System.identityHashCode(conc_ref);
        if (nonNullRefs.containsKey(identityHashCode)) {
            // already known object
            ReferenceExpression symb_ref = nonNullRefs.get(identityHashCode);
            return symb_ref;
        } else {
            // unknown object
            final Type type = Type.getType(conc_ref.getClass());
            ReferenceConstant ref_constant = new ReferenceConstant(type, newInstanceCount++);
            ref_constant.initializeReference(conc_ref);
            nonNullRefs.put(identityHashCode, ref_constant);
            return ref_constant;
        }
    }
}
Also used : ReferenceConstant(org.evosuite.symbolic.expr.ref.ReferenceConstant) Type(org.objectweb.asm.Type) ReferenceExpression(org.evosuite.symbolic.expr.ref.ReferenceExpression)

Example 45 with ReferenceExpression

use of org.evosuite.symbolic.expr.ref.ReferenceExpression in project evosuite by EvoSuite.

the class SymbolicFunctionVM method INVOKEINTERFACE.

@Override
public void INVOKEINTERFACE(Object conc_receiver, String owner, String name, String desc) {
    functionUnderExecution = getFunction(owner, name, desc);
    if (functionUnderExecution != null) {
        ReferenceExpression symb_receiver = getReceiverFromStack();
        functionUnderExecution.setReceiver(conc_receiver, symb_receiver);
        if (Type.getArgumentTypes(functionUnderExecution.getDesc()).length == 0) {
            callBeforeExecution(functionUnderExecution);
        }
    }
}
Also used : ReferenceExpression(org.evosuite.symbolic.expr.ref.ReferenceExpression)

Aggregations

ReferenceExpression (org.evosuite.symbolic.expr.ref.ReferenceExpression)73 IntegerValue (org.evosuite.symbolic.expr.bv.IntegerValue)27 IntegerConstraint (org.evosuite.symbolic.expr.IntegerConstraint)19 ReferenceConstant (org.evosuite.symbolic.expr.ref.ReferenceConstant)18 StringValue (org.evosuite.symbolic.expr.str.StringValue)16 Expression (org.evosuite.symbolic.expr.Expression)13 RealValue (org.evosuite.symbolic.expr.fp.RealValue)13 VariableReference (org.evosuite.testcase.variable.VariableReference)11 Type (org.objectweb.asm.Type)9 CodeUnderTestException (org.evosuite.testcase.execution.CodeUnderTestException)6 PrimitiveExpression (org.evosuite.testcase.statements.PrimitiveExpression)5 Field (java.lang.reflect.Field)3 StringBinaryComparison (org.evosuite.symbolic.expr.bv.StringBinaryComparison)3 Method (java.lang.reflect.Method)2 StringMultipleExpression (org.evosuite.symbolic.expr.str.StringMultipleExpression)2 EvosuiteError (org.evosuite.testcase.execution.EvosuiteError)2 ArrayReference (org.evosuite.testcase.variable.ArrayReference)2 BigInteger (java.math.BigInteger)1 Matcher (java.util.regex.Matcher)1 EvoSuiteFile (org.evosuite.runtime.testdata.EvoSuiteFile)1