Java Code Examples for jdk.nashorn.internal.ir.TryNode#getCatchBlocks()
The following examples show how to use
jdk.nashorn.internal.ir.TryNode#getCatchBlocks() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PrintVisitor.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@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; }
Example 2
Source File: PrintVisitor.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
@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; }
Example 3
Source File: PrintVisitor.java From nashorn with GNU General Public License v2.0 | 6 votes |
@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; }
Example 4
Source File: PrintVisitor.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@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; }
Example 5
Source File: PrintVisitor.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@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; }
Example 6
Source File: PrintVisitor.java From jdk8u_nashorn with GNU General Public License v2.0 | 6 votes |
@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; }
Example 7
Source File: PrintVisitor.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@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; }
Example 8
Source File: PrintVisitor.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
@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; }
Example 9
Source File: PrintVisitor.java From hottub with GNU General Public License v2.0 | 6 votes |
@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; }
Example 10
Source File: PrintVisitor.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
@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; }
Example 11
Source File: Lower.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
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); }
Example 12
Source File: Lower.java From jdk8u_nashorn with GNU General Public License v2.0 | 5 votes |
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); }
Example 13
Source File: Lower.java From hottub with GNU General Public License v2.0 | 5 votes |
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); }
Example 14
Source File: Lower.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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); }
Example 15
Source File: Lower.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
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); }
Example 16
Source File: Lower.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
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); }
Example 17
Source File: Lower.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
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); }
Example 18
Source File: CodeGenerator.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
@Override public boolean enterTryNode(final TryNode tryNode) { lineNumber(tryNode); final Block body = tryNode.getBody(); final List<Block> catchBlocks = tryNode.getCatchBlocks(); final Symbol symbol = tryNode.getException(); final Label entry = new Label("try"); final Label recovery = new Label("catch"); final Label exit = tryNode.getExit(); final Label skip = new Label("skip"); method.label(entry); body.accept(this); if (!body.hasTerminalFlags()) { method._goto(skip); } method.label(exit); method._catch(recovery); method.store(symbol); for (int i = 0; i < catchBlocks.size(); i++) { final Block catchBlock = catchBlocks.get(i); //TODO this is very ugly - try not to call enter/leave methods directly //better to use the implicit lexical context scoping given by the visitor's //accept method. lc.push(catchBlock); enterBlock(catchBlock); final CatchNode catchNode = (CatchNode)catchBlocks.get(i).getStatements().get(0); final IdentNode exception = catchNode.getException(); final Expression exceptionCondition = catchNode.getExceptionCondition(); final Block catchBody = catchNode.getBody(); new Store<IdentNode>(exception) { @Override protected void storeNonDiscard() { return; } @Override protected void evaluate() { if (catchNode.isSyntheticRethrow()) { method.load(symbol); return; } /* * If caught object is an instance of ECMAException, then * bind obj.thrown to the script catch var. Or else bind the * caught object itself to the script catch var. */ final Label notEcmaException = new Label("no_ecma_exception"); method.load(symbol).dup()._instanceof(ECMAException.class).ifeq(notEcmaException); method.checkcast(ECMAException.class); //TODO is this necessary? method.getField(ECMAException.THROWN); method.label(notEcmaException); } }.store(); final Label next; if (exceptionCondition != null) { next = new Label("next"); load(exceptionCondition, Type.BOOLEAN).ifeq(next); } else { next = null; } catchBody.accept(this); if (i + 1 != catchBlocks.size() && !catchBody.hasTerminalFlags()) { method._goto(skip); } if (next != null) { if (i + 1 == catchBlocks.size()) { // no next catch block - rethrow if condition failed method._goto(skip); method.label(next); method.load(symbol).athrow(); } else { method.label(next); } } leaveBlock(catchBlock); lc.pop(catchBlock); } method.label(skip); method._try(entry, exit, recovery, Throwable.class); // Finally body is always inlined elsewhere so it doesn't need to be emitted return false; }
Example 19
Source File: CodeGenerator.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
@Override public boolean enterTryNode(final TryNode tryNode) { lineNumber(tryNode); final Block body = tryNode.getBody(); final List<Block> catchBlocks = tryNode.getCatchBlocks(); final Symbol symbol = tryNode.getException(); final Label entry = new Label("try"); final Label recovery = new Label("catch"); final Label exit = tryNode.getExit(); final Label skip = new Label("skip"); method.label(entry); body.accept(this); if (!body.hasTerminalFlags()) { method._goto(skip); } method.label(exit); method._catch(recovery); method.store(symbol); for (int i = 0; i < catchBlocks.size(); i++) { final Block catchBlock = catchBlocks.get(i); //TODO this is very ugly - try not to call enter/leave methods directly //better to use the implicit lexical context scoping given by the visitor's //accept method. lc.push(catchBlock); enterBlock(catchBlock); final CatchNode catchNode = (CatchNode)catchBlocks.get(i).getStatements().get(0); final IdentNode exception = catchNode.getException(); final Expression exceptionCondition = catchNode.getExceptionCondition(); final Block catchBody = catchNode.getBody(); new Store<IdentNode>(exception) { @Override protected void storeNonDiscard() { return; } @Override protected void evaluate() { if (catchNode.isSyntheticRethrow()) { method.load(symbol); return; } /* * If caught object is an instance of ECMAException, then * bind obj.thrown to the script catch var. Or else bind the * caught object itself to the script catch var. */ final Label notEcmaException = new Label("no_ecma_exception"); method.load(symbol).dup()._instanceof(ECMAException.class).ifeq(notEcmaException); method.checkcast(ECMAException.class); //TODO is this necessary? method.getField(ECMAException.THROWN); method.label(notEcmaException); } }.store(); final Label next; if (exceptionCondition != null) { next = new Label("next"); load(exceptionCondition, Type.BOOLEAN).ifeq(next); } else { next = null; } catchBody.accept(this); if (i + 1 != catchBlocks.size() && !catchBody.hasTerminalFlags()) { method._goto(skip); } if (next != null) { if (i + 1 == catchBlocks.size()) { // no next catch block - rethrow if condition failed method._goto(skip); method.label(next); method.load(symbol).athrow(); } else { method.label(next); } } leaveBlock(catchBlock); lc.pop(catchBlock); } method.label(skip); method._try(entry, exit, recovery, Throwable.class); // Finally body is always inlined elsewhere so it doesn't need to be emitted return false; }
Example 20
Source File: CodeGenerator.java From nashorn with GNU General Public License v2.0 | 4 votes |
@Override public boolean enterTryNode(final TryNode tryNode) { lineNumber(tryNode); final Block body = tryNode.getBody(); final List<Block> catchBlocks = tryNode.getCatchBlocks(); final Symbol symbol = tryNode.getException(); final Label entry = new Label("try"); final Label recovery = new Label("catch"); final Label exit = tryNode.getExit(); final Label skip = new Label("skip"); method.label(entry); body.accept(this); if (!body.hasTerminalFlags()) { method._goto(skip); } method.label(exit); method._catch(recovery); method.store(symbol); for (int i = 0; i < catchBlocks.size(); i++) { final Block catchBlock = catchBlocks.get(i); //TODO this is very ugly - try not to call enter/leave methods directly //better to use the implicit lexical context scoping given by the visitor's //accept method. lc.push(catchBlock); enterBlock(catchBlock); final CatchNode catchNode = (CatchNode)catchBlocks.get(i).getStatements().get(0); final IdentNode exception = catchNode.getException(); final Expression exceptionCondition = catchNode.getExceptionCondition(); final Block catchBody = catchNode.getBody(); new Store<IdentNode>(exception) { @Override protected void storeNonDiscard() { return; } @Override protected void evaluate() { if (catchNode.isSyntheticRethrow()) { method.load(symbol); return; } /* * If caught object is an instance of ECMAException, then * bind obj.thrown to the script catch var. Or else bind the * caught object itself to the script catch var. */ final Label notEcmaException = new Label("no_ecma_exception"); method.load(symbol).dup()._instanceof(ECMAException.class).ifeq(notEcmaException); method.checkcast(ECMAException.class); //TODO is this necessary? method.getField(ECMAException.THROWN); method.label(notEcmaException); } }.store(); final Label next; if (exceptionCondition != null) { next = new Label("next"); load(exceptionCondition).convert(Type.BOOLEAN).ifeq(next); } else { next = null; } catchBody.accept(this); if (i + 1 != catchBlocks.size() && !catchBody.hasTerminalFlags()) { method._goto(skip); } if (next != null) { if (i + 1 == catchBlocks.size()) { // no next catch block - rethrow if condition failed method._goto(skip); method.label(next); method.load(symbol).athrow(); } else { method.label(next); } } leaveBlock(catchBlock); lc.pop(catchBlock); } method.label(skip); method._try(entry, exit, recovery, Throwable.class); // Finally body is always inlined elsewhere so it doesn't need to be emitted return false; }