Search in sources :

Example 1 with FunctionTypeRef

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

the class InternalTypeSystem method lowerBoundImpl.

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

            public Object get() {
                return ruleName("lowerBoundFunctionTypeRef") + stringRepForEnv(G) + " |~ " + stringRep(F) + " \\/ " + stringRep(_result_.getFirst());
            }
        });
        addAsSubtrace(_trace_, _subtrace_);
        return _result_;
    } catch (Exception e_applyRuleLowerBoundFunctionTypeRef) {
        lowerBoundThrowException(ruleName("lowerBoundFunctionTypeRef") + stringRepForEnv(G) + " |~ " + stringRep(F) + " \\/ " + "TypeRef", LOWERBOUNDFUNCTIONTYPEREF, e_applyRuleLowerBoundFunctionTypeRef, F, new ErrorInformation[] { new ErrorInformation(F) });
        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 2 with FunctionTypeRef

use of org.eclipse.n4js.ts.typeRefs.FunctionTypeRef 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)

Example 3 with FunctionTypeRef

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

the class InternalTypeSystem method applyRuleLowerBoundFunctionTypeRef.

protected Result<TypeRef> applyRuleLowerBoundFunctionTypeRef(final RuleEnvironment G, final RuleApplicationTrace _trace_, final FunctionTypeRef F) throws RuleFailedException {
    // output parameter
    TypeRef T = null;
    T = this.applyRuleLowerBoundFunctionTypeExprOrRef(G, _trace_, F).getValue();
    return new Result<TypeRef>(T);
}
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 4 with FunctionTypeRef

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

the class TypeUtils method createConstructorTypeRef.

/**
 * Creates new type reference for constructor. if the declared type is TFunction a FunctionTypeRef is created. If
 * declared type is TClassifier than TypeTypeRef is created (i.e. <code>constructor{A}</code> in N4JS code)
 */
public static TypeRef createConstructorTypeRef(Type declaredType, TypeArgument... typeArgs) {
    TypeRef typeRef = null;
    if (declaredType instanceof TFunction) {
        // TODO is this correct?
        FunctionTypeRef ref = TypeRefsFactory.eINSTANCE.createFunctionTypeRef();
        ref.setDeclaredType(declaredType);
        for (TypeArgument typeArg : typeArgs) {
            ref.getTypeArgs().add(TypeUtils.copyIfContained(typeArg));
        }
        typeRef = ref;
    } else if (declaredType instanceof TClassifier) {
        TClassifier tClassifier = (TClassifier) declaredType;
        typeRef = createTypeTypeRef(createTypeRef(tClassifier, typeArgs), true);
    } else if (declaredType instanceof TypeVariable) {
        TypeVariable tTypeVar = (TypeVariable) declaredType;
        typeRef = createTypeTypeRef(createTypeRef(tTypeVar), true);
    }
    return typeRef;
}
Also used : TClassifier(org.eclipse.n4js.ts.types.TClassifier) TFunction(org.eclipse.n4js.ts.types.TFunction) TypeVariable(org.eclipse.n4js.ts.types.TypeVariable) ExistentialTypeRef(org.eclipse.n4js.ts.typeRefs.ExistentialTypeRef) ThisTypeRef(org.eclipse.n4js.ts.typeRefs.ThisTypeRef) BoundThisTypeRef(org.eclipse.n4js.ts.typeRefs.BoundThisTypeRef) ParameterizedTypeRef(org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef) StructuralTypeRef(org.eclipse.n4js.ts.typeRefs.StructuralTypeRef) TypeRef(org.eclipse.n4js.ts.typeRefs.TypeRef) TypeTypeRef(org.eclipse.n4js.ts.typeRefs.TypeTypeRef) DeferredTypeRef(org.eclipse.n4js.ts.typeRefs.DeferredTypeRef) BaseTypeRef(org.eclipse.n4js.ts.typeRefs.BaseTypeRef) ComposedTypeRef(org.eclipse.n4js.ts.typeRefs.ComposedTypeRef) FunctionTypeRef(org.eclipse.n4js.ts.typeRefs.FunctionTypeRef) FunctionTypeRef(org.eclipse.n4js.ts.typeRefs.FunctionTypeRef) TypeArgument(org.eclipse.n4js.ts.typeRefs.TypeArgument)

Example 5 with FunctionTypeRef

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

the class InternalTypeSystem method upperBoundImpl.

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

            public Object get() {
                return ruleName("upperBoundFunctionTypeRef") + stringRepForEnv(G) + " |~ " + stringRep(F) + " /\\ " + stringRep(_result_.getFirst());
            }
        });
        addAsSubtrace(_trace_, _subtrace_);
        return _result_;
    } catch (Exception e_applyRuleUpperBoundFunctionTypeRef) {
        upperBoundThrowException(ruleName("upperBoundFunctionTypeRef") + stringRepForEnv(G) + " |~ " + stringRep(F) + " /\\ " + "TypeRef", UPPERBOUNDFUNCTIONTYPEREF, e_applyRuleUpperBoundFunctionTypeRef, F, new ErrorInformation[] { new ErrorInformation(F) });
        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

BaseTypeRef (org.eclipse.n4js.ts.typeRefs.BaseTypeRef)6 BoundThisTypeRef (org.eclipse.n4js.ts.typeRefs.BoundThisTypeRef)6 ComposedTypeRef (org.eclipse.n4js.ts.typeRefs.ComposedTypeRef)6 ExistentialTypeRef (org.eclipse.n4js.ts.typeRefs.ExistentialTypeRef)6 FunctionTypeRef (org.eclipse.n4js.ts.typeRefs.FunctionTypeRef)6 ParameterizedTypeRef (org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef)6 StructuralTypeRef (org.eclipse.n4js.ts.typeRefs.StructuralTypeRef)6 ThisTypeRef (org.eclipse.n4js.ts.typeRefs.ThisTypeRef)6 TypeRef (org.eclipse.n4js.ts.typeRefs.TypeRef)6 TypeTypeRef (org.eclipse.n4js.ts.typeRefs.TypeTypeRef)6 StaticBaseTypeRef (org.eclipse.n4js.ts.typeRefs.StaticBaseTypeRef)5 UnknownTypeRef (org.eclipse.n4js.ts.typeRefs.UnknownTypeRef)5 StructuralTypingResult (org.eclipse.n4js.typesystem.StructuralTypingResult)3 Result (org.eclipse.xsemantics.runtime.Result)3 EObject (org.eclipse.emf.ecore.EObject)2 TypeArgument (org.eclipse.n4js.ts.typeRefs.TypeArgument)2 ErrorInformation (org.eclipse.xsemantics.runtime.ErrorInformation)2 RuleApplicationTrace (org.eclipse.xsemantics.runtime.RuleApplicationTrace)2 RuleFailedException (org.eclipse.xsemantics.runtime.RuleFailedException)2 DeferredTypeRef (org.eclipse.n4js.ts.typeRefs.DeferredTypeRef)1