本文整理汇总了Java中jdk.nashorn.internal.ir.TryNode类的典型用法代码示例。如果您正苦于以下问题:Java TryNode类的具体用法?Java TryNode怎么用?Java TryNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TryNode类属于jdk.nashorn.internal.ir包,在下文中一共展示了TryNode类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: enterTryNode
import jdk.nashorn.internal.ir.TryNode; //导入依赖的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;
}
示例2: catchAllBlock
import jdk.nashorn.internal.ir.TryNode; //导入依赖的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
}
示例3: enterTryNode
import jdk.nashorn.internal.ir.TryNode; //导入依赖的package包/类
@Override
public boolean enterTryNode(final TryNode tryNode) {
final List<? extends CatchNode> catchNodes = tryNode.getCatches();
final List<CatchTreeImpl> catchTrees = new ArrayList<>(catchNodes.size());
for (final CatchNode catchNode : catchNodes) {
catchTrees.add(new CatchTreeImpl(catchNode,
translateExpr(catchNode.getException()),
(BlockTree) translateBlock(catchNode.getBody()),
translateExpr(catchNode.getExceptionCondition())));
}
curStat = new TryTreeImpl(tryNode,
(BlockTree) translateBlock(tryNode.getBody()),
catchTrees,
(BlockTree) translateBlock(tryNode.getFinallyBody()));
return false;
}
示例4: enterTryNode
import jdk.nashorn.internal.ir.TryNode; //导入依赖的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);
}
for (final Block inlinedFinally : tryNode.getInlinedFinallies()) {
inlinedFinally.accept(this);
}
return false;
}
示例5: enterTryNode
import jdk.nashorn.internal.ir.TryNode; //导入依赖的package包/类
@Override
public boolean enterTryNode(final TryNode tryNode) {
final List<? extends CatchNode> catchNodes = tryNode.getCatches();
final List<CatchTreeImpl> catchTrees = new ArrayList<>(catchNodes.size());
for (final CatchNode catchNode : catchNodes) {
catchTrees.add(new CatchTreeImpl(catchNode,
translateIdent(catchNode.getException()),
(BlockTree) translateBlock(catchNode.getBody()),
translateExpr(catchNode.getExceptionCondition())));
}
curStat = new TryTreeImpl(tryNode,
(BlockTree) translateBlock(tryNode.getBody()),
catchTrees,
(BlockTree) translateBlock(tryNode.getFinallyBody()));
return false;
}
示例6: enterTryNode
import jdk.nashorn.internal.ir.TryNode; //导入依赖的package包/类
@Override
public boolean enterTryNode(final TryNode tryNode) {
tryNode.toString(sb);
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);
catchNode.getBody().accept(this);
}
final Block finallyBody = tryNode.getFinallyBody();
if (finallyBody != null) {
sb.append(" finally ");
finallyBody.accept(this);
}
return false;
}
示例7: catchAllBlock
import jdk.nashorn.internal.ir.TryNode; //导入依赖的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("catch_all"));
final Block catchBody = new Block(token, finish, new ThrowNode(lineNumber, token, finish, new IdentNode(exception), ThrowNode.IS_SYNTHETIC_RETHROW));
assert catchBody.isTerminal(); //ends with throw, so terminal
final CatchNode catchAllNode = new CatchNode(lineNumber, token, finish, new IdentNode(exception), null, catchBody, CatchNode.IS_SYNTHETIC_RETHROW);
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
}
示例8: beforeTry
import jdk.nashorn.internal.ir.TryNode; //导入依赖的package包/类
void beforeTry(final TryNode tryNode, final Label recovery) {
LocalVariableConversion next = tryNode.getLocalVariableConversion();
while(next != null) {
if(next.isLive()) {
final Type to = emitLocalVariableConversion(next, false);
recovery.getStack().onLocalStore(to, next.getSymbol().getSlot(to), true);
}
next = next.getNext();
}
}
示例9: leaveTryNode
import jdk.nashorn.internal.ir.TryNode; //导入依赖的package包/类
@Override
public Node leaveTryNode(final TryNode tryNode) {
tryNode.setException(exceptionSymbol());
if (tryNode.getFinallyBody() != null) {
tryNode.setFinallyCatchAll(exceptionSymbol());
}
end(tryNode);
return tryNode;
}
示例10: ensureUnconditionalCatch
import jdk.nashorn.internal.ir.TryNode; //导入依赖的package包/类
private TryNode ensureUnconditionalCatch(final TryNode tryNode) {
final List<CatchNode> catches = tryNode.getCatches();
if(catches == null || catches.isEmpty() || catches.get(catches.size() - 1).getExceptionCondition() == null) {
return tryNode;
}
// If the last catch block is conditional, add an unconditional rethrow block
final List<Block> newCatchBlocks = new ArrayList<>(tryNode.getCatchBlocks());
newCatchBlocks.add(catchAllBlock(tryNode));
return tryNode.setCatchBlocks(newCatchBlocks);
}
示例11: TryTreeImpl
import jdk.nashorn.internal.ir.TryNode; //导入依赖的package包/类
TryTreeImpl(final TryNode node,
final BlockTree block,
final List<? extends CatchTree> catches,
final BlockTree finallyBlock) {
super(node);
this.block = block;
this.catches = catches;
this.finallyBlock = finallyBlock;
}
示例12: leaveTryNode
import jdk.nashorn.internal.ir.TryNode; //导入依赖的package包/类
@Override
public Node leaveTryNode(final TryNode tryNode) {
assert tryNode.getFinallyBody() == null;
end(tryNode);
return tryNode.setException(lc, exceptionSymbol());
}
示例13: ensureUnconditionalCatch
import jdk.nashorn.internal.ir.TryNode; //导入依赖的package包/类
private TryNode ensureUnconditionalCatch(final TryNode tryNode) {
final List<CatchNode> catches = tryNode.getCatches();
if(catches == null || catches.isEmpty() || catches.get(catches.size() - 1).getExceptionCondition() == null) {
return tryNode;
}
// If the last catch block is conditional, add an unconditional rethrow block
final List<Block> newCatchBlocks = new ArrayList<>(tryNode.getCatchBlocks());
newCatchBlocks.add(catchAllBlock(tryNode));
return tryNode.setCatchBlocks(lc, newCatchBlocks);
}
示例14: leaveTryNode
import jdk.nashorn.internal.ir.TryNode; //导入依赖的package包/类
@Override
public Node leaveTryNode(final TryNode tryNode) {
tryNode.setException(exceptionSymbol());
assert tryNode.getFinallyBody() == null;
end(tryNode);
return tryNode;
}