Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(709)

Side by Side Diff: runtime/vm/parser.cc

Issue 22460008: Fix attempt to find metadata of a library with no metadata. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/lib/lib.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "vm/bigint_operations.h" 8 #include "vm/bigint_operations.h"
9 #include "vm/bootstrap.h" 9 #include "vm/bootstrap.h"
10 #include "vm/class_finalizer.h" 10 #include "vm/class_finalizer.h"
(...skipping 4725 matching lines...) Expand 10 before | Expand all | Expand 10 after
4736 // Nothing to do for script tags except to skip them. 4736 // Nothing to do for script tags except to skip them.
4737 ConsumeToken(); 4737 ConsumeToken();
4738 } 4738 }
4739 4739
4740 ASSERT(script_.kind() != RawScript::kSourceTag); 4740 ASSERT(script_.kind() != RawScript::kSourceTag);
4741 4741
4742 // We may read metadata tokens that are part of the toplevel 4742 // We may read metadata tokens that are part of the toplevel
4743 // declaration that follows the library definitions. Therefore, we 4743 // declaration that follows the library definitions. Therefore, we
4744 // need to remember the position of the last token that was 4744 // need to remember the position of the last token that was
4745 // successfully consumed. 4745 // successfully consumed.
4746 intptr_t metadata_pos = TokenPos(); 4746 intptr_t pre_metadata_pos = TokenPos();
rmacnak 2013/08/07 23:30:37 Questionable name
hausner 2013/08/08 07:55:17 How about naming it rewind_pos or fallback_pos? O
rmacnak 2013/08/08 16:49:28 Much better.
4747 SkipMetadata(); 4747 intptr_t metadata_pos = SkipMetadata();
4748 if (CurrentToken() == Token::kLIBRARY) { 4748 if (CurrentToken() == Token::kLIBRARY) {
4749 if (is_patch_source()) { 4749 if (is_patch_source()) {
4750 ErrorMsg("patch cannot override library name"); 4750 ErrorMsg("patch cannot override library name");
4751 } 4751 }
4752 ParseLibraryName(); 4752 ParseLibraryName();
4753 if (metadata_pos >= 0) { 4753 if (metadata_pos >= 0) {
4754 library_.AddLibraryMetadata(current_class(), metadata_pos); 4754 library_.AddLibraryMetadata(current_class(), metadata_pos);
4755 } 4755 }
4756 metadata_pos = TokenPos(); 4756 pre_metadata_pos = TokenPos();
4757 SkipMetadata(); 4757 SkipMetadata();
hausner 2013/08/08 07:55:17 Even though we are not using the metadata for impo
rmacnak 2013/08/08 16:49:28 Got 'em.
4758 } 4758 }
4759 while ((CurrentToken() == Token::kIMPORT) || 4759 while ((CurrentToken() == Token::kIMPORT) ||
4760 (CurrentToken() == Token::kEXPORT)) { 4760 (CurrentToken() == Token::kEXPORT)) {
4761 ParseLibraryImportExport(); 4761 ParseLibraryImportExport();
4762 metadata_pos = TokenPos(); 4762 pre_metadata_pos = TokenPos();
4763 SkipMetadata(); 4763 SkipMetadata();
hausner 2013/08/08 07:55:17 ditto
4764 } 4764 }
4765 // Core lib has not been explicitly imported, so we implicitly 4765 // Core lib has not been explicitly imported, so we implicitly
4766 // import it here. 4766 // import it here.
4767 if (!library_.ImportsCorelib()) { 4767 if (!library_.ImportsCorelib()) {
4768 Library& core_lib = Library::Handle(Library::CoreLibrary()); 4768 Library& core_lib = Library::Handle(Library::CoreLibrary());
4769 ASSERT(!core_lib.IsNull()); 4769 ASSERT(!core_lib.IsNull());
4770 const Namespace& core_ns = Namespace::Handle( 4770 const Namespace& core_ns = Namespace::Handle(
4771 Namespace::New(core_lib, Object::null_array(), Object::null_array())); 4771 Namespace::New(core_lib, Object::null_array(), Object::null_array()));
4772 library_.AddImport(core_ns); 4772 library_.AddImport(core_ns);
4773 } 4773 }
4774 while (CurrentToken() == Token::kPART) { 4774 while (CurrentToken() == Token::kPART) {
4775 ParseLibraryPart(); 4775 ParseLibraryPart();
4776 metadata_pos = TokenPos(); 4776 pre_metadata_pos = TokenPos();
4777 SkipMetadata(); 4777 SkipMetadata();
hausner 2013/08/08 07:55:17 ditto
4778 } 4778 }
4779 SetPosition(metadata_pos); 4779 SetPosition(pre_metadata_pos);
4780 } 4780 }
4781 4781
4782 4782
4783 void Parser::ParsePartHeader() { 4783 void Parser::ParsePartHeader() {
4784 SkipMetadata(); 4784 SkipMetadata();
4785 if (CurrentToken() != Token::kPART) { 4785 if (CurrentToken() != Token::kPART) {
4786 ErrorMsg("'part of' expected"); 4786 ErrorMsg("'part of' expected");
4787 } 4787 }
4788 ConsumeToken(); 4788 ConsumeToken();
4789 if (!IsLiteral("of")) { 4789 if (!IsLiteral("of")) {
(...skipping 5501 matching lines...) Expand 10 before | Expand all | Expand 10 after
10291 void Parser::SkipQualIdent() { 10291 void Parser::SkipQualIdent() {
10292 ASSERT(IsIdentifier()); 10292 ASSERT(IsIdentifier());
10293 ConsumeToken(); 10293 ConsumeToken();
10294 if (CurrentToken() == Token::kPERIOD) { 10294 if (CurrentToken() == Token::kPERIOD) {
10295 ConsumeToken(); // Consume the kPERIOD token. 10295 ConsumeToken(); // Consume the kPERIOD token.
10296 ExpectIdentifier("identifier expected after '.'"); 10296 ExpectIdentifier("identifier expected after '.'");
10297 } 10297 }
10298 } 10298 }
10299 10299
10300 } // namespace dart 10300 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | tests/lib/lib.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698