Java Code Examples for jdk.nashorn.internal.ir.Symbol#setRange()
The following examples show how to use
jdk.nashorn.internal.ir.Symbol#setRange() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RangeAnalyzer.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Check for a loop counter. This is currently quite conservative, in that it only handles * x <= counter and x < counter. * * @param node loop node to check * @return */ private static Symbol findLoopCounter(final LoopNode node) { final Expression test = node.getTest(); if (test != null && test.isComparison()) { final BinaryNode binaryNode = (BinaryNode)test; final Expression lhs = binaryNode.lhs(); final Expression rhs = binaryNode.rhs(); //detect ident cmp int_literal if (lhs instanceof IdentNode && rhs instanceof LiteralNode && ((LiteralNode<?>)rhs).getType().isInteger()) { final Symbol symbol = lhs.getSymbol(); final int margin = ((LiteralNode<?>)rhs).getInt32(); final TokenType op = test.tokenType(); switch (op) { case LT: case LE: symbol.setRange(RANGE.join(symbol.getRange(), Range.createRange(op == TokenType.LT ? margin - 1 : margin))); return symbol; case GT: case GE: //setRange(lhs, Range.createRange(op == TokenType.GT ? margin + 1 : margin)); //return symbol; default: break; } } } return null; }
Example 2
Source File: RangeAnalyzer.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Check for a loop counter. This is currently quite conservative, in that it only handles * x <= counter and x < counter. * * @param node loop node to check * @return */ private static Symbol findLoopCounter(final LoopNode node) { final Expression test = node.getTest(); if (test != null && test.isComparison()) { final BinaryNode binaryNode = (BinaryNode)test; final Expression lhs = binaryNode.lhs(); final Expression rhs = binaryNode.rhs(); //detect ident cmp int_literal if (lhs instanceof IdentNode && rhs instanceof LiteralNode && ((LiteralNode<?>)rhs).getType().isInteger()) { final Symbol symbol = lhs.getSymbol(); final int margin = ((LiteralNode<?>)rhs).getInt32(); final TokenType op = test.tokenType(); switch (op) { case LT: case LE: symbol.setRange(RANGE.join(symbol.getRange(), Range.createRange(op == TokenType.LT ? margin - 1 : margin))); return symbol; case GT: case GE: //setRange(lhs, Range.createRange(op == TokenType.GT ? margin + 1 : margin)); //return symbol; default: break; } } } return null; }
Example 3
Source File: RangeAnalyzer.java From nashorn with GNU General Public License v2.0 | 5 votes |
/** * Check for a loop counter. This is currently quite conservative, in that it only handles * x <= counter and x < counter. * * @param node loop node to check * @return */ private static Symbol findLoopCounter(final LoopNode node) { final Expression test = node.getTest(); if (test != null && test.isComparison()) { final BinaryNode binaryNode = (BinaryNode)test; final Expression lhs = binaryNode.lhs(); final Expression rhs = binaryNode.rhs(); //detect ident cmp int_literal if (lhs instanceof IdentNode && rhs instanceof LiteralNode && ((LiteralNode<?>)rhs).getType().isInteger()) { final Symbol symbol = lhs.getSymbol(); final int margin = ((LiteralNode<?>)rhs).getInt32(); final TokenType op = test.tokenType(); switch (op) { case LT: case LE: symbol.setRange(RANGE.join(symbol.getRange(), Range.createRange(op == TokenType.LT ? margin - 1 : margin))); return symbol; case GT: case GE: //setRange(lhs, Range.createRange(op == TokenType.GT ? margin + 1 : margin)); //return symbol; default: break; } } } return null; }