OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/parsing/parser.h" | 5 #include "src/parsing/parser.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "src/api.h" | 9 #include "src/api.h" |
10 #include "src/ast/ast-expression-rewriter.h" | 10 #include "src/ast/ast-expression-rewriter.h" |
(...skipping 1796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1807 // Simplify the AST nodes by converting: | 1807 // Simplify the AST nodes by converting: |
1808 // 'try B0 catch B1 finally B2' | 1808 // 'try B0 catch B1 finally B2' |
1809 // to: | 1809 // to: |
1810 // 'try { try B0 catch B1 } finally B2' | 1810 // 'try { try B0 catch B1 } finally B2' |
1811 | 1811 |
1812 if (catch_block != nullptr && finally_block != nullptr) { | 1812 if (catch_block != nullptr && finally_block != nullptr) { |
1813 // If we have both, create an inner try/catch. | 1813 // If we have both, create an inner try/catch. |
1814 DCHECK_NOT_NULL(catch_info.scope); | 1814 DCHECK_NOT_NULL(catch_info.scope); |
1815 DCHECK_NOT_NULL(catch_info.variable); | 1815 DCHECK_NOT_NULL(catch_info.variable); |
1816 TryCatchStatement* statement; | 1816 TryCatchStatement* statement; |
1817 if (catch_info.for_promise_reject) { | 1817 statement = factory()->NewTryCatchStatement(try_block, catch_info.scope, |
1818 statement = factory()->NewTryCatchStatementForPromiseReject( | 1818 catch_info.variable, |
1819 try_block, catch_info.scope, catch_info.variable, catch_block, | 1819 catch_block, kNoSourcePosition); |
1820 kNoSourcePosition); | |
1821 } else { | |
1822 statement = factory()->NewTryCatchStatement( | |
1823 try_block, catch_info.scope, catch_info.variable, catch_block, | |
1824 kNoSourcePosition); | |
1825 } | |
1826 | 1820 |
1827 try_block = factory()->NewBlock(nullptr, 1, false, kNoSourcePosition); | 1821 try_block = factory()->NewBlock(nullptr, 1, false, kNoSourcePosition); |
1828 try_block->statements()->Add(statement, zone()); | 1822 try_block->statements()->Add(statement, zone()); |
1829 catch_block = nullptr; // Clear to indicate it's been handled. | 1823 catch_block = nullptr; // Clear to indicate it's been handled. |
1830 } | 1824 } |
1831 | 1825 |
1832 if (catch_block != nullptr) { | 1826 if (catch_block != nullptr) { |
1833 // For a try-catch construct append return expressions from the catch block | 1827 // For a try-catch construct append return expressions from the catch block |
1834 // to the list of return expressions. | 1828 // to the list of return expressions. |
1835 function_state_->tail_call_expressions().Append( | 1829 function_state_->tail_call_expressions().Append( |
(...skipping 3597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5433 | 5427 |
5434 return final_loop; | 5428 return final_loop; |
5435 } | 5429 } |
5436 | 5430 |
5437 #undef CHECK_OK | 5431 #undef CHECK_OK |
5438 #undef CHECK_OK_VOID | 5432 #undef CHECK_OK_VOID |
5439 #undef CHECK_FAILED | 5433 #undef CHECK_FAILED |
5440 | 5434 |
5441 } // namespace internal | 5435 } // namespace internal |
5442 } // namespace v8 | 5436 } // namespace v8 |
OLD | NEW |