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.library_loader; | 5 library dart2js.library_loader; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'common/names.dart' show Uris; | 9 import 'common/names.dart' show Uris; |
10 import 'common/tasks.dart' show CompilerTask; | 10 import 'common/tasks.dart' show CompilerTask; |
(...skipping 11 matching lines...) Expand all Loading... |
22 CompilationUnitElementX, | 22 CompilationUnitElementX, |
23 DeferredLoaderGetterElementX, | 23 DeferredLoaderGetterElementX, |
24 ErroneousElementX, | 24 ErroneousElementX, |
25 ExportElementX, | 25 ExportElementX, |
26 ImportElementX, | 26 ImportElementX, |
27 LibraryElementX, | 27 LibraryElementX, |
28 LibraryDependencyElementX, | 28 LibraryDependencyElementX, |
29 PrefixElementX, | 29 PrefixElementX, |
30 SyntheticImportElement; | 30 SyntheticImportElement; |
31 import 'environment.dart'; | 31 import 'environment.dart'; |
| 32 import 'resolved_uri_translator.dart'; |
32 import 'script.dart'; | 33 import 'script.dart'; |
33 import 'serialization/serialization.dart' show LibraryDeserializer; | 34 import 'serialization/serialization.dart' show LibraryDeserializer; |
34 import 'tree/tree.dart'; | 35 import 'tree/tree.dart'; |
35 import 'util/util.dart' show Link, LinkBuilder; | 36 import 'util/util.dart' show Link, LinkBuilder; |
36 | 37 |
37 /** | 38 /** |
38 * [CompilerTask] for loading libraries and setting up the import/export scopes. | 39 * [CompilerTask] for loading libraries and setting up the import/export scopes. |
39 * | 40 * |
40 * The library loader uses four different kinds of URIs in different parts of | 41 * The library loader uses four different kinds of URIs in different parts of |
41 * the loading process. | 42 * the loading process. |
(...skipping 1355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1397 suffixChainMap[library] = suffixes; | 1398 suffixChainMap[library] = suffixes; |
1398 return; | 1399 return; |
1399 } | 1400 } |
1400 | 1401 |
1401 computeSuffixes(rootLibrary, const Link<Uri>()); | 1402 computeSuffixes(rootLibrary, const Link<Uri>()); |
1402 } | 1403 } |
1403 | 1404 |
1404 String toString() => 'root=$rootLibrary,libraries=${loadedLibraries.keys}'; | 1405 String toString() => 'root=$rootLibrary,libraries=${loadedLibraries.keys}'; |
1405 } | 1406 } |
1406 | 1407 |
1407 /// API used by the library loader to translate internal SDK URIs into file | |
1408 /// system readable URIs. | |
1409 abstract class ResolvedUriTranslator { | |
1410 // TODO(sigmund): move here the comments from library loader. | |
1411 /// Translate the resolved [uri] in the context of [importingLibrary]. | |
1412 /// | |
1413 /// Use [spannable] for error reporting. | |
1414 Uri translate(LibraryElement importingLibrary, Uri uri, | |
1415 [Spannable spannable]); | |
1416 } | |
1417 | |
1418 // TODO(sigmund): remove ScriptLoader & ElementScanner. Such abstraction seems | 1408 // TODO(sigmund): remove ScriptLoader & ElementScanner. Such abstraction seems |
1419 // rather low-level. It might be more practical to split the library-loading | 1409 // rather low-level. It might be more practical to split the library-loading |
1420 // task itself. The task would continue to do the work of recursively loading | 1410 // task itself. The task would continue to do the work of recursively loading |
1421 // dependencies, but it can delegate to a set of subloaders how to do the actual | 1411 // dependencies, but it can delegate to a set of subloaders how to do the actual |
1422 // loading. We would then have a list of subloaders that use different | 1412 // loading. We would then have a list of subloaders that use different |
1423 // implementations: in-memory cache, deserialization, scanning from files. | 1413 // implementations: in-memory cache, deserialization, scanning from files. |
1424 // | 1414 // |
1425 // For example, the API might look like this: | 1415 // For example, the API might look like this: |
1426 // | 1416 // |
1427 // /// APIs to create [LibraryElement] and [CompilationUnitElements] given it's | 1417 // /// APIs to create [LibraryElement] and [CompilationUnitElements] given it's |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1474 /// Called after a request to load a library. The [results] will include all | 1464 /// Called after a request to load a library. The [results] will include all |
1475 /// transitive libraries loaded as a result of the initial request. | 1465 /// transitive libraries loaded as a result of the initial request. |
1476 Future onLibrariesLoaded(LoadedLibraries results); | 1466 Future onLibrariesLoaded(LoadedLibraries results); |
1477 | 1467 |
1478 /// Called whenever a library element is created. | 1468 /// Called whenever a library element is created. |
1479 void onLibraryCreated(LibraryElement library); | 1469 void onLibraryCreated(LibraryElement library); |
1480 | 1470 |
1481 /// Called whenever a library is scanned from a script file. | 1471 /// Called whenever a library is scanned from a script file. |
1482 Future onLibraryScanned(LibraryElement library, LibraryLoader loader); | 1472 Future onLibraryScanned(LibraryElement library, LibraryLoader loader); |
1483 } | 1473 } |
OLD | NEW |