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

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

Issue 10949028: Fix for issue 5223 : Import 'dart:core' implicitly only if it has not been (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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 | « runtime/vm/object.cc ('k') | tests/language/import_core_prefix_test.dart » ('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 "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/compiler_stats.h" 10 #include "vm/compiler_stats.h"
(...skipping 4201 matching lines...) Expand 10 before | Expand all | Expand 10 after
4212 ConsumeToken(); 4212 ConsumeToken();
4213 } 4213 }
4214 4214
4215 // TODO(hausner): Remove support for old library definition syntax. 4215 // TODO(hausner): Remove support for old library definition syntax.
4216 if ((CurrentToken() == Token::kLIBRARY) || 4216 if ((CurrentToken() == Token::kLIBRARY) ||
4217 (CurrentToken() == Token::kIMPORT) || 4217 (CurrentToken() == Token::kIMPORT) ||
4218 (CurrentToken() == Token::kSOURCE)) { 4218 (CurrentToken() == Token::kSOURCE)) {
4219 ParseLibraryNameObsoleteSyntax(); 4219 ParseLibraryNameObsoleteSyntax();
4220 ParseLibraryImportObsoleteSyntax(); 4220 ParseLibraryImportObsoleteSyntax();
4221 ParseLibraryIncludeObsoleteSyntax(); 4221 ParseLibraryIncludeObsoleteSyntax();
4222 // Core lib has not been explicitly imported, so we implicitly
4223 // import it here.
4224 if (!library_.ImportsCorelib()) {
4225 Library& core_lib = Library::Handle(Library::CoreLibrary());
4226 ASSERT(!core_lib.IsNull());
4227 library_.AddImport(core_lib);
4228 }
4222 return; 4229 return;
4223 } 4230 }
4224 4231
4225 // We may read metadata tokens that are part of the toplevel 4232 // We may read metadata tokens that are part of the toplevel
4226 // declaration that follows the library definitions. Therefore, we 4233 // declaration that follows the library definitions. Therefore, we
4227 // need to remember the position of the last token that was 4234 // need to remember the position of the last token that was
4228 // successfully consumed. 4235 // successfully consumed.
4229 intptr_t metadata_pos = TokenPos(); 4236 intptr_t metadata_pos = TokenPos();
4230 SkipMetadata(); 4237 SkipMetadata();
4231 if (IsLiteral("library")) { 4238 if (IsLiteral("library")) {
4232 ParseLibraryName(); 4239 ParseLibraryName();
4233 metadata_pos = TokenPos(); 4240 metadata_pos = TokenPos();
4234 SkipMetadata(); 4241 SkipMetadata();
4235 } else if (script_.kind() == RawScript::kLibraryTag) { 4242 } else if (script_.kind() == RawScript::kLibraryTag) {
4236 ErrorMsg("library name definition expected"); 4243 ErrorMsg("library name definition expected");
4237 } 4244 }
4238 while (IsLiteral("import") || IsLiteral("export")) { 4245 while (IsLiteral("import") || IsLiteral("export")) {
4239 ParseLibraryImportExport(); 4246 ParseLibraryImportExport();
4240 metadata_pos = TokenPos(); 4247 metadata_pos = TokenPos();
4241 SkipMetadata(); 4248 SkipMetadata();
4242 } 4249 }
4250 // Core lib has not been explicitly imported, so we implicitly
4251 // import it here.
4252 if (!library_.ImportsCorelib()) {
4253 Library& core_lib = Library::Handle(Library::CoreLibrary());
4254 ASSERT(!core_lib.IsNull());
4255 library_.AddImport(core_lib);
4256 }
4243 while (IsLiteral("part")) { 4257 while (IsLiteral("part")) {
4244 ParseLibraryPart(); 4258 ParseLibraryPart();
4245 metadata_pos = TokenPos(); 4259 metadata_pos = TokenPos();
4246 SkipMetadata(); 4260 SkipMetadata();
4247 } 4261 }
4248 if (IsLiteral("library") || IsLiteral("import") || IsLiteral("export")) { 4262 if (IsLiteral("library") || IsLiteral("import") || IsLiteral("export")) {
4249 ErrorMsg("unexpected token '%s'", CurrentLiteral()->ToCString()); 4263 ErrorMsg("unexpected token '%s'", CurrentLiteral()->ToCString());
4250 } 4264 }
4251 SetPosition(metadata_pos); 4265 SetPosition(metadata_pos);
4252 } 4266 }
(...skipping 5270 matching lines...) Expand 10 before | Expand all | Expand 10 after
9523 void Parser::SkipQualIdent() { 9537 void Parser::SkipQualIdent() {
9524 ASSERT(IsIdentifier()); 9538 ASSERT(IsIdentifier());
9525 ConsumeToken(); 9539 ConsumeToken();
9526 if (CurrentToken() == Token::kPERIOD) { 9540 if (CurrentToken() == Token::kPERIOD) {
9527 ConsumeToken(); // Consume the kPERIOD token. 9541 ConsumeToken(); // Consume the kPERIOD token.
9528 ExpectIdentifier("identifier expected after '.'"); 9542 ExpectIdentifier("identifier expected after '.'");
9529 } 9543 }
9530 } 9544 }
9531 9545
9532 } // namespace dart 9546 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.cc ('k') | tests/language/import_core_prefix_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698