| 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 | 5 |
| 6 /** | 6 /** |
| 7 * If true, print a warning for each method that was resolved, but not | 7 * If true, print a warning for each method that was resolved, but not |
| 8 * compiled. | 8 * compiled. |
| 9 */ | 9 */ |
| 10 const bool REPORT_EXCESS_RESOLUTION = false; | 10 const bool REPORT_EXCESS_RESOLUTION = false; |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 | 376 |
| 377 libraries['dart:core'] = coreLibrary; | 377 libraries['dart:core'] = coreLibrary; |
| 378 libraries['dart:coreimpl'] = coreImplLibrary; | 378 libraries['dart:coreimpl'] = coreImplLibrary; |
| 379 | 379 |
| 380 assertMethod = jsHelperLibrary.find(const SourceString('assert')); | 380 assertMethod = jsHelperLibrary.find(const SourceString('assert')); |
| 381 identicalFunction = coreLibrary.find(const SourceString('identical')); | 381 identicalFunction = coreLibrary.find(const SourceString('identical')); |
| 382 | 382 |
| 383 initializeSpecialClasses(); | 383 initializeSpecialClasses(); |
| 384 } | 384 } |
| 385 | 385 |
| 386 void importCoreLibrary(LibraryElement library) { | 386 /** |
| 387 * Lazily loads and returns the [LibraryElement] for the dart:core library. |
| 388 */ |
| 389 LibraryElement importCoreLibrary(ImportExportHandler handler) { |
| 387 Uri coreUri = new Uri.fromComponents(scheme: 'dart', path: 'core'); | 390 Uri coreUri = new Uri.fromComponents(scheme: 'dart', path: 'core'); |
| 388 if (coreLibrary === null) { | 391 if (coreLibrary === null) { |
| 389 coreLibrary = scanner.loadLibrary(coreUri, null, coreUri); | 392 coreLibrary = |
| 393 scanner.loadLibraryInternal(handler, coreUri, null, coreUri); |
| 390 } | 394 } |
| 391 scanner.importLibrary(library, | 395 return coreLibrary; |
| 392 coreLibrary, | |
| 393 null, | |
| 394 library.entryCompilationUnit); | |
| 395 } | 396 } |
| 396 | 397 |
| 397 void patchDartLibrary(LibraryElement library, String dartLibraryPath) { | 398 void patchDartLibrary(ImportExportHandler handler, |
| 399 LibraryElement library, String dartLibraryPath) { |
| 398 if (library.isPatched) return; | 400 if (library.isPatched) return; |
| 399 Uri patchUri = resolvePatchUri(dartLibraryPath); | 401 Uri patchUri = resolvePatchUri(dartLibraryPath); |
| 400 if (patchUri !== null) { | 402 if (patchUri !== null) { |
| 401 patchParser.patchLibrary(patchUri, library); | 403 patchParser.patchLibrary(handler, patchUri, library); |
| 402 } | 404 } |
| 403 } | 405 } |
| 404 | 406 |
| 405 void applyContainerPatch(ScopeContainerElement original, | 407 void applyContainerPatch(ScopeContainerElement original, |
| 406 Link<Element> patches) { | 408 Link<Element> patches) { |
| 407 while (!patches.isEmpty()) { | 409 while (!patches.isEmpty()) { |
| 408 Element patchElement = patches.head; | 410 Element patchElement = patches.head; |
| 409 Element originalElement = original.localLookup(patchElement.name); | 411 Element originalElement = original.localLookup(patchElement.name); |
| 410 if (patchElement.isAccessor() && originalElement !== null) { | 412 if (patchElement.isAccessor() && originalElement !== null) { |
| 411 if (originalElement.kind !== ElementKind.ABSTRACT_FIELD) { | 413 if (originalElement.kind !== ElementKind.ABSTRACT_FIELD) { |
| (...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 975 * information in the generated error message. | 977 * information in the generated error message. |
| 976 */ | 978 */ |
| 977 bool invariant(Spannable spannable, var condition, {String message: null}) { | 979 bool invariant(Spannable spannable, var condition, {String message: null}) { |
| 978 // TODO(johnniwinther): Use [spannable] and [message] to provide better | 980 // TODO(johnniwinther): Use [spannable] and [message] to provide better |
| 979 // information on assertion errors. | 981 // information on assertion errors. |
| 980 if (condition is Function){ | 982 if (condition is Function){ |
| 981 condition = condition(); | 983 condition = condition(); |
| 982 } | 984 } |
| 983 return spannable != null && condition; | 985 return spannable != null && condition; |
| 984 } | 986 } |
| OLD | NEW |