| 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 final bool REPORT_EXCESS_RESOLUTION = false; | 10 final bool REPORT_EXCESS_RESOLUTION = false; |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 } | 342 } |
| 343 | 343 |
| 344 jsIndexingBehaviorInterface = | 344 jsIndexingBehaviorInterface = |
| 345 findHelper(const SourceString('JavaScriptIndexingBehavior')); | 345 findHelper(const SourceString('JavaScriptIndexingBehavior')); |
| 346 } | 346 } |
| 347 | 347 |
| 348 void scanBuiltinLibraries() { | 348 void scanBuiltinLibraries() { |
| 349 coreImplLibrary = scanBuiltinLibrary('coreimpl'); | 349 coreImplLibrary = scanBuiltinLibrary('coreimpl'); |
| 350 jsHelperLibrary = scanBuiltinLibrary('_js_helper'); | 350 jsHelperLibrary = scanBuiltinLibrary('_js_helper'); |
| 351 interceptorsLibrary = scanBuiltinLibrary('_interceptors'); | 351 interceptorsLibrary = scanBuiltinLibrary('_interceptors'); |
| 352 coreLibrary = scanBuiltinLibrary('core'); | |
| 353 | 352 |
| 354 // Since coreLibrary import the libraries "coreimpl", "js_helper", | |
| 355 // and "interceptors", coreLibrary is null when they are being | |
| 356 // built. So we add the implicit import of coreLibrary now. This | |
| 357 // can be cleaned up when we have proper support for "dart:core" | |
| 358 // and don't need to access it through the field "coreLibrary". | |
| 359 // TODO(ahe): Clean this up as described above. | |
| 360 scanner.importLibrary(coreImplLibrary, coreLibrary, null); | |
| 361 scanner.importLibrary(jsHelperLibrary, coreLibrary, null); | |
| 362 scanner.importLibrary(interceptorsLibrary, coreLibrary, null); | |
| 363 addForeignFunctions(jsHelperLibrary); | 353 addForeignFunctions(jsHelperLibrary); |
| 364 addForeignFunctions(interceptorsLibrary); | 354 addForeignFunctions(interceptorsLibrary); |
| 365 | 355 |
| 366 libraries['dart:core'] = coreLibrary; | 356 libraries['dart:core'] = coreLibrary; |
| 367 libraries['dart:coreimpl'] = coreImplLibrary; | 357 libraries['dart:coreimpl'] = coreImplLibrary; |
| 368 | 358 |
| 369 assertMethod = coreLibrary.find(const SourceString('assert')); | 359 assertMethod = coreLibrary.find(const SourceString('assert')); |
| 370 | 360 |
| 371 initializeSpecialClasses(); | 361 initializeSpecialClasses(); |
| 372 | 362 |
| 373 //patchDartLibrary(coreLibrary, 'core'); | 363 //patchDartLibrary(coreLibrary, 'core'); |
| 374 //patchDartLibrary(coreImplLibrary, 'coreimpl'); | 364 //patchDartLibrary(coreImplLibrary, 'coreimpl'); |
| 375 } | 365 } |
| 376 | 366 |
| 367 void importCoreLibrary(LibraryElement library) { |
| 368 Uri coreUri = new Uri.fromComponents(scheme: 'dart', path: 'core'); |
| 369 if (coreLibrary === null) { |
| 370 coreLibrary = scanner.loadLibrary(coreUri, null, coreUri); |
| 371 } |
| 372 scanner.importLibrary(library, |
| 373 coreLibrary, |
| 374 null, |
| 375 library.entryCompilationUnit); |
| 376 } |
| 377 |
| 377 void patchDartLibrary(LibraryElement library, String dartLibraryPath) { | 378 void patchDartLibrary(LibraryElement library, String dartLibraryPath) { |
| 378 if (library.isPatched) return; | 379 if (library.isPatched) return; |
| 379 Uri patchUri = resolvePatchUri(dartLibraryPath); | 380 Uri patchUri = resolvePatchUri(dartLibraryPath); |
| 380 if (patchUri !== null) { | 381 if (patchUri !== null) { |
| 381 patchParser.patchLibrary(patchUri, library); | 382 patchParser.patchLibrary(patchUri, library); |
| 382 // We allow foreign functions in patched libraries. | 383 // We allow foreign functions in patched libraries. |
| 383 addForeignFunctions(library); // Is safe even if already added. | 384 addForeignFunctions(library); // Is safe even if already added. |
| 384 // TODO(lrn): Make this lazy. | 385 // TODO(lrn): Make this lazy. |
| 385 applyClassPatches(library); | 386 applyClassPatches(library); |
| 386 } | 387 } |
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 935 final endOffset = end.charOffset + end.slowCharCount; | 936 final endOffset = end.charOffset + end.slowCharCount; |
| 936 | 937 |
| 937 // [begin] and [end] might be the same for the same empty token. This | 938 // [begin] and [end] might be the same for the same empty token. This |
| 938 // happens for instance when scanning '$$'. | 939 // happens for instance when scanning '$$'. |
| 939 assert(endOffset >= beginOffset); | 940 assert(endOffset >= beginOffset); |
| 940 return f(beginOffset, endOffset); | 941 return f(beginOffset, endOffset); |
| 941 } | 942 } |
| 942 | 943 |
| 943 String toString() => 'SourceSpan($uri, $begin, $end)'; | 944 String toString() => 'SourceSpan($uri, $begin, $end)'; |
| 944 } | 945 } |
| OLD | NEW |