jdk.nashorn.internal.ir.ExpressionStatement Java Examples
The following examples show how to use
jdk.nashorn.internal.ir.ExpressionStatement.
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 jdk8u_nashorn 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: Parser.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * Directive value or null if statement is not a directive. * * @param stmt Statement to be checked * @return Directive value if the given statement is a directive */ private String getDirective(final Node stmt) { if (stmt instanceof ExpressionStatement) { final Node expr = ((ExpressionStatement)stmt).getExpression(); if (expr instanceof LiteralNode) { final LiteralNode<?> lit = (LiteralNode<?>)expr; final long litToken = lit.getToken(); final TokenType tt = Token.descType(litToken); // A directive is either a string or an escape string if (tt == TokenType.STRING || tt == TokenType.ESCSTRING) { // Make sure that we don't unescape anything. Return as seen in source! return source.getString(lit.getStart(), Token.descLength(litToken)); } } } return null; }
Example #3
Source File: Parser.java From jdk8u_nashorn with GNU General Public License v2.0 | 6 votes |
/** * Directive value or null if statement is not a directive. * * @param stmt Statement to be checked * @return Directive value if the given statement is a directive */ private String getDirective(final Node stmt) { if (stmt instanceof ExpressionStatement) { final Node expr = ((ExpressionStatement)stmt).getExpression(); if (expr instanceof LiteralNode) { final LiteralNode<?> lit = (LiteralNode<?>)expr; final long litToken = lit.getToken(); final TokenType tt = Token.descType(litToken); // A directive is either a string or an escape string if (tt == TokenType.STRING || tt == TokenType.ESCSTRING) { // Make sure that we don't unescape anything. Return as seen in source! return source.getString(lit.getStart(), Token.descLength(litToken)); } } } return null; }
Example #4
Source File: Lower.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
@Override public Node leaveExpressionStatement(final ExpressionStatement expressionStatement) { final Expression expr = expressionStatement.getExpression(); ExpressionStatement node = expressionStatement; final FunctionNode currentFunction = lc.getCurrentFunction(); if (currentFunction.isProgram()) { if (!isInternalExpression(expr) && !isEvalResultAssignment(expr)) { node = expressionStatement.setExpression( new BinaryNode( Token.recast( expressionStatement.getToken(), TokenType.ASSIGN), compilerConstant(RETURN), expr)); } } return addStatement(node); }
Example #5
Source File: SplitIntoFunctions.java From TencentKona-8 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 #6
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 #7
Source File: Lower.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
@Override public Node leaveExpressionStatement(final ExpressionStatement expressionStatement) { final Expression expr = expressionStatement.getExpression(); ExpressionStatement node = expressionStatement; final FunctionNode currentFunction = lc.getCurrentFunction(); if (currentFunction.isProgram()) { if (!isInternalExpression(expr) && !isEvalResultAssignment(expr)) { node = expressionStatement.setExpression( new BinaryNode( Token.recast( expressionStatement.getToken(), TokenType.ASSIGN), compilerConstant(RETURN), expr)); } } return addStatement(node); }
Example #8
Source File: Parser.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Directive value or null if statement is not a directive. * * @param stmt Statement to be checked * @return Directive value if the given statement is a directive */ private String getDirective(final Node stmt) { if (stmt instanceof ExpressionStatement) { final Node expr = ((ExpressionStatement)stmt).getExpression(); if (expr instanceof LiteralNode) { final LiteralNode<?> lit = (LiteralNode<?>)expr; final long litToken = lit.getToken(); final TokenType tt = Token.descType(litToken); // A directive is either a string or an escape string if (tt == TokenType.STRING || tt == TokenType.ESCSTRING) { // Make sure that we don't unescape anything. Return as seen in source! return source.getString(lit.getStart(), Token.descLength(litToken)); } } } return null; }
Example #9
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 #10
Source File: JSONWriter.java From jdk8u_nashorn 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 #11
Source File: JSONWriter.java From openjdk-jdk8u-backup 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 #12
Source File: Parser.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * Directive value or null if statement is not a directive. * * @param stmt Statement to be checked * @return Directive value if the given statement is a directive */ private String getDirective(final Node stmt) { if (stmt instanceof ExpressionStatement) { final Node expr = ((ExpressionStatement)stmt).getExpression(); if (expr instanceof LiteralNode) { final LiteralNode<?> lit = (LiteralNode<?>)expr; final long litToken = lit.getToken(); final TokenType tt = Token.descType(litToken); // A directive is either a string or an escape string if (tt == TokenType.STRING || tt == TokenType.ESCSTRING) { // Make sure that we don't unescape anything. Return as seen in source! return source.getString(lit.getStart(), Token.descLength(litToken)); } } } return null; }
Example #13
Source File: SplitIntoFunctions.java From openjdk-jdk8u-backup 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 #14
Source File: JSONWriter.java From openjdk-8-source 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 #15
Source File: Lower.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
@Override public Node leaveExpressionStatement(final ExpressionStatement expressionStatement) { final Expression expr = expressionStatement.getExpression(); ExpressionStatement node = expressionStatement; final FunctionNode currentFunction = lc.getCurrentFunction(); if (currentFunction.isProgram()) { if (!isInternalExpression(expr) && !isEvalResultAssignment(expr)) { node = expressionStatement.setExpression( new BinaryNode( Token.recast( expressionStatement.getToken(), TokenType.ASSIGN), compilerConstant(RETURN), expr)); } } return addStatement(node); }
Example #16
Source File: SplitIntoFunctions.java From hottub 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 #17
Source File: Lower.java From hottub with GNU General Public License v2.0 | 6 votes |
@Override public Node leaveExpressionStatement(final ExpressionStatement expressionStatement) { final Expression expr = expressionStatement.getExpression(); ExpressionStatement node = expressionStatement; final FunctionNode currentFunction = lc.getCurrentFunction(); if (currentFunction.isProgram()) { if (!isInternalExpression(expr) && !isEvalResultAssignment(expr)) { node = expressionStatement.setExpression( new BinaryNode( Token.recast( expressionStatement.getToken(), TokenType.ASSIGN), compilerConstant(RETURN), expr)); } } return addStatement(node); }
Example #18
Source File: JSONWriter.java From hottub 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 #19
Source File: Parser.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Directive value or null if statement is not a directive. * * @param stmt Statement to be checked * @return Directive value if the given statement is a directive */ private String getDirective(final Node stmt) { if (stmt instanceof ExpressionStatement) { final Node expr = ((ExpressionStatement)stmt).getExpression(); if (expr instanceof LiteralNode) { final LiteralNode<?> lit = (LiteralNode<?>)expr; final long litToken = lit.getToken(); final TokenType tt = Token.descType(litToken); // A directive is either a string or an escape string if (tt == TokenType.STRING || tt == TokenType.ESCSTRING) { // Make sure that we don't unescape anything. Return as seen in source! return source.getString(lit.getStart(), Token.descLength(litToken)); } } } return null; }
Example #20
Source File: SplitIntoFunctions.java From openjdk-jdk9 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 #21
Source File: Parser.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Directive value or null if statement is not a directive. * * @param stmt Statement to be checked * @return Directive value if the given statement is a directive */ private String getDirective(final Node stmt) { if (stmt instanceof ExpressionStatement) { final Node expr = ((ExpressionStatement)stmt).getExpression(); if (expr instanceof LiteralNode) { final LiteralNode<?> lit = (LiteralNode<?>)expr; final long litToken = lit.getToken(); final TokenType tt = Token.descType(litToken); // A directive is either a string or an escape string if (tt == TokenType.STRING || tt == TokenType.ESCSTRING) { // Make sure that we don't unescape anything. Return as seen in source! return source.getString(lit.getStart(), Token.descLength(litToken)); } } } return null; }
Example #22
Source File: Parser.java From nashorn with GNU General Public License v2.0 | 6 votes |
/** * Directive value or null if statement is not a directive. * * @param stmt Statement to be checked * @return Directive value if the given statement is a directive */ private String getDirective(final Node stmt) { if (stmt instanceof ExpressionStatement) { final Node expr = ((ExpressionStatement)stmt).getExpression(); if (expr instanceof LiteralNode) { final LiteralNode<?> lit = (LiteralNode<?>)expr; final long litToken = lit.getToken(); final TokenType tt = Token.descType(litToken); // A directive is either a string or an escape string if (tt == TokenType.STRING || tt == TokenType.ESCSTRING) { // Make sure that we don't unescape anything. Return as seen in source! return source.getString(lit.getStart(), Token.descLength(litToken)); } } } return null; }
Example #23
Source File: JSONWriter.java From openjdk-jdk9 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) { assert false : "should not reach here: RuntimeNode"; return false; } enterDefault(expressionStatement); type("ExpressionStatement"); comma(); property("expression"); expression.accept(this); return leave(); }
Example #24
Source File: Lower.java From jdk8u_nashorn with GNU General Public License v2.0 | 6 votes |
@Override public Node leaveExpressionStatement(final ExpressionStatement expressionStatement) { final Expression expr = expressionStatement.getExpression(); ExpressionStatement node = expressionStatement; final FunctionNode currentFunction = lc.getCurrentFunction(); if (currentFunction.isProgram()) { if (!isInternalExpression(expr) && !isEvalResultAssignment(expr)) { node = expressionStatement.setExpression( new BinaryNode( Token.recast( expressionStatement.getToken(), TokenType.ASSIGN), compilerConstant(RETURN), expr)); } } return addStatement(node); }
Example #25
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 #26
Source File: LocalVariableTypesCalculator.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override public boolean enterExpressionStatement(final ExpressionStatement expressionStatement) { if (reachable) { visitExpressionOnEmptyStack(expressionStatement.getExpression()); } return false; }
Example #27
Source File: Lower.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override public Node leaveVarNode(final VarNode varNode) { addStatement(varNode); if (varNode.getFlag(VarNode.IS_LAST_FUNCTION_DECLARATION) && lc.getCurrentFunction().isProgram()) { new ExpressionStatement(varNode.getLineNumber(), varNode.getToken(), varNode.getFinish(), new IdentNode(varNode.getName())).accept(this); } return varNode; }
Example #28
Source File: OptimisticTypesCalculator.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override public boolean enterExpressionStatement(final ExpressionStatement expressionStatement) { final Expression expr = expressionStatement.getExpression(); if(!expr.isSelfModifying()) { tagNeverOptimistic(expr); } return true; }
Example #29
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 #30
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>()))); }