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 4720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4731 for (int i = 1; i < args->length(); ++i) { | 4731 for (int i = 1; i < args->length(); ++i) { |
4732 expr = factory()->NewBinaryOperation(Token::COMMA, expr, args->at(i), | 4732 expr = factory()->NewBinaryOperation(Token::COMMA, expr, args->at(i), |
4733 expr->position()); | 4733 expr->position()); |
4734 } | 4734 } |
4735 return expr; | 4735 return expr; |
4736 } | 4736 } |
4737 | 4737 |
4738 Expression* Parser::RewriteAwaitExpression(Expression* value, int await_pos) { | 4738 Expression* Parser::RewriteAwaitExpression(Expression* value, int await_pos) { |
4739 // yield do { | 4739 // yield do { |
4740 // tmp = <operand>; | 4740 // tmp = <operand>; |
4741 // tmp = %AsyncFunctionAwait(.generator_object, tmp); | 4741 // tmp = %AsyncFunctionAwait(.generator_object, tmp); |
jgruber
2016/09/12 13:22:00
Please update the comment.
| |
4742 // } | 4742 // } |
4743 Variable* generator_object_variable = | 4743 Variable* generator_object_variable = |
4744 function_state_->generator_object_variable(); | 4744 function_state_->generator_object_variable(); |
4745 | 4745 |
4746 // If generator_object_variable is null, | 4746 // If generator_object_variable is null, |
4747 if (!generator_object_variable) return value; | 4747 if (!generator_object_variable) return value; |
4748 | 4748 |
4749 const int nopos = kNoSourcePosition; | 4749 const int nopos = kNoSourcePosition; |
4750 | 4750 |
4751 Variable* temp_var = NewTemporary(ast_value_factory()->empty_string()); | 4751 Variable* temp_var = NewTemporary(ast_value_factory()->empty_string()); |
4752 Block* do_block = factory()->NewBlock(nullptr, 2, false, nopos); | 4752 Block* do_block = factory()->NewBlock(nullptr, 2, false, nopos); |
4753 | 4753 |
4754 // Wrap value evaluation to provide a break location. | 4754 // Wrap value evaluation to provide a break location. |
4755 Expression* value_assignment = factory()->NewAssignment( | 4755 Expression* value_assignment = factory()->NewAssignment( |
4756 Token::ASSIGN, factory()->NewVariableProxy(temp_var), value, nopos); | 4756 Token::ASSIGN, factory()->NewVariableProxy(temp_var), value, nopos); |
4757 do_block->statements()->Add( | 4757 do_block->statements()->Add( |
4758 factory()->NewExpressionStatement(value_assignment, value->position()), | 4758 factory()->NewExpressionStatement(value_assignment, value->position()), |
4759 zone()); | 4759 zone()); |
4760 | 4760 |
4761 ZoneList<Expression*>* async_function_await_args = | 4761 ZoneList<Expression*>* async_function_await_args = |
4762 new (zone()) ZoneList<Expression*>(2, zone()); | 4762 new (zone()) ZoneList<Expression*>(3, zone()); |
4763 Expression* generator_object = | 4763 Expression* generator_object = |
4764 factory()->NewVariableProxy(generator_object_variable); | 4764 factory()->NewVariableProxy(generator_object_variable); |
4765 async_function_await_args->Add(generator_object, zone()); | 4765 async_function_await_args->Add(generator_object, zone()); |
4766 async_function_await_args->Add(factory()->NewVariableProxy(temp_var), zone()); | 4766 async_function_await_args->Add(factory()->NewVariableProxy(temp_var), zone()); |
4767 async_function_await_args->Add(BuildDotPromise(), zone()); | |
4767 | 4768 |
4768 // The parser emits calls to AsyncFunctionAwaitCaught, but the | 4769 // The parser emits calls to AsyncFunctionAwaitCaught, but the |
4769 // AstNumberingVisitor will rewrite this to AsyncFunctionAwaitUncaught | 4770 // AstNumberingVisitor will rewrite this to AsyncFunctionAwaitUncaught |
4770 // if there is no local enclosing try/catch block. | 4771 // if there is no local enclosing try/catch block. |
4771 Expression* async_function_await = | 4772 Expression* async_function_await = |
4772 factory()->NewCallRuntime(Context::ASYNC_FUNCTION_AWAIT_CAUGHT_INDEX, | 4773 factory()->NewCallRuntime(Context::ASYNC_FUNCTION_AWAIT_CAUGHT_INDEX, |
4773 async_function_await_args, nopos); | 4774 async_function_await_args, nopos); |
4774 | 4775 |
4775 // Wrap await to provide a break location between value evaluation and yield. | 4776 // Wrap await to provide a break location between value evaluation and yield. |
4776 Expression* await_assignment = factory()->NewAssignment( | 4777 Expression* await_assignment = factory()->NewAssignment( |
(...skipping 1208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5985 node->Print(Isolate::Current()); | 5986 node->Print(Isolate::Current()); |
5986 } | 5987 } |
5987 #endif // DEBUG | 5988 #endif // DEBUG |
5988 | 5989 |
5989 #undef CHECK_OK | 5990 #undef CHECK_OK |
5990 #undef CHECK_OK_VOID | 5991 #undef CHECK_OK_VOID |
5991 #undef CHECK_FAILED | 5992 #undef CHECK_FAILED |
5992 | 5993 |
5993 } // namespace internal | 5994 } // namespace internal |
5994 } // namespace v8 | 5995 } // namespace v8 |
OLD | NEW |