本文整理汇总了Java中jdk.nashorn.internal.ir.Block.setStatements方法的典型用法代码示例。如果您正苦于以下问题:Java Block.setStatements方法的具体用法?Java Block.setStatements怎么用?Java Block.setStatements使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jdk.nashorn.internal.ir.Block
的用法示例。
在下文中一共展示了Block.setStatements方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: splitBlock
import jdk.nashorn.internal.ir.Block; //导入方法依赖的package包/类
/**
* Split a block into sub methods.
*
* @param block Block or function to split.
*
* @return new weight for the resulting block.
*/
private Block splitBlock(final Block block, final FunctionNode function) {
final List<Statement> splits = new ArrayList<>();
List<Statement> statements = new ArrayList<>();
long statementsWeight = 0;
for (final Statement statement : block.getStatements()) {
final long weight = WeighNodes.weigh(statement, weightCache);
if (statementsWeight + weight >= SPLIT_THRESHOLD || statement.isTerminal()) {
if (!statements.isEmpty()) {
splits.add(createBlockSplitNode(block, function, statements, statementsWeight));
statements = new ArrayList<>();
statementsWeight = 0;
}
}
if (statement.isTerminal()) {
splits.add(statement);
} else {
statements.add(statement);
statementsWeight += weight;
}
}
if (!statements.isEmpty()) {
splits.add(createBlockSplitNode(block, function, statements, statementsWeight));
}
return block.setStatements(lc, splits);
}
示例2: createFinallyBlock
import jdk.nashorn.internal.ir.Block; //导入方法依赖的package包/类
private static Block createFinallyBlock(final Block finallyBody) {
final List<Statement> newStatements = new ArrayList<>();
for (final Statement statement : finallyBody.getStatements()) {
newStatements.add(statement);
if (statement.hasTerminalFlags()) {
break;
}
}
return finallyBody.setStatements(null, newStatements);
}