Search in sources :

Example 51 with ReferenceConstant

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

the class I_IntValue method executeFunction.

@Override
public Object executeFunction() {
    ReferenceConstant symb_integer = this.getSymbReceiver();
    Integer conc_integer = (Integer) this.getConcReceiver();
    int conc_int_value = this.getConcIntRetVal();
    IntegerValue symb_int_value = env.heap.getField(Types.JAVA_LANG_INTEGER, SymbolicHeap.$INT_VALUE, conc_integer, symb_integer, conc_int_value);
    return symb_int_value;
}
Also used : ReferenceConstant(org.evosuite.symbolic.expr.ref.ReferenceConstant) IntegerValue(org.evosuite.symbolic.expr.bv.IntegerValue)

Example 52 with ReferenceConstant

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

the class J_ValueOf method executeFunction.

@Override
public Object executeFunction() {
    IntegerValue int_value = this.getSymbIntegerArgument(0);
    ReferenceConstant symb_long = (ReferenceConstant) this.getSymbRetVal();
    Long conc_long = (Long) this.getConcRetVal();
    env.heap.putField(Types.JAVA_LANG_LONG, SymbolicHeap.$LONG_VALUE, conc_long, symb_long, int_value);
    return symb_long;
}
Also used : ReferenceConstant(org.evosuite.symbolic.expr.ref.ReferenceConstant) IntegerValue(org.evosuite.symbolic.expr.bv.IntegerValue)

Example 53 with ReferenceConstant

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

the class S_ShortValue method executeFunction.

@Override
public Object executeFunction() {
    ReferenceConstant symb_short = this.getSymbReceiver();
    Short conc_short = (Short) this.getConcReceiver();
    short conc_short_value = this.getConcShortRetVal();
    IntegerValue symb_short_value = env.heap.getField(Types.JAVA_LANG_SHORT, SymbolicHeap.$SHORT_VALUE, conc_short, symb_short, conc_short_value);
    return symb_short_value;
}
Also used : ReferenceConstant(org.evosuite.symbolic.expr.ref.ReferenceConstant) IntegerValue(org.evosuite.symbolic.expr.bv.IntegerValue)

Example 54 with ReferenceConstant

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

the class CallVM method HANDLER_BEGIN.

/**
 * Begin of a basic block that is the begin of an exception handler.
 *
 * We could be in an entirely different invocation frame than the previous
 * instruction was in.
 *
 * TODO: Account for different call sites in the same method. This may lead
 * to the need to discard frames although they are of the same function as
 * indicated by the parameters.
 */
@Override
public void HANDLER_BEGIN(int access, String className, String methName, String methDesc) {
    if (conf.CLINIT.equals(methName)) {
        discardFramesClassInitializer(className, methName);
    } else {
        // the method or constructor containing this handler
        Member function = null;
        if (conf.INIT.equals(methName))
            function = resolveConstructorOverloading(className, methDesc);
        else
            function = resolveMethodOverloading(className, methName, methDesc);
        /**
         * function could be equal to null if handler is in class
         * initializer
         */
        discardFrames(className, methName, function);
    }
    env.topFrame().operandStack.clearOperands();
    /**
     * This exception is added to the HANDLER_BEGIN because no other
     * instruction adds the corresponding exception. The handler will store
     * the exception to the locals table
     */
    ReferenceConstant exception_reference = new ReferenceConstant(Type.getType(Exception.class), -1);
    env.topFrame().operandStack.pushRef(exception_reference);
}
Also used : ReferenceConstant(org.evosuite.symbolic.expr.ref.ReferenceConstant) Member(java.lang.reflect.Member)

Example 55 with ReferenceConstant

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

the class HeapVM method NEW.

/**
 * Allocate space on the heap and push a reference ref to it onto the stack.
 *
 * For each instance field declared by class className, we add a tuple (ref,
 * default value) to the field's map.
 *
 * http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.
 * doc10.html#new
 */
@Override
public void NEW(String className) {
    /**
     * Since this callback is invoked before the actual object creation, we
     * do nothing.
     *
     * We do not need to discard any elements from the operand stack since
     * it is given empty.
     *
     * PRE-Stack: empty
     *
     * POST-Stack: objectref (delayed)
     */
    Class<?> clazz = classLoader.getClassForName(className);
    Type objectType = Type.getType(clazz);
    ReferenceConstant newObject = this.env.heap.buildNewReferenceConstant(objectType);
    env.topFrame().operandStack.pushRef(newObject);
}
Also used : ReferenceConstant(org.evosuite.symbolic.expr.ref.ReferenceConstant) Type(org.objectweb.asm.Type)

Aggregations

ReferenceConstant (org.evosuite.symbolic.expr.ref.ReferenceConstant)99 StringValue (org.evosuite.symbolic.expr.str.StringValue)39 IntegerValue (org.evosuite.symbolic.expr.bv.IntegerValue)32 ReferenceExpression (org.evosuite.symbolic.expr.ref.ReferenceExpression)18 CodeUnderTestException (org.evosuite.testcase.execution.CodeUnderTestException)16 VariableReference (org.evosuite.testcase.variable.VariableReference)14 Type (org.objectweb.asm.Type)12 RealValue (org.evosuite.symbolic.expr.fp.RealValue)11 EvosuiteError (org.evosuite.testcase.execution.EvosuiteError)11 Expression (org.evosuite.symbolic.expr.Expression)9 StringBinaryComparison (org.evosuite.symbolic.expr.bv.StringBinaryComparison)8 IntegerVariable (org.evosuite.symbolic.expr.bv.IntegerVariable)6 PrimitiveExpression (org.evosuite.testcase.statements.PrimitiveExpression)5 StringConstant (org.evosuite.symbolic.expr.str.StringConstant)4 BigInteger (java.math.BigInteger)3 ArrayList (java.util.ArrayList)3 IntegerConstraint (org.evosuite.symbolic.expr.IntegerConstraint)3 IntegerConstant (org.evosuite.symbolic.expr.bv.IntegerConstant)3 StringBinaryToIntegerExpression (org.evosuite.symbolic.expr.bv.StringBinaryToIntegerExpression)3 StringReaderExpr (org.evosuite.symbolic.expr.reader.StringReaderExpr)3