use of org.evosuite.symbolic.expr.bv.RealToIntegerCast in project evosuite by EvoSuite.
the class SymbolicObserver method pushParameterList.
private void pushParameterList(List<VariableReference> parameters, Scope scope, String desc) {
Type[] argTypes = Type.getArgumentTypes(desc);
for (int i = 0; i < parameters.size(); i++) {
VariableReference varRef = parameters.get(i);
Type argType = argTypes[i];
ReferenceExpressionPair readResult = this.read(varRef, scope);
Expression<?> symb_expr = readResult.getExpression();
ReferenceExpression symb_ref = readResult.getReference();
if (isValue(argType)) {
if (symb_expr instanceof RealValue) {
RealValue realExpr = (RealValue) symb_expr;
if (isFp32(argType)) {
env.topFrame().operandStack.pushFp32(realExpr);
} else if (isFp64(argType)) {
env.topFrame().operandStack.pushFp64(realExpr);
} else if (isBv32(argType)) {
int concV = realExpr.getConcreteValue().intValue();
RealToIntegerCast castExpr = new RealToIntegerCast(realExpr, (long) concV);
env.topFrame().operandStack.pushBv32(castExpr);
} else if (isBv64(argType)) {
long concV = realExpr.getConcreteValue().longValue();
RealToIntegerCast castExpr = new RealToIntegerCast(realExpr, concV);
env.topFrame().operandStack.pushBv64(castExpr);
} else {
/* unreachable code */
}
} else if (symb_expr instanceof IntegerValue) {
IntegerValue integerExpr = (IntegerValue) symb_expr;
if (isBv32(argType)) {
env.topFrame().operandStack.pushBv32(integerExpr);
} else if (isBv64(argType)) {
env.topFrame().operandStack.pushBv64(integerExpr);
} else if (isFp32(argType)) {
float concV = integerExpr.getConcreteValue().floatValue();
IntegerToRealCast castExpr = new IntegerToRealCast(integerExpr, (double) concV);
env.topFrame().operandStack.pushFp32(castExpr);
} else if (isFp64(argType)) {
double concV = integerExpr.getConcreteValue().doubleValue();
IntegerToRealCast castExpr = new IntegerToRealCast(integerExpr, concV);
env.topFrame().operandStack.pushFp64(castExpr);
} else {
/* unreachable code */
}
} else {
if (symb_ref.getConcreteValue() == null) {
// although this will lead in the JVM to a NPE, we push
// a dummy
// value to prevent the DSE VM from crashing
pushDummyValue(argType);
} else {
// auto unboxing reference
ReferenceConstant non_null_symb_ref = (ReferenceConstant) symb_ref;
Object conc_object = scope.getObject(varRef);
Expression<?> unboxed_expr = unboxReference(argType, conc_object, non_null_symb_ref);
pushValue(argType, unboxed_expr);
}
}
} else {
ReferenceExpression ref = readResult.getReference();
env.topFrame().operandStack.pushRef(ref);
}
}
}
use of org.evosuite.symbolic.expr.bv.RealToIntegerCast in project evosuite by EvoSuite.
the class ArithmeticVM method D2I.
@Override
public void D2I() {
RealValue realExpr = env.topFrame().operandStack.popFp64();
double doubleValue = ((Double) realExpr.getConcreteValue()).doubleValue();
IntegerValue intExpr;
int concreteValue = (int) doubleValue;
if (!realExpr.containsSymbolicVariable()) {
intExpr = ExpressionFactory.buildNewIntegerConstant(concreteValue);
} else {
intExpr = new RealToIntegerCast(realExpr, (long) concreteValue);
}
env.topFrame().operandStack.pushBv32(intExpr);
}
use of org.evosuite.symbolic.expr.bv.RealToIntegerCast in project evosuite by EvoSuite.
the class ArithmeticVM method F2I.
@Override
public void F2I() {
RealValue realExpr = env.topFrame().operandStack.popFp32();
float doubleValue = ((Double) realExpr.getConcreteValue()).floatValue();
IntegerValue intExpr;
int concreteValue = (int) doubleValue;
if (!realExpr.containsSymbolicVariable()) {
intExpr = ExpressionFactory.buildNewIntegerConstant(concreteValue);
} else {
intExpr = new RealToIntegerCast(realExpr, (long) concreteValue);
}
env.topFrame().operandStack.pushBv32(intExpr);
}
use of org.evosuite.symbolic.expr.bv.RealToIntegerCast in project evosuite by EvoSuite.
the class ArithmeticVM method D2L.
@Override
public void D2L() {
RealValue realExpr = env.topFrame().operandStack.popFp64();
double doubleValue = ((Double) realExpr.getConcreteValue()).doubleValue();
IntegerValue intExpr;
long concreteValue = (long) doubleValue;
if (!realExpr.containsSymbolicVariable()) {
intExpr = ExpressionFactory.buildNewIntegerConstant(concreteValue);
} else {
intExpr = new RealToIntegerCast(realExpr, concreteValue);
}
env.topFrame().operandStack.pushBv64(intExpr);
}
use of org.evosuite.symbolic.expr.bv.RealToIntegerCast in project evosuite by EvoSuite.
the class ArithmeticVM method F2L.
@Override
public void F2L() {
RealValue realExpr = env.topFrame().operandStack.popFp32();
float floatValue = ((Double) realExpr.getConcreteValue()).floatValue();
IntegerValue intExpr;
long concreteValue = (long) floatValue;
if (!realExpr.containsSymbolicVariable()) {
intExpr = ExpressionFactory.buildNewIntegerConstant(concreteValue);
} else {
intExpr = new RealToIntegerCast(realExpr, concreteValue);
}
env.topFrame().operandStack.pushBv64(intExpr);
}
Aggregations