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


Java Block类代码示例

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


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

示例1: ifStatement

import jdk.nashorn.internal.ir.Block; //导入依赖的package包/类
/**
 * IfStatement :
 *      if ( Expression ) Statement else Statement
 *      if ( Expression ) Statement
 *
 * See 12.5
 *
 * Parse an IF statement.
 */
private void ifStatement() {
    // Capture IF token.
    final int  ifLine  = line;
    final long ifToken = token;
     // IF tested in caller.
    next();

    expect(LPAREN);
    final Expression test = expression();
    expect(RPAREN);
    final Block pass = getStatement();

    Block fail = null;
    if (type == ELSE) {
        next();
        fail = getStatement();
    }

    appendStatement(new IfNode(ifLine, ifToken, fail != null ? fail.getFinish() : pass.getFinish(), test, pass, fail));
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:30,代码来源:Parser.java

示例2: enterTryNode

import jdk.nashorn.internal.ir.Block; //导入依赖的package包/类
@Override
public boolean enterTryNode(final TryNode tryNode) {
    tryNode.toString(sb, printTypes);
    printLocalVariableConversion(tryNode);
    tryNode.getBody().accept(this);

    final List<Block> catchBlocks = tryNode.getCatchBlocks();

    for (final Block catchBlock : catchBlocks) {
        final CatchNode catchNode = (CatchNode)catchBlock.getStatements().get(0);
        catchNode.toString(sb, printTypes);
        catchNode.getBody().accept(this);
    }

    final Block finallyBody = tryNode.getFinallyBody();

    if (finallyBody != null) {
        sb.append(" finally ");
        finallyBody.accept(this);
    }

    return false;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:PrintVisitor.java

示例3: enterBlock

import jdk.nashorn.internal.ir.Block; //导入依赖的package包/类
@Override
public boolean enterBlock(final Block block) {
    start(block);

    if (lc.isFunctionBody()) {
        block.clearSymbols();
        final FunctionNode fn = lc.getCurrentFunction();
        if (isUnparsedFunction(fn)) {
            // It's a skipped nested function. Just mark the symbols being used by it as being in use.
            for(final String name: compiler.getScriptFunctionData(fn.getId()).getExternalSymbolNames()) {
                nameIsUsed(name, null);
            }
            // Don't bother descending into it, it must be empty anyway.
            assert block.getStatements().isEmpty();
            return false;
        }

        enterFunctionBody();
    }

    return true;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:AssignSymbols.java

示例4: enterBlock

import jdk.nashorn.internal.ir.Block; //导入依赖的package包/类
@Override
public boolean enterBlock(final Block block) {
    boolean cloned = false;
    for(final Symbol symbol: block.getSymbols()) {
        if(symbol.isBytecodeLocal()) {
            if (getLocalVariableTypeOrNull(symbol) == null) {
                if (!cloned) {
                    cloneOrNewLocalVariableTypes();
                    cloned = true;
                }
                localVariableTypes.put(symbol, LvarType.UNDEFINED);
            }
            // In case we're repeating analysis of a lexical scope (e.g. it's in a loop),
            // make sure all symbols lexically scoped by the block become valid again.
            invalidatedSymbols.remove(symbol);
        }
    }
    return true;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:LocalVariableTypesCalculator.java

示例5: initParameters

import jdk.nashorn.internal.ir.Block; //导入依赖的package包/类
/**
 * Initialize parameters for function node.
 * @param functionNode the function node
 */
private void initParameters(final FunctionNode functionNode, final Block body) {
    final boolean isVarArg = functionNode.isVarArg();
    final boolean scopeParams = functionNode.allVarsInScope() || isVarArg;
    for (final IdentNode param : functionNode.getParameters()) {
        final Symbol symbol = defineSymbol(body, param.getName(), param, IS_PARAM);
        if(scopeParams) {
            // NOTE: this "set is scope" is a poor substitute for clear expression of where the symbol is stored.
            // It will force creation of scopes where they would otherwise not necessarily be needed (functions
            // using arguments object and other variable arity functions). Tracked by JDK-8038942.
            symbol.setIsScope();
            assert symbol.hasSlot();
            if(isVarArg) {
                symbol.setNeedsSlot(false);
            }
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:AssignSymbols.java

示例6: initFunctionWideVariables

import jdk.nashorn.internal.ir.Block; //导入依赖的package包/类
private void initFunctionWideVariables(final FunctionNode functionNode, final Block body) {
    initCompileConstant(CALLEE, body, IS_PARAM | IS_INTERNAL | HAS_OBJECT_VALUE);
    initCompileConstant(THIS, body, IS_PARAM | IS_THIS | HAS_OBJECT_VALUE);

    if (functionNode.isVarArg()) {
        initCompileConstant(VARARGS, body, IS_PARAM | IS_INTERNAL | HAS_OBJECT_VALUE);
        if (functionNode.needsArguments()) {
            initCompileConstant(ARGUMENTS, body, IS_VAR | IS_INTERNAL | HAS_OBJECT_VALUE);
            defineSymbol(body, ARGUMENTS_VAR.symbolName(), null, IS_VAR | HAS_OBJECT_VALUE);
        }
    }

    initParameters(functionNode, body);
    initCompileConstant(SCOPE, body, IS_VAR | IS_INTERNAL | HAS_OBJECT_VALUE);
    initCompileConstant(RETURN, body, IS_VAR | IS_INTERNAL);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:AssignSymbols.java

示例7: getScopeProtoDepth

import jdk.nashorn.internal.ir.Block; //导入依赖的package包/类
private int getScopeProtoDepth(final Block startingBlock, final Symbol symbol) {
    //walk up the chain from starting block and when we bump into the current function boundary, add the external
    //information.
    final FunctionNode fn   = lc.getCurrentFunction();
    final int externalDepth = compiler.getScriptFunctionData(fn.getId()).getExternalSymbolDepth(symbol.getName());

    //count the number of scopes from this place to the start of the function

    final int internalDepth = FindScopeDepths.findInternalDepth(lc, fn, startingBlock, symbol);
    final int scopesToStart = FindScopeDepths.findScopesToStart(lc, fn, startingBlock);
    int depth = 0;
    if (internalDepth == -1) {
        depth = scopesToStart + externalDepth;
    } else {
        assert internalDepth <= scopesToStart;
        depth = internalDepth;
    }

    return depth;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:CodeGenerator.java

示例8: catchAllBlock

import jdk.nashorn.internal.ir.Block; //导入依赖的package包/类
private Block catchAllBlock(final TryNode tryNode) {
    final int  lineNumber = tryNode.getLineNumber();
    final long token      = tryNode.getToken();
    final int  finish     = tryNode.getFinish();

    final IdentNode exception = new IdentNode(token, finish, lc.getCurrentFunction().uniqueName(CompilerConstants.EXCEPTION_PREFIX.symbolName()));

    final Block catchBody = new Block(token, finish, new ThrowNode(lineNumber, token, finish, new IdentNode(exception), true));
    assert catchBody.isTerminal(); //ends with throw, so terminal

    final CatchNode catchAllNode  = new CatchNode(lineNumber, token, finish, new IdentNode(exception), null, catchBody, true);
    final Block     catchAllBlock = new Block(token, finish, catchAllNode);

    //catchallblock -> catchallnode (catchnode) -> exception -> throw

    return (Block)catchAllBlock.accept(this); //not accepted. has to be accepted by lower
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:Lower.java

示例9: findScopesToStart

import jdk.nashorn.internal.ir.Block; //导入依赖的package包/类
static int findScopesToStart(final LexicalContext lc, final FunctionNode fn, final Block block) {
    final Block bodyBlock = findBodyBlock(lc, fn, block);
    final Iterator<Block> iter = lc.getBlocks(block);
    Block b = iter.next();
    int scopesToStart = 0;
    while (true) {
        if (b.needsScope()) {
            scopesToStart++;
        }
        if (b == bodyBlock) {
            break;
        }
        b = iter.next();
    }
    return scopesToStart;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:FindScopeDepths.java

示例10: findInternalDepth

import jdk.nashorn.internal.ir.Block; //导入依赖的package包/类
static int findInternalDepth(final LexicalContext lc, final FunctionNode fn, final Block block, final Symbol symbol) {
    final Block bodyBlock = findBodyBlock(lc, fn, block);
    final Iterator<Block> iter = lc.getBlocks(block);
    Block b = iter.next();
    int scopesToStart = 0;
    while (true) {
        if (definedInBlock(b, symbol)) {
            return scopesToStart;
        }
        if (b.needsScope()) {
            scopesToStart++;
        }
        if (b == bodyBlock) {
            break; //don't go past body block, but process it
        }
        b = iter.next();
    }
    return -1;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:FindScopeDepths.java

示例11: leaveBlock

import jdk.nashorn.internal.ir.Block; //导入依赖的package包/类
@Override
public Node leaveBlock(final Block block) {
    assert !block.isCatchBlock();

    Block newBlock = block;

    // Block was heavier than SLIT_THRESHOLD in enter, but a sub-block may have
    // been split already, so weigh again before splitting.
    long weight = WeighNodes.weigh(block, weightCache);
    if (weight >= SPLIT_THRESHOLD) {
        final FunctionNode currentFunction = lc.getCurrentFunction();
        newBlock = splitBlock(block, currentFunction);
        weight   = WeighNodes.weigh(newBlock, weightCache);
        lc.setFlag(currentFunction, FunctionNode.IS_SPLIT);
    }
    weightCache.put(newBlock, weight);
    return newBlock;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:Splitter.java

示例12: enterBlock

import jdk.nashorn.internal.ir.Block; //导入依赖的package包/类
@Override
public boolean enterBlock(final Block block) {
    final Label entryLabel = block.getEntryLabel();
    if (entryLabel.isBreakTarget()) {
        // Entry label is a break target only for an inlined finally block.
        assert !method.isReachable();
        method.breakLabel(entryLabel, lc.getUsedSlotCount());
    } else {
        method.label(entryLabel);
    }
    if(!method.isReachable()) {
        return false;
    }
    if(lc.isFunctionBody() && emittedMethods.contains(lc.getCurrentFunction().getName())) {
        return false;
    }
    initLocals(block);

    assert lc.getUsedSlotCount() == method.getFirstTemp();
    return true;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:CodeGenerator.java

示例13: leaveBlock

import jdk.nashorn.internal.ir.Block; //导入依赖的package包/类
@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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:SplitIntoFunctions.java

示例14: enterCatchNode

import jdk.nashorn.internal.ir.Block; //导入依赖的package包/类
@Override
public boolean enterCatchNode(final CatchNode catchNode) {
    final IdentNode exception = catchNode.getExceptionIdentifier();
    final Block     block     = lc.getCurrentBlock();

    start(catchNode);

    // define block-local exception variable
    final String exname = exception.getName();
    // If the name of the exception starts with ":e", this is a synthetic catch block, likely a catch-all. Its
    // symbol is naturally internal, and should be treated as such.
    final boolean isInternal = exname.startsWith(EXCEPTION_PREFIX.symbolName());
    // IS_LET flag is required to make sure symbol is not visible outside catch block. However, we need to
    // clear the IS_LET flag after creation to allow redefinition of symbol inside the catch block.
    final Symbol symbol = defineSymbol(block, exname, catchNode, IS_VAR | IS_LET | (isInternal ? IS_INTERNAL : 0) | HAS_OBJECT_VALUE);
    symbol.clearFlag(IS_LET);

    return true;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:AssignSymbols.java

示例15: getBreakTargetTypes

import jdk.nashorn.internal.ir.Block; //导入依赖的package包/类
private Map<Symbol, LvarType> getBreakTargetTypes(final BreakableNode target) {
    // Remove symbols defined in the the blocks that are being broken out of.
    Map<Symbol, LvarType> types = localVariableTypes;
    for(final Iterator<LexicalContextNode> it = lc.getAllNodes(); it.hasNext();) {
        final LexicalContextNode node = it.next();
        if(node instanceof Block) {
            for(final Symbol symbol: ((Block)node).getSymbols()) {
                if(localVariableTypes.containsKey(symbol)) {
                    if(types == localVariableTypes) {
                        types = cloneMap(localVariableTypes);
                    }
                    types.remove(symbol);
                }
            }
        }
        if(node == target) {
            break;
        }
    }
    return types;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:LocalVariableTypesCalculator.java


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