Search in sources :

Example 6 with ParameterizedTypeRef

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

the class InternalTypeSystem method applyRuleExpectedTypeInRelationalExpression.

protected Result<TypeRef> applyRuleExpectedTypeInRelationalExpression(final RuleEnvironment G, final RuleApplicationTrace _trace_, final RelationalExpression e, final Expression expression) throws RuleFailedException {
    // output parameter
    TypeRef T = null;
    RelationalOperator _op = e.getOp();
    if (_op != null) {
        switch(_op) {
            case INSTANCEOF:
                Expression _rhs = e.getRhs();
                boolean _tripleEquals = (expression == _rhs);
                if (_tripleEquals) {
                    T = TypeUtils.createNonSimplifiedUnionType(RuleEnvironmentExtensions.functionTypeRef(G), TypeUtils.createTypeTypeRef(RuleEnvironmentExtensions.objectTypeRef(G), false), TypeUtils.createTypeTypeRef(RuleEnvironmentExtensions.n4EnumTypeRef(G), false));
                } else {
                    T = RuleEnvironmentExtensions.anyTypeRef(G);
                }
                break;
            case IN:
                Expression _rhs_1 = e.getRhs();
                boolean _tripleEquals_1 = (expression == _rhs_1);
                if (_tripleEquals_1) {
                    T = RuleEnvironmentExtensions.objectTypeRef(G);
                } else {
                    boolean _isTypeAware = this.jsVariantHelper.isTypeAware(e);
                    if (_isTypeAware) {
                        T = TypeUtils.createNonSimplifiedUnionType(RuleEnvironmentExtensions.numberTypeRef(G), RuleEnvironmentExtensions.stringTypeRef(G));
                    } else {
                        T = RuleEnvironmentExtensions.anyTypeRef(G);
                    }
                }
                break;
            default:
                boolean _isTypeAware_1 = this.jsVariantHelper.isTypeAware(e);
                if (_isTypeAware_1) {
                    final UnionTypeExpression primsTR = TypeUtils.createNonSimplifiedUnionType(RuleEnvironmentExtensions.numberTypeRef(G), RuleEnvironmentExtensions.stringTypeRef(G), RuleEnvironmentExtensions.booleanTypeRef(G));
                    Expression _xifexpression = null;
                    Expression _lhs = e.getLhs();
                    boolean _tripleEquals_2 = (expression == _lhs);
                    if (_tripleEquals_2) {
                        _xifexpression = e.getRhs();
                    } else {
                        _xifexpression = e.getLhs();
                    }
                    final Expression otherSide = _xifexpression;
                    /* G |- otherSide : var TypeRef otherSideTR */
                    TypeRef otherSideTR = null;
                    Result<TypeRef> result = typeInternal(G, _trace_, otherSide);
                    checkAssignableTo(result.getFirst(), TypeRef.class);
                    otherSideTR = (TypeRef) result.getFirst();
                    boolean _and = false;
                    /* G |- otherSideTR <: primsTR */
                    boolean _ruleinvocation = subtypeSucceeded(G, _trace_, otherSideTR, primsTR);
                    if (!_ruleinvocation) {
                        _and = false;
                    } else {
                        /* G |- otherSideTR <: G.nullTypeRef */
                        ParameterizedTypeRef _nullTypeRef = RuleEnvironmentExtensions.nullTypeRef(G);
                        boolean _ruleinvocation_1 = subtypeSucceeded(G, _trace_, otherSideTR, _nullTypeRef);
                        boolean _not = (!_ruleinvocation_1);
                        _and = _not;
                    }
                    if (_and) {
                        T = otherSideTR;
                    } else {
                        T = primsTR;
                    }
                } else {
                    T = RuleEnvironmentExtensions.anyTypeRef(G);
                }
                break;
        }
    } else {
        boolean _isTypeAware_1 = this.jsVariantHelper.isTypeAware(e);
        if (_isTypeAware_1) {
            final UnionTypeExpression primsTR = TypeUtils.createNonSimplifiedUnionType(RuleEnvironmentExtensions.numberTypeRef(G), RuleEnvironmentExtensions.stringTypeRef(G), RuleEnvironmentExtensions.booleanTypeRef(G));
            Expression _xifexpression = null;
            Expression _lhs = e.getLhs();
            boolean _tripleEquals_2 = (expression == _lhs);
            if (_tripleEquals_2) {
                _xifexpression = e.getRhs();
            } else {
                _xifexpression = e.getLhs();
            }
            final Expression otherSide = _xifexpression;
            /* G |- otherSide : var TypeRef otherSideTR */
            TypeRef otherSideTR = null;
            Result<TypeRef> result = typeInternal(G, _trace_, otherSide);
            checkAssignableTo(result.getFirst(), TypeRef.class);
            otherSideTR = (TypeRef) result.getFirst();
            boolean _and = false;
            /* G |- otherSideTR <: primsTR */
            boolean _ruleinvocation = subtypeSucceeded(G, _trace_, otherSideTR, primsTR);
            if (!_ruleinvocation) {
                _and = false;
            } else {
                /* G |- otherSideTR <: G.nullTypeRef */
                ParameterizedTypeRef _nullTypeRef = RuleEnvironmentExtensions.nullTypeRef(G);
                boolean _ruleinvocation_1 = subtypeSucceeded(G, _trace_, otherSideTR, _nullTypeRef);
                boolean _not = (!_ruleinvocation_1);
                _and = _not;
            }
            if (_and) {
                T = otherSideTR;
            } else {
                T = primsTR;
            }
        } else {
            T = RuleEnvironmentExtensions.anyTypeRef(G);
        }
    }
    return new Result<TypeRef>(T);
}
Also used : RelationalOperator(org.eclipse.n4js.n4JS.RelationalOperator) ParameterizedTypeRef(org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef) 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) UnionTypeExpression(org.eclipse.n4js.ts.typeRefs.UnionTypeExpression) Result(org.eclipse.xsemantics.runtime.Result) StructuralTypingResult(org.eclipse.n4js.typesystem.StructuralTypingResult)

Example 7 with ParameterizedTypeRef

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

the class InternalTypeSystem method typeImpl.

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

            public Object get() {
                return ruleName("typePostfixExpression") + stringRepForEnv(G) + " |- " + stringRep(e) + " : " + stringRep(_result_.getFirst());
            }
        });
        addAsSubtrace(_trace_, _subtrace_);
        return _result_;
    } catch (Exception e_applyRuleTypePostfixExpression) {
        typeThrowException(ruleName("typePostfixExpression") + stringRepForEnv(G) + " |- " + stringRep(e) + " : " + "ParameterizedTypeRef", TYPEPOSTFIXEXPRESSION, e_applyRuleTypePostfixExpression, e, new ErrorInformation[] { new ErrorInformation(e) });
        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 8 with ParameterizedTypeRef

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

the class InternalTypeSystem method typeImpl.

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

            public Object get() {
                return ruleName("typeBinaryBitwiseExpression") + stringRepForEnv(G) + " |- " + stringRep(e) + " : " + stringRep(_result_.getFirst());
            }
        });
        addAsSubtrace(_trace_, _subtrace_);
        return _result_;
    } catch (Exception e_applyRuleTypeBinaryBitwiseExpression) {
        typeThrowException(ruleName("typeBinaryBitwiseExpression") + stringRepForEnv(G) + " |- " + stringRep(e) + " : " + "ParameterizedTypeRef", TYPEBINARYBITWISEEXPRESSION, e_applyRuleTypeBinaryBitwiseExpression, e, new ErrorInformation[] { new ErrorInformation(e) });
        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 9 with ParameterizedTypeRef

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

the class InternalTypeSystem method typeImpl.

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

            public Object get() {
                return ruleName("typeNullLiteral") + stringRepForEnv(G) + " |- " + stringRep(l) + " : " + stringRep(_result_.getFirst());
            }
        });
        addAsSubtrace(_trace_, _subtrace_);
        return _result_;
    } catch (Exception e_applyRuleTypeNullLiteral) {
        typeThrowException(ruleName("typeNullLiteral") + stringRepForEnv(G) + " |- " + stringRep(l) + " : " + "ParameterizedTypeRef", TYPENULLLITERAL, e_applyRuleTypeNullLiteral, l, new ErrorInformation[] { new ErrorInformation(l) });
        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 10 with ParameterizedTypeRef

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

the class InternalTypeSystem method typeImpl.

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

            public Object get() {
                return ruleName("typeRegExpLiteral") + stringRepForEnv(G) + " |- " + stringRep(l) + " : " + stringRep(_result_.getFirst());
            }
        });
        addAsSubtrace(_trace_, _subtrace_);
        return _result_;
    } catch (Exception e_applyRuleTypeRegExpLiteral) {
        typeThrowException(ruleName("typeRegExpLiteral") + stringRepForEnv(G) + " |- " + stringRep(l) + " : " + "ParameterizedTypeRef", TYPEREGEXPLITERAL, e_applyRuleTypeRegExpLiteral, l, new ErrorInformation[] { new ErrorInformation(l) });
        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

ParameterizedTypeRef (org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef)80 TypeTypeRef (org.eclipse.n4js.ts.typeRefs.TypeTypeRef)48 TypeRef (org.eclipse.n4js.ts.typeRefs.TypeRef)47 BoundThisTypeRef (org.eclipse.n4js.ts.typeRefs.BoundThisTypeRef)45 ComposedTypeRef (org.eclipse.n4js.ts.typeRefs.ComposedTypeRef)44 ExistentialTypeRef (org.eclipse.n4js.ts.typeRefs.ExistentialTypeRef)44 StructuralTypeRef (org.eclipse.n4js.ts.typeRefs.StructuralTypeRef)44 BaseTypeRef (org.eclipse.n4js.ts.typeRefs.BaseTypeRef)42 FunctionTypeRef (org.eclipse.n4js.ts.typeRefs.FunctionTypeRef)42 ThisTypeRef (org.eclipse.n4js.ts.typeRefs.ThisTypeRef)42 UnknownTypeRef (org.eclipse.n4js.ts.typeRefs.UnknownTypeRef)42 StaticBaseTypeRef (org.eclipse.n4js.ts.typeRefs.StaticBaseTypeRef)41 RuleFailedException (org.eclipse.xsemantics.runtime.RuleFailedException)32 EObject (org.eclipse.emf.ecore.EObject)30 ErrorInformation (org.eclipse.xsemantics.runtime.ErrorInformation)23 Result (org.eclipse.xsemantics.runtime.Result)23 StructuralTypingResult (org.eclipse.n4js.typesystem.StructuralTypingResult)22 Type (org.eclipse.n4js.ts.types.Type)21 RuleApplicationTrace (org.eclipse.xsemantics.runtime.RuleApplicationTrace)21 ContainerType (org.eclipse.n4js.ts.types.ContainerType)17