Java 类jdk.nashorn.internal.ir.ExpressionStatement 实例源码

项目:OpenJSharp    文件:Parser.java   
/**
 * 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;
}
项目:OpenJSharp    文件:JSONWriter.java   
@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();
}
项目:OpenJSharp    文件:Lower.java   
@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);
}
项目:OpenJSharp    文件:SplitIntoFunctions.java   
@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;
}
项目:openjdk-jdk10    文件:Parser.java   
/**
 * 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;
}
项目:openjdk-jdk10    文件:JSONWriter.java   
@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();
}
项目:openjdk-jdk10    文件:Lower.java   
@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));
        }
    }

    if (es6 && expressionStatement.destructuringDeclarationType() != null) {
        throwNotImplementedYet("es6.destructuring", expressionStatement);
    }

    return addStatement(node);
}
项目:openjdk-jdk10    文件:SplitIntoFunctions.java   
@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;
}
项目:openjdk9    文件:Parser.java   
/**
 * 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;
}
项目:openjdk9    文件:JSONWriter.java   
@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();
}
项目:openjdk9    文件:Lower.java   
@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);
}
项目:openjdk9    文件:SplitIntoFunctions.java   
@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;
}
项目:kaziranga    文件:Parser.java   
/**
 * 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;
}
项目:kaziranga    文件:JSONWriter.java   
@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();
}
项目:kaziranga    文件:Lower.java   
@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);
}
项目:kaziranga    文件:SplitIntoFunctions.java   
@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;
}
项目:lookaside_java-1.8.0-openjdk    文件:Parser.java   
/**
 * 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;
}
项目:lookaside_java-1.8.0-openjdk    文件:JSONWriter.java   
@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();
}
项目:lookaside_java-1.8.0-openjdk    文件:Lower.java   
@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);
}
项目:lookaside_java-1.8.0-openjdk    文件:SplitIntoFunctions.java   
@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;
}
项目:jdk8u_nashorn    文件:Parser.java   
/**
 * 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;
}
项目:jdk8u_nashorn    文件:JSONWriter.java   
@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();
}
项目:jdk8u_nashorn    文件:Lower.java   
@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);
}
项目:jdk8u_nashorn    文件:SplitIntoFunctions.java   
@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;
}
项目:infobip-open-jdk-8    文件:Parser.java   
/**
 * 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;
}
项目:infobip-open-jdk-8    文件:JSONWriter.java   
@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();
}
项目:infobip-open-jdk-8    文件:Lower.java   
@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);
}
项目:infobip-open-jdk-8    文件:SplitIntoFunctions.java   
@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;
}
项目:OLD-OpenJDK8    文件:Parser.java   
/**
 * 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;
}
项目:OLD-OpenJDK8    文件:JSONWriter.java   
@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();
}
项目:OLD-OpenJDK8    文件:Lower.java   
@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);
}
项目:nashorn-backport    文件:Parser.java   
/**
 * 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;
}
项目:nashorn-backport    文件:JSONWriter.java   
@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();
}
项目:nashorn-backport    文件:Lower.java   
@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);
}
项目:nashorn    文件:Parser.java   
/**
 * 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;
}
项目:nashorn    文件:JSONWriter.java   
@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();
}
项目:nashorn    文件:Lower.java   
@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);
}
项目:OpenJSharp    文件:Parser.java   
/**
 * 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>())));
}
项目:OpenJSharp    文件:Lower.java   
@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;
}
项目:OpenJSharp    文件:OptimisticTypesCalculator.java   
@Override
public boolean enterExpressionStatement(final ExpressionStatement expressionStatement) {
    final Expression expr = expressionStatement.getExpression();
    if(!expr.isSelfModifying()) {
        tagNeverOptimistic(expr);
    }
    return true;
}