Search in sources :

Example 76 with Type

use of com.google.api.expr.v1alpha1.Type in project snail by acgist.

the class M3u8Builder method buildM3u8.

/**
 * <p>新建M3U8信息</p>
 *
 * @return {@link M3u8}
 *
 * @throws NetException 网络异常
 */
private M3u8 buildM3u8() throws NetException {
    final M3u8.Type type = this.buildType();
    final Cipher cipher = this.buildCipher();
    List<String> links;
    if (type == Type.M3U8) {
        links = this.buildM3u8Links();
    } else {
        // 获取LABEL_EXTINF标签数据
        links = this.buildFileLinks(LABEL_EXTINF);
        // 没有LABEL_EXTINF标签数据:获取LABEL_EXT_X_BITRATE标签数据
        if (CollectionUtils.isEmpty(links)) {
            links = this.buildFileLinks(LABEL_EXT_X_BITRATE);
        }
        if (CollectionUtils.isEmpty(links)) {
            throw new NetException("没有下载文件");
        }
    }
    return new M3u8(type, cipher, links);
}
Also used : Type(com.acgist.snail.pojo.bean.M3u8.Type) NetException(com.acgist.snail.context.exception.NetException) M3u8(com.acgist.snail.pojo.bean.M3u8) Cipher(javax.crypto.Cipher)

Example 77 with Type

use of com.google.api.expr.v1alpha1.Type in project java-smt by sosy-lab.

the class CVC4FormulaCreator method convertValue.

@Override
public Object convertValue(Expr expForType, Expr value) {
    final Type type = expForType.getType();
    final Type valueType = value.getType();
    if (value.getKind() == Kind.BOUND_VARIABLE) {
        // CVC4 does not allow model values for bound vars
        return value.toString();
    } else if (valueType.isBoolean()) {
        return value.getConstBoolean();
    } else if (valueType.isInteger() && type.isInteger()) {
        return new BigInteger(value.getConstRational().toString());
    } else if (valueType.isReal() && type.isReal()) {
        Rational rat = value.getConstRational();
        return org.sosy_lab.common.rationals.Rational.of(new BigInteger(rat.getNumerator().toString()), new BigInteger(rat.getDenominator().toString()));
    } else if (valueType.isBitVector()) {
        Integer bv = value.getConstBitVector().getValue();
        if (bv.fitsSignedLong()) {
            return BigInteger.valueOf(bv.getUnsignedLong());
        } else {
            // default
            return value.toString();
        }
    } else if (valueType.isFloatingPoint()) {
        return parseFloatingPoint(value);
    } else if (valueType.isString()) {
        return value.getConstString().toString();
    } else {
        // String serialization for unknown terms.
        return value.toString();
    }
}
Also used : Integer(edu.stanford.CVC4.Integer) UnsignedInteger(com.google.common.primitives.UnsignedInteger) BigInteger(java.math.BigInteger) FloatingPointType(org.sosy_lab.java_smt.api.FormulaType.FloatingPointType) CVC4.vectorType(edu.stanford.CVC4.vectorType) Type(edu.stanford.CVC4.Type) BitVectorType(edu.stanford.CVC4.BitVectorType) FormulaType(org.sosy_lab.java_smt.api.FormulaType) ArrayFormulaType(org.sosy_lab.java_smt.api.FormulaType.ArrayFormulaType) ArrayType(edu.stanford.CVC4.ArrayType) FunctionType(edu.stanford.CVC4.FunctionType) Rational(edu.stanford.CVC4.Rational) BigInteger(java.math.BigInteger)

Example 78 with Type

use of com.google.api.expr.v1alpha1.Type in project java-smt by sosy-lab.

the class CVC4FormulaCreator method makeBoundCopy.

/**
 * Makes a bound copy of a variable for use in quantifier. Note that all occurrences of the free
 * var have to be substituted by the bound once it exists.
 *
 * @param var Variable you want a bound copy of.
 * @return Bound Variable
 */
public Expr makeBoundCopy(Expr var) {
    Type type = var.getType();
    String name = getName(var);
    Expr boundCopy = exprManager.mkBoundVar(name, type);
    return boundCopy;
}
Also used : FloatingPointType(org.sosy_lab.java_smt.api.FormulaType.FloatingPointType) CVC4.vectorType(edu.stanford.CVC4.vectorType) Type(edu.stanford.CVC4.Type) BitVectorType(edu.stanford.CVC4.BitVectorType) FormulaType(org.sosy_lab.java_smt.api.FormulaType) ArrayFormulaType(org.sosy_lab.java_smt.api.FormulaType.ArrayFormulaType) ArrayType(edu.stanford.CVC4.ArrayType) FunctionType(edu.stanford.CVC4.FunctionType) CVC4.vectorExpr(edu.stanford.CVC4.vectorExpr) Expr(edu.stanford.CVC4.Expr)

Example 79 with Type

use of com.google.api.expr.v1alpha1.Type in project java-smt by sosy-lab.

the class CVC4ArrayFormulaManager method internalMakeArray.

@Override
@SuppressWarnings("MethodTypeParameterName")
protected <TI extends Formula, TE extends Formula> Expr internalMakeArray(String pName, FormulaType<TI> pIndexType, FormulaType<TE> pElementType) {
    final ArrayFormulaType<TI, TE> arrayFormulaType = FormulaType.getArrayType(pIndexType, pElementType);
    final Type cvc4ArrayType = toSolverType(arrayFormulaType);
    return getFormulaCreator().makeVariable(cvc4ArrayType, pName);
}
Also used : Type(edu.stanford.CVC4.Type) FormulaType(org.sosy_lab.java_smt.api.FormulaType) ArrayFormulaType(org.sosy_lab.java_smt.api.FormulaType.ArrayFormulaType)

Example 80 with Type

use of com.google.api.expr.v1alpha1.Type in project java-smt by sosy-lab.

the class CVC4FloatingPointFormulaManager method genericCast.

private Expr genericCast(Expr pNumber, FormulaType<?> pTargetType) {
    Type type = pNumber.getType();
    FormulaType<?> argType = getFormulaCreator().getFormulaType(pNumber);
    Expr castFuncDecl = getFormulaCreator().declareUFImpl("__cast_" + argType + "_to_" + pTargetType, toSolverType(pTargetType), ImmutableList.of(type));
    return exprManager.mkExpr(Kind.APPLY_UF, castFuncDecl, pNumber);
}
Also used : FloatingPointType(org.sosy_lab.java_smt.api.FormulaType.FloatingPointType) Type(edu.stanford.CVC4.Type) FormulaType(org.sosy_lab.java_smt.api.FormulaType) BitvectorType(org.sosy_lab.java_smt.api.FormulaType.BitvectorType) Expr(edu.stanford.CVC4.Expr)

Aggregations

Type (com.google.api.expr.v1alpha1.Type)30 Test (org.junit.Test)16 MapType (com.google.api.expr.v1alpha1.Type.MapType)15 Type (edu.stanford.CVC4.Type)14 Type (com.google.spanner.v1.Type)12 Test (org.junit.jupiter.api.Test)12 CheckedExpr (com.google.api.expr.v1alpha1.CheckedExpr)11 ByteString (com.google.protobuf.ByteString)11 ArrayType (edu.stanford.CVC4.ArrayType)11 BitVectorType (edu.stanford.CVC4.BitVectorType)11 Expr (edu.stanford.CVC4.Expr)11 ArrayList (java.util.ArrayList)11 Type (org.apache.xbean.asm9.Type)10 Expr (com.google.api.expr.v1alpha1.Expr)9 CVC4.vectorExpr (edu.stanford.CVC4.vectorExpr)9 FieldType (org.projectnessie.cel.common.types.ref.FieldType)8 ListValue (com.google.protobuf.ListValue)7 ExecuteSqlRequest (com.google.spanner.v1.ExecuteSqlRequest)7 CheckerEnv.dynElementType (org.projectnessie.cel.checker.CheckerEnv.dynElementType)7 CheckerEnv.getObjectWellKnownType (org.projectnessie.cel.checker.CheckerEnv.getObjectWellKnownType)7