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.dart'; | |
10 import 'common/names.dart' show Uris; | 9 import 'common/names.dart' show Uris; |
11 import 'common/tasks.dart' show CompilerTask; | 10 import 'common/tasks.dart' show CompilerTask; |
| 11 import 'common.dart'; |
12 import 'compiler.dart' show Compiler; | 12 import 'compiler.dart' show Compiler; |
13 import 'elements/elements.dart' | 13 import 'elements/elements.dart' |
14 show | 14 show |
15 CompilationUnitElement, | 15 CompilationUnitElement, |
16 Element, | 16 Element, |
17 ImportElement, | 17 ImportElement, |
18 ExportElement, | 18 ExportElement, |
19 LibraryElement, | 19 LibraryElement; |
20 PrefixElement; | |
21 import 'elements/modelx.dart' | 20 import 'elements/modelx.dart' |
22 show | 21 show |
23 CompilationUnitElementX, | 22 CompilationUnitElementX, |
24 DeferredLoaderGetterElementX, | 23 DeferredLoaderGetterElementX, |
25 ErroneousElementX, | 24 ErroneousElementX, |
26 ExportElementX, | 25 ExportElementX, |
27 ImportElementX, | 26 ImportElementX, |
28 LibraryElementX, | 27 LibraryElementX, |
29 LibraryDependencyElementX, | 28 LibraryDependencyElementX, |
30 PrefixElementX, | 29 PrefixElementX, |
31 SyntheticImportElement; | 30 SyntheticImportElement; |
32 import 'environment.dart'; | 31 import 'environment.dart'; |
| 32 import 'resolved_uri_translator.dart'; |
33 import 'script.dart'; | 33 import 'script.dart'; |
34 import 'serialization/serialization.dart' show LibraryDeserializer; | 34 import 'serialization/serialization.dart' show LibraryDeserializer; |
35 import 'tree/tree.dart'; | 35 import 'tree/tree.dart'; |
36 import 'util/util.dart' show Link, LinkBuilder; | 36 import 'util/util.dart' show Link, LinkBuilder; |
37 | 37 |
38 /** | 38 /** |
39 * [CompilerTask] for loading libraries and setting up the import/export scopes. | 39 * [CompilerTask] for loading libraries and setting up the import/export scopes. |
40 * | 40 * |
41 * 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 |
42 * the loading process. | 42 * the loading process. |
(...skipping 1355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1398 suffixChainMap[library] = suffixes; | 1398 suffixChainMap[library] = suffixes; |
1399 return; | 1399 return; |
1400 } | 1400 } |
1401 | 1401 |
1402 computeSuffixes(rootLibrary, const Link<Uri>()); | 1402 computeSuffixes(rootLibrary, const Link<Uri>()); |
1403 } | 1403 } |
1404 | 1404 |
1405 String toString() => 'root=$rootLibrary,libraries=${loadedLibraries.keys}'; | 1405 String toString() => 'root=$rootLibrary,libraries=${loadedLibraries.keys}'; |
1406 } | 1406 } |
1407 | 1407 |
1408 /// API used by the library loader to translate internal SDK URIs into file | |
1409 /// system readable URIs. | |
1410 abstract class ResolvedUriTranslator { | |
1411 // TODO(sigmund): move here the comments from library loader. | |
1412 /// Translate the resolved [uri] in the context of [importingLibrary]. | |
1413 /// | |
1414 /// Use [spannable] for error reporting. | |
1415 Uri translate(LibraryElement importingLibrary, Uri uri, | |
1416 [Spannable spannable]); | |
1417 } | |
1418 | |
1419 // TODO(sigmund): remove ScriptLoader & ElementScanner. Such abstraction seems | 1408 // TODO(sigmund): remove ScriptLoader & ElementScanner. Such abstraction seems |
1420 // 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 |
1421 // 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 |
1422 // 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 |
1423 // 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 |
1424 // implementations: in-memory cache, deserialization, scanning from files. | 1413 // implementations: in-memory cache, deserialization, scanning from files. |
1425 // | 1414 // |
1426 // For example, the API might look like this: | 1415 // For example, the API might look like this: |
1427 // | 1416 // |
1428 // /// 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... |
1475 /// 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 |
1476 /// transitive libraries loaded as a result of the initial request. | 1465 /// transitive libraries loaded as a result of the initial request. |
1477 Future onLibrariesLoaded(LoadedLibraries results); | 1466 Future onLibrariesLoaded(LoadedLibraries results); |
1478 | 1467 |
1479 /// Called whenever a library element is created. | 1468 /// Called whenever a library element is created. |
1480 void onLibraryCreated(LibraryElement library); | 1469 void onLibraryCreated(LibraryElement library); |
1481 | 1470 |
1482 /// Called whenever a library is scanned from a script file. | 1471 /// Called whenever a library is scanned from a script file. |
1483 Future onLibraryScanned(LibraryElement library, LibraryLoader loader); | 1472 Future onLibraryScanned(LibraryElement library, LibraryLoader loader); |
1484 } | 1473 } |
OLD | NEW |