| 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 class ScannerTask extends CompilerTask { | 5 class ScannerTask extends CompilerTask { |
| 6 ScannerTask(Compiler compiler) : super(compiler); | 6 ScannerTask(Compiler compiler) : super(compiler); |
| 7 String get name() => 'Scanner'; | 7 String get name() => 'Scanner'; |
| 8 | 8 |
| 9 void scanLibrary(LibraryElement library) { | 9 void scanLibrary(LibraryElement library) { |
| 10 var compilationUnit = library.entryCompilationUnit; | 10 var compilationUnit = library.entryCompilationUnit; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 } | 71 } |
| 72 | 72 |
| 73 // Apply patch, if any. | 73 // Apply patch, if any. |
| 74 if (library.uri.scheme == 'dart') { | 74 if (library.uri.scheme == 'dart') { |
| 75 compiler.patchDartLibrary(library, library.uri.path); | 75 compiler.patchDartLibrary(library, library.uri.path); |
| 76 } | 76 } |
| 77 | 77 |
| 78 // Now that we have processed all the source tags, it is safe to | 78 // Now that we have processed all the source tags, it is safe to |
| 79 // start loading other libraries. | 79 // start loading other libraries. |
| 80 | 80 |
| 81 // TODO(ahe): During Compiler.scanBuiltinLibraries, | 81 if (library.uri.scheme != 'dart' || library.uri.path != 'core') { |
| 82 // compiler.coreLibrary is null. Clean this up when there is a | 82 compiler.importCoreLibrary(library); |
| 83 // better way to access "dart:core". | 83 } |
| 84 bool implicitlyImportCoreLibrary = compiler.coreLibrary !== null; | |
| 85 | 84 |
| 86 for (ScriptTag tag in imports.toLink()) { | 85 for (ScriptTag tag in imports.toLink()) { |
| 87 Uri resolvedUri = | 86 importLibraryFromTag(tag, library.entryCompilationUnit); |
| 88 importLibraryFromTag(tag, library.entryCompilationUnit); | |
| 89 if (resolvedUri.toString() == "dart:core") { | |
| 90 implicitlyImportCoreLibrary = false; | |
| 91 } | |
| 92 } | |
| 93 if (implicitlyImportCoreLibrary) { | |
| 94 importLibrary(library, compiler.coreLibrary, null); | |
| 95 } | 87 } |
| 96 } | 88 } |
| 97 | 89 |
| 98 /** | 90 /** |
| 99 * Handle an import script tag by importing the referenced library into the | 91 * Handle an import script tag by importing the referenced library into the |
| 100 * current library. | 92 * current library. |
| 101 * Returns the resolved library [Uri]. | 93 * Returns the resolved library [Uri]. |
| 102 */ | 94 */ |
| 103 Uri importLibraryFromTag(ScriptTag tag, | 95 Uri importLibraryFromTag(ScriptTag tag, |
| 104 CompilationUnitElement compilationUnit) { | 96 CompilationUnitElement compilationUnit) { |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 static final int RESOURCE = 4; | 221 static final int RESOURCE = 4; |
| 230 | 222 |
| 231 /** Next state. */ | 223 /** Next state. */ |
| 232 static final List<int> NEXT = | 224 static final List<int> NEXT = |
| 233 const <int>[NO_TAG_SEEN, | 225 const <int>[NO_TAG_SEEN, |
| 234 IMPORT, // Only one library tag is allowed. | 226 IMPORT, // Only one library tag is allowed. |
| 235 IMPORT, | 227 IMPORT, |
| 236 SOURCE, | 228 SOURCE, |
| 237 RESOURCE]; | 229 RESOURCE]; |
| 238 } | 230 } |
| OLD | NEW |