Search in sources :

Example 41 with Expression

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

the class SwitchStatementImpl method basicSetExpression.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetExpression(Expression newExpression, NotificationChain msgs) {
    Expression oldExpression = expression;
    expression = newExpression;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, N4JSPackage.SWITCH_STATEMENT__EXPRESSION, oldExpression, newExpression);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : Expression(org.eclipse.n4js.n4JS.Expression) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 42 with Expression

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

the class AssignmentRelation method toString.

@Override
public String toString() {
    String str = "";
    str += leftSymbol.toString() + " := ";
    int count = 0;
    for (Object obj : rhsObjects) {
        if (count++ > 0) {
            str += " | ";
        }
        str += (obj instanceof Expression) ? FGUtils.getSourceText((EObject) obj) : obj;
    }
    return str;
}
Also used : Expression(org.eclipse.n4js.n4JS.Expression) EObject(org.eclipse.emf.ecore.EObject)

Example 43 with Expression

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

the class AssignmentRelationFactory method findInAssignmentExpression.

private void findInAssignmentExpression(Multimap<Symbol, Object> assgns, AssignmentExpression ae) {
    Expression lhs = ae.getLhs();
    Expression rhs = ae.getRhs();
    handleSubexpressions(assgns, lhs, rhs);
}
Also used : BinaryLogicalExpression(org.eclipse.n4js.n4JS.BinaryLogicalExpression) AssignmentExpression(org.eclipse.n4js.n4JS.AssignmentExpression) Expression(org.eclipse.n4js.n4JS.Expression) ConditionalExpression(org.eclipse.n4js.n4JS.ConditionalExpression)

Example 44 with Expression

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

the class AssignmentRelationFactory method handleSubexpressions.

private void handleSubexpressions(Multimap<Symbol, Object> assgns, ControlFlowElement lhs, Expression rhs) {
    rhs = ASTUtils.unwrapParentheses(rhs);
    if (rhs instanceof AssignmentExpression) {
        AssignmentExpression ae = (AssignmentExpression) rhs;
        Expression innerRhs = ae.getRhs();
        // The inner assignment is handled already.
        handleSubexpressions(assgns, lhs, innerRhs);
    } else if (rhs instanceof ConditionalExpression) {
        ConditionalExpression ce = (ConditionalExpression) rhs;
        Expression trueExpr = ce.getTrueExpression();
        Expression falseExpr = ce.getFalseExpression();
        handleSubexpressions(assgns, lhs, trueExpr);
        handleSubexpressions(assgns, lhs, falseExpr);
    } else if (rhs instanceof BinaryLogicalExpression) {
        BinaryLogicalExpression ble = (BinaryLogicalExpression) rhs;
        if (ble.getOp() == BinaryLogicalOperator.OR) {
            handleSubexpressions(assgns, lhs, ble.getLhs());
        }
        handleSubexpressions(assgns, lhs, ble.getRhs());
    } else {
        createRelation(assgns, lhs, rhs);
    }
}
Also used : BinaryLogicalExpression(org.eclipse.n4js.n4JS.BinaryLogicalExpression) AssignmentExpression(org.eclipse.n4js.n4JS.AssignmentExpression) BinaryLogicalExpression(org.eclipse.n4js.n4JS.BinaryLogicalExpression) AssignmentExpression(org.eclipse.n4js.n4JS.AssignmentExpression) Expression(org.eclipse.n4js.n4JS.Expression) ConditionalExpression(org.eclipse.n4js.n4JS.ConditionalExpression) ConditionalExpression(org.eclipse.n4js.n4JS.ConditionalExpression)

Example 45 with Expression

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

the class AssignmentRelationFactory method findInCorrespondingDestructNodes.

private void findInCorrespondingDestructNodes(Multimap<Symbol, Object> assgns, ControlFlowElement cfe) {
    DestructNode dNode = DestructureUtils.getCorrespondingDestructNode(cfe);
    if (dNode == null) {
        return;
    }
    EObject parentOfDestrNode = DestructureUtils.getTop(cfe);
    if (parentOfDestrNode instanceof ForStatement) {
        ForStatement fs = (ForStatement) parentOfDestrNode;
        Expression fsExpr = fs.getExpression();
        if (fsExpr instanceof ArrayLiteral) {
            ArrayLiteral al = (ArrayLiteral) fsExpr;
            EObject rootOfDestrNode = DestructureUtils.getRoot(cfe);
            for (ArrayElement arrElem : al.getElements()) {
                dNode = DestructNode.unify(rootOfDestrNode, arrElem.getExpression());
                findInDestructNodes(assgns, dNode);
            }
        }
    } else {
        findInDestructNodes(assgns, dNode);
    }
}
Also used : BinaryLogicalExpression(org.eclipse.n4js.n4JS.BinaryLogicalExpression) AssignmentExpression(org.eclipse.n4js.n4JS.AssignmentExpression) Expression(org.eclipse.n4js.n4JS.Expression) ConditionalExpression(org.eclipse.n4js.n4JS.ConditionalExpression) EObject(org.eclipse.emf.ecore.EObject) DestructNode(org.eclipse.n4js.n4JS.DestructNode) ForStatement(org.eclipse.n4js.n4JS.ForStatement) ArrayLiteral(org.eclipse.n4js.n4JS.ArrayLiteral) ArrayElement(org.eclipse.n4js.n4JS.ArrayElement)

Aggregations

Expression (org.eclipse.n4js.n4JS.Expression)111 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)58 ConditionalExpression (org.eclipse.n4js.n4JS.ConditionalExpression)40 BinaryLogicalExpression (org.eclipse.n4js.n4JS.BinaryLogicalExpression)38 ParameterizedCallExpression (org.eclipse.n4js.n4JS.ParameterizedCallExpression)37 AssignmentExpression (org.eclipse.n4js.n4JS.AssignmentExpression)35 ParameterizedPropertyAccessExpression (org.eclipse.n4js.n4JS.ParameterizedPropertyAccessExpression)33 EqualityExpression (org.eclipse.n4js.n4JS.EqualityExpression)31 ParenExpression (org.eclipse.n4js.n4JS.ParenExpression)31 RelationalExpression (org.eclipse.n4js.n4JS.RelationalExpression)31 UnaryExpression (org.eclipse.n4js.n4JS.UnaryExpression)31 AdditiveExpression (org.eclipse.n4js.n4JS.AdditiveExpression)27 BinaryBitwiseExpression (org.eclipse.n4js.n4JS.BinaryBitwiseExpression)27 IndexedAccessExpression (org.eclipse.n4js.n4JS.IndexedAccessExpression)27 MultiplicativeExpression (org.eclipse.n4js.n4JS.MultiplicativeExpression)27 ShiftExpression (org.eclipse.n4js.n4JS.ShiftExpression)27 AwaitExpression (org.eclipse.n4js.n4JS.AwaitExpression)26 CastExpression (org.eclipse.n4js.n4JS.CastExpression)26 FunctionExpression (org.eclipse.n4js.n4JS.FunctionExpression)26 NewExpression (org.eclipse.n4js.n4JS.NewExpression)26