use of org.evosuite.symbolic.expr.bv.IntegerConstant 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();
}
use of org.evosuite.symbolic.expr.bv.IntegerConstant in project evosuite by EvoSuite.
the class StringBuffer_SetLength method executeFunction.
@Override
public Object executeFunction() {
ReferenceConstant symb_str_buffer = this.getSymbReceiver();
StringBuffer conc_str_buffer = (StringBuffer) this.getConcReceiver();
IntegerValue newSymbLength = this.getSymbIntegerArgument(0);
int newConcLength = this.getConcIntArgument(0);
// retrieve symbolic value from heap
String conc_value = conc_str_buffer.toString();
StringValue symb_value = env.heap.getField(Types.JAVA_LANG_STRING_BUFFER, SymbolicHeap.$STRING_BUFFER_CONTENTS, conc_str_buffer, symb_str_buffer, pre_conc_value);
if (symb_value.containsSymbolicVariable() || newSymbLength.containsSymbolicVariable()) {
StringValue new_symb_value = null;
if (!newSymbLength.containsSymbolicVariable() && newConcLength == 0) {
// StringBuffer contents equals to "" string
new_symb_value = new StringConstant("");
} else {
// StringBuffer contents equ
new_symb_value = new StringMultipleExpression(symb_value, Operator.SUBSTRING, new IntegerConstant(0), new ArrayList<Expression<?>>(Collections.singletonList(newSymbLength)), conc_value);
}
env.heap.putField(Types.JAVA_LANG_STRING_BUFFER, SymbolicHeap.$STRING_BUFFER_CONTENTS, conc_str_buffer, symb_str_buffer, new_symb_value);
}
// return void
return null;
}
use of org.evosuite.symbolic.expr.bv.IntegerConstant in project evosuite by EvoSuite.
the class CallVM method CALL_RESULT.
/**
* Our chance to capture the value returned by a native or un-instrumented
* method.
*/
@Override
public void CALL_RESULT(boolean res, String owner, String name, String desc) {
CALL_RESULT(owner, name, desc);
if (env.topFrame().weInvokedInstrumentedCode()) {
// it
return;
} else {
/**
* We are returning from uninstrumented code. This is the only way
* of storing the uninstrumented return value to the symbolic state.
*/
int i = res ? 1 : 0;
IntegerConstant value = ExpressionFactory.buildNewIntegerConstant(i);
env.topFrame().operandStack.pushBv32(value);
}
}
use of org.evosuite.symbolic.expr.bv.IntegerConstant in project evosuite by EvoSuite.
the class CallVM method METHOD_BEGIN_PARAM.
@Override
public void METHOD_BEGIN_PARAM(int nr, int index, int value) {
if (!env.callerFrame().weInvokedInstrumentedCode()) {
IntegerConstant literal_value = ExpressionFactory.buildNewIntegerConstant(value);
env.topFrame().localsTable.setBv32Local(index, literal_value);
}
}
use of org.evosuite.symbolic.expr.bv.IntegerConstant in project evosuite by EvoSuite.
the class CallVM method CALL_RESULT.
/**
* int, short, byte all map to a BitVec32
*
* TODO: Will this work for char?
*/
@Override
public void CALL_RESULT(int res, String owner, String name, String desc) {
CALL_RESULT(owner, name, desc);
if (env.topFrame().weInvokedInstrumentedCode()) {
// it
return;
} else {
/**
* We are returning from uninstrumented code. This is the only way
* of storing the uninstrumented return value to the symbolic state.
*/
IntegerConstant value = ExpressionFactory.buildNewIntegerConstant(res);
env.topFrame().operandStack.pushBv32(value);
}
}
Aggregations