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 library dart2js.compiler_base; | 5 library dart2js.compiler_base; |
| 6 | 6 |
| 7 import 'dart:async' show EventSink, Future; | 7 import 'dart:async' show EventSink, Future; |
| 8 | 8 |
| 9 import '../compiler_new.dart' as api; | 9 import '../compiler_new.dart' as api; |
| 10 import 'cache_strategy.dart' show CacheStrategy; | 10 import 'cache_strategy.dart' show CacheStrategy; |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 430 /// been scanned. | 430 /// been scanned. |
| 431 /// | 431 /// |
| 432 /// Use this callback method to store references to specific member declared | 432 /// Use this callback method to store references to specific member declared |
| 433 /// in certain libraries. Note that [library] has not been patched yet, nor | 433 /// in certain libraries. Note that [library] has not been patched yet, nor |
| 434 /// has its imports/exports been resolved. | 434 /// has its imports/exports been resolved. |
| 435 /// | 435 /// |
| 436 /// Use [loader] to register the creation and scanning of a patch library | 436 /// Use [loader] to register the creation and scanning of a patch library |
| 437 /// for [library]. | 437 /// for [library]. |
| 438 Future onLibraryScanned(LibraryElement library, LibraryLoader loader) { | 438 Future onLibraryScanned(LibraryElement library, LibraryLoader loader) { |
| 439 Uri uri = library.canonicalUri; | 439 Uri uri = library.canonicalUri; |
| 440 if (uri == Uris.dart_core) { | 440 // If the script of the library is synthesized, the library does not exist |
| 441 initializeCoreClasses(); | 441 // and we do not try to load the helpers. |
| 442 identicalFunction = coreLibrary.find('identical'); | 442 // |
| 443 } else if (uri == Uris.dart_mirrors) { | 443 // This could for example happen if dart:async is disabled, then loading it |
| 444 mirrorSystemClass = findRequiredElement(library, 'MirrorSystem'); | 444 // should not try to find the given element. |
| 445 mirrorsUsedClass = findRequiredElement(library, 'MirrorsUsed'); | 445 if (!library.compilationUnit.script.isSynthesized) { |
|
Johnni Winther
2016/04/27 07:34:57
-> 'if (!library.isSynthesized) {'
sigurdm
2016/04/27 07:48:17
Does not work for elementz. Added a TODO
| |
| 446 } else if (uri == Uris.dart_async) { | 446 if (uri == Uris.dart_core) { |
| 447 asyncLibrary = library; | 447 initializeCoreClasses(); |
| 448 deferredLibraryClass = findRequiredElement(library, 'DeferredLibrary'); | 448 identicalFunction = coreLibrary.find('identical'); |
| 449 _coreTypes.futureClass = findRequiredElement(library, 'Future'); | 449 } else if (uri == Uris.dart_mirrors) { |
| 450 _coreTypes.streamClass = findRequiredElement(library, 'Stream'); | 450 mirrorSystemClass = findRequiredElement(library, 'MirrorSystem'); |
| 451 } else if (uri == Uris.dart__native_typed_data) { | 451 mirrorsUsedClass = findRequiredElement(library, 'MirrorsUsed'); |
| 452 typedDataClass = findRequiredElement(library, 'NativeTypedData'); | 452 } else if (uri == Uris.dart_async) { |
| 453 } else if (uri == js_backend.BackendHelpers.DART_JS_HELPER) { | 453 asyncLibrary = library; |
| 454 patchAnnotationClass = findRequiredElement(library, '_Patch'); | 454 deferredLibraryClass = findRequiredElement(library, 'DeferredLibrary'); |
| 455 nativeAnnotationClass = findRequiredElement(library, 'Native'); | 455 _coreTypes.futureClass = findRequiredElement(library, 'Future'); |
| 456 _coreTypes.streamClass = findRequiredElement(library, 'Stream'); | |
| 457 } else if (uri == Uris.dart__native_typed_data) { | |
| 458 typedDataClass = findRequiredElement(library, 'NativeTypedData'); | |
| 459 } else if (uri == js_backend.BackendHelpers.DART_JS_HELPER) { | |
| 460 patchAnnotationClass = findRequiredElement(library, '_Patch'); | |
| 461 nativeAnnotationClass = findRequiredElement(library, 'Native'); | |
| 462 } | |
| 456 } | 463 } |
| 457 return backend.onLibraryScanned(library, loader); | 464 return backend.onLibraryScanned(library, loader); |
| 458 } | 465 } |
| 459 | 466 |
| 460 /// Compute the set of distinct import chains to the library at [uri] within | 467 /// Compute the set of distinct import chains to the library at [uri] within |
| 461 /// [loadedLibraries]. | 468 /// [loadedLibraries]. |
| 462 /// | 469 /// |
| 463 /// The chains are strings of the form | 470 /// The chains are strings of the form |
| 464 /// | 471 /// |
| 465 /// <main-uri> => <intermediate-uri1> => <intermediate-uri2> => <uri> | 472 /// <main-uri> => <intermediate-uri1> => <intermediate-uri2> => <uri> |
| (...skipping 1595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2061 _ElementScanner(this.scanner); | 2068 _ElementScanner(this.scanner); |
| 2062 void scanLibrary(LibraryElement library) => scanner.scanLibrary(library); | 2069 void scanLibrary(LibraryElement library) => scanner.scanLibrary(library); |
| 2063 void scanUnit(CompilationUnitElement unit) => scanner.scan(unit); | 2070 void scanUnit(CompilationUnitElement unit) => scanner.scan(unit); |
| 2064 } | 2071 } |
| 2065 | 2072 |
| 2066 class _EmptyEnvironment implements Environment { | 2073 class _EmptyEnvironment implements Environment { |
| 2067 const _EmptyEnvironment(); | 2074 const _EmptyEnvironment(); |
| 2068 | 2075 |
| 2069 String valueOf(String key) => null; | 2076 String valueOf(String key) => null; |
| 2070 } | 2077 } |
| OLD | NEW |