Search in sources :

Example 46 with ReferenceExpression

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

the class SymbolicFunctionVM method INVOKEVIRTUAL.

@Override
public void INVOKEVIRTUAL(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(desc).length == 0) {
            callBeforeExecution(functionUnderExecution);
        }
    }
}
Also used : ReferenceExpression(org.evosuite.symbolic.expr.ref.ReferenceExpression)

Example 47 with ReferenceExpression

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

the class SymbolicFunctionVM method INVOKESPECIAL.

@Override
public void INVOKESPECIAL(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(desc).length == 0) {
            callBeforeExecution(functionUnderExecution);
        }
    }
}
Also used : ReferenceExpression(org.evosuite.symbolic.expr.ref.ReferenceExpression)

Example 48 with ReferenceExpression

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

the class CallVM method INVOKEVIRTUAL.

/**
 * We get this callback right before the user code makes the corresponding
 * virtual call to method className.methName(methDesc). See:
 * {@link ConcolicMethodAdapter#visitMethodInsn}
 *
 * <p>
 * The current instrumentation system only calls this version of
 * INVOKEVIRTUAL for methods that take two or fewer parameters.
 *
 * http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.
 * doc6.html#invokevirtual
 */
@Override
public void INVOKEVIRTUAL(Object conc_receiver, String className, String methName, String methDesc) {
    stackParamCount = 0;
    env.topFrame().invokeNeedsThis = true;
    Iterator<Operand> it = env.topFrame().operandStack.iterator();
    Type[] argTypes = Type.getArgumentTypes(methDesc);
    for (int i = 0; i < argTypes.length; i++) {
        it.next();
    }
    ReferenceOperand ref_operand = (ReferenceOperand) it.next();
    ReferenceExpression symb_receiver = ref_operand.getReference();
    env.heap.initializeReference(conc_receiver, symb_receiver);
    if (nullReferenceViolation(conc_receiver, symb_receiver))
        return;
    String concreteClassName = conc_receiver.getClass().getName();
    Method virtualMethod = methodCall(concreteClassName, methName, methDesc);
    chooseReceiverType(className, conc_receiver, methDesc, virtualMethod);
}
Also used : Type(org.objectweb.asm.Type) ReferenceExpression(org.evosuite.symbolic.expr.ref.ReferenceExpression) Method(java.lang.reflect.Method)

Example 49 with ReferenceExpression

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

the class CallVM method METHOD_BEGIN_RECEIVER.

@Override
public void METHOD_BEGIN_RECEIVER(Object value) {
    if (!env.callerFrame().weInvokedInstrumentedCode()) {
        ReferenceExpression ref = env.heap.getReference(value);
        env.topFrame().localsTable.setRefLocal(0, ref);
    }
}
Also used : ReferenceExpression(org.evosuite.symbolic.expr.ref.ReferenceExpression)

Example 50 with ReferenceExpression

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

the class CallVM method CALL_RESULT.

@Override
public void CALL_RESULT(Object res, String owner, String name, String desc) {
    CALL_RESULT(owner, name, desc);
    if (env.topFrame().weInvokedInstrumentedCode())
        // RETURN already did it
        return;
    else {
        /**
         * We are returning from uninstrumented code. This is the only way
         * of storing the method return value to the symbolic state.
         */
        ReferenceExpression symb_ref = env.heap.getReference(res);
        env.topFrame().operandStack.pushRef(symb_ref);
    }
}
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