Search in sources :

Example 41 with TypeArgument

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

the class InternalTypeSystem method substTypeVariablesImpl.

protected Result<TypeArgument> substTypeVariablesImpl(final RuleEnvironment G, final RuleApplicationTrace _trace_, final ThisTypeRefStructural thisTypeRef) throws RuleFailedException {
    try {
        final RuleApplicationTrace _subtrace_ = newTrace(_trace_);
        final Result<TypeArgument> _result_ = applyRuleSubstTypeVariablesThisTypeRefStructural(G, _subtrace_, thisTypeRef);
        addToTrace(_trace_, new Provider<Object>() {

            public Object get() {
                return ruleName("substTypeVariablesThisTypeRefStructural") + stringRepForEnv(G) + " |- " + stringRep(thisTypeRef) + " ~> " + stringRep(_result_.getFirst());
            }
        });
        addAsSubtrace(_trace_, _subtrace_);
        return _result_;
    } catch (Exception e_applyRuleSubstTypeVariablesThisTypeRefStructural) {
        substTypeVariablesThrowException(ruleName("substTypeVariablesThisTypeRefStructural") + stringRepForEnv(G) + " |- " + stringRep(thisTypeRef) + " ~> " + "ThisTypeRef", SUBSTTYPEVARIABLESTHISTYPEREFSTRUCTURAL, e_applyRuleSubstTypeVariablesThisTypeRefStructural, thisTypeRef, new ErrorInformation[] { new ErrorInformation(thisTypeRef) });
        return null;
    }
}
Also used : ErrorInformation(org.eclipse.xsemantics.runtime.ErrorInformation) RuleApplicationTrace(org.eclipse.xsemantics.runtime.RuleApplicationTrace) TypeArgument(org.eclipse.n4js.ts.typeRefs.TypeArgument) EObject(org.eclipse.emf.ecore.EObject) RuleFailedException(org.eclipse.xsemantics.runtime.RuleFailedException)

Example 42 with TypeArgument

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

the class InternalTypeSystem method substTypeVariablesImpl.

protected Result<TypeArgument> substTypeVariablesImpl(final RuleEnvironment G, final RuleApplicationTrace _trace_, final Wildcard wildcard) throws RuleFailedException {
    try {
        final RuleApplicationTrace _subtrace_ = newTrace(_trace_);
        final Result<TypeArgument> _result_ = applyRuleSubstTypeVariablesWildcard(G, _subtrace_, wildcard);
        addToTrace(_trace_, new Provider<Object>() {

            public Object get() {
                return ruleName("substTypeVariablesWildcard") + stringRepForEnv(G) + " |- " + stringRep(wildcard) + " ~> " + stringRep(_result_.getFirst());
            }
        });
        addAsSubtrace(_trace_, _subtrace_);
        return _result_;
    } catch (Exception e_applyRuleSubstTypeVariablesWildcard) {
        substTypeVariablesThrowException(ruleName("substTypeVariablesWildcard") + stringRepForEnv(G) + " |- " + stringRep(wildcard) + " ~> " + "Wildcard", SUBSTTYPEVARIABLESWILDCARD, e_applyRuleSubstTypeVariablesWildcard, wildcard, new ErrorInformation[] { new ErrorInformation(wildcard) });
        return null;
    }
}
Also used : ErrorInformation(org.eclipse.xsemantics.runtime.ErrorInformation) RuleApplicationTrace(org.eclipse.xsemantics.runtime.RuleApplicationTrace) TypeArgument(org.eclipse.n4js.ts.typeRefs.TypeArgument) EObject(org.eclipse.emf.ecore.EObject) RuleFailedException(org.eclipse.xsemantics.runtime.RuleFailedException)

Example 43 with TypeArgument

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

the class InternalTypeSystem method applyRuleTypeNewExpression.

protected Result<TypeRef> applyRuleTypeNewExpression(final RuleEnvironment G, final RuleApplicationTrace _trace_, final NewExpression e) throws RuleFailedException {
    // output parameter
    TypeRef T = null;
    /* G |- e.callee: T */
    Expression _callee = e.getCallee();
    Result<TypeRef> result = typeInternal(G, _trace_, _callee);
    checkAssignableTo(result.getFirst(), TypeRef.class);
    T = (TypeRef) result.getFirst();
    if ((T instanceof TypeTypeRef)) {
        T = this.typeSystemHelper.createTypeRefFromStaticType(G, ((TypeTypeRef) T), ((TypeArgument[]) Conversions.unwrapArray(e.getTypeArgs(), TypeArgument.class)));
    }
    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) TypeTypeRef(org.eclipse.n4js.ts.typeRefs.TypeTypeRef) TypeArgument(org.eclipse.n4js.ts.typeRefs.TypeArgument) Result(org.eclipse.xsemantics.runtime.Result) StructuralTypingResult(org.eclipse.n4js.typesystem.StructuralTypingResult)

Example 44 with TypeArgument

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

the class InternalTypeSystem method substTypeVariablesImpl.

protected Result<TypeArgument> substTypeVariablesImpl(final RuleEnvironment G, final RuleApplicationTrace _trace_, final FunctionTypeExprOrRef typeRef) throws RuleFailedException {
    try {
        final RuleApplicationTrace _subtrace_ = newTrace(_trace_);
        final Result<TypeArgument> _result_ = applyRuleSubstTypeVariablesInFunctionTypeExprOrRef(G, _subtrace_, typeRef);
        addToTrace(_trace_, new Provider<Object>() {

            public Object get() {
                return ruleName("substTypeVariablesInFunctionTypeExprOrRef") + stringRepForEnv(G) + " |- " + stringRep(typeRef) + " ~> " + stringRep(_result_.getFirst());
            }
        });
        addAsSubtrace(_trace_, _subtrace_);
        return _result_;
    } catch (Exception e_applyRuleSubstTypeVariablesInFunctionTypeExprOrRef) {
        substTypeVariablesThrowException(ruleName("substTypeVariablesInFunctionTypeExprOrRef") + stringRepForEnv(G) + " |- " + stringRep(typeRef) + " ~> " + "TypeRef", SUBSTTYPEVARIABLESINFUNCTIONTYPEEXPRORREF, e_applyRuleSubstTypeVariablesInFunctionTypeExprOrRef, typeRef, new ErrorInformation[] { new ErrorInformation(typeRef) });
        return null;
    }
}
Also used : ErrorInformation(org.eclipse.xsemantics.runtime.ErrorInformation) RuleApplicationTrace(org.eclipse.xsemantics.runtime.RuleApplicationTrace) TypeArgument(org.eclipse.n4js.ts.typeRefs.TypeArgument) EObject(org.eclipse.emf.ecore.EObject) RuleFailedException(org.eclipse.xsemantics.runtime.RuleFailedException)

Aggregations

TypeArgument (org.eclipse.n4js.ts.typeRefs.TypeArgument)44 ParameterizedTypeRef (org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef)22 TypeTypeRef (org.eclipse.n4js.ts.typeRefs.TypeTypeRef)21 ComposedTypeRef (org.eclipse.n4js.ts.typeRefs.ComposedTypeRef)19 ExistentialTypeRef (org.eclipse.n4js.ts.typeRefs.ExistentialTypeRef)19 TypeRef (org.eclipse.n4js.ts.typeRefs.TypeRef)19 BoundThisTypeRef (org.eclipse.n4js.ts.typeRefs.BoundThisTypeRef)18 BaseTypeRef (org.eclipse.n4js.ts.typeRefs.BaseTypeRef)17 FunctionTypeRef (org.eclipse.n4js.ts.typeRefs.FunctionTypeRef)17 StructuralTypeRef (org.eclipse.n4js.ts.typeRefs.StructuralTypeRef)17 ThisTypeRef (org.eclipse.n4js.ts.typeRefs.ThisTypeRef)17 StructuralTypingResult (org.eclipse.n4js.typesystem.StructuralTypingResult)16 Result (org.eclipse.xsemantics.runtime.Result)16 StaticBaseTypeRef (org.eclipse.n4js.ts.typeRefs.StaticBaseTypeRef)15 UnknownTypeRef (org.eclipse.n4js.ts.typeRefs.UnknownTypeRef)15 RuleFailedException (org.eclipse.xsemantics.runtime.RuleFailedException)15 EObject (org.eclipse.emf.ecore.EObject)14 Type (org.eclipse.n4js.ts.types.Type)14 TStructuralType (org.eclipse.n4js.ts.types.TStructuralType)13 RuleEnvironment (org.eclipse.xsemantics.runtime.RuleEnvironment)12