Search in sources :

Example 1 with EqualityOperator

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

the class EqualityExpressionImpl method setOp.

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

Example 2 with EqualityOperator

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

the class GuardFactory method create.

/**
 * @return a {@link Guard} from a given {@link Expression} that is used as condition.
 */
static Guard create(EObject topContainer, Expression expr, boolean negateTree) {
    if (expr instanceof EqualityExpression) {
        EqualityExpression eqe = (EqualityExpression) expr;
        EqualityOperator operation = eqe.getOp();
        boolean sameEqual = operation == EqualityOperator.EQ || operation == EqualityOperator.SAME;
        boolean sameEqualNot = operation == EqualityOperator.NEQ || operation == EqualityOperator.NSAME;
        if (sameEqual || sameEqualNot) {
            return createGuardForEquality(topContainer, negateTree, eqe, sameEqualNot);
        }
    } else if (expr instanceof RelationalExpression) {
        RelationalExpression re = (RelationalExpression) expr;
        if (re.getOp() == RelationalOperator.INSTANCEOF) {
            return createGuardForInstanceof(topContainer, negateTree, re);
        }
    } else if (expr instanceof ParameterizedCallExpression) {
    // TODO: implement GuardType.InState here
    } else {
        // if (a) {...}
        return createGuardForTruthy(topContainer, expr, negateTree);
    }
    return null;
}
Also used : RelationalExpression(org.eclipse.n4js.n4JS.RelationalExpression) ParameterizedCallExpression(org.eclipse.n4js.n4JS.ParameterizedCallExpression) EqualityExpression(org.eclipse.n4js.n4JS.EqualityExpression) EqualityOperator(org.eclipse.n4js.n4JS.EqualityOperator)

Aggregations

EqualityOperator (org.eclipse.n4js.n4JS.EqualityOperator)2 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)1 EqualityExpression (org.eclipse.n4js.n4JS.EqualityExpression)1 ParameterizedCallExpression (org.eclipse.n4js.n4JS.ParameterizedCallExpression)1 RelationalExpression (org.eclipse.n4js.n4JS.RelationalExpression)1