| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/parser.h" | 5 #include "vm/parser.h" |
| 6 | 6 |
| 7 #include "lib/invocation_mirror.h" | 7 #include "lib/invocation_mirror.h" |
| 8 #include "platform/utils.h" | 8 #include "platform/utils.h" |
| 9 #include "vm/ast_transformer.h" | 9 #include "vm/ast_transformer.h" |
| 10 #include "vm/bootstrap.h" | 10 #include "vm/bootstrap.h" |
| (...skipping 9581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9592 Token::Str(jump_kind)); | 9592 Token::Str(jump_kind)); |
| 9593 } | 9593 } |
| 9594 return new(Z) JumpNode(jump_pos, jump_kind, target); | 9594 return new(Z) JumpNode(jump_pos, jump_kind, target); |
| 9595 } | 9595 } |
| 9596 | 9596 |
| 9597 | 9597 |
| 9598 AstNode* Parser::ParseYieldStatement() { | 9598 AstNode* Parser::ParseYieldStatement() { |
| 9599 bool is_yield_each = false; | 9599 bool is_yield_each = false; |
| 9600 const intptr_t yield_pos = TokenPos(); | 9600 const intptr_t yield_pos = TokenPos(); |
| 9601 ConsumeToken(); // yield reserved word. | 9601 ConsumeToken(); // yield reserved word. |
| 9602 ASSERT(innermost_function().IsGenerator() || | |
| 9603 innermost_function().IsSyncGenClosure() || | |
| 9604 innermost_function().IsAsyncGenerator() || | |
| 9605 innermost_function().IsAsyncGenClosure()); | |
| 9606 if (CurrentToken() == Token::kMUL) { | 9602 if (CurrentToken() == Token::kMUL) { |
| 9607 is_yield_each = true; | 9603 is_yield_each = true; |
| 9608 ConsumeToken(); | 9604 ConsumeToken(); |
| 9609 } | 9605 } |
| 9606 if (!innermost_function().IsGenerator() && |
| 9607 !innermost_function().IsGeneratorClosure()) { |
| 9608 ReportError(yield_pos, |
| 9609 "yield%s statement only allowed in generator functions", |
| 9610 is_yield_each ? "*" : ""); |
| 9611 } |
| 9612 |
| 9610 AstNode* expr = ParseAwaitableExpr(kAllowConst, kConsumeCascades, NULL); | 9613 AstNode* expr = ParseAwaitableExpr(kAllowConst, kConsumeCascades, NULL); |
| 9611 | 9614 |
| 9612 LetNode* yield = new(Z) LetNode(yield_pos); | 9615 LetNode* yield = new(Z) LetNode(yield_pos); |
| 9613 if (innermost_function().IsSyncGenerator() || | 9616 if (innermost_function().IsSyncGenerator() || |
| 9614 innermost_function().IsSyncGenClosure()) { | 9617 innermost_function().IsSyncGenClosure()) { |
| 9615 // Yield statement in sync* function. | 9618 // Yield statement in sync* function. |
| 9616 | 9619 |
| 9617 LocalVariable* iterator_param = | 9620 LocalVariable* iterator_param = |
| 9618 LookupLocalScope(Symbols::IteratorParameter()); | 9621 LookupLocalScope(Symbols::IteratorParameter()); |
| 9619 ASSERT(iterator_param != NULL); | 9622 ASSERT(iterator_param != NULL); |
| (...skipping 3903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13523 void Parser::SkipQualIdent() { | 13526 void Parser::SkipQualIdent() { |
| 13524 ASSERT(IsIdentifier()); | 13527 ASSERT(IsIdentifier()); |
| 13525 ConsumeToken(); | 13528 ConsumeToken(); |
| 13526 if (CurrentToken() == Token::kPERIOD) { | 13529 if (CurrentToken() == Token::kPERIOD) { |
| 13527 ConsumeToken(); // Consume the kPERIOD token. | 13530 ConsumeToken(); // Consume the kPERIOD token. |
| 13528 ExpectIdentifier("identifier expected after '.'"); | 13531 ExpectIdentifier("identifier expected after '.'"); |
| 13529 } | 13532 } |
| 13530 } | 13533 } |
| 13531 | 13534 |
| 13532 } // namespace dart | 13535 } // namespace dart |
| OLD | NEW |