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 #ifndef V8_PARSING_PARSER_BASE_H | 5 #ifndef V8_PARSING_PARSER_BASE_H |
6 #define V8_PARSING_PARSER_BASE_H | 6 #define V8_PARSING_PARSER_BASE_H |
7 | 7 |
8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
9 #include "src/ast/scopes.h" | 9 #include "src/ast/scopes.h" |
10 #include "src/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
(...skipping 1370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1381 scope->GetDeclarationScope()->RecordEvalCall(); | 1381 scope->GetDeclarationScope()->RecordEvalCall(); |
1382 } | 1382 } |
1383 return Call::IS_POSSIBLY_EVAL; | 1383 return Call::IS_POSSIBLY_EVAL; |
1384 } | 1384 } |
1385 return Call::NOT_EVAL; | 1385 return Call::NOT_EVAL; |
1386 } | 1386 } |
1387 | 1387 |
1388 // Convenience method which determines the type of return statement to emit | 1388 // Convenience method which determines the type of return statement to emit |
1389 // depending on the current function type. | 1389 // depending on the current function type. |
1390 inline StatementT BuildReturnStatement(ExpressionT expr, int pos) { | 1390 inline StatementT BuildReturnStatement(ExpressionT expr, int pos) { |
1391 if (is_generator() && !is_async_generator()) { | |
1392 expr = impl()->BuildIteratorResult(expr, true); | |
1393 } | |
1394 | |
1395 if (is_async_function()) { | 1391 if (is_async_function()) { |
1396 return factory()->NewAsyncReturnStatement(expr, pos); | 1392 return factory()->NewAsyncReturnStatement(expr, pos); |
1397 } | 1393 } |
1398 return factory()->NewReturnStatement(expr, pos); | 1394 return factory()->NewReturnStatement(expr, pos); |
1399 } | 1395 } |
1400 | 1396 |
1401 inline SuspendExpressionT BuildSuspend( | 1397 inline SuspendExpressionT BuildSuspend( |
1402 ExpressionT generator, ExpressionT expr, int pos, | 1398 ExpressionT generator, ExpressionT expr, int pos, |
1403 Suspend::OnAbruptResume on_abrupt_resume, SuspendFlags suspend_type) { | 1399 Suspend::OnAbruptResume on_abrupt_resume, SuspendFlags suspend_type) { |
1404 DCHECK_EQ(0, | 1400 DCHECK_EQ(0, |
(...skipping 1590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2995 expression = ParseAssignmentExpression(accept_IN, CHECK_OK); | 2991 expression = ParseAssignmentExpression(accept_IN, CHECK_OK); |
2996 impl()->RewriteNonPattern(CHECK_OK); | 2992 impl()->RewriteNonPattern(CHECK_OK); |
2997 break; | 2993 break; |
2998 } | 2994 } |
2999 } | 2995 } |
3000 | 2996 |
3001 if (delegating) { | 2997 if (delegating) { |
3002 return impl()->RewriteYieldStar(generator_object, expression, pos); | 2998 return impl()->RewriteYieldStar(generator_object, expression, pos); |
3003 } | 2999 } |
3004 | 3000 |
3005 if (!is_async_generator()) { | |
3006 // Async generator yield is rewritten in Ignition, and doesn't require | |
3007 // producing an Iterator Result. | |
3008 expression = impl()->BuildIteratorResult(expression, false); | |
3009 } | |
3010 | |
3011 // Hackily disambiguate o from o.next and o [Symbol.iterator](). | 3001 // Hackily disambiguate o from o.next and o [Symbol.iterator](). |
3012 // TODO(verwaest): Come up with a better solution. | 3002 // TODO(verwaest): Come up with a better solution. |
3013 ExpressionT yield = | 3003 ExpressionT yield = |
3014 BuildSuspend(generator_object, expression, pos, | 3004 BuildSuspend(generator_object, expression, pos, |
3015 Suspend::kOnExceptionThrow, SuspendFlags::kYield); | 3005 Suspend::kOnExceptionThrow, SuspendFlags::kYield); |
3016 return yield; | 3006 return yield; |
3017 } | 3007 } |
3018 | 3008 |
3019 // Precedence = 3 | 3009 // Precedence = 3 |
3020 template <typename Impl> | 3010 template <typename Impl> |
(...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4088 inner_scope = NewVarblockScope(); | 4078 inner_scope = NewVarblockScope(); |
4089 inner_scope->set_start_position(scanner()->location().beg_pos); | 4079 inner_scope->set_start_position(scanner()->location().beg_pos); |
4090 inner_block = factory()->NewBlock(NULL, 8, true, kNoSourcePosition); | 4080 inner_block = factory()->NewBlock(NULL, 8, true, kNoSourcePosition); |
4091 inner_block->set_scope(inner_scope); | 4081 inner_block->set_scope(inner_scope); |
4092 body = inner_block->statements(); | 4082 body = inner_block->statements(); |
4093 } | 4083 } |
4094 | 4084 |
4095 { | 4085 { |
4096 BlockState block_state(&scope_, inner_scope); | 4086 BlockState block_state(&scope_, inner_scope); |
4097 | 4087 |
4098 if (IsGeneratorFunction(kind)) { | 4088 if (IsAsyncGeneratorFunction(kind)) { |
| 4089 impl()->ParseAndRewriteAsyncGeneratorFunctionBody(pos, kind, body, ok); |
| 4090 } else if (IsGeneratorFunction(kind)) { |
4099 impl()->ParseAndRewriteGeneratorFunctionBody(pos, kind, body, ok); | 4091 impl()->ParseAndRewriteGeneratorFunctionBody(pos, kind, body, ok); |
4100 } else if (IsAsyncFunction(kind)) { | 4092 } else if (IsAsyncFunction(kind)) { |
4101 const bool accept_IN = true; | 4093 const bool accept_IN = true; |
4102 ParseAsyncFunctionBody(inner_scope, body, kind, FunctionBodyType::kNormal, | 4094 ParseAsyncFunctionBody(inner_scope, body, kind, FunctionBodyType::kNormal, |
4103 accept_IN, pos, CHECK_OK_VOID); | 4095 accept_IN, pos, CHECK_OK_VOID); |
4104 } else { | 4096 } else { |
4105 ParseStatementList(body, Token::RBRACE, CHECK_OK_VOID); | 4097 ParseStatementList(body, Token::RBRACE, CHECK_OK_VOID); |
4106 } | 4098 } |
4107 | 4099 |
4108 if (IsDerivedConstructor(kind)) { | 4100 if (IsDerivedConstructor(kind)) { |
(...skipping 1899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6008 } | 6000 } |
6009 | 6001 |
6010 #undef CHECK_OK | 6002 #undef CHECK_OK |
6011 #undef CHECK_OK_CUSTOM | 6003 #undef CHECK_OK_CUSTOM |
6012 #undef CHECK_OK_VOID | 6004 #undef CHECK_OK_VOID |
6013 | 6005 |
6014 } // namespace internal | 6006 } // namespace internal |
6015 } // namespace v8 | 6007 } // namespace v8 |
6016 | 6008 |
6017 #endif // V8_PARSING_PARSER_BASE_H | 6009 #endif // V8_PARSING_PARSER_BASE_H |
OLD | NEW |