jdk.nashorn.internal.ir.RuntimeNode Java Examples
The following examples show how to use
jdk.nashorn.internal.ir.RuntimeNode.
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: AssignSymbols.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
private Node leaveTYPEOF(final UnaryNode unaryNode) { final Expression rhs = unaryNode.getExpression(); final List<Expression> args = new ArrayList<>(); if (rhs instanceof IdentNode && !isParamOrVar((IdentNode)rhs)) { args.add(compilerConstantIdentifier(SCOPE)); args.add(LiteralNode.newInstance(rhs, ((IdentNode)rhs).getName())); //null } else { args.add(rhs); args.add(LiteralNode.newInstance(unaryNode)); //null, do not reuse token of identifier rhs, it can be e.g. 'this' } final Node runtimeNode = new RuntimeNode(unaryNode, Request.TYPEOF, args); end(unaryNode); return runtimeNode; }
Example #2
Source File: JSONWriter.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@Override public boolean enterExpressionStatement(final ExpressionStatement expressionStatement) { // handle debugger statement final Node expression = expressionStatement.getExpression(); if (expression instanceof RuntimeNode) { expression.accept(this); return false; } enterDefault(expressionStatement); type("ExpressionStatement"); comma(); property("expression"); expression.accept(this); return leave(); }
Example #3
Source File: AssignSymbols.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
private Node leaveTYPEOF(final UnaryNode unaryNode) { final Expression rhs = unaryNode.getExpression(); final List<Expression> args = new ArrayList<>(); if (rhs instanceof IdentNode && !isParamOrVar((IdentNode)rhs)) { args.add(compilerConstantIdentifier(SCOPE)); args.add((Expression)LiteralNode.newInstance(rhs, ((IdentNode)rhs).getName()).accept(this)); //null } else { args.add(rhs); args.add((Expression)LiteralNode.newInstance(unaryNode).accept(this)); //null, do not reuse token of identifier rhs, it can be e.g. 'this' } final Node runtimeNode = new RuntimeNode(unaryNode, Request.TYPEOF, args).accept(this); end(unaryNode); return runtimeNode; }
Example #4
Source File: AssignSymbols.java From hottub with GNU General Public License v2.0 | 6 votes |
private Node leaveTYPEOF(final UnaryNode unaryNode) { final Expression rhs = unaryNode.getExpression(); final List<Expression> args = new ArrayList<>(); if (rhs instanceof IdentNode && !isParamOrVar((IdentNode)rhs)) { args.add(compilerConstantIdentifier(SCOPE)); args.add(LiteralNode.newInstance(rhs, ((IdentNode)rhs).getName())); //null } else { args.add(rhs); args.add(LiteralNode.newInstance(unaryNode)); //null, do not reuse token of identifier rhs, it can be e.g. 'this' } final Node runtimeNode = new RuntimeNode(unaryNode, Request.TYPEOF, args); end(unaryNode); return runtimeNode; }
Example #5
Source File: JSONWriter.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
@Override public boolean enterExpressionStatement(final ExpressionStatement expressionStatement) { // handle debugger statement final Node expression = expressionStatement.getExpression(); if (expression instanceof RuntimeNode) { expression.accept(this); return false; } enterDefault(expressionStatement); type("ExpressionStatement"); comma(); property("expression"); expression.accept(this); return leave(); }
Example #6
Source File: AssignSymbols.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private Node leaveTYPEOF(final UnaryNode unaryNode) { final Expression rhs = unaryNode.getExpression(); final List<Expression> args = new ArrayList<>(); if (rhs instanceof IdentNode && !isParamOrVar((IdentNode)rhs)) { args.add(compilerConstantIdentifier(SCOPE)); args.add(LiteralNode.newInstance(rhs, ((IdentNode)rhs).getName())); //null } else { args.add(rhs); args.add(LiteralNode.newInstance(unaryNode)); //null, do not reuse token of identifier rhs, it can be e.g. 'this' } final Node runtimeNode = new RuntimeNode(unaryNode, Request.TYPEOF, args); end(unaryNode); return runtimeNode; }
Example #7
Source File: JSONWriter.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
@Override public boolean enterExpressionStatement(final ExpressionStatement expressionStatement) { // handle debugger statement final Node expression = expressionStatement.getExpression(); if (expression instanceof RuntimeNode) { expression.accept(this); return false; } enterDefault(expressionStatement); type("ExpressionStatement"); comma(); property("expression"); expression.accept(this); return leave(); }
Example #8
Source File: JSONWriter.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@Override public boolean enterExpressionStatement(final ExpressionStatement expressionStatement) { // handle debugger statement final Node expression = expressionStatement.getExpression(); if (expression instanceof RuntimeNode) { expression.accept(this); return false; } enterDefault(expressionStatement); type("ExpressionStatement"); comma(); property("expression"); expression.accept(this); return leave(); }
Example #9
Source File: CodeGenerator.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private boolean specializationCheck(final RuntimeNode.Request request, final Expression node, final List<Expression> args) { if (!request.canSpecialize()) { return false; } assert args.size() == 2; final Type returnType = node.getType(); load(args.get(0)); load(args.get(1)); Request finalRequest = request; //if the request is a comparison, i.e. one that can be reversed //it keeps its semantic, but make sure that the object comes in //last final Request reverse = Request.reverse(request); if (method.peekType().isObject() && reverse != null) { //rhs is object if (!method.peekType(1).isObject()) { //lhs is not object method.swap(); //prefer object as lhs finalRequest = reverse; } } method.dynamicRuntimeCall( new SpecializedRuntimeNode( finalRequest, new Type[] { method.peekType(1), method.peekType() }, returnType).getInitialName(), returnType, finalRequest); method.convert(node.getType()); method.store(node.getSymbol()); return true; }
Example #10
Source File: CodeGenerator.java From nashorn with GNU General Public License v2.0 | 5 votes |
private boolean specializationCheck(final RuntimeNode.Request request, final Expression node, final List<Expression> args) { if (!request.canSpecialize()) { return false; } assert args.size() == 2; final Type returnType = node.getType(); load(args.get(0)); load(args.get(1)); Request finalRequest = request; //if the request is a comparison, i.e. one that can be reversed //it keeps its semantic, but make sure that the object comes in //last final Request reverse = Request.reverse(request); if (method.peekType().isObject() && reverse != null) { //rhs is object if (!method.peekType(1).isObject()) { //lhs is not object method.swap(); //prefer object as lhs finalRequest = reverse; } } method.dynamicRuntimeCall( new SpecializedRuntimeNode( finalRequest, new Type[] { method.peekType(1), method.peekType() }, returnType).getInitialName(), returnType, finalRequest); method.convert(node.getType()); method.store(node.getSymbol()); return true; }
Example #11
Source File: Parser.java From jdk8u_nashorn with GNU General Public License v2.0 | 5 votes |
private RuntimeNode referenceError(final Expression lhs, final Expression rhs, final boolean earlyError) { if (earlyError) { throw error(JSErrorType.REFERENCE_ERROR, AbstractParser.message("invalid.lvalue"), lhs.getToken()); } final ArrayList<Expression> args = new ArrayList<>(); args.add(lhs); if (rhs == null) { args.add(LiteralNode.newInstance(lhs.getToken(), lhs.getFinish())); } else { args.add(rhs); } args.add(LiteralNode.newInstance(lhs.getToken(), lhs.getFinish(), lhs.toString())); return new RuntimeNode(lhs.getToken(), lhs.getFinish(), RuntimeNode.Request.REFERENCE_ERROR, args); }
Example #12
Source File: Parser.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * DebuggerStatement : * debugger ; * * See 12.15 * * Parse debugger statement. */ private void debuggerStatement() { // Capture DEBUGGER token. final int debuggerLine = line; final long debuggerToken = token; // DEBUGGER tested in caller. next(); endOfLine(); appendStatement(new ExpressionStatement(debuggerLine, debuggerToken, finish, new RuntimeNode(debuggerToken, finish, RuntimeNode.Request.DEBUGGER, new ArrayList<Expression>()))); }
Example #13
Source File: LocalVariableTypesCalculator.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override public Node leaveRuntimeNode(final RuntimeNode runtimeNode) { final Request request = runtimeNode.getRequest(); final boolean isEqStrict = request == Request.EQ_STRICT; if(isEqStrict || request == Request.NE_STRICT) { return createIsUndefined(runtimeNode, runtimeNode.getArgs().get(0), runtimeNode.getArgs().get(1), isEqStrict ? Request.IS_UNDEFINED : Request.IS_NOT_UNDEFINED); } return runtimeNode; }
Example #14
Source File: Attr.java From openjdk-8 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 #15
Source File: MethodEmitter.java From nashorn with GNU General Public License v2.0 | 5 votes |
/** * Generate a dynamic call for a runtime node * * @param name tag for the invoke dynamic for this runtime node * @param returnType return type * @param request RuntimeNode request * * @return the method emitter */ MethodEmitter dynamicRuntimeCall(final String name, final Type returnType, final RuntimeNode.Request request) { debug("dynamic_runtime_call", name, "args=", request.getArity(), "returnType=", returnType); final String signature = getDynamicSignature(returnType, request.getArity()); debug(" signature", signature); method.visitInvokeDynamicInsn(name, signature, RUNTIMEBOOTSTRAP); pushType(returnType); return this; }
Example #16
Source File: Parser.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * DebuggerStatement : * debugger ; * * See 12.15 * * Parse debugger statement. */ private void debuggerStatement() { // Capture DEBUGGER token. final int debuggerLine = line; final long debuggerToken = token; // DEBUGGER tested in caller. next(); endOfLine(); appendStatement(new ExpressionStatement(debuggerLine, debuggerToken, finish, new RuntimeNode(debuggerToken, finish, RuntimeNode.Request.DEBUGGER, new ArrayList<Expression>()))); }
Example #17
Source File: LocalVariableTypesCalculator.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Override public Node leaveRuntimeNode(final RuntimeNode runtimeNode) { final Request request = runtimeNode.getRequest(); final boolean isEqStrict = request == Request.EQ_STRICT; if(isEqStrict || request == Request.NE_STRICT) { return createIsUndefined(runtimeNode, runtimeNode.getArgs().get(0), runtimeNode.getArgs().get(1), isEqStrict ? Request.IS_UNDEFINED : Request.IS_NOT_UNDEFINED); } return runtimeNode; }
Example #18
Source File: Parser.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * DebuggerStatement : * debugger ; * * See 12.15 * * Parse debugger statement. */ private void debuggerStatement() { // Capture DEBUGGER token. final int debuggerLine = line; final long debuggerToken = token; // DEBUGGER tested in caller. next(); endOfLine(); appendStatement(new ExpressionStatement(debuggerLine, debuggerToken, finish, new RuntimeNode(debuggerToken, finish, RuntimeNode.Request.DEBUGGER, new ArrayList<Expression>()))); }
Example #19
Source File: Parser.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * DebuggerStatement : * debugger ; * * See 12.15 * * Parse debugger statement. */ private void debuggerStatement() { // Capture DEBUGGER token. final int debuggerLine = line; final long debuggerToken = token; // DEBUGGER tested in caller. next(); endOfLine(); appendStatement(new ExpressionStatement(debuggerLine, debuggerToken, finish, new RuntimeNode(debuggerToken, finish, RuntimeNode.Request.DEBUGGER, new ArrayList<Expression>()))); }
Example #20
Source File: JSONWriter.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Override public boolean enterRuntimeNode(final RuntimeNode runtimeNode) { final RuntimeNode.Request req = runtimeNode.getRequest(); if (req == RuntimeNode.Request.DEBUGGER) { enterDefault(runtimeNode); type("DebuggerStatement"); return leave(); } return false; }
Example #21
Source File: Attr.java From openjdk-8-source 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 #22
Source File: CodeGenerator.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private boolean specializationCheck(final RuntimeNode.Request request, final Expression node, final List<Expression> args) { if (!request.canSpecialize()) { return false; } assert args.size() == 2; final Type returnType = node.getType(); load(args.get(0)); load(args.get(1)); Request finalRequest = request; //if the request is a comparison, i.e. one that can be reversed //it keeps its semantic, but make sure that the object comes in //last final Request reverse = Request.reverse(request); if (method.peekType().isObject() && reverse != null) { //rhs is object if (!method.peekType(1).isObject()) { //lhs is not object method.swap(); //prefer object as lhs finalRequest = reverse; } } method.dynamicRuntimeCall( new SpecializedRuntimeNode( finalRequest, new Type[] { method.peekType(1), method.peekType() }, returnType).getInitialName(), returnType, finalRequest); method.convert(node.getType()); method.store(node.getSymbol()); return true; }
Example #23
Source File: LocalVariableTypesCalculator.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Override public Node leaveRuntimeNode(final RuntimeNode runtimeNode) { final Request request = runtimeNode.getRequest(); final boolean isEqStrict = request == Request.EQ_STRICT; if(isEqStrict || request == Request.NE_STRICT) { return createIsUndefined(runtimeNode, runtimeNode.getArgs().get(0), runtimeNode.getArgs().get(1), isEqStrict ? Request.IS_UNDEFINED : Request.IS_NOT_UNDEFINED); } return runtimeNode; }
Example #24
Source File: JSONWriter.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
@Override public boolean enterRuntimeNode(final RuntimeNode runtimeNode) { final RuntimeNode.Request req = runtimeNode.getRequest(); if (req == RuntimeNode.Request.DEBUGGER) { enterDefault(runtimeNode); type("DebuggerStatement"); return leave(); } return false; }
Example #25
Source File: Lower.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override public boolean enterDebuggerNode(final DebuggerNode debuggerNode) { final int line = debuggerNode.getLineNumber(); final long token = debuggerNode.getToken(); final int finish = debuggerNode.getFinish(); addStatement(new ExpressionStatement(line, token, finish, new RuntimeNode(token, finish, RuntimeNode.Request.DEBUGGER, new ArrayList<Expression>()))); return false; }
Example #26
Source File: Parser.java From nashorn with GNU General Public License v2.0 | 5 votes |
private RuntimeNode referenceError(final Expression lhs, final Expression rhs, final boolean earlyError) { if (earlyError) { throw error(JSErrorType.REFERENCE_ERROR, AbstractParser.message("invalid.lvalue"), lhs.getToken()); } final ArrayList<Expression> args = new ArrayList<>(); args.add(lhs); if (rhs == null) { args.add(LiteralNode.newInstance(lhs.getToken(), lhs.getFinish())); } else { args.add(rhs); } args.add(LiteralNode.newInstance(lhs.getToken(), lhs.getFinish(), lhs.toString())); return new RuntimeNode(lhs.getToken(), lhs.getFinish(), RuntimeNode.Request.REFERENCE_ERROR, args); }
Example #27
Source File: LocalVariableTypesCalculator.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override public Node leaveRuntimeNode(final RuntimeNode runtimeNode) { final Request request = runtimeNode.getRequest(); final boolean isEqStrict = request == Request.EQ_STRICT; if(isEqStrict || request == Request.NE_STRICT) { return createIsUndefined(runtimeNode, runtimeNode.getArgs().get(0), runtimeNode.getArgs().get(1), isEqStrict ? Request.IS_UNDEFINED : Request.IS_NOT_UNDEFINED); } return runtimeNode; }
Example #28
Source File: Parser.java From hottub with GNU General Public License v2.0 | 5 votes |
private RuntimeNode referenceError(final Expression lhs, final Expression rhs, final boolean earlyError) { if (earlyError) { throw error(JSErrorType.REFERENCE_ERROR, AbstractParser.message("invalid.lvalue"), lhs.getToken()); } final ArrayList<Expression> args = new ArrayList<>(); args.add(lhs); if (rhs == null) { args.add(LiteralNode.newInstance(lhs.getToken(), lhs.getFinish())); } else { args.add(rhs); } args.add(LiteralNode.newInstance(lhs.getToken(), lhs.getFinish(), lhs.toString())); return new RuntimeNode(lhs.getToken(), lhs.getFinish(), RuntimeNode.Request.REFERENCE_ERROR, args); }
Example #29
Source File: Parser.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private RuntimeNode referenceError(final Expression lhs, final Expression rhs, final boolean earlyError) { if (earlyError) { throw error(JSErrorType.REFERENCE_ERROR, AbstractParser.message("invalid.lvalue"), lhs.getToken()); } final ArrayList<Expression> args = new ArrayList<>(); args.add(lhs); if (rhs == null) { args.add(LiteralNode.newInstance(lhs.getToken(), lhs.getFinish())); } else { args.add(rhs); } args.add(LiteralNode.newInstance(lhs.getToken(), lhs.getFinish(), lhs.toString())); return new RuntimeNode(lhs.getToken(), lhs.getFinish(), RuntimeNode.Request.REFERENCE_ERROR, args); }
Example #30
Source File: JSONWriter.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@Override public boolean enterRuntimeNode(final RuntimeNode runtimeNode) { final RuntimeNode.Request req = runtimeNode.getRequest(); if (req == RuntimeNode.Request.DEBUGGER) { enterDefault(runtimeNode); type("DebuggerStatement"); return leave(); } return false; }