jdk.nashorn.internal.ir.BinaryNode Java Examples
The following examples show how to use
jdk.nashorn.internal.ir.BinaryNode.
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: SplitIntoFunctions.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
@Override public Node leaveBlock(final Block block) { if (!artificialBlock) { if (lc.isFunctionBody()) { // Prepend declaration-only var statements to the top of the statement list. lc.prependStatements(getCurrentFunctionState().varStatements); } else if (lc.isSplitBody()) { appendSplitReturn(FALLTHROUGH_STATE, NO_LINE_NUMBER); if (getCurrentFunctionState().fn.isProgram()) { // If we're splitting the program, make sure every shard ends with "return :return" and // begins with ":return = :return-in;". lc.prependStatement(new ExpressionStatement(NO_LINE_NUMBER, NO_TOKEN, NO_FINISH, new BinaryNode(Token.toDesc(TokenType.ASSIGN, 0, 0), createReturnIdent(), createReturnParamIdent()))); } } } return block; }
Example #2
Source File: PrintVisitor.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
@Override public boolean enterBinaryNode(final BinaryNode binaryNode) { binaryNode.lhs().accept(this); sb.append(' '); sb.append(binaryNode.tokenType()); sb.append(' '); binaryNode.rhs().accept(this); return false; }
Example #3
Source File: CodeGenerator.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@Override public boolean enterSAR(final BinaryNode binaryNode) { new BinaryArith() { @Override protected void op() { method.sar(); } }.evaluate(binaryNode); return false; }
Example #4
Source File: AssignSymbols.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Override public Node leaveBinaryNode(final BinaryNode binaryNode) { if (binaryNode.isTokenType(TokenType.ASSIGN)) { return leaveASSIGN(binaryNode); } return super.leaveBinaryNode(binaryNode); }
Example #5
Source File: SplitIntoFunctions.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private static IfNode makeIfStateEquals(final int lineNumber, final long token, final int finish, final int value, final Block pass, final Statement fail) { return new IfNode(lineNumber, token, finish, new BinaryNode(Token.recast(token, TokenType.EQ_STRICT), GetSplitState.INSTANCE, intLiteral(value)), pass, fail == null ? null : new Block(NO_TOKEN, NO_FINISH, fail)); }
Example #6
Source File: CodeGenerator.java From nashorn with GNU General Public License v2.0 | 5 votes |
@Override public boolean enterASSIGN_SHL(final BinaryNode binaryNode) { new AssignOp(Type.INT, binaryNode) { @Override protected void op() { method.shl(); } }.store(); return false; }
Example #7
Source File: LocalVariableTypesCalculator.java From hottub with GNU General Public License v2.0 | 5 votes |
@Override public boolean enterBinaryNode(final BinaryNode binaryNode) { // NOTE: regardless of operator's lexical associativity, lhs is always evaluated first. final Expression lhs = binaryNode.lhs(); final LvarType lhsType; if (!(lhs instanceof IdentNode && binaryNode.isTokenType(TokenType.ASSIGN))) { lhsType = visitExpression(lhs); } else { // Can't visit IdentNode on LHS of a simple assignment, as visits imply use, and this is def. // The type is irrelevant, as only RHS is used to determine the type anyway. lhsType = LvarType.UNDEFINED; } final boolean isLogical = binaryNode.isLogical(); final Label joinLabel = isLogical ? new Label("") : null; if(isLogical) { jumpToLabel((JoinPredecessor)lhs, joinLabel); } final Expression rhs = binaryNode.rhs(); final LvarType rhsType = visitExpression(rhs); if(isLogical) { jumpToLabel((JoinPredecessor)rhs, joinLabel); } joinOnLabel(joinLabel); final LvarType type = toLvarType(binaryNode.setOperands(lhsType.typeExpression, rhsType.typeExpression).getType()); if(binaryNode.isAssignment() && lhs instanceof IdentNode) { if(binaryNode.isSelfModifying()) { onSelfAssignment((IdentNode)lhs, type); } else { onAssignment((IdentNode)lhs, type); } } typeStack.push(type); return false; }
Example #8
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; }
Example #9
Source File: Attr.java From nashorn with GNU General Public License v2.0 | 5 votes |
private Node leaveBinaryRuntimeOperator(final BinaryNode binaryNode, final Request request) { try { // Don't do a full RuntimeNode.accept, as we don't want to double-visit the binary node operands return leaveRuntimeNode(new RuntimeNode(binaryNode, request)); } finally { end(binaryNode); } }
Example #10
Source File: WeighNodes.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
@Override public Node leaveASSIGN_SHR(final BinaryNode binaryNode) { return binaryNodeWeight(binaryNode); }
Example #11
Source File: Attr.java From nashorn with GNU General Public License v2.0 | 4 votes |
private Node leaveCmp(final BinaryNode binaryNode) { ensureTypeNotUnknown(binaryNode.lhs()); ensureTypeNotUnknown(binaryNode.rhs()); return end(ensureSymbol(Type.BOOLEAN, binaryNode)); }
Example #12
Source File: CodeGenerator.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
@Override public boolean enterNE_STRICT(final BinaryNode binaryNode) { return enterCmp(binaryNode, Condition.NE); }
Example #13
Source File: Attr.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
private Node coerce(final BinaryNode binaryNode, final Type type) { return coerce(binaryNode, type, type); }
Example #14
Source File: WeighNodes.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Override public Node leaveASSIGN_MOD(final BinaryNode binaryNode) { return binaryNodeWeight(binaryNode); }
Example #15
Source File: Attr.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
@Override public Node leaveBIT_AND(final BinaryNode binaryNode) { return end(coerce(binaryNode, Type.INT)); }
Example #16
Source File: WeighNodes.java From hottub with GNU General Public License v2.0 | 4 votes |
@Override public Node leaveSAR(final BinaryNode binaryNode) { return binaryNodeWeight(binaryNode); }
Example #17
Source File: WeighNodes.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
@Override public Node leaveMOD(final BinaryNode binaryNode) { return binaryNodeWeight(binaryNode); }
Example #18
Source File: ProgramPoints.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Override public Node leaveBinaryNode(final BinaryNode binaryNode) { return setProgramPoint(binaryNode); }
Example #19
Source File: WeighNodes.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Override public Node leaveASSIGN_BIT_AND(final BinaryNode binaryNode) { return binaryNodeWeight(binaryNode); }
Example #20
Source File: WeighNodes.java From hottub with GNU General Public License v2.0 | 4 votes |
@Override public Node leaveAND(final BinaryNode binaryNode) { return binaryNodeWeight(binaryNode); }
Example #21
Source File: Attr.java From nashorn with GNU General Public License v2.0 | 4 votes |
@Override public Node leaveASSIGN_MOD(final BinaryNode binaryNode) { return leaveSelfModifyingAssignmentNode(binaryNode); }
Example #22
Source File: RangeAnalyzer.java From nashorn with GNU General Public License v2.0 | 4 votes |
private Node leaveSelfModifyingAssign(final BinaryNode node, final Range range) { setRange(node.lhs(), range); setRange(node, range); return node; }
Example #23
Source File: Attr.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
@Override public Node leaveDIV(final BinaryNode binaryNode) { return leaveBinaryArithmetic(binaryNode); }
Example #24
Source File: Attr.java From nashorn with GNU General Public License v2.0 | 4 votes |
private Node leaveBinaryArithmetic(final BinaryNode binaryNode) { assert !Compiler.shouldUseIntegerArithmetic(); return end(coerce(binaryNode, Type.NUMBER)); }
Example #25
Source File: FinalizeTypes.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
@Override public Node leaveCOMMALEFT(final BinaryNode binaryNode) { assert binaryNode.getSymbol() != null; return binaryNode.setRHS(discard(binaryNode.rhs())); }
Example #26
Source File: WeighNodes.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
@Override public Node leaveBIT_OR(final BinaryNode binaryNode) { return binaryNodeWeight(binaryNode); }
Example #27
Source File: WeighNodes.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
@Override public Node leaveSHR(final BinaryNode binaryNode) { return binaryNodeWeight(binaryNode); }
Example #28
Source File: Attr.java From nashorn with GNU General Public License v2.0 | 4 votes |
@Override public Node leaveIN(final BinaryNode binaryNode) { return leaveBinaryRuntimeOperator(binaryNode, Request.IN); }
Example #29
Source File: RangeAnalyzer.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
@Override public Node leaveSHR(final BinaryNode node) { setRange(node, RANGE.shr(node.lhs().getSymbol().getRange(), node.rhs().getSymbol().getRange())); return node; }
Example #30
Source File: WeighNodes.java From hottub with GNU General Public License v2.0 | 4 votes |
@Override public Node leaveASSIGN_SAR(final BinaryNode binaryNode) { return binaryNodeWeight(binaryNode); }