Search in sources :

Example 1 with SLLongLiteralNode

use of com.oracle.truffle.sl.nodes.expression.SLLongLiteralNode in project graal by oracle.

the class SLNodeFactory method createNumericLiteral.

public SLExpressionNode createNumericLiteral(Token literalToken) {
    SLExpressionNode result;
    try {
        /* Try if the literal is small enough to fit into a long value. */
        result = new SLLongLiteralNode(Long.parseLong(literalToken.val));
    } catch (NumberFormatException ex) {
        /* Overflow of long value, so fall back to BigInteger. */
        result = new SLBigIntegerLiteralNode(new BigInteger(literalToken.val));
    }
    srcFromToken(result, literalToken);
    return result;
}
Also used : SLExpressionNode(com.oracle.truffle.sl.nodes.SLExpressionNode) BigInteger(java.math.BigInteger) SLLongLiteralNode(com.oracle.truffle.sl.nodes.expression.SLLongLiteralNode) SLBigIntegerLiteralNode(com.oracle.truffle.sl.nodes.expression.SLBigIntegerLiteralNode)

Aggregations

SLExpressionNode (com.oracle.truffle.sl.nodes.SLExpressionNode)1 SLBigIntegerLiteralNode (com.oracle.truffle.sl.nodes.expression.SLBigIntegerLiteralNode)1 SLLongLiteralNode (com.oracle.truffle.sl.nodes.expression.SLLongLiteralNode)1 BigInteger (java.math.BigInteger)1