Search in sources :

Example 1 with AdditiveOperator

use of org.eclipse.n4js.n4JS.AdditiveOperator in project n4js by eclipse.

the class AdditiveExpressionImpl method setOp.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setOp(AdditiveOperator newOp) {
    AdditiveOperator oldOp = op;
    op = newOp == null ? OP_EDEFAULT : newOp;
    if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, N4JSPackage.ADDITIVE_EXPRESSION__OP, oldOp, op));
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) AdditiveOperator(org.eclipse.n4js.n4JS.AdditiveOperator)

Example 2 with AdditiveOperator

use of org.eclipse.n4js.n4JS.AdditiveOperator in project n4js by eclipse.

the class InternalTypeSystem method applyRuleTypeAdditiveExpression.

protected Result<TypeRef> applyRuleTypeAdditiveExpression(final RuleEnvironment G, final RuleApplicationTrace _trace_, final AdditiveExpression expr) throws RuleFailedException {
    // output parameter
    TypeRef T = null;
    AdditiveOperator _op = expr.getOp();
    boolean _equals = Objects.equal(_op, AdditiveOperator.ADD);
    if (_equals) {
        /* G |- expr.lhs: var TypeRef l */
        Expression _lhs = expr.getLhs();
        TypeRef l = null;
        Result<TypeRef> result = typeInternal(G, _trace_, _lhs);
        checkAssignableTo(result.getFirst(), TypeRef.class);
        l = (TypeRef) result.getFirst();
        /* G |- expr.rhs: var TypeRef r */
        Expression _rhs = expr.getRhs();
        TypeRef r = null;
        Result<TypeRef> result_1 = typeInternal(G, _trace_, _rhs);
        checkAssignableTo(result_1.getFirst(), TypeRef.class);
        r = (TypeRef) result_1.getFirst();
        final boolean lunknown = (l instanceof UnknownTypeRef);
        final boolean runknown = (r instanceof UnknownTypeRef);
        if ((lunknown && runknown)) {
            T = this.typeSystemHelper.createUnionType(G, RuleEnvironmentExtensions.numberTypeRef(G), RuleEnvironmentExtensions.stringTypeRef(G));
        } else {
            final boolean lnum = RuleEnvironmentExtensions.isNumericOperand(G, l);
            final boolean rnum = RuleEnvironmentExtensions.isNumericOperand(G, r);
            if ((lnum && rnum)) {
                T = RuleEnvironmentExtensions.numberTypeRef(G);
            } else {
                if (((lunknown || runknown) && (lnum || rnum))) {
                    T = this.typeSystemHelper.createUnionType(G, RuleEnvironmentExtensions.numberTypeRef(G), RuleEnvironmentExtensions.stringTypeRef(G));
                } else {
                    final boolean lMayNum = (((lnum || RuleEnvironmentExtensions.containsNumericOperand(G, l)) || RuleEnvironmentExtensions.isAny(G, l)) || RuleEnvironmentExtensions.isSymbol(G, l));
                    final boolean rMayNum = (((rnum || RuleEnvironmentExtensions.containsNumericOperand(G, r)) || RuleEnvironmentExtensions.isAny(G, r)) || RuleEnvironmentExtensions.isSymbol(G, r));
                    if ((lMayNum && rMayNum)) {
                        T = this.typeSystemHelper.createUnionType(G, RuleEnvironmentExtensions.numberTypeRef(G), RuleEnvironmentExtensions.stringTypeRef(G));
                    } else {
                        T = RuleEnvironmentExtensions.stringTypeRef(G);
                    }
                }
            }
        }
    } else {
        T = RuleEnvironmentExtensions.numberTypeRef(G);
    }
    return new Result<TypeRef>(T);
}
Also used : UnknownTypeRef(org.eclipse.n4js.ts.typeRefs.UnknownTypeRef) 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) AdditiveOperator(org.eclipse.n4js.n4JS.AdditiveOperator) Result(org.eclipse.xsemantics.runtime.Result) StructuralTypingResult(org.eclipse.n4js.typesystem.StructuralTypingResult)

Aggregations

AdditiveOperator (org.eclipse.n4js.n4JS.AdditiveOperator)2 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)1 AdditiveExpression (org.eclipse.n4js.n4JS.AdditiveExpression)1 AssignmentExpression (org.eclipse.n4js.n4JS.AssignmentExpression)1 AwaitExpression (org.eclipse.n4js.n4JS.AwaitExpression)1 BinaryBitwiseExpression (org.eclipse.n4js.n4JS.BinaryBitwiseExpression)1 BinaryLogicalExpression (org.eclipse.n4js.n4JS.BinaryLogicalExpression)1 CastExpression (org.eclipse.n4js.n4JS.CastExpression)1 CommaExpression (org.eclipse.n4js.n4JS.CommaExpression)1 ConditionalExpression (org.eclipse.n4js.n4JS.ConditionalExpression)1 EqualityExpression (org.eclipse.n4js.n4JS.EqualityExpression)1 Expression (org.eclipse.n4js.n4JS.Expression)1 FunctionExpression (org.eclipse.n4js.n4JS.FunctionExpression)1 IndexedAccessExpression (org.eclipse.n4js.n4JS.IndexedAccessExpression)1 MultiplicativeExpression (org.eclipse.n4js.n4JS.MultiplicativeExpression)1 N4ClassExpression (org.eclipse.n4js.n4JS.N4ClassExpression)1 NewExpression (org.eclipse.n4js.n4JS.NewExpression)1 ParameterizedCallExpression (org.eclipse.n4js.n4JS.ParameterizedCallExpression)1 ParameterizedPropertyAccessExpression (org.eclipse.n4js.n4JS.ParameterizedPropertyAccessExpression)1 ParenExpression (org.eclipse.n4js.n4JS.ParenExpression)1