Chromium Code Reviews| 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 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 360 closureClass = lookupSpecialClass(const SourceString('Closure')); | 360 closureClass = lookupSpecialClass(const SourceString('Closure')); |
| 361 dynamicClass = lookupSpecialClass(const SourceString('Dynamic_')); | 361 dynamicClass = lookupSpecialClass(const SourceString('Dynamic_')); |
| 362 nullClass = lookupSpecialClass(const SourceString('Null')); | 362 nullClass = lookupSpecialClass(const SourceString('Null')); |
| 363 types = new Types(this, dynamicClass); | 363 types = new Types(this, dynamicClass); |
| 364 if (!coreLibValid) { | 364 if (!coreLibValid) { |
| 365 cancel('core library does not contain required classes'); | 365 cancel('core library does not contain required classes'); |
| 366 } | 366 } |
| 367 } | 367 } |
| 368 | 368 |
| 369 void scanBuiltinLibraries() { | 369 void scanBuiltinLibraries() { |
| 370 coreImplLibrary = scanBuiltinLibrary('coreimpl'); | 370 loadCoreImplLibrary(); |
| 371 jsHelperLibrary = scanBuiltinLibrary('_js_helper'); | 371 jsHelperLibrary = scanBuiltinLibrary('_js_helper'); |
| 372 interceptorsLibrary = scanBuiltinLibrary('_interceptors'); | 372 interceptorsLibrary = scanBuiltinLibrary('_interceptors'); |
| 373 | 373 |
| 374 // The core and coreimpl libraries were loaded and patched before | |
| 375 // jsHelperLibrary was initialized, so it wasn't imported into those | |
| 376 // two libraries during patching. | |
| 377 importHelperLibrary(coreLibrary); | |
| 378 importHelperLibrary(coreImplLibrary); | |
| 379 importHelperLibrary(interceptorsLibrary); | |
| 380 | |
| 374 addForeignFunctions(jsHelperLibrary); | 381 addForeignFunctions(jsHelperLibrary); |
| 375 addForeignFunctions(interceptorsLibrary); | 382 addForeignFunctions(interceptorsLibrary); |
| 376 | 383 |
| 377 libraries['dart:core'] = coreLibrary; | |
| 378 libraries['dart:coreimpl'] = coreImplLibrary; | |
| 379 | |
| 380 assertMethod = jsHelperLibrary.find(const SourceString('assert')); | 384 assertMethod = jsHelperLibrary.find(const SourceString('assert')); |
| 381 identicalFunction = coreLibrary.find(const SourceString('identical')); | 385 identicalFunction = coreLibrary.find(const SourceString('identical')); |
|
Lasse Reichstein Nielsen
2012/09/24 13:52:03
These two look like they would belong in (a genera
| |
| 382 | 386 |
| 383 initializeSpecialClasses(); | 387 initializeSpecialClasses(); |
| 384 } | 388 } |
| 385 | 389 |
| 390 void loadCoreImplLibrary() { | |
| 391 Uri coreImplUri = new Uri.fromComponents(scheme: 'dart', path: 'coreimpl'); | |
| 392 coreImplLibrary = scanner.loadLibrary(coreImplUri, null, coreImplUri); | |
| 393 } | |
| 394 | |
| 395 void importHelperLibrary(LibraryElement library) { | |
| 396 if (jsHelperLibrary !== null) { | |
| 397 scanner.importLibrary(library, jsHelperLibrary, null); | |
| 398 } | |
| 399 } | |
| 400 | |
| 386 void importCoreLibrary(LibraryElement library) { | 401 void importCoreLibrary(LibraryElement library) { |
| 387 Uri coreUri = new Uri.fromComponents(scheme: 'dart', path: 'core'); | |
| 388 if (coreLibrary === null) { | 402 if (coreLibrary === null) { |
| 403 Uri coreUri = new Uri.fromComponents(scheme: 'dart', path: 'core'); | |
| 389 coreLibrary = scanner.loadLibrary(coreUri, null, coreUri); | 404 coreLibrary = scanner.loadLibrary(coreUri, null, coreUri); |
| 390 } | 405 } |
| 391 scanner.importLibrary(library, | 406 scanner.importLibrary(library, |
| 392 coreLibrary, | 407 coreLibrary, |
| 393 null, | 408 null, |
| 394 library.entryCompilationUnit); | 409 library.entryCompilationUnit); |
| 395 } | 410 } |
| 396 | 411 |
| 397 void patchDartLibrary(LibraryElement library, String dartLibraryPath) { | 412 void patchDartLibrary(LibraryElement library, String dartLibraryPath) { |
| 398 if (library.isPatched) return; | 413 if (library.isPatched) return; |
| (...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 975 * information in the generated error message. | 990 * information in the generated error message. |
| 976 */ | 991 */ |
| 977 bool invariant(Spannable spannable, var condition, {String message: null}) { | 992 bool invariant(Spannable spannable, var condition, {String message: null}) { |
| 978 // TODO(johnniwinther): Use [spannable] and [message] to provide better | 993 // TODO(johnniwinther): Use [spannable] and [message] to provide better |
| 979 // information on assertion errors. | 994 // information on assertion errors. |
| 980 if (condition is Function){ | 995 if (condition is Function){ |
| 981 condition = condition(); | 996 condition = condition(); |
| 982 } | 997 } |
| 983 return spannable != null && condition; | 998 return spannable != null && condition; |
| 984 } | 999 } |
| OLD | NEW |