| 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 3866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3877 catch_scope->DeclareLocal(ast_value_factory()->dot_catch_string(), VAR, | 3877 catch_scope->DeclareLocal(ast_value_factory()->dot_catch_string(), VAR, |
| 3878 kCreatedInitialized, Variable::NORMAL); | 3878 kCreatedInitialized, Variable::NORMAL); |
| 3879 Block* catch_block = factory()->NewBlock(nullptr, 1, true, kNoSourcePosition); | 3879 Block* catch_block = factory()->NewBlock(nullptr, 1, true, kNoSourcePosition); |
| 3880 | 3880 |
| 3881 Expression* promise_reject = BuildRejectPromise( | 3881 Expression* promise_reject = BuildRejectPromise( |
| 3882 factory()->NewVariableProxy(catch_variable), kNoSourcePosition); | 3882 factory()->NewVariableProxy(catch_variable), kNoSourcePosition); |
| 3883 ReturnStatement* return_promise_reject = | 3883 ReturnStatement* return_promise_reject = |
| 3884 factory()->NewReturnStatement(promise_reject, kNoSourcePosition); | 3884 factory()->NewReturnStatement(promise_reject, kNoSourcePosition); |
| 3885 catch_block->statements()->Add(return_promise_reject, zone()); | 3885 catch_block->statements()->Add(return_promise_reject, zone()); |
| 3886 | 3886 |
| 3887 TryStatement* try_catch_statement = factory()->NewTryCatchStatement( | 3887 TryStatement* try_catch_statement = |
| 3888 inner_block, catch_scope, catch_variable, catch_block, kNoSourcePosition); | 3888 factory()->NewTryCatchStatementForAsyncAwait(inner_block, catch_scope, |
| 3889 catch_variable, catch_block, |
| 3890 kNoSourcePosition); |
| 3889 | 3891 |
| 3890 // There is no TryCatchFinally node, so wrap it in an outer try/finally | 3892 // There is no TryCatchFinally node, so wrap it in an outer try/finally |
| 3891 Block* outer_try_block = | 3893 Block* outer_try_block = |
| 3892 factory()->NewBlock(nullptr, 1, true, kNoSourcePosition); | 3894 factory()->NewBlock(nullptr, 1, true, kNoSourcePosition); |
| 3893 outer_try_block->statements()->Add(try_catch_statement, zone()); | 3895 outer_try_block->statements()->Add(try_catch_statement, zone()); |
| 3894 | 3896 |
| 3895 // finally { if (.debug_is_active) %DebugPopPromise(); } | 3897 // finally { if (.debug_is_active) %DebugPopPromise(); } |
| 3896 Block* finally_block = | 3898 Block* finally_block = |
| 3897 factory()->NewBlock(nullptr, 1, true, kNoSourcePosition); | 3899 factory()->NewBlock(nullptr, 1, true, kNoSourcePosition); |
| 3898 { | 3900 { |
| (...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4877 do_block->statements()->Add( | 4879 do_block->statements()->Add( |
| 4878 factory()->NewExpressionStatement(value_assignment, value->position()), | 4880 factory()->NewExpressionStatement(value_assignment, value->position()), |
| 4879 zone()); | 4881 zone()); |
| 4880 | 4882 |
| 4881 ZoneList<Expression*>* async_function_await_args = | 4883 ZoneList<Expression*>* async_function_await_args = |
| 4882 new (zone()) ZoneList<Expression*>(2, zone()); | 4884 new (zone()) ZoneList<Expression*>(2, zone()); |
| 4883 Expression* generator_object = | 4885 Expression* generator_object = |
| 4884 factory()->NewVariableProxy(generator_object_variable); | 4886 factory()->NewVariableProxy(generator_object_variable); |
| 4885 async_function_await_args->Add(generator_object, zone()); | 4887 async_function_await_args->Add(generator_object, zone()); |
| 4886 async_function_await_args->Add(temp_proxy, zone()); | 4888 async_function_await_args->Add(temp_proxy, zone()); |
| 4887 Expression* async_function_await = factory()->NewCallRuntime( | 4889 Expression* async_function_await = |
| 4888 Context::ASYNC_FUNCTION_AWAIT_INDEX, async_function_await_args, nopos); | 4890 factory()->NewCallRuntime(Context::ASYNC_FUNCTION_AWAIT_CAUGHT_INDEX, |
| 4891 async_function_await_args, nopos); |
| 4889 // Wrap await to provide a break location between value evaluation and yield. | 4892 // Wrap await to provide a break location between value evaluation and yield. |
| 4890 Expression* await_assignment = factory()->NewAssignment( | 4893 Expression* await_assignment = factory()->NewAssignment( |
| 4891 Token::ASSIGN, temp_proxy, async_function_await, nopos); | 4894 Token::ASSIGN, temp_proxy, async_function_await, nopos); |
| 4892 do_block->statements()->Add( | 4895 do_block->statements()->Add( |
| 4893 factory()->NewExpressionStatement(await_assignment, await_pos), zone()); | 4896 factory()->NewExpressionStatement(await_assignment, await_pos), zone()); |
| 4894 Expression* do_expr = factory()->NewDoExpression(do_block, temp_var, nopos); | 4897 Expression* do_expr = factory()->NewDoExpression(do_block, temp_var, nopos); |
| 4895 | 4898 |
| 4896 generator_object = factory()->NewVariableProxy(generator_object_variable); | 4899 generator_object = factory()->NewVariableProxy(generator_object_variable); |
| 4897 return factory()->NewYield(generator_object, do_expr, nopos, | 4900 return factory()->NewYield(generator_object, do_expr, nopos, |
| 4898 Yield::kOnExceptionRethrow); | 4901 Yield::kOnExceptionRethrow); |
| (...skipping 1183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6082 node->Print(Isolate::Current()); | 6085 node->Print(Isolate::Current()); |
| 6083 } | 6086 } |
| 6084 #endif // DEBUG | 6087 #endif // DEBUG |
| 6085 | 6088 |
| 6086 #undef CHECK_OK | 6089 #undef CHECK_OK |
| 6087 #undef CHECK_OK_VOID | 6090 #undef CHECK_OK_VOID |
| 6088 #undef CHECK_FAILED | 6091 #undef CHECK_FAILED |
| 6089 | 6092 |
| 6090 } // namespace internal | 6093 } // namespace internal |
| 6091 } // namespace v8 | 6094 } // namespace v8 |
| OLD | NEW |