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/bootstrap.h" | 9 #include "vm/bootstrap.h" |
10 #include "vm/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
(...skipping 8552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8563 current_class(), type, ClassFinalizer::kCanonicalize); | 8563 current_class(), type, ClassFinalizer::kCanonicalize); |
8564 // Type may be malbounded, but not malformed. | 8564 // Type may be malbounded, but not malformed. |
8565 ASSERT(!type.IsMalformed()); | 8565 ASSERT(!type.IsMalformed()); |
8566 selector = new TypeNode(primary_pos, type); | 8566 selector = new TypeNode(primary_pos, type); |
8567 } else { | 8567 } else { |
8568 UNREACHABLE(); // Internal parser error. | 8568 UNREACHABLE(); // Internal parser error. |
8569 } | 8569 } |
8570 } else { | 8570 } else { |
8571 // Left is not a primary node; this must be a closure call. | 8571 // Left is not a primary node; this must be a closure call. |
8572 AstNode* closure = left; | 8572 AstNode* closure = left; |
| 8573 if (parsing_metadata_) { |
| 8574 // Compiling closure calls involves saving the current context based |
| 8575 // on the current function, and metadata has no current function. |
| 8576 // Fail early rather than limping along only to discover later that |
| 8577 // we parsed something that isn't a compile-time constant. |
| 8578 ErrorMsg(closure->token_pos(), |
| 8579 "expression is not a valid compile-time constant"); |
| 8580 } |
8573 selector = ParseClosureCall(closure); | 8581 selector = ParseClosureCall(closure); |
8574 } | 8582 } |
8575 } else { | 8583 } else { |
8576 // No (more) selectors to parse. | 8584 // No (more) selectors to parse. |
8577 left = LoadFieldIfUnresolved(left); | 8585 left = LoadFieldIfUnresolved(left); |
8578 if (left->IsPrimaryNode()) { | 8586 if (left->IsPrimaryNode()) { |
8579 PrimaryNode* primary_node = left->AsPrimaryNode(); | 8587 PrimaryNode* primary_node = left->AsPrimaryNode(); |
8580 const intptr_t primary_pos = primary->token_pos(); | 8588 const intptr_t primary_pos = primary->token_pos(); |
8581 if (primary_node->primary().IsFunction()) { | 8589 if (primary_node->primary().IsFunction()) { |
8582 // Treat as implicit closure. | 8590 // Treat as implicit closure. |
(...skipping 2195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10778 void Parser::SkipQualIdent() { | 10786 void Parser::SkipQualIdent() { |
10779 ASSERT(IsIdentifier()); | 10787 ASSERT(IsIdentifier()); |
10780 ConsumeToken(); | 10788 ConsumeToken(); |
10781 if (CurrentToken() == Token::kPERIOD) { | 10789 if (CurrentToken() == Token::kPERIOD) { |
10782 ConsumeToken(); // Consume the kPERIOD token. | 10790 ConsumeToken(); // Consume the kPERIOD token. |
10783 ExpectIdentifier("identifier expected after '.'"); | 10791 ExpectIdentifier("identifier expected after '.'"); |
10784 } | 10792 } |
10785 } | 10793 } |
10786 | 10794 |
10787 } // namespace dart | 10795 } // namespace dart |
OLD | NEW |