Search in sources :

Example 66 with Result

use of org.eclipse.xsemantics.runtime.Result in project n4js by eclipse.

the class InternalTypeSystem method applyRuleSubstTypeVariablesInTypeTypeRef.

protected Result<TypeArgument> applyRuleSubstTypeVariablesInTypeTypeRef(final RuleEnvironment G, final RuleApplicationTrace _trace_, final TypeTypeRef typeRef) throws RuleFailedException {
    // output parameter
    TypeTypeRef result = null;
    /* G |- typeRef.getTypeArg ~> var TypeArgument tResult */
    TypeArgument _typeArg = typeRef.getTypeArg();
    TypeArgument tResult = null;
    Result<TypeArgument> result_1 = substTypeVariablesInternal(G, _trace_, _typeArg);
    checkAssignableTo(result_1.getFirst(), TypeArgument.class);
    tResult = (TypeArgument) result_1.getFirst();
    TypeArgument _typeArg_1 = typeRef.getTypeArg();
    boolean _tripleNotEquals = (_typeArg_1 != tResult);
    if (_tripleNotEquals) {
        tResult = TypeUtils.<TypeArgument>copyIfContained(tResult);
        result = TypeUtils.<TypeTypeRef>copyIfContained(typeRef);
        result.setTypeArg(tResult);
    } else {
        result = typeRef;
    }
    return new Result<TypeArgument>(result);
}
Also used : 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 67 with Result

use of org.eclipse.xsemantics.runtime.Result in project n4js by eclipse.

the class InternalTypeSystem method applyRuleTypeFunctionExpression.

protected Result<TypeRef> applyRuleTypeFunctionExpression(final RuleEnvironment G, final RuleApplicationTrace _trace_, final FunctionExpression e) throws RuleFailedException {
    // output parameter
    TypeRef T = null;
    T = this.applyRuleTypeTypeDefiningElement(G, _trace_, e).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 68 with Result

use of org.eclipse.xsemantics.runtime.Result in project n4js by eclipse.

the class InternalTypeSystem method applyRuleTypeTGetter.

protected Result<TypeRef> applyRuleTypeTGetter(final RuleEnvironment G, final RuleApplicationTrace _trace_, final TGetter tgetter) throws RuleFailedException {
    // output parameter
    TypeRef T = null;
    TypeRef _elvis = null;
    TypeRef _declaredTypeRef = tgetter.getDeclaredTypeRef();
    if (_declaredTypeRef != null) {
        _elvis = _declaredTypeRef;
    } else {
        ParameterizedTypeRef _anyTypeRef = RuleEnvironmentExtensions.anyTypeRef(G);
        _elvis = _anyTypeRef;
    }
    T = _elvis;
    return new Result<TypeRef>(T);
}
Also used : ParameterizedTypeRef(org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef) 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 69 with Result

use of org.eclipse.xsemantics.runtime.Result in project n4js by eclipse.

the class InternalTypeSystem method applyRuleTypeModuleNamespace.

protected Result<TypeRef> applyRuleTypeModuleNamespace(final RuleEnvironment G, final RuleApplicationTrace _trace_, final ModuleNamespaceVirtualType t) throws RuleFailedException {
    // output parameter
    TypeRef T = null;
    T = TypeUtils.createTypeRef(t);
    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 70 with Result

use of org.eclipse.xsemantics.runtime.Result in project n4js by eclipse.

the class InternalTypeSystem method applyRuleSubtypeExistentialTypeRef_Right.

protected Result<Boolean> applyRuleSubtypeExistentialTypeRef_Right(final RuleEnvironment G, final RuleApplicationTrace _trace_, final TypeRef left, final ExistentialTypeRef existentialTypeRef) throws RuleFailedException {
    boolean _isExistentialTypeToBeReopened = RuleEnvironmentExtensions.isExistentialTypeToBeReopened(G, existentialTypeRef);
    if (_isExistentialTypeToBeReopened) {
        final Wildcard wildThing = existentialTypeRef.getWildcard();
        /* G |~ wildThing /\ var TypeRef upperBound */
        TypeRef upperBound = null;
        Result<TypeRef> result = upperBoundInternal(G, _trace_, wildThing);
        checkAssignableTo(result.getFirst(), TypeRef.class);
        upperBound = (TypeRef) result.getFirst();
        /* G |~ wildThing \/ var TypeRef lowerBound */
        TypeRef lowerBound = null;
        Result<TypeRef> result_1 = lowerBoundInternal(G, _trace_, wildThing);
        checkAssignableTo(result_1.getFirst(), TypeRef.class);
        lowerBound = (TypeRef) result_1.getFirst();
        /* G |- left <: upperBound */
        subtypeInternal(G, _trace_, left, upperBound);
        /* G |- lowerBound <: left */
        subtypeInternal(G, _trace_, lowerBound, left);
    } else {
        /* left===existentialTypeRef or { left instanceof ParameterizedTypeRef && (left as ParameterizedTypeRef).declaredType instanceof NullType } or { G |~ existentialTypeRef \/ var TypeRef lowerExt G |- left <: lowerExt } */
        {
            RuleFailedException previousFailure = null;
            try {
                /* left===existentialTypeRef */
                if (!(left == existentialTypeRef)) {
                    sneakyThrowRuleFailedException("left===existentialTypeRef");
                }
            } catch (Exception e) {
                previousFailure = extractRuleFailedException(e);
                /* { left instanceof ParameterizedTypeRef && (left as ParameterizedTypeRef).declaredType instanceof NullType } or { G |~ existentialTypeRef \/ var TypeRef lowerExt G |- left <: lowerExt } */
                {
                    try {
                        /* left instanceof ParameterizedTypeRef && (left as ParameterizedTypeRef).declaredType instanceof NullType */
                        if (!((left instanceof ParameterizedTypeRef) && (((ParameterizedTypeRef) left).getDeclaredType() instanceof NullType))) {
                            sneakyThrowRuleFailedException("left instanceof ParameterizedTypeRef && (left as ParameterizedTypeRef).declaredType instanceof NullType");
                        }
                    } catch (Exception e_1) {
                        previousFailure = extractRuleFailedException(e_1);
                        /* G |~ existentialTypeRef \/ var TypeRef lowerExt */
                        TypeRef lowerExt = null;
                        Result<TypeRef> result_2 = lowerBoundInternal(G, _trace_, existentialTypeRef);
                        checkAssignableTo(result_2.getFirst(), TypeRef.class);
                        lowerExt = (TypeRef) result_2.getFirst();
                        /* G |- left <: lowerExt */
                        subtypeInternal(G, _trace_, left, lowerExt);
                    }
                }
            }
        }
    }
    return new Result<Boolean>(true);
}
Also used : ParameterizedTypeRef(org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef) 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) NullType(org.eclipse.n4js.ts.types.NullType) RuleFailedException(org.eclipse.xsemantics.runtime.RuleFailedException) RuleFailedException(org.eclipse.xsemantics.runtime.RuleFailedException) Result(org.eclipse.xsemantics.runtime.Result) StructuralTypingResult(org.eclipse.n4js.typesystem.StructuralTypingResult)

Aggregations

Result (org.eclipse.xsemantics.runtime.Result)93 StructuralTypingResult (org.eclipse.n4js.typesystem.StructuralTypingResult)92 ParameterizedTypeRef (org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef)91 TypeRef (org.eclipse.n4js.ts.typeRefs.TypeRef)90 TypeTypeRef (org.eclipse.n4js.ts.typeRefs.TypeTypeRef)90 BaseTypeRef (org.eclipse.n4js.ts.typeRefs.BaseTypeRef)89 BoundThisTypeRef (org.eclipse.n4js.ts.typeRefs.BoundThisTypeRef)89 ComposedTypeRef (org.eclipse.n4js.ts.typeRefs.ComposedTypeRef)89 ExistentialTypeRef (org.eclipse.n4js.ts.typeRefs.ExistentialTypeRef)89 FunctionTypeRef (org.eclipse.n4js.ts.typeRefs.FunctionTypeRef)89 StaticBaseTypeRef (org.eclipse.n4js.ts.typeRefs.StaticBaseTypeRef)89 StructuralTypeRef (org.eclipse.n4js.ts.typeRefs.StructuralTypeRef)89 ThisTypeRef (org.eclipse.n4js.ts.typeRefs.ThisTypeRef)89 UnknownTypeRef (org.eclipse.n4js.ts.typeRefs.UnknownTypeRef)89 ParameterizedCallExpression (org.eclipse.n4js.n4JS.ParameterizedCallExpression)25 IndexedAccessExpression (org.eclipse.n4js.n4JS.IndexedAccessExpression)24 NewExpression (org.eclipse.n4js.n4JS.NewExpression)24 ParameterizedPropertyAccessExpression (org.eclipse.n4js.n4JS.ParameterizedPropertyAccessExpression)24 AdditiveExpression (org.eclipse.n4js.n4JS.AdditiveExpression)23 AssignmentExpression (org.eclipse.n4js.n4JS.AssignmentExpression)23