Search in sources :

Example 91 with TypeRef

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

the class InternalTypeSystem method _applyRuleTypeTypeDefiningElement_1.

private TypeRef _applyRuleTypeTypeDefiningElement_1(final RuleEnvironment G, final TypeDefiningElement elem) throws RuleFailedException {
    TypeRef _elvis = null;
    TypeRef _wrapTypeInTypeRef = TypeUtils.wrapTypeInTypeRef(elem.getDefinedType());
    if (_wrapTypeInTypeRef != null) {
        _elvis = _wrapTypeInTypeRef;
    } else {
        UnknownTypeRef _createUnknownTypeRef = TypeRefsFactory.eINSTANCE.createUnknownTypeRef();
        _elvis = _createUnknownTypeRef;
    }
    return _elvis;
}
Also used : UnknownTypeRef(org.eclipse.n4js.ts.typeRefs.UnknownTypeRef) 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)

Example 92 with TypeRef

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

the class InternalTypeSystem method upperBoundImpl.

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

            public Object get() {
                return ruleName("upperBoundExistentialTypeRef") + stringRepForEnv(G) + " |~ " + stringRep(existentialTypeRef) + " /\\ " + stringRep(_result_.getFirst());
            }
        });
        addAsSubtrace(_trace_, _subtrace_);
        return _result_;
    } catch (Exception e_applyRuleUpperBoundExistentialTypeRef) {
        upperBoundThrowException(ruleName("upperBoundExistentialTypeRef") + stringRepForEnv(G) + " |~ " + stringRep(existentialTypeRef) + " /\\ " + "TypeRef", UPPERBOUNDEXISTENTIALTYPEREF, e_applyRuleUpperBoundExistentialTypeRef, 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 93 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 LocalArgumentsVariable lArgumentsVar) throws RuleFailedException {
    try {
        final RuleApplicationTrace _subtrace_ = newTrace(_trace_);
        final Result<TypeRef> _result_ = applyRuleTypeLocalArgumentsVariable(G, _subtrace_, lArgumentsVar);
        addToTrace(_trace_, new Provider<Object>() {

            public Object get() {
                return ruleName("typeLocalArgumentsVariable") + stringRepForEnv(G) + " |- " + stringRep(lArgumentsVar) + " : " + stringRep(_result_.getFirst());
            }
        });
        addAsSubtrace(_trace_, _subtrace_);
        return _result_;
    } catch (Exception e_applyRuleTypeLocalArgumentsVariable) {
        typeThrowException(ruleName("typeLocalArgumentsVariable") + stringRepForEnv(G) + " |- " + stringRep(lArgumentsVar) + " : " + "ParameterizedTypeRef", TYPELOCALARGUMENTSVARIABLE, e_applyRuleTypeLocalArgumentsVariable, lArgumentsVar, new ErrorInformation[] { new ErrorInformation(lArgumentsVar) });
        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 94 with TypeRef

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

the class InternalTypeSystem method applyRuleLowerBoundExistentialTypeRef.

protected Result<TypeRef> applyRuleLowerBoundExistentialTypeRef(final RuleEnvironment G, final RuleApplicationTrace _trace_, final ExistentialTypeRef existentialTypeRef) throws RuleFailedException {
    // output parameter
    TypeRef T = null;
    /* G |~ existentialTypeRef.wildcard \/ T */
    Wildcard _wildcard = existentialTypeRef.getWildcard();
    Result<TypeRef> result = lowerBoundInternal(G, _trace_, _wildcard);
    checkAssignableTo(result.getFirst(), TypeRef.class);
    T = (TypeRef) result.getFirst();
    T = TypeUtils.<TypeRef>copy(T);
    TypeUtils.copyTypeModifiers(T, existentialTypeRef);
    return new Result<TypeRef>(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) Result(org.eclipse.xsemantics.runtime.Result) StructuralTypingResult(org.eclipse.n4js.typesystem.StructuralTypingResult)

Example 95 with TypeRef

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

the class InternalTypeSystem method expectedTypeInImpl.

protected Result<TypeRef> expectedTypeInImpl(final RuleEnvironment G, final RuleApplicationTrace _trace_, final PropertyNameValuePair pnvp, final Expression rhs) throws RuleFailedException {
    try {
        final RuleApplicationTrace _subtrace_ = newTrace(_trace_);
        final Result<TypeRef> _result_ = applyRuleExpectedTypeOfRightSideInPropertyNameValuePair(G, _subtrace_, pnvp, rhs);
        addToTrace(_trace_, new Provider<Object>() {

            public Object get() {
                return ruleName("expectedTypeOfRightSideInPropertyNameValuePair") + stringRepForEnv(G) + " |- " + stringRep(pnvp) + " |> " + stringRep(rhs) + " : " + stringRep(_result_.getFirst());
            }
        });
        addAsSubtrace(_trace_, _subtrace_);
        return _result_;
    } catch (Exception e_applyRuleExpectedTypeOfRightSideInPropertyNameValuePair) {
        expectedTypeInThrowException(ruleName("expectedTypeOfRightSideInPropertyNameValuePair") + stringRepForEnv(G) + " |- " + stringRep(pnvp) + " |> " + stringRep(rhs) + " : " + "TypeRef", EXPECTEDTYPEOFRIGHTSIDEINPROPERTYNAMEVALUEPAIR, e_applyRuleExpectedTypeOfRightSideInPropertyNameValuePair, pnvp, rhs, new ErrorInformation[] { new ErrorInformation(pnvp), new ErrorInformation(rhs) });
        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