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 3455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3466 catch_scope->DeclareLocal(ast_value_factory()->dot_catch_string(), VAR, | 3466 catch_scope->DeclareLocal(ast_value_factory()->dot_catch_string(), VAR, |
3467 kCreatedInitialized, NORMAL_VARIABLE); | 3467 kCreatedInitialized, NORMAL_VARIABLE); |
3468 Block* catch_block = factory()->NewBlock(nullptr, 1, true, kNoSourcePosition); | 3468 Block* catch_block = factory()->NewBlock(nullptr, 1, true, kNoSourcePosition); |
3469 | 3469 |
3470 Expression* promise_reject = BuildRejectPromise( | 3470 Expression* promise_reject = BuildRejectPromise( |
3471 factory()->NewVariableProxy(catch_variable), kNoSourcePosition); | 3471 factory()->NewVariableProxy(catch_variable), kNoSourcePosition); |
3472 ReturnStatement* return_promise_reject = | 3472 ReturnStatement* return_promise_reject = |
3473 factory()->NewReturnStatement(promise_reject, kNoSourcePosition); | 3473 factory()->NewReturnStatement(promise_reject, kNoSourcePosition); |
3474 catch_block->statements()->Add(return_promise_reject, zone()); | 3474 catch_block->statements()->Add(return_promise_reject, zone()); |
3475 | 3475 |
3476 TryStatement* try_catch_statement = factory()->NewTryCatchStatement( | 3476 TryStatement* try_catch_statement = |
3477 inner_block, catch_scope, catch_variable, catch_block, kNoSourcePosition); | 3477 factory()->NewTryCatchStatementForAsyncAwait(inner_block, catch_scope, |
| 3478 catch_variable, catch_block, |
| 3479 kNoSourcePosition); |
3478 | 3480 |
3479 // There is no TryCatchFinally node, so wrap it in an outer try/finally | 3481 // There is no TryCatchFinally node, so wrap it in an outer try/finally |
3480 Block* outer_try_block = | 3482 Block* outer_try_block = |
3481 factory()->NewBlock(nullptr, 1, true, kNoSourcePosition); | 3483 factory()->NewBlock(nullptr, 1, true, kNoSourcePosition); |
3482 outer_try_block->statements()->Add(try_catch_statement, zone()); | 3484 outer_try_block->statements()->Add(try_catch_statement, zone()); |
3483 | 3485 |
3484 // finally { if (.debug_is_active) %DebugPopPromise(); } | 3486 // finally { if (.debug_is_active) %DebugPopPromise(); } |
3485 Block* finally_block = | 3487 Block* finally_block = |
3486 factory()->NewBlock(nullptr, 1, true, kNoSourcePosition); | 3488 factory()->NewBlock(nullptr, 1, true, kNoSourcePosition); |
3487 { | 3489 { |
(...skipping 909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4397 do_block->statements()->Add( | 4399 do_block->statements()->Add( |
4398 factory()->NewExpressionStatement(value_assignment, value->position()), | 4400 factory()->NewExpressionStatement(value_assignment, value->position()), |
4399 zone()); | 4401 zone()); |
4400 | 4402 |
4401 ZoneList<Expression*>* async_function_await_args = | 4403 ZoneList<Expression*>* async_function_await_args = |
4402 new (zone()) ZoneList<Expression*>(2, zone()); | 4404 new (zone()) ZoneList<Expression*>(2, zone()); |
4403 Expression* generator_object = | 4405 Expression* generator_object = |
4404 factory()->NewVariableProxy(generator_object_variable); | 4406 factory()->NewVariableProxy(generator_object_variable); |
4405 async_function_await_args->Add(generator_object, zone()); | 4407 async_function_await_args->Add(generator_object, zone()); |
4406 async_function_await_args->Add(factory()->NewVariableProxy(temp_var), zone()); | 4408 async_function_await_args->Add(factory()->NewVariableProxy(temp_var), zone()); |
4407 Expression* async_function_await = factory()->NewCallRuntime( | 4409 |
4408 Context::ASYNC_FUNCTION_AWAIT_INDEX, async_function_await_args, nopos); | 4410 // The parser emits calls to AsyncFunctionAwaitCaught, but the |
| 4411 // AstNumberingVisitor will rewrite this to AsyncFunctionAwaitUncaught |
| 4412 // if there is no local enclosing try/catch block. |
| 4413 Expression* async_function_await = |
| 4414 factory()->NewCallRuntime(Context::ASYNC_FUNCTION_AWAIT_CAUGHT_INDEX, |
| 4415 async_function_await_args, nopos); |
4409 | 4416 |
4410 // Wrap await to provide a break location between value evaluation and yield. | 4417 // Wrap await to provide a break location between value evaluation and yield. |
4411 Expression* await_assignment = factory()->NewAssignment( | 4418 Expression* await_assignment = factory()->NewAssignment( |
4412 Token::ASSIGN, factory()->NewVariableProxy(temp_var), | 4419 Token::ASSIGN, factory()->NewVariableProxy(temp_var), |
4413 async_function_await, nopos); | 4420 async_function_await, nopos); |
4414 do_block->statements()->Add( | 4421 do_block->statements()->Add( |
4415 factory()->NewExpressionStatement(await_assignment, await_pos), zone()); | 4422 factory()->NewExpressionStatement(await_assignment, await_pos), zone()); |
4416 Expression* do_expr = factory()->NewDoExpression(do_block, temp_var, nopos); | 4423 Expression* do_expr = factory()->NewDoExpression(do_block, temp_var, nopos); |
4417 | 4424 |
4418 generator_object = factory()->NewVariableProxy(generator_object_variable); | 4425 generator_object = factory()->NewVariableProxy(generator_object_variable); |
(...skipping 1201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5620 node->Print(Isolate::Current()); | 5627 node->Print(Isolate::Current()); |
5621 } | 5628 } |
5622 #endif // DEBUG | 5629 #endif // DEBUG |
5623 | 5630 |
5624 #undef CHECK_OK | 5631 #undef CHECK_OK |
5625 #undef CHECK_OK_VOID | 5632 #undef CHECK_OK_VOID |
5626 #undef CHECK_FAILED | 5633 #undef CHECK_FAILED |
5627 | 5634 |
5628 } // namespace internal | 5635 } // namespace internal |
5629 } // namespace v8 | 5636 } // namespace v8 |
OLD | NEW |