Search in sources :

Example 1 with NumericLiteral

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

the class GuardFactory method createGuardForVoid.

private static Guard createGuardForVoid(EObject topContainer, UnaryExpression ue, boolean negateTree, boolean negateEqe, Expression symbolExpr) {
    Expression voidExpr = ue.getExpression();
    if (voidExpr instanceof NumericLiteral) {
        NumericLiteral nl = (NumericLiteral) voidExpr;
        String numVal = nl.getValueAsString();
        if (!"0".equals(numVal)) {
            return null;
        }
    }
    GuardAssertion asserts = FlowAssertionFactory.getGuard(topContainer, ue.eContainer(), negateTree, negateEqe);
    Guard guard = createIsUndefinedGuard(ue, asserts, symbolExpr);
    return guard;
}
Also used : NumericLiteral(org.eclipse.n4js.n4JS.NumericLiteral) BinaryLogicalExpression(org.eclipse.n4js.n4JS.BinaryLogicalExpression) RelationalExpression(org.eclipse.n4js.n4JS.RelationalExpression) UnaryExpression(org.eclipse.n4js.n4JS.UnaryExpression) EqualityExpression(org.eclipse.n4js.n4JS.EqualityExpression) ParenExpression(org.eclipse.n4js.n4JS.ParenExpression) Expression(org.eclipse.n4js.n4JS.Expression) ParameterizedCallExpression(org.eclipse.n4js.n4JS.ParameterizedCallExpression) ConditionalExpression(org.eclipse.n4js.n4JS.ConditionalExpression)

Example 2 with NumericLiteral

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

the class DivisionByZeroAnalyser method isZeroLiteral.

private static boolean isZeroLiteral(Expression expr) {
    if (expr instanceof NumericLiteral) {
        NumericLiteral numLit = (NumericLiteral) expr;
        BigDecimal litValue = numLit.getValue();
        return litValue.equals(0);
    }
    return false;
}
Also used : NumericLiteral(org.eclipse.n4js.n4JS.NumericLiteral) BigDecimal(java.math.BigDecimal)

Aggregations

NumericLiteral (org.eclipse.n4js.n4JS.NumericLiteral)2 BigDecimal (java.math.BigDecimal)1 BinaryLogicalExpression (org.eclipse.n4js.n4JS.BinaryLogicalExpression)1 ConditionalExpression (org.eclipse.n4js.n4JS.ConditionalExpression)1 EqualityExpression (org.eclipse.n4js.n4JS.EqualityExpression)1 Expression (org.eclipse.n4js.n4JS.Expression)1 ParameterizedCallExpression (org.eclipse.n4js.n4JS.ParameterizedCallExpression)1 ParenExpression (org.eclipse.n4js.n4JS.ParenExpression)1 RelationalExpression (org.eclipse.n4js.n4JS.RelationalExpression)1 UnaryExpression (org.eclipse.n4js.n4JS.UnaryExpression)1