Search in sources :

Example 21 with TypeRef

use of org.eclipse.n4js.ts.typeRefs.TypeRef in project n4js by eclipse.

the class InternalTypeSystem method lowerBoundImpl.

protected Result<TypeRef> lowerBoundImpl(final RuleEnvironment G, final RuleApplicationTrace _trace_, final ExistentialTypeRef existentialTypeRef) throws RuleFailedException {
    try {
        final RuleApplicationTrace _subtrace_ = newTrace(_trace_);
        final Result<TypeRef> _result_ = applyRuleLowerBoundExistentialTypeRef(G, _subtrace_, existentialTypeRef);
        addToTrace(_trace_, new Provider<Object>() {

            public Object get() {
                return ruleName("lowerBoundExistentialTypeRef") + stringRepForEnv(G) + " |~ " + stringRep(existentialTypeRef) + " \\/ " + stringRep(_result_.getFirst());
            }
        });
        addAsSubtrace(_trace_, _subtrace_);
        return _result_;
    } catch (Exception e_applyRuleLowerBoundExistentialTypeRef) {
        lowerBoundThrowException(ruleName("lowerBoundExistentialTypeRef") + stringRepForEnv(G) + " |~ " + stringRep(existentialTypeRef) + " \\/ " + "TypeRef", LOWERBOUNDEXISTENTIALTYPEREF, e_applyRuleLowerBoundExistentialTypeRef, existentialTypeRef, new ErrorInformation[] { new ErrorInformation(existentialTypeRef) });
        return null;
    }
}
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) RuleApplicationTrace(org.eclipse.xsemantics.runtime.RuleApplicationTrace) EObject(org.eclipse.emf.ecore.EObject) RuleFailedException(org.eclipse.xsemantics.runtime.RuleFailedException)

Example 22 with TypeRef

use of org.eclipse.n4js.ts.typeRefs.TypeRef in project n4js by eclipse.

the class InternalTypeSystem method typeImpl.

protected Result<TypeRef> typeImpl(final RuleEnvironment G, final RuleApplicationTrace _trace_, final N4EnumLiteral enumLiteral) throws RuleFailedException {
    try {
        final RuleApplicationTrace _subtrace_ = newTrace(_trace_);
        final Result<TypeRef> _result_ = applyRuleTypeN4EnumLiteral(G, _subtrace_, enumLiteral);
        addToTrace(_trace_, new Provider<Object>() {

            public Object get() {
                return ruleName("typeN4EnumLiteral") + stringRepForEnv(G) + " |- " + stringRep(enumLiteral) + " : " + stringRep(_result_.getFirst());
            }
        });
        addAsSubtrace(_trace_, _subtrace_);
        return _result_;
    } catch (Exception e_applyRuleTypeN4EnumLiteral) {
        typeThrowException(ruleName("typeN4EnumLiteral") + stringRepForEnv(G) + " |- " + stringRep(enumLiteral) + " : " + "TypeRef", TYPEN4ENUMLITERAL, e_applyRuleTypeN4EnumLiteral, enumLiteral, new ErrorInformation[] { new ErrorInformation(enumLiteral) });
        return null;
    }
}
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) RuleApplicationTrace(org.eclipse.xsemantics.runtime.RuleApplicationTrace) EObject(org.eclipse.emf.ecore.EObject) RuleFailedException(org.eclipse.xsemantics.runtime.RuleFailedException)

Example 23 with TypeRef

use of org.eclipse.n4js.ts.typeRefs.TypeRef in project n4js by eclipse.

the class InternalTypeSystem method applyRuleSubtypeTypeArgument.

protected Result<Boolean> applyRuleSubtypeTypeArgument(final RuleEnvironment G, final RuleApplicationTrace _trace_, final TypeArgument left, final TypeArgument right) throws RuleFailedException {
    /* G |~ left /\ var TypeRef leftUpper */
    TypeRef leftUpper = null;
    Result<TypeRef> result = upperBoundInternal(G, _trace_, left);
    checkAssignableTo(result.getFirst(), TypeRef.class);
    leftUpper = (TypeRef) result.getFirst();
    /* G |~ right \/ var TypeRef rightLower */
    TypeRef rightLower = null;
    Result<TypeRef> result_1 = lowerBoundInternal(G, _trace_, right);
    checkAssignableTo(result_1.getFirst(), TypeRef.class);
    rightLower = (TypeRef) result_1.getFirst();
    if (((leftUpper == left) && (rightLower == right))) {
        /* fail */
        throwForExplicitFail();
    /* "Prevent endless loop, check rules, see subtypeTypeArgument" */
    } else {
        /* G |- leftUpper <: rightLower */
        subtypeInternal(G, _trace_, leftUpper, rightLower);
    }
    return new Result<Boolean>(true);
}
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) Result(org.eclipse.xsemantics.runtime.Result) StructuralTypingResult(org.eclipse.n4js.typesystem.StructuralTypingResult)

Example 24 with TypeRef

use of org.eclipse.n4js.ts.typeRefs.TypeRef in project n4js by eclipse.

the class InternalTypeSystem method applyRuleTypeConditionalExpression.

protected Result<TypeRef> applyRuleTypeConditionalExpression(final RuleEnvironment G, final RuleApplicationTrace _trace_, final ConditionalExpression expr) throws RuleFailedException {
    // output parameter
    TypeRef T = null;
    /* G |- expr.trueExpression : var TypeRef left */
    Expression _trueExpression = expr.getTrueExpression();
    TypeRef left = null;
    Result<TypeRef> result = typeInternal(G, _trace_, _trueExpression);
    checkAssignableTo(result.getFirst(), TypeRef.class);
    left = (TypeRef) result.getFirst();
    /* G |- expr.falseExpression : var TypeRef right */
    Expression _falseExpression = expr.getFalseExpression();
    TypeRef right = null;
    Result<TypeRef> result_1 = typeInternal(G, _trace_, _falseExpression);
    checkAssignableTo(result_1.getFirst(), TypeRef.class);
    right = (TypeRef) result_1.getFirst();
    T = this.typeSystemHelper.createUnionType(G, left, right);
    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 25 with TypeRef

use of org.eclipse.n4js.ts.typeRefs.TypeRef in project n4js by eclipse.

the class InternalTypeSystem method typeImpl.

protected Result<TypeRef> typeImpl(final RuleEnvironment G, final RuleApplicationTrace _trace_, final TGetter tgetter) throws RuleFailedException {
    try {
        final RuleApplicationTrace _subtrace_ = newTrace(_trace_);
        final Result<TypeRef> _result_ = applyRuleTypeTGetter(G, _subtrace_, tgetter);
        addToTrace(_trace_, new Provider<Object>() {

            public Object get() {
                return ruleName("typeTGetter") + stringRepForEnv(G) + " |- " + stringRep(tgetter) + " : " + stringRep(_result_.getFirst());
            }
        });
        addAsSubtrace(_trace_, _subtrace_);
        return _result_;
    } catch (Exception e_applyRuleTypeTGetter) {
        typeThrowException(ruleName("typeTGetter") + stringRepForEnv(G) + " |- " + stringRep(tgetter) + " : " + "TypeRef", TYPETGETTER, e_applyRuleTypeTGetter, tgetter, new ErrorInformation[] { new ErrorInformation(tgetter) });
        return null;
    }
}
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) RuleApplicationTrace(org.eclipse.xsemantics.runtime.RuleApplicationTrace) EObject(org.eclipse.emf.ecore.EObject) RuleFailedException(org.eclipse.xsemantics.runtime.RuleFailedException)

Aggregations

TypeRef (org.eclipse.n4js.ts.typeRefs.TypeRef)292 ParameterizedTypeRef (org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef)223 ComposedTypeRef (org.eclipse.n4js.ts.typeRefs.ComposedTypeRef)206 TypeTypeRef (org.eclipse.n4js.ts.typeRefs.TypeTypeRef)206 ExistentialTypeRef (org.eclipse.n4js.ts.typeRefs.ExistentialTypeRef)205 UnknownTypeRef (org.eclipse.n4js.ts.typeRefs.UnknownTypeRef)202 FunctionTypeRef (org.eclipse.n4js.ts.typeRefs.FunctionTypeRef)201 BoundThisTypeRef (org.eclipse.n4js.ts.typeRefs.BoundThisTypeRef)200 StructuralTypeRef (org.eclipse.n4js.ts.typeRefs.StructuralTypeRef)200 ThisTypeRef (org.eclipse.n4js.ts.typeRefs.ThisTypeRef)200 BaseTypeRef (org.eclipse.n4js.ts.typeRefs.BaseTypeRef)199 StaticBaseTypeRef (org.eclipse.n4js.ts.typeRefs.StaticBaseTypeRef)193 EObject (org.eclipse.emf.ecore.EObject)117 RuleFailedException (org.eclipse.xsemantics.runtime.RuleFailedException)117 ErrorInformation (org.eclipse.xsemantics.runtime.ErrorInformation)103 RuleApplicationTrace (org.eclipse.xsemantics.runtime.RuleApplicationTrace)101 Result (org.eclipse.xsemantics.runtime.Result)90 StructuralTypingResult (org.eclipse.n4js.typesystem.StructuralTypingResult)89 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)42 ParameterizedCallExpression (org.eclipse.n4js.n4JS.ParameterizedCallExpression)26