Java Code Examples for jdk.nashorn.internal.ir.CatchNode#getException()
The following examples show how to use
jdk.nashorn.internal.ir.CatchNode#getException() .
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: AssignSymbols.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@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; }
Example 2
Source File: AssignSymbols.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
@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; }
Example 3
Source File: AssignSymbols.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@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; }
Example 4
Source File: AssignSymbols.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@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; }
Example 5
Source File: AssignSymbols.java From hottub with GNU General Public License v2.0 | 6 votes |
@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; }
Example 6
Source File: Attr.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
@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; }
Example 7
Source File: Attr.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
@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; }
Example 8
Source File: AssignSymbols.java From jdk8u_nashorn with GNU General Public License v2.0 | 6 votes |
@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; }
Example 9
Source File: Attr.java From nashorn with GNU General Public License v2.0 | 6 votes |
@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; }
Example 10
Source File: Lower.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override public boolean enterCatchNode(final CatchNode catchNode) { Expression exception = catchNode.getException(); if ((exception != null) && !(exception instanceof IdentNode)) { throwNotImplementedYet("es6.destructuring", exception); } return true; }
Example 11
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 12
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 13
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; }