Java Code Examples for jdk.nashorn.internal.ir.UnaryNode#rhs()
The following examples show how to use
jdk.nashorn.internal.ir.UnaryNode#rhs() .
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: BranchOptimizer.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
private void branchOptimizer(final UnaryNode unaryNode, final Label label, final boolean state) { final Expression rhs = unaryNode.rhs(); switch (unaryNode.tokenType()) { case NOT: branchOptimizer(rhs, label, !state); return; default: if (unaryNode.getType().isBoolean()) { branchOptimizer(rhs, label, state); return; } break; } // convert to boolean codegen.load(unaryNode, Type.BOOLEAN); if (state) { method.ifne(label); } else { method.ifeq(label); } }
Example 2
Source File: CodeGenerator.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
@Override public boolean enterNOT(final UnaryNode unaryNode) { final Expression rhs = unaryNode.rhs(); load(rhs, Type.BOOLEAN); final Label trueLabel = new Label("true"); final Label afterLabel = new Label("after"); method.ifne(trueLabel); method.load(true); method._goto(afterLabel); method.label(trueLabel); method.load(false); method.label(afterLabel); method.store(unaryNode.getSymbol()); return false; }
Example 3
Source File: BranchOptimizer.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
private void branchOptimizer(final UnaryNode unaryNode, final Label label, final boolean state) { final Expression rhs = unaryNode.rhs(); switch (unaryNode.tokenType()) { case NOT: branchOptimizer(rhs, label, !state); return; default: if (unaryNode.getType().isBoolean()) { branchOptimizer(rhs, label, state); return; } break; } // convert to boolean codegen.load(unaryNode, Type.BOOLEAN); if (state) { method.ifne(label); } else { method.ifeq(label); } }
Example 4
Source File: CodeGenerator.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
@Override public boolean enterNOT(final UnaryNode unaryNode) { final Expression rhs = unaryNode.rhs(); load(rhs, Type.BOOLEAN); final Label trueLabel = new Label("true"); final Label afterLabel = new Label("after"); method.ifne(trueLabel); method.load(true); method._goto(afterLabel); method.label(trueLabel); method.load(false); method.label(afterLabel); method.store(unaryNode.getSymbol()); return false; }
Example 5
Source File: BranchOptimizer.java From nashorn with GNU General Public License v2.0 | 6 votes |
private void branchOptimizer(final UnaryNode unaryNode, final Label label, final boolean state) { final Expression rhs = unaryNode.rhs(); switch (unaryNode.tokenType()) { case NOT: branchOptimizer(rhs, label, !state); return; case CONVERT: if (unaryNode.getType().isBoolean()) { branchOptimizer(rhs, label, state); return; } break; default: break; } // convert to boolean load(unaryNode); method.convert(Type.BOOLEAN); if (state) { method.ifne(label); } else { method.ifeq(label); } }
Example 6
Source File: CodeGenerator.java From nashorn with GNU General Public License v2.0 | 6 votes |
@Override public boolean enterNOT(final UnaryNode unaryNode) { final Expression rhs = unaryNode.rhs(); load(rhs); final Label trueLabel = new Label("true"); final Label afterLabel = new Label("after"); method.convert(Type.BOOLEAN); method.ifne(trueLabel); method.load(true); method._goto(afterLabel); method.label(trueLabel); method.load(false); method.label(afterLabel); method.store(unaryNode.getSymbol()); return false; }
Example 7
Source File: CodeGenerator.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
@Override public boolean enterNEW(final UnaryNode unaryNode) { final CallNode callNode = (CallNode)unaryNode.rhs(); final List<Expression> args = callNode.getArgs(); // Load function reference. load(callNode.getFunction(), Type.OBJECT); // must detect type error method.dynamicNew(1 + loadArgs(args), getCallSiteFlags()); method.store(unaryNode.getSymbol()); return false; }
Example 8
Source File: CodeGenerator.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@Override public boolean enterNEW(final UnaryNode unaryNode) { final CallNode callNode = (CallNode)unaryNode.rhs(); final List<Expression> args = callNode.getArgs(); // Load function reference. load(callNode.getFunction(), Type.OBJECT); // must detect type error method.dynamicNew(1 + loadArgs(args), getCallSiteFlags()); method.store(unaryNode.getSymbol()); return false; }
Example 9
Source File: CodeGenerator.java From nashorn with GNU General Public License v2.0 | 5 votes |
@Override public boolean enterNEW(final UnaryNode unaryNode) { final CallNode callNode = (CallNode)unaryNode.rhs(); final List<Expression> args = callNode.getArgs(); // Load function reference. load(callNode.getFunction()).convert(Type.OBJECT); // must detect type error method.dynamicNew(1 + loadArgs(args), getCallSiteFlags()); method.store(unaryNode.getSymbol()); return false; }
Example 10
Source File: JSONWriter.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
@Override public boolean enterUnaryNode(final UnaryNode unaryNode) { enterDefault(unaryNode); final TokenType tokenType = unaryNode.tokenType(); if (tokenType == TokenType.NEW) { type("NewExpression"); comma(); final CallNode callNode = (CallNode)unaryNode.rhs(); property("callee"); callNode.getFunction().accept(this); comma(); array("arguments", callNode.getArgs()); } else { final String operator; final boolean prefix; switch (tokenType) { case INCPOSTFIX: prefix = false; operator = "++"; break; case DECPOSTFIX: prefix = false; operator = "--"; break; case INCPREFIX: operator = "++"; prefix = true; break; case DECPREFIX: operator = "--"; prefix = true; break; default: prefix = true; operator = tokenType.getName(); break; } type(unaryNode.isAssignment()? "UpdateExpression" : "UnaryExpression"); comma(); property("operator", operator); comma(); property("prefix", prefix); comma(); property("argument"); unaryNode.rhs().accept(this); } return leave(); }
Example 11
Source File: JSONWriter.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
@Override public boolean enterUnaryNode(final UnaryNode unaryNode) { enterDefault(unaryNode); final TokenType tokenType = unaryNode.tokenType(); if (tokenType == TokenType.NEW) { type("NewExpression"); comma(); final CallNode callNode = (CallNode)unaryNode.rhs(); property("callee"); callNode.getFunction().accept(this); comma(); array("arguments", callNode.getArgs()); } else { final String operator; final boolean prefix; switch (tokenType) { case INCPOSTFIX: prefix = false; operator = "++"; break; case DECPOSTFIX: prefix = false; operator = "--"; break; case INCPREFIX: operator = "++"; prefix = true; break; case DECPREFIX: operator = "--"; prefix = true; break; default: prefix = true; operator = tokenType.getName(); break; } type(unaryNode.isAssignment()? "UpdateExpression" : "UnaryExpression"); comma(); property("operator", operator); comma(); property("prefix", prefix); comma(); property("argument"); unaryNode.rhs().accept(this); } return leave(); }
Example 12
Source File: JSONWriter.java From nashorn with GNU General Public License v2.0 | 4 votes |
@Override public boolean enterUnaryNode(final UnaryNode unaryNode) { enterDefault(unaryNode); final TokenType tokenType = unaryNode.tokenType(); if (tokenType == TokenType.NEW) { type("NewExpression"); comma(); final CallNode callNode = (CallNode)unaryNode.rhs(); property("callee"); callNode.getFunction().accept(this); comma(); array("arguments", callNode.getArgs()); } else { final String operator; final boolean prefix; switch (tokenType) { case INCPOSTFIX: prefix = false; operator = "++"; break; case DECPOSTFIX: prefix = false; operator = "--"; break; case INCPREFIX: operator = "++"; prefix = true; break; case DECPREFIX: operator = "--"; prefix = true; break; default: prefix = true; operator = tokenType.getName(); break; } type(unaryNode.isAssignment()? "UpdateExpression" : "UnaryExpression"); comma(); property("operator", operator); comma(); property("prefix", prefix); comma(); property("argument"); unaryNode.rhs().accept(this); } return leave(); }