OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 fasta.dill_loader; | 5 library fasta.dill_loader; |
6 | 6 |
7 import 'dart:async' show Future; | 7 import 'dart:async' show Future; |
8 | 8 |
9 import 'package:kernel/ast.dart' show Library, Program, Source; | 9 import 'package:kernel/ast.dart' show Library, Program, Source; |
10 | 10 |
| 11 import '../errors.dart' show internalError; |
11 import '../loader.dart' show Loader; | 12 import '../loader.dart' show Loader; |
12 import '../target_implementation.dart' show TargetImplementation; | 13 import '../target_implementation.dart' show TargetImplementation; |
13 import 'dill_library_builder.dart' show DillLibraryBuilder; | 14 import 'dill_library_builder.dart' show DillLibraryBuilder; |
14 | 15 |
15 class DillLoader extends Loader<Library> { | 16 class DillLoader extends Loader<Library> { |
16 /// Source targets are compiled against these binary libraries. | 17 /// Source targets are compiled against these binary libraries. |
17 final libraries = <Library>[]; | 18 final libraries = <Library>[]; |
18 | 19 |
19 /// Sources for all appended programs. | 20 /// Sources for all appended programs. |
20 final Map<String, Source> uriToSource = <String, Source>{}; | 21 final Map<String, Source> uriToSource = <String, Source>{}; |
(...skipping 11 matching lines...) Expand all Loading... |
32 DillLibraryBuilder builder = read(library.importUri, -1); | 33 DillLibraryBuilder builder = read(library.importUri, -1); |
33 builder.library = library; | 34 builder.library = library; |
34 builders.add(builder); | 35 builders.add(builder); |
35 } | 36 } |
36 } | 37 } |
37 uriToSource.addAll(program.uriToSource); | 38 uriToSource.addAll(program.uriToSource); |
38 return builders; | 39 return builders; |
39 } | 40 } |
40 | 41 |
41 Future<Null> buildOutline(DillLibraryBuilder builder) async { | 42 Future<Null> buildOutline(DillLibraryBuilder builder) async { |
| 43 if (builder.library == null) { |
| 44 internalError("Builder.library for ${builder.uri} should not be null."); |
| 45 } |
42 builder.library.classes.forEach(builder.addClass); | 46 builder.library.classes.forEach(builder.addClass); |
43 builder.library.procedures.forEach(builder.addMember); | 47 builder.library.procedures.forEach(builder.addMember); |
44 builder.library.typedefs.forEach(builder.addTypedef); | 48 builder.library.typedefs.forEach(builder.addTypedef); |
45 builder.library.fields.forEach(builder.addMember); | 49 builder.library.fields.forEach(builder.addMember); |
46 } | 50 } |
47 | 51 |
48 Future<Null> buildBody(DillLibraryBuilder builder) { | 52 Future<Null> buildBody(DillLibraryBuilder builder) { |
49 return buildOutline(builder); | 53 return buildOutline(builder); |
50 } | 54 } |
51 } | 55 } |
OLD | NEW |