@Override public boolean enterCatchNode(final CatchNode catchNode) { enterDefault(catchNode); type("CatchClause"); comma(); property("param"); catchNode.getException().accept(this); comma(); final Node guard = catchNode.getExceptionCondition(); if (guard != null) { property("guard"); guard.accept(this); comma(); } property("body"); catchNode.getBody().accept(this); return leave(); }
@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; }
@Override public boolean enterCatchNode(final CatchNode catchNode) { final IdentNode exception = catchNode.getException(); 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; }
@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; }
@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; }
@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; }
@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; }
@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; }
@Override public boolean enterCatchNode(final CatchNode catchNode) { final IdentNode exception = catchNode.getException(); final Block block = lc.getCurrentBlock(); start(catchNode); catchNestingLevel++; // define block-local exception variable final String exname = exception.getName(); final Symbol def = defineSymbol(block, exname, IS_VAR | IS_LET | IS_ALWAYS_DEFINED); newType(def, Type.OBJECT); //we can catch anything, not just ecma exceptions addLocalDef(exname); return true; }
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); }
CatchTreeImpl(final CatchNode node, final ExpressionTree param, final BlockTree block, final ExpressionTree condition) { super(node); this.param = param; this.block = block; this.condition = condition; }
@Override public boolean enterCatchNode(final CatchNode catchNode) { Expression exception = catchNode.getException(); if ((exception != null) && !(exception instanceof IdentNode)) { throwNotImplementedYet("es6.destructuring", exception); } return true; }
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); }
CatchTreeImpl(final CatchNode node, final IdentifierTree param, final BlockTree block, final ExpressionTree condition) { super(node); this.param = param; this.block = block; this.condition = condition; }