当前位置: 首页>>代码示例>>Java>>正文


Java Block.IS_SYNTHETIC属性代码示例

本文整理汇总了Java中jdk.nashorn.internal.ir.Block.IS_SYNTHETIC属性的典型用法代码示例。如果您正苦于以下问题:Java Block.IS_SYNTHETIC属性的具体用法?Java Block.IS_SYNTHETIC怎么用?Java Block.IS_SYNTHETIC使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在jdk.nashorn.internal.ir.Block的用法示例。


在下文中一共展示了Block.IS_SYNTHETIC属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getBlock

/**
 * Get the statements in a block.
 * @return Block statements.
 */
private Block getBlock(final boolean needsBraces) {
    final long blockToken = token;
    final ParserContextBlockNode newBlock = newBlock();
    try {
        // Block opening brace.
        if (needsBraces) {
            expect(LBRACE);
        }
        // Accumulate block statements.
        statementList();

    } finally {
        restoreBlock(newBlock);
    }

    // Block closing brace.
    if (needsBraces) {
        expect(RBRACE);
    }

    final int flags = newBlock.getFlags() | (needsBraces ? 0 : Block.IS_SYNTHETIC);
    return new Block(blockToken, finish, flags, newBlock.getStatements());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:Parser.java

示例2: getStatement

private Block getStatement(final boolean labelledStatement) {
    if (type == LBRACE) {
        return getBlock(true);
    }
    // Set up new block. Captures first token.
    final ParserContextBlockNode newBlock = newBlock();
    try {
        statement(false, 0, true, labelledStatement);
    } finally {
        restoreBlock(newBlock);
    }
    return new Block(newBlock.getToken(), finish, newBlock.getFlags() | Block.IS_SYNTHETIC, newBlock.getStatements());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:Parser.java

示例3: program

/**
 * Program :
 *      SourceElements?
 *
 * See 14
 *
 * Parse the top level script.
 */
private FunctionNode program(final String scriptName, final int reparseFlags) {
    // Make a pseudo-token for the script holding its start and length.
    final long functionToken = Token.toDesc(FUNCTION, Token.descPosition(Token.withDelimiter(token)), source.getLength());
    final int  functionLine  = line;

    final IdentNode ident = new IdentNode(functionToken, Token.descPosition(functionToken), scriptName);
    final ParserContextFunctionNode script = createParserContextFunctionNode(
            ident,
            functionToken,
            FunctionNode.Kind.SCRIPT,
            functionLine,
            Collections.<IdentNode>emptyList());
    lc.push(script);
    final ParserContextBlockNode body = newBlock();

    functionDeclarations = new ArrayList<>();
    sourceElements(reparseFlags);
    addFunctionDeclarations(script);
    functionDeclarations = null;

    restoreBlock(body);
    body.setFlag(Block.NEEDS_SCOPE);
    final Block programBody = new Block(functionToken, finish, body.getFlags() | Block.IS_SYNTHETIC | Block.IS_BODY, body.getStatements());
    lc.pop(script);
    script.setLastToken(token);

    expect(EOF);

    return createFunctionNode(script, functionToken, ident, Collections.<IdentNode>emptyList(), FunctionNode.Kind.SCRIPT, functionLine, programBody);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:38,代码来源:Parser.java

示例4: parseFunctionBody

/**
 * Execute parse and return the resulting function node.
 * Errors will be thrown and the error manager will contain information
 * if parsing should fail. This method is used to check if code String
 * passed to "Function" constructor is a valid function body or not.
 *
 * @return function node resulting from successful parse
 */
public FunctionNode parseFunctionBody() {
    try {
        stream = new TokenStream();
        lexer  = new Lexer(source, stream, scripting && !env._no_syntax_extensions, env._es6);
        final int functionLine = line;

        scanFirstToken();

        // Make a fake token for the function.
        final long functionToken = Token.toDesc(FUNCTION, 0, source.getLength());
        // Set up the function to append elements.

        final IdentNode ident = new IdentNode(functionToken, Token.descPosition(functionToken), PROGRAM.symbolName());
        final ParserContextFunctionNode function = createParserContextFunctionNode(ident, functionToken, FunctionNode.Kind.NORMAL, functionLine, Collections.<IdentNode>emptyList());
        lc.push(function);

        final ParserContextBlockNode body = newBlock();

        functionDeclarations = new ArrayList<>();
        sourceElements(0);
        addFunctionDeclarations(function);
        functionDeclarations = null;

        restoreBlock(body);
        body.setFlag(Block.NEEDS_SCOPE);

        final Block functionBody = new Block(functionToken, source.getLength() - 1,
            body.getFlags() | Block.IS_SYNTHETIC, body.getStatements());
        lc.pop(function);

        expect(EOF);

        final FunctionNode functionNode = createFunctionNode(
                function,
                functionToken,
                ident,
                Collections.<IdentNode>emptyList(),
                FunctionNode.Kind.NORMAL,
                functionLine,
                functionBody);
        printAST(functionNode);
        return functionNode;
    } catch (final Exception e) {
        handleParseException(e);
        return null;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:55,代码来源:Parser.java


注:本文中的jdk.nashorn.internal.ir.Block.IS_SYNTHETIC属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。