Search in sources :

Example 61 with Type

use of com.acgist.snail.pojo.bean.M3u8.Type in project cel-java by projectnessie.

the class TypeErrors method formatFunction.

static void formatFunction(StringBuilder result, Type resultType, List<Type> argTypes, boolean isInstance) {
    if (isInstance) {
        Type target = argTypes.get(0);
        argTypes = argTypes.subList(1, argTypes.size());
        formatCheckedType(result, target);
        result.append(".");
    }
    result.append("(");
    for (int i = 0; i < argTypes.size(); i++) {
        Type arg = argTypes.get(i);
        if (i > 0) {
            result.append(", ");
        }
        formatCheckedType(result, arg);
    }
    result.append(")");
    if (resultType != null) {
        result.append(" -> ");
        formatCheckedType(result, resultType);
    }
}
Also used : Types.formatCheckedType(org.projectnessie.cel.checker.Types.formatCheckedType) Type(com.google.api.expr.v1alpha1.Type)

Example 62 with Type

use of com.acgist.snail.pojo.bean.M3u8.Type in project cel-java by projectnessie.

the class Types method notReferencedIn.

/**
 * notReferencedIn checks whether the type doesn't appear directly or transitively within the
 * other type. This is a standard requirement for type unification, commonly referred to as the
 * "occurs check".
 */
static boolean notReferencedIn(Mapping m, Type t, Type withinType) {
    if (t.equals(withinType)) {
        return false;
    }
    Kind withinKind = kindOf(withinType);
    switch(withinKind) {
        case kindTypeParam:
            Type wtSub = m.find(withinType);
            if (wtSub == null) {
                return true;
            }
            return notReferencedIn(m, t, wtSub);
        case kindAbstract:
            for (Type pt : withinType.getAbstractType().getParameterTypesList()) {
                if (!notReferencedIn(m, t, pt)) {
                    return false;
                }
            }
            return true;
        case kindFunction:
            FunctionType fn = withinType.getFunction();
            List<Type> types = flattenFunctionTypes(fn);
            for (Type a : types) {
                if (!notReferencedIn(m, t, a)) {
                    return false;
                }
            }
            return true;
        case kindList:
            return notReferencedIn(m, t, withinType.getListType().getElemType());
        case kindMap:
            MapType mt = withinType.getMapType();
            return notReferencedIn(m, t, mt.getKeyType()) && notReferencedIn(m, t, mt.getValueType());
        case kindWrapper:
            return notReferencedIn(m, t, Decls.newPrimitiveType(withinType.getWrapper()));
        default:
            return true;
    }
}
Also used : AbstractType(com.google.api.expr.v1alpha1.Type.AbstractType) PrimitiveType(com.google.api.expr.v1alpha1.Type.PrimitiveType) Type(com.google.api.expr.v1alpha1.Type) WellKnownType(com.google.api.expr.v1alpha1.Type.WellKnownType) FunctionType(com.google.api.expr.v1alpha1.Type.FunctionType) MapType(com.google.api.expr.v1alpha1.Type.MapType) FunctionType(com.google.api.expr.v1alpha1.Type.FunctionType) MapType(com.google.api.expr.v1alpha1.Type.MapType)

Example 63 with Type

use of com.acgist.snail.pojo.bean.M3u8.Type in project osate2 by osate.

the class QualifiedNamedElementImpl method setType.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void setType(Type newType) {
    Type oldType = type;
    type = newType;
    if (eNotificationRequired()) {
        eNotify(new ENotificationImpl(this, Notification.SET, DeclarativePackage.QUALIFIED_NAMED_ELEMENT__TYPE, oldType, type));
    }
}
Also used : PropertyType(org.osate.aadl2.PropertyType) Type(org.osate.aadl2.Type) ProcessorSubcomponentType(org.osate.aadl2.ProcessorSubcomponentType) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 64 with Type

use of com.acgist.snail.pojo.bean.M3u8.Type in project cel-java by projectnessie.

the class CheckerTest method check.

@ParameterizedTest
@MethodSource("checkTestCases")
void check(TestCase tc) {
    Assumptions.assumeTrue(tc.disabled == null, tc.disabled);
    Source src = newTextSource(tc.i);
    ParseResult parsed = Parser.parseAllMacros(src);
    assertThat(parsed.getErrors().getErrors()).withFailMessage(parsed.getErrors()::toDisplayString).isEmpty();
    TypeRegistry reg = ProtoTypeRegistry.newRegistry(com.google.api.expr.test.v1.proto2.TestAllTypesProto.TestAllTypes.getDefaultInstance(), com.google.api.expr.test.v1.proto3.TestAllTypesProto.TestAllTypes.getDefaultInstance());
    Container cont = Container.newContainer(Container.name(tc.container));
    CheckerEnv env = newStandardCheckerEnv(cont, reg);
    if (tc.disableStdEnv) {
        env = newCheckerEnv(cont, reg);
    }
    if (tc.homogeneousAggregateLiterals) {
        env.enableDynamicAggregateLiterals(false);
    }
    if (tc.env != null) {
        if (tc.env.idents != null) {
            for (Decl ident : tc.env.idents) {
                env.add(ident);
            }
        }
        if (tc.env.functions != null) {
            for (Decl fn : tc.env.functions) {
                env.add(fn);
            }
        }
    }
    CheckResult checkResult = Checker.Check(parsed, src, env);
    if (checkResult.hasErrors()) {
        String errorString = checkResult.getErrors().toDisplayString();
        if (tc.error != null) {
            assertThat(errorString).isEqualTo(tc.error);
        } else {
            fail(String.format("Unexpected type-check errors: %s", errorString));
        }
    } else if (tc.error != null) {
        assertThat(tc.error).withFailMessage(String.format("Expected error not thrown: %s", tc.error)).isNull();
    }
    Type actual = checkResult.getCheckedExpr().getTypeMapMap().get(parsed.getExpr().getId());
    if (tc.error == null) {
        if (actual == null || !actual.equals(tc.type)) {
            fail(String.format("Type Error: '%s' vs expected '%s'", actual, tc.type));
        }
    }
    if (tc.r != null) {
        String actualStr = print(checkResult.getCheckedExpr().getExpr(), checkResult.getCheckedExpr());
        String actualCmp = actualStr.replaceAll("[ \n\t]", "");
        String rCmp = tc.r.replaceAll("[ \n\t]", "");
        assertThat(actualCmp).isEqualTo(rCmp);
    }
}
Also used : Container(org.projectnessie.cel.common.containers.Container) Type(com.google.api.expr.v1alpha1.Type) ParseResult(org.projectnessie.cel.parser.Parser.ParseResult) CheckResult(org.projectnessie.cel.checker.Checker.CheckResult) CheckerEnv.newStandardCheckerEnv(org.projectnessie.cel.checker.CheckerEnv.newStandardCheckerEnv) CheckerEnv.newCheckerEnv(org.projectnessie.cel.checker.CheckerEnv.newCheckerEnv) Decl(com.google.api.expr.v1alpha1.Decl) ProtoTypeRegistry(org.projectnessie.cel.common.types.pb.ProtoTypeRegistry) TypeRegistry(org.projectnessie.cel.common.types.ref.TypeRegistry) Source(org.projectnessie.cel.common.Source) Source.newTextSource(org.projectnessie.cel.common.Source.newTextSource) MethodSource(org.junit.jupiter.params.provider.MethodSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 65 with Type

use of com.acgist.snail.pojo.bean.M3u8.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)

Aggregations

Type (com.google.api.expr.v1alpha1.Type)30 Test (org.junit.Test)16 Type (edu.stanford.CVC4.Type)14 Type (com.google.spanner.v1.Type)12 ArrayType (edu.stanford.CVC4.ArrayType)11 BitVectorType (edu.stanford.CVC4.BitVectorType)11 Expr (edu.stanford.CVC4.Expr)11 MapType (com.google.api.expr.v1alpha1.Type.MapType)10 Type (org.apache.xbean.asm9.Type)10 ByteString (com.google.protobuf.ByteString)9 CVC4.vectorExpr (edu.stanford.CVC4.vectorExpr)9 ArrayList (java.util.ArrayList)9 CheckedExpr (com.google.api.expr.v1alpha1.CheckedExpr)8 FieldType (org.projectnessie.cel.common.types.ref.FieldType)8 FormulaType (org.sosy_lab.java_smt.api.FormulaType)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 CheckerEnv.isObjectWellKnownType (org.projectnessie.cel.checker.CheckerEnv.isObjectWellKnownType)7