Search in sources :

Example 26 with Result

use of org.eclipse.xsemantics.runtime.Result in project n4js by eclipse.

the class InternalTypeSystem method applyRuleSubstTypeVariablesWildcard.

protected Result<TypeArgument> applyRuleSubstTypeVariablesWildcard(final RuleEnvironment G, final RuleApplicationTrace _trace_, final Wildcard wildcard) throws RuleFailedException {
    // output parameter
    Wildcard T = null;
    TypeRef ub = wildcard.getDeclaredUpperBound();
    if ((ub != null)) {
        /* G |- ub ~> ub */
        Result<TypeArgument> result = substTypeVariablesInternal(G, _trace_, ub);
        checkAssignableTo(result.getFirst(), TypeRef.class);
        ub = (TypeRef) result.getFirst();
    }
    TypeRef lb = wildcard.getDeclaredLowerBound();
    if ((lb != null)) {
        /* G |- lb ~> lb */
        Result<TypeArgument> result_1 = substTypeVariablesInternal(G, _trace_, lb);
        checkAssignableTo(result_1.getFirst(), TypeRef.class);
        lb = (TypeRef) result_1.getFirst();
    }
    if (((ub != wildcard.getDeclaredUpperBound()) || (lb != wildcard.getDeclaredLowerBound()))) {
        T = TypeUtils.<Wildcard>copy(wildcard);
        T.setDeclaredUpperBound(TypeUtils.<TypeRef>copyIfContained(ub));
        T.setDeclaredLowerBound(TypeUtils.<TypeRef>copyIfContained(lb));
    } else {
        T = wildcard;
    }
    return new Result<TypeArgument>(T);
}
Also used : Wildcard(org.eclipse.n4js.ts.typeRefs.Wildcard) ThisTypeRef(org.eclipse.n4js.ts.typeRefs.ThisTypeRef) ParameterizedTypeRef(org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef) BaseTypeRef(org.eclipse.n4js.ts.typeRefs.BaseTypeRef) FunctionTypeRef(org.eclipse.n4js.ts.typeRefs.FunctionTypeRef) ExistentialTypeRef(org.eclipse.n4js.ts.typeRefs.ExistentialTypeRef) BoundThisTypeRef(org.eclipse.n4js.ts.typeRefs.BoundThisTypeRef) StructuralTypeRef(org.eclipse.n4js.ts.typeRefs.StructuralTypeRef) TypeRef(org.eclipse.n4js.ts.typeRefs.TypeRef) TypeTypeRef(org.eclipse.n4js.ts.typeRefs.TypeTypeRef) StaticBaseTypeRef(org.eclipse.n4js.ts.typeRefs.StaticBaseTypeRef) ComposedTypeRef(org.eclipse.n4js.ts.typeRefs.ComposedTypeRef) UnknownTypeRef(org.eclipse.n4js.ts.typeRefs.UnknownTypeRef) TypeArgument(org.eclipse.n4js.ts.typeRefs.TypeArgument) Result(org.eclipse.xsemantics.runtime.Result) StructuralTypingResult(org.eclipse.n4js.typesystem.StructuralTypingResult)

Example 27 with Result

use of org.eclipse.xsemantics.runtime.Result in project n4js by eclipse.

the class InternalTypeSystem method applyRuleTypeN4FieldDeclaration.

protected Result<TypeRef> applyRuleTypeN4FieldDeclaration(final RuleEnvironment G, final RuleApplicationTrace _trace_, final N4FieldDeclaration fieldDecl) throws RuleFailedException {
    // output parameter
    TypeRef T = null;
    TypeRef _declaredTypeRef = fieldDecl.getDeclaredTypeRef();
    boolean _tripleNotEquals = (_declaredTypeRef != null);
    if (_tripleNotEquals) {
        T = fieldDecl.getDeclaredTypeRef();
    } else {
        Expression _expression = fieldDecl.getExpression();
        boolean _tripleNotEquals_1 = (_expression != null);
        if (_tripleNotEquals_1) {
            /* G |- fieldDecl.expression : var TypeRef E */
            Expression _expression_1 = fieldDecl.getExpression();
            TypeRef E = null;
            Result<TypeRef> result = typeInternal(G, _trace_, _expression_1);
            checkAssignableTo(result.getFirst(), TypeRef.class);
            E = (TypeRef) result.getFirst();
            /* G |~ E /\ E */
            Result<TypeRef> result_1 = upperBoundInternal(G, _trace_, E);
            checkAssignableTo(result_1.getFirst(), TypeRef.class);
            E = (TypeRef) result_1.getFirst();
            if ((((E.getDeclaredType() == RuleEnvironmentExtensions.undefinedType(G)) || (E.getDeclaredType() == RuleEnvironmentExtensions.nullType(G))) || (E.getDeclaredType() == RuleEnvironmentExtensions.voidType(G)))) {
                T = RuleEnvironmentExtensions.anyTypeRef(G);
            } else {
                T = E;
            }
        } else {
            T = RuleEnvironmentExtensions.anyTypeRef(G);
        }
    }
    return new Result<TypeRef>(T);
}
Also used : BinaryBitwiseExpression(org.eclipse.n4js.n4JS.BinaryBitwiseExpression) AssignmentExpression(org.eclipse.n4js.n4JS.AssignmentExpression) IndexedAccessExpression(org.eclipse.n4js.n4JS.IndexedAccessExpression) UnionTypeExpression(org.eclipse.n4js.ts.typeRefs.UnionTypeExpression) FunctionExpression(org.eclipse.n4js.n4JS.FunctionExpression) PromisifyExpression(org.eclipse.n4js.n4JS.PromisifyExpression) UnaryExpression(org.eclipse.n4js.n4JS.UnaryExpression) ParenExpression(org.eclipse.n4js.n4JS.ParenExpression) ParameterizedCallExpression(org.eclipse.n4js.n4JS.ParameterizedCallExpression) AdditiveExpression(org.eclipse.n4js.n4JS.AdditiveExpression) PostfixExpression(org.eclipse.n4js.n4JS.PostfixExpression) YieldExpression(org.eclipse.n4js.n4JS.YieldExpression) ConditionalExpression(org.eclipse.n4js.n4JS.ConditionalExpression) FunctionTypeExpression(org.eclipse.n4js.ts.typeRefs.FunctionTypeExpression) RelationalExpression(org.eclipse.n4js.n4JS.RelationalExpression) NewExpression(org.eclipse.n4js.n4JS.NewExpression) IntersectionTypeExpression(org.eclipse.n4js.ts.typeRefs.IntersectionTypeExpression) AwaitExpression(org.eclipse.n4js.n4JS.AwaitExpression) CommaExpression(org.eclipse.n4js.n4JS.CommaExpression) Expression(org.eclipse.n4js.n4JS.Expression) CastExpression(org.eclipse.n4js.n4JS.CastExpression) BinaryLogicalExpression(org.eclipse.n4js.n4JS.BinaryLogicalExpression) EqualityExpression(org.eclipse.n4js.n4JS.EqualityExpression) ShiftExpression(org.eclipse.n4js.n4JS.ShiftExpression) ParameterizedPropertyAccessExpression(org.eclipse.n4js.n4JS.ParameterizedPropertyAccessExpression) MultiplicativeExpression(org.eclipse.n4js.n4JS.MultiplicativeExpression) N4ClassExpression(org.eclipse.n4js.n4JS.N4ClassExpression) ThisTypeRef(org.eclipse.n4js.ts.typeRefs.ThisTypeRef) ParameterizedTypeRef(org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef) BaseTypeRef(org.eclipse.n4js.ts.typeRefs.BaseTypeRef) FunctionTypeRef(org.eclipse.n4js.ts.typeRefs.FunctionTypeRef) ExistentialTypeRef(org.eclipse.n4js.ts.typeRefs.ExistentialTypeRef) BoundThisTypeRef(org.eclipse.n4js.ts.typeRefs.BoundThisTypeRef) StructuralTypeRef(org.eclipse.n4js.ts.typeRefs.StructuralTypeRef) TypeRef(org.eclipse.n4js.ts.typeRefs.TypeRef) TypeTypeRef(org.eclipse.n4js.ts.typeRefs.TypeTypeRef) StaticBaseTypeRef(org.eclipse.n4js.ts.typeRefs.StaticBaseTypeRef) ComposedTypeRef(org.eclipse.n4js.ts.typeRefs.ComposedTypeRef) UnknownTypeRef(org.eclipse.n4js.ts.typeRefs.UnknownTypeRef) Result(org.eclipse.xsemantics.runtime.Result) StructuralTypingResult(org.eclipse.n4js.typesystem.StructuralTypingResult)

Example 28 with Result

use of org.eclipse.xsemantics.runtime.Result in project n4js by eclipse.

the class InternalTypeSystem method applyRuleTypeArrayLiteral.

protected Result<TypeRef> applyRuleTypeArrayLiteral(final RuleEnvironment G, final RuleApplicationTrace _trace_, final ArrayLiteral al) throws RuleFailedException {
    // output parameter
    TypeRef T = null;
    /* fail error "rule typeArrayLiteral should never be invoked (PolyComputer is responsible for typing ArrayLiterals)" */
    String error = "rule typeArrayLiteral should never be invoked (PolyComputer is responsible for typing ArrayLiterals)";
    throwForExplicitFail(error, new ErrorInformation(null, null));
    return new Result<TypeRef>(T);
}
Also used : ErrorInformation(org.eclipse.xsemantics.runtime.ErrorInformation) ThisTypeRef(org.eclipse.n4js.ts.typeRefs.ThisTypeRef) ParameterizedTypeRef(org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef) BaseTypeRef(org.eclipse.n4js.ts.typeRefs.BaseTypeRef) FunctionTypeRef(org.eclipse.n4js.ts.typeRefs.FunctionTypeRef) ExistentialTypeRef(org.eclipse.n4js.ts.typeRefs.ExistentialTypeRef) BoundThisTypeRef(org.eclipse.n4js.ts.typeRefs.BoundThisTypeRef) StructuralTypeRef(org.eclipse.n4js.ts.typeRefs.StructuralTypeRef) TypeRef(org.eclipse.n4js.ts.typeRefs.TypeRef) TypeTypeRef(org.eclipse.n4js.ts.typeRefs.TypeTypeRef) StaticBaseTypeRef(org.eclipse.n4js.ts.typeRefs.StaticBaseTypeRef) ComposedTypeRef(org.eclipse.n4js.ts.typeRefs.ComposedTypeRef) UnknownTypeRef(org.eclipse.n4js.ts.typeRefs.UnknownTypeRef) TaggedTemplateString(org.eclipse.n4js.n4JS.TaggedTemplateString) Result(org.eclipse.xsemantics.runtime.Result) StructuralTypingResult(org.eclipse.n4js.typesystem.StructuralTypingResult)

Example 29 with Result

use of org.eclipse.xsemantics.runtime.Result in project n4js by eclipse.

the class InternalTypeSystem method applyRuleLowerBoundParameterizedTypeRef.

protected Result<TypeRef> applyRuleLowerBoundParameterizedTypeRef(final RuleEnvironment G, final RuleApplicationTrace _trace_, final ParameterizedTypeRef ptr) throws RuleFailedException {
    // output parameter
    TypeRef T = null;
    Type _declaredType = ptr.getDeclaredType();
    if ((_declaredType instanceof TypeVariable)) {
        T = ptr;
    } else {
        T = ptr;
    }
    return new Result<TypeRef>(T);
}
Also used : Type(org.eclipse.n4js.ts.types.Type) PrimitiveType(org.eclipse.n4js.ts.types.PrimitiveType) VoidType(org.eclipse.n4js.ts.types.VoidType) AnyType(org.eclipse.n4js.ts.types.AnyType) ModuleNamespaceVirtualType(org.eclipse.n4js.ts.types.ModuleNamespaceVirtualType) NullType(org.eclipse.n4js.ts.types.NullType) UndefinedType(org.eclipse.n4js.ts.types.UndefinedType) ContainerType(org.eclipse.n4js.ts.types.ContainerType) TStructuralType(org.eclipse.n4js.ts.types.TStructuralType) TypeVariable(org.eclipse.n4js.ts.types.TypeVariable) ThisTypeRef(org.eclipse.n4js.ts.typeRefs.ThisTypeRef) ParameterizedTypeRef(org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef) BaseTypeRef(org.eclipse.n4js.ts.typeRefs.BaseTypeRef) FunctionTypeRef(org.eclipse.n4js.ts.typeRefs.FunctionTypeRef) ExistentialTypeRef(org.eclipse.n4js.ts.typeRefs.ExistentialTypeRef) BoundThisTypeRef(org.eclipse.n4js.ts.typeRefs.BoundThisTypeRef) StructuralTypeRef(org.eclipse.n4js.ts.typeRefs.StructuralTypeRef) TypeRef(org.eclipse.n4js.ts.typeRefs.TypeRef) TypeTypeRef(org.eclipse.n4js.ts.typeRefs.TypeTypeRef) StaticBaseTypeRef(org.eclipse.n4js.ts.typeRefs.StaticBaseTypeRef) ComposedTypeRef(org.eclipse.n4js.ts.typeRefs.ComposedTypeRef) UnknownTypeRef(org.eclipse.n4js.ts.typeRefs.UnknownTypeRef) Result(org.eclipse.xsemantics.runtime.Result) StructuralTypingResult(org.eclipse.n4js.typesystem.StructuralTypingResult)

Example 30 with Result

use of org.eclipse.xsemantics.runtime.Result in project n4js by eclipse.

the class InternalTypeSystem method applyRuleSubstTypeVariablesInFunctionTypeRef.

protected Result<TypeArgument> applyRuleSubstTypeVariablesInFunctionTypeRef(final RuleEnvironment G, final RuleApplicationTrace _trace_, final FunctionTypeRef typeRef) throws RuleFailedException {
    // output parameter
    TypeRef result = null;
    TypeArgument _value = this.applyRuleSubstTypeVariablesInFunctionTypeExprOrRef(G, _trace_, typeRef).getValue();
    result = ((TypeRef) _value);
    return new Result<TypeArgument>(result);
}
Also used : ThisTypeRef(org.eclipse.n4js.ts.typeRefs.ThisTypeRef) ParameterizedTypeRef(org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef) BaseTypeRef(org.eclipse.n4js.ts.typeRefs.BaseTypeRef) FunctionTypeRef(org.eclipse.n4js.ts.typeRefs.FunctionTypeRef) ExistentialTypeRef(org.eclipse.n4js.ts.typeRefs.ExistentialTypeRef) BoundThisTypeRef(org.eclipse.n4js.ts.typeRefs.BoundThisTypeRef) StructuralTypeRef(org.eclipse.n4js.ts.typeRefs.StructuralTypeRef) TypeRef(org.eclipse.n4js.ts.typeRefs.TypeRef) TypeTypeRef(org.eclipse.n4js.ts.typeRefs.TypeTypeRef) StaticBaseTypeRef(org.eclipse.n4js.ts.typeRefs.StaticBaseTypeRef) ComposedTypeRef(org.eclipse.n4js.ts.typeRefs.ComposedTypeRef) UnknownTypeRef(org.eclipse.n4js.ts.typeRefs.UnknownTypeRef) TypeArgument(org.eclipse.n4js.ts.typeRefs.TypeArgument) Result(org.eclipse.xsemantics.runtime.Result) StructuralTypingResult(org.eclipse.n4js.typesystem.StructuralTypingResult)

Aggregations

Result (org.eclipse.xsemantics.runtime.Result)93 StructuralTypingResult (org.eclipse.n4js.typesystem.StructuralTypingResult)92 ParameterizedTypeRef (org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef)91 TypeRef (org.eclipse.n4js.ts.typeRefs.TypeRef)90 TypeTypeRef (org.eclipse.n4js.ts.typeRefs.TypeTypeRef)90 BaseTypeRef (org.eclipse.n4js.ts.typeRefs.BaseTypeRef)89 BoundThisTypeRef (org.eclipse.n4js.ts.typeRefs.BoundThisTypeRef)89 ComposedTypeRef (org.eclipse.n4js.ts.typeRefs.ComposedTypeRef)89 ExistentialTypeRef (org.eclipse.n4js.ts.typeRefs.ExistentialTypeRef)89 FunctionTypeRef (org.eclipse.n4js.ts.typeRefs.FunctionTypeRef)89 StaticBaseTypeRef (org.eclipse.n4js.ts.typeRefs.StaticBaseTypeRef)89 StructuralTypeRef (org.eclipse.n4js.ts.typeRefs.StructuralTypeRef)89 ThisTypeRef (org.eclipse.n4js.ts.typeRefs.ThisTypeRef)89 UnknownTypeRef (org.eclipse.n4js.ts.typeRefs.UnknownTypeRef)89 ParameterizedCallExpression (org.eclipse.n4js.n4JS.ParameterizedCallExpression)25 IndexedAccessExpression (org.eclipse.n4js.n4JS.IndexedAccessExpression)24 NewExpression (org.eclipse.n4js.n4JS.NewExpression)24 ParameterizedPropertyAccessExpression (org.eclipse.n4js.n4JS.ParameterizedPropertyAccessExpression)24 AdditiveExpression (org.eclipse.n4js.n4JS.AdditiveExpression)23 AssignmentExpression (org.eclipse.n4js.n4JS.AssignmentExpression)23