本文整理汇总了Java中gov.nasa.jpf.constraints.types.RealType类的典型用法代码示例。如果您正苦于以下问题:Java RealType类的具体用法?Java RealType怎么用?Java RealType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RealType类属于gov.nasa.jpf.constraints.types包,在下文中一共展示了RealType类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getOrCreateVar
import gov.nasa.jpf.constraints.types.RealType; //导入依赖的package包/类
protected Expr getOrCreateVar(Variable<?> v) {
Type<?> type = v.getType();
if(type.equals(BuiltinTypes.BOOL)) {
return getOrCreateBoolVar(v);
}
if(type instanceof BVIntegerType) {
return getOrCreateBVVar((Variable<?>)v);
}
if(type instanceof IntegerType) {
return getOrCreateIntVar((Variable<?>)v);
}
if(type instanceof RealType) {
return getOrCreateRealVar((Variable<?>)v);
}
throw new IllegalArgumentException("Cannot handle variable type " + type);
}
示例2: visit
import gov.nasa.jpf.constraints.types.RealType; //导入依赖的package包/类
@Override
public <F,E> Object visit(CastExpression<F,E> cast, Void data) {
Expression<F> casted = cast.getCasted();
Type<F> ft = casted.getType();
Type<E> tt = cast.getType();
if(ft.equals(tt))
return visit(casted, null);
Object castedExpr = visit(casted, null);
if(tt instanceof IntegerType<?>) {
return Util.createASInt((SymNumber)castedExpr);
} else if(tt instanceof RealType<?>) {
return Util.createASDouble((SymNumber)castedExpr);
}
throw new UnsupportedOperationException("Cast from " + ft.getName() + " to type " + tt.getName() + " is not supported");
}
示例3: visit
import gov.nasa.jpf.constraints.types.RealType; //导入依赖的package包/类
@Override
public <E> Expr visit(Constant<E> c, Void data) {
Type<E> type = c.getType();
try {
if(type.equals(BuiltinTypes.BOOL))
return ctx.mkBool(((Boolean)c.getValue()).booleanValue());
if(type instanceof BVIntegerType) {
BVIntegerType<? super E> bvt = (BVIntegerType<? super E>)type;
return ctx.mkBV(c.getValue().toString(), bvt.getNumBits());
}
if(type instanceof IntegerType) {
return ctx.mkInt(c.getValue().toString());
}
if(type instanceof RealType) {
RealType<E> nt = (RealType<E>)type;
// FIXME: this is imprecise for nan and infinity
String val = nt.toPlainString(c.getValue());
if (val.equals("Infinity") || val.equals("NaN")) {
return getOrCreateRealVar(new Variable(type, val));
}
return ctx.mkReal(val);
}
throw new IllegalStateException("Cannot handle expression type " + type);
}
catch(Z3Exception ex) {
logger.severe("Cannot handle constant " + c);
throw new RuntimeException(ex);
}
}
示例4: makeBitvectorCast
import gov.nasa.jpf.constraints.types.RealType; //导入依赖的package包/类
private <F,T,TT extends Type<T>>
Expr makeBitvectorCast(BitVecExpr castedExpr, BVIntegerType<F> from, TT to) throws Z3Exception {
try {
if(to instanceof BVIntegerType) {
BVIntegerType<?> bvTo = (BVIntegerType<?>)to;
if(from.getNumBits() == bvTo.getNumBits()) {
Expr tmp = castedExpr;
castedExpr = null; // prevent disposal
return tmp;
}
int diff = bvTo.getNumBits() - from.getNumBits();
if(diff > 0) {
if(from.isSigned())
return ctx.mkSignExt(diff, castedExpr);
return ctx.mkZeroExt(diff, castedExpr);
}
return ctx.mkExtract(bvTo.getNumBits() - 1, 0, castedExpr);
}
if(to instanceof IntegerType) {
//return ctx.mkBV2Int(castedExpr, from.isSigned());
return makeBV2Int(castedExpr, from);
}
if(to instanceof RealType) {
if(to instanceof FloatingPointType) {
FloatingPointType<?> ft = (FloatingPointType<?>)to;
int bitsAvail = ft.getSignificantBits() + 1;
if(bitsAvail < from.getNumBits()) {
BigInteger mask = BigInteger.valueOf(1L).shiftLeft(from.getNumBits() - bitsAvail).subtract(BigInteger.valueOf(1)).shiftLeft(bitsAvail);
BoolExpr posCheck = null, negCheck = null;
BoolExpr check = null;
BoolExpr condCheck = null;
BitVecExpr zero = null;
BitVecExpr maskExpr = null;
BitVecExpr andExpr = null;
try {
maskExpr = ctx.mkBV(mask.toString(), from.getNumBits());
zero = ctx.mkBV(0, from.getNumBits());
andExpr = ctx.mkBVAND(castedExpr, maskExpr);
posCheck = ctx.mkEq(andExpr, zero);
if(from.isSigned()) {
negCheck = ctx.mkEq(andExpr, maskExpr);
check = ctx.mkOr(posCheck, negCheck);
}
if(check != null)
condCheck = ctx.mkOr(check, tainted);
else
condCheck = ctx.mkOr(posCheck, tainted);
solver.add(condCheck);
}
finally {
uncheckedDispose(posCheck, negCheck, check, zero, maskExpr, andExpr);
}
}
}
IntExpr intTmp = null;
try {
intTmp = makeBV2Int(castedExpr, from);
return ctx.mkInt2Real(intTmp);
}
finally {
uncheckedDispose(intTmp);
}
}
throw new IllegalArgumentException("Cannot handle bitvector cast to " + to);
}
finally {
safeDispose(castedExpr);
}
}
示例5: isRealSort
import gov.nasa.jpf.constraints.types.RealType; //导入依赖的package包/类
public static boolean isRealSort(Expression<?> expression) {
return (expression.getType() instanceof RealType);
}