Search in sources :

Example 26 with ReferenceExpression

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

the class LocalsVM method LDC.

/**
 * Class literal described in Java Spec 3rd ed, Section 15.8.2
 *
 * ".class" Java expression, such as for example in:
 * I.class.isAssignableFrom(..)
 *
 * <p>
 * Represent reference to Class object with symbolic function application:
 * ClassRef(Type)
 *
 * @see http
 *      ://java.sun.com/docs/books/jls/third_edition/html/expressions.html
 *      #15.8.2
 */
@Override
public void LDC(Class<?> x) {
    ReferenceExpression ref = env.heap.getReference(x);
    env.topFrame().operandStack.pushRef(ref);
}
Also used : ReferenceExpression(org.evosuite.symbolic.expr.ref.ReferenceExpression)

Example 27 with ReferenceExpression

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

the class StringBuilder_Init method executeFunction.

@Override
public Object executeFunction() {
    // symbolic receiver (new object)
    ReferenceConstant symb_str_builder = (ReferenceConstant) this.getSymbReceiver();
    // string argument
    String conc_str = (String) this.getConcArgument(0);
    ReferenceExpression symb_str = this.getSymbArgument(0);
    if (symb_str instanceof ReferenceConstant) {
        ReferenceConstant non_null_symb_string = (ReferenceConstant) symb_str;
        assert conc_str != null;
        StringValue strExpr = env.heap.getField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_str, non_null_symb_string, conc_str);
        // update symbolic heap
        env.heap.putField(Types.JAVA_LANG_STRING_BUILDER, SymbolicHeap.$STRING_BUILDER_CONTENTS, null, symb_str_builder, strExpr);
    }
    // return void
    return null;
}
Also used : ReferenceConstant(org.evosuite.symbolic.expr.ref.ReferenceConstant) ReferenceExpression(org.evosuite.symbolic.expr.ref.ReferenceExpression) StringValue(org.evosuite.symbolic.expr.str.StringValue)

Example 28 with ReferenceExpression

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

the class StringReader_Init method executeFunction.

@Override
public Object executeFunction() {
    // symbolic receiver (new object)
    ReferenceConstant symb_str_reader = (ReferenceConstant) this.getSymbReceiver();
    // string argument
    String conc_str = (String) this.getConcArgument(0);
    ReferenceExpression symb_str = this.getSymbArgument(0);
    if (symb_str instanceof ReferenceConstant) {
        ReferenceConstant non_null_symb_string = (ReferenceConstant) symb_str;
        assert conc_str != null;
        StringValue strExpr = env.heap.getField(Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_str, non_null_symb_string, conc_str);
        if (strExpr.containsSymbolicVariable()) {
            int conc_string_reader_value;
            if (conc_str.length() == 0) {
                conc_string_reader_value = -1;
            } else {
                conc_string_reader_value = conc_str.charAt(0);
            }
            StringReaderExpr newStringReaderExpr = new StringReaderExpr((long) conc_string_reader_value, strExpr);
            // update symbolic heap
            env.heap.putField(Types.JAVA_IO_STRING_READER, SymbolicHeap.$STRING_READER_VALUE, null, symb_str_reader, newStringReaderExpr);
        }
    }
    // constructor returns void
    return null;
}
Also used : ReferenceConstant(org.evosuite.symbolic.expr.ref.ReferenceConstant) StringReaderExpr(org.evosuite.symbolic.expr.reader.StringReaderExpr) ReferenceExpression(org.evosuite.symbolic.expr.ref.ReferenceExpression) StringValue(org.evosuite.symbolic.expr.str.StringValue)

Example 29 with ReferenceExpression

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

the class CallVM method METHOD_BEGIN_PARAM.

@Override
public void METHOD_BEGIN_PARAM(int nr, int index, Object conc_ref) {
    if (!env.callerFrame().weInvokedInstrumentedCode()) {
        ReferenceExpression symb_ref = env.heap.getReference(conc_ref);
        env.topFrame().localsTable.setRefLocal(index, symb_ref);
    }
}
Also used : ReferenceExpression(org.evosuite.symbolic.expr.ref.ReferenceExpression)

Example 30 with ReferenceExpression

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

the class CallVM method CALLER_STACK_PARAM.

@Override
public void CALLER_STACK_PARAM(int nr, int calleeLocalsIndex, Object conc_ref) {
    stackParamCount++;
    int operand_index = stackParamCount - 1;
    Operand op = getOperand(operand_index);
    ReferenceOperand ref_op = (ReferenceOperand) op;
    ReferenceExpression symb_ref = ref_op.getReference();
    env.heap.initializeReference(conc_ref, 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