| 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 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 closureClass = lookupSpecialClass(const SourceString('Closure')); | 357 closureClass = lookupSpecialClass(const SourceString('Closure')); |
| 358 dynamicClass = lookupSpecialClass(const SourceString('Dynamic_')); | 358 dynamicClass = lookupSpecialClass(const SourceString('Dynamic_')); |
| 359 nullClass = lookupSpecialClass(const SourceString('Null')); | 359 nullClass = lookupSpecialClass(const SourceString('Null')); |
| 360 types = new Types(this, dynamicClass); | 360 types = new Types(this, dynamicClass); |
| 361 if (!coreLibValid) { | 361 if (!coreLibValid) { |
| 362 cancel('core library does not contain required classes'); | 362 cancel('core library does not contain required classes'); |
| 363 } | 363 } |
| 364 } | 364 } |
| 365 | 365 |
| 366 void scanBuiltinLibraries() { | 366 void scanBuiltinLibraries() { |
| 367 coreImplLibrary = scanBuiltinLibrary('coreimpl'); | 367 loadCoreImplLibrary(); |
| 368 jsHelperLibrary = scanBuiltinLibrary('_js_helper'); | 368 jsHelperLibrary = scanBuiltinLibrary('_js_helper'); |
| 369 interceptorsLibrary = scanBuiltinLibrary('_interceptors'); | 369 interceptorsLibrary = scanBuiltinLibrary('_interceptors'); |
| 370 | 370 |
| 371 // The core and coreimpl libraries were loaded and patched before |
| 372 // jsHelperLibrary was initialized, so it wasn't imported into those |
| 373 // two libraries during patching. |
| 374 importHelperLibrary(coreLibrary); |
| 375 importHelperLibrary(coreImplLibrary); |
| 376 importHelperLibrary(interceptorsLibrary); |
| 377 |
| 371 addForeignFunctions(jsHelperLibrary); | 378 addForeignFunctions(jsHelperLibrary); |
| 372 addForeignFunctions(interceptorsLibrary); | 379 addForeignFunctions(interceptorsLibrary); |
| 373 | 380 |
| 374 libraries['dart:core'] = coreLibrary; | |
| 375 libraries['dart:coreimpl'] = coreImplLibrary; | |
| 376 | |
| 377 assertMethod = jsHelperLibrary.find(const SourceString('assert')); | 381 assertMethod = jsHelperLibrary.find(const SourceString('assert')); |
| 378 identicalFunction = coreLibrary.find(const SourceString('identical')); | 382 identicalFunction = coreLibrary.find(const SourceString('identical')); |
| 379 | 383 |
| 380 initializeSpecialClasses(); | 384 initializeSpecialClasses(); |
| 381 } | 385 } |
| 382 | 386 |
| 387 void loadCoreImplLibrary() { |
| 388 Uri coreImplUri = new Uri.fromComponents(scheme: 'dart', path: 'coreimpl'); |
| 389 coreImplLibrary = scanner.loadLibrary(coreImplUri, null, coreImplUri); |
| 390 } |
| 391 |
| 392 void importHelperLibrary(LibraryElement library) { |
| 393 if (jsHelperLibrary !== null) { |
| 394 scanner.importLibrary(library, jsHelperLibrary, null); |
| 395 } |
| 396 } |
| 397 |
| 383 void importCoreLibrary(LibraryElement library) { | 398 void importCoreLibrary(LibraryElement library) { |
| 384 Uri coreUri = new Uri.fromComponents(scheme: 'dart', path: 'core'); | |
| 385 if (coreLibrary === null) { | 399 if (coreLibrary === null) { |
| 400 Uri coreUri = new Uri.fromComponents(scheme: 'dart', path: 'core'); |
| 386 coreLibrary = scanner.loadLibrary(coreUri, null, coreUri); | 401 coreLibrary = scanner.loadLibrary(coreUri, null, coreUri); |
| 387 } | 402 } |
| 388 scanner.importLibrary(library, | 403 scanner.importLibrary(library, |
| 389 coreLibrary, | 404 coreLibrary, |
| 390 null, | 405 null, |
| 391 library.entryCompilationUnit); | 406 library.entryCompilationUnit); |
| 392 } | 407 } |
| 393 | 408 |
| 394 void patchDartLibrary(LibraryElement library, String dartLibraryPath) { | 409 void patchDartLibrary(LibraryElement library, String dartLibraryPath) { |
| 395 if (library.isPatched) return; | 410 if (library.isPatched) return; |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 835 * information in the generated error message. | 850 * information in the generated error message. |
| 836 */ | 851 */ |
| 837 bool invariant(Spannable spannable, var condition, {String message: null}) { | 852 bool invariant(Spannable spannable, var condition, {String message: null}) { |
| 838 // TODO(johnniwinther): Use [spannable] and [message] to provide better | 853 // TODO(johnniwinther): Use [spannable] and [message] to provide better |
| 839 // information on assertion errors. | 854 // information on assertion errors. |
| 840 if (condition is Function){ | 855 if (condition is Function){ |
| 841 condition = condition(); | 856 condition = condition(); |
| 842 } | 857 } |
| 843 return spannable != null && condition; | 858 return spannable != null && condition; |
| 844 } | 859 } |
| OLD | NEW |