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 expr, int pos, Suspend::OnAbruptResume on_abrupt_resume, | 1398 ExpressionT expr, int pos, Suspend::OnAbruptResume on_abrupt_resume, |
1403 SuspendFlags suspend_type) { | 1399 SuspendFlags suspend_type) { |
1404 DCHECK_EQ(0, | 1400 DCHECK_EQ(0, |
(...skipping 1587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2992 expression = ParseAssignmentExpression(accept_IN, CHECK_OK); | 2988 expression = ParseAssignmentExpression(accept_IN, CHECK_OK); |
2993 impl()->RewriteNonPattern(CHECK_OK); | 2989 impl()->RewriteNonPattern(CHECK_OK); |
2994 break; | 2990 break; |
2995 } | 2991 } |
2996 } | 2992 } |
2997 | 2993 |
2998 if (delegating) { | 2994 if (delegating) { |
2999 return impl()->RewriteYieldStar(expression, pos); | 2995 return impl()->RewriteYieldStar(expression, pos); |
3000 } | 2996 } |
3001 | 2997 |
3002 if (!is_async_generator()) { | |
3003 // Async generator yield is rewritten in Ignition, and doesn't require | |
3004 // producing an Iterator Result. | |
3005 expression = impl()->BuildIteratorResult(expression, false); | |
3006 } | |
3007 | |
3008 // Hackily disambiguate o from o.next and o [Symbol.iterator](). | 2998 // Hackily disambiguate o from o.next and o [Symbol.iterator](). |
3009 // TODO(verwaest): Come up with a better solution. | 2999 // TODO(verwaest): Come up with a better solution. |
3010 ExpressionT yield = BuildSuspend(expression, pos, Suspend::kOnExceptionThrow, | 3000 ExpressionT yield = BuildSuspend(expression, pos, Suspend::kOnExceptionThrow, |
3011 SuspendFlags::kYield); | 3001 SuspendFlags::kYield); |
3012 return yield; | 3002 return yield; |
3013 } | 3003 } |
3014 | 3004 |
3015 // Precedence = 3 | 3005 // Precedence = 3 |
3016 template <typename Impl> | 3006 template <typename Impl> |
3017 typename ParserBase<Impl>::ExpressionT | 3007 typename ParserBase<Impl>::ExpressionT |
(...skipping 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4084 inner_scope = NewVarblockScope(); | 4074 inner_scope = NewVarblockScope(); |
4085 inner_scope->set_start_position(scanner()->location().beg_pos); | 4075 inner_scope->set_start_position(scanner()->location().beg_pos); |
4086 inner_block = factory()->NewBlock(NULL, 8, true, kNoSourcePosition); | 4076 inner_block = factory()->NewBlock(NULL, 8, true, kNoSourcePosition); |
4087 inner_block->set_scope(inner_scope); | 4077 inner_block->set_scope(inner_scope); |
4088 body = inner_block->statements(); | 4078 body = inner_block->statements(); |
4089 } | 4079 } |
4090 | 4080 |
4091 { | 4081 { |
4092 BlockState block_state(&scope_, inner_scope); | 4082 BlockState block_state(&scope_, inner_scope); |
4093 | 4083 |
4094 if (IsGeneratorFunction(kind)) { | 4084 if (IsAsyncGeneratorFunction(kind)) { |
| 4085 impl()->ParseAndRewriteAsyncGeneratorFunctionBody(pos, kind, body, ok); |
| 4086 } else if (IsGeneratorFunction(kind)) { |
4095 impl()->ParseAndRewriteGeneratorFunctionBody(pos, kind, body, ok); | 4087 impl()->ParseAndRewriteGeneratorFunctionBody(pos, kind, body, ok); |
4096 } else if (IsAsyncFunction(kind)) { | 4088 } else if (IsAsyncFunction(kind)) { |
4097 const bool accept_IN = true; | 4089 const bool accept_IN = true; |
4098 ParseAsyncFunctionBody(inner_scope, body, kind, FunctionBodyType::kNormal, | 4090 ParseAsyncFunctionBody(inner_scope, body, kind, FunctionBodyType::kNormal, |
4099 accept_IN, pos, CHECK_OK_VOID); | 4091 accept_IN, pos, CHECK_OK_VOID); |
4100 } else { | 4092 } else { |
4101 ParseStatementList(body, Token::RBRACE, CHECK_OK_VOID); | 4093 ParseStatementList(body, Token::RBRACE, CHECK_OK_VOID); |
4102 } | 4094 } |
4103 | 4095 |
4104 if (IsDerivedConstructor(kind)) { | 4096 if (IsDerivedConstructor(kind)) { |
(...skipping 1899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6004 } | 5996 } |
6005 | 5997 |
6006 #undef CHECK_OK | 5998 #undef CHECK_OK |
6007 #undef CHECK_OK_CUSTOM | 5999 #undef CHECK_OK_CUSTOM |
6008 #undef CHECK_OK_VOID | 6000 #undef CHECK_OK_VOID |
6009 | 6001 |
6010 } // namespace internal | 6002 } // namespace internal |
6011 } // namespace v8 | 6003 } // namespace v8 |
6012 | 6004 |
6013 #endif // V8_PARSING_PARSER_BASE_H | 6005 #endif // V8_PARSING_PARSER_BASE_H |
OLD | NEW |