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.kernel_library_builder; | 5 library fasta.kernel_library_builder; |
6 | 6 |
7 import 'package:front_end/src/fasta/dill/dill_library_builder.dart'; | |
8 import 'package:front_end/src/fasta/combinator.dart' as fasta; | 7 import 'package:front_end/src/fasta/combinator.dart' as fasta; |
9 import 'package:front_end/src/fasta/export.dart'; | 8 import 'package:front_end/src/fasta/export.dart'; |
10 import 'package:front_end/src/fasta/import.dart'; | 9 import 'package:front_end/src/fasta/import.dart'; |
11 import 'package:kernel/ast.dart'; | 10 import 'package:kernel/ast.dart'; |
12 | 11 |
13 import 'package:kernel/clone.dart' show CloneVisitor; | 12 import 'package:kernel/clone.dart' show CloneVisitor; |
14 | 13 |
15 import '../../scanner/token.dart' show Token; | 14 import '../../scanner/token.dart' show Token; |
16 | 15 |
17 import '../fasta_codes.dart' | 16 import '../fasta_codes.dart' |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 | 88 |
90 final List<KernelProcedureBuilder> nativeMethods = <KernelProcedureBuilder>[]; | 89 final List<KernelProcedureBuilder> nativeMethods = <KernelProcedureBuilder>[]; |
91 | 90 |
92 final List<KernelTypeVariableBuilder> boundlessTypeVariables = | 91 final List<KernelTypeVariableBuilder> boundlessTypeVariables = |
93 <KernelTypeVariableBuilder>[]; | 92 <KernelTypeVariableBuilder>[]; |
94 | 93 |
95 KernelLibraryBuilder(Uri uri, Uri fileUri, Loader loader, this.isPatch) | 94 KernelLibraryBuilder(Uri uri, Uri fileUri, Loader loader, this.isPatch) |
96 : library = new Library(uri, fileUri: relativizeUri(fileUri)), | 95 : library = new Library(uri, fileUri: relativizeUri(fileUri)), |
97 super(loader, fileUri); | 96 super(loader, fileUri); |
98 | 97 |
| 98 @override |
99 Library get target => library; | 99 Library get target => library; |
100 | 100 |
101 Uri get uri => library.importUri; | 101 Uri get uri => library.importUri; |
102 | 102 |
103 KernelTypeBuilder addNamedType( | 103 KernelTypeBuilder addNamedType( |
104 String name, List<KernelTypeBuilder> arguments, int charOffset) { | 104 String name, List<KernelTypeBuilder> arguments, int charOffset) { |
105 return addType( | 105 return addType( |
106 new KernelNamedTypeBuilder(name, arguments, charOffset, fileUri)); | 106 new KernelNamedTypeBuilder(name, arguments, charOffset, fileUri)); |
107 } | 107 } |
108 | 108 |
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
748 Iterable<fasta.Combinator> fastaCombinators) { | 748 Iterable<fasta.Combinator> fastaCombinators) { |
749 return fastaCombinators?.map((c) { | 749 return fastaCombinators?.map((c) { |
750 List<String> nameList = c.names.toList(); | 750 List<String> nameList = c.names.toList(); |
751 return c.isShow | 751 return c.isShow |
752 ? new Combinator.show(nameList) | 752 ? new Combinator.show(nameList) |
753 : new Combinator.hide(nameList); | 753 : new Combinator.hide(nameList); |
754 })?.toList(); | 754 })?.toList(); |
755 } | 755 } |
756 | 756 |
757 for (Import import in imports) { | 757 for (Import import in imports) { |
758 var importedBuilder = import.imported; | 758 Library importedLibrary = import.imported.target; |
759 Library importedLibrary; | |
760 if (importedBuilder is DillLibraryBuilder) { | |
761 importedLibrary = importedBuilder.library; | |
762 } else if (importedBuilder is KernelLibraryBuilder) { | |
763 importedLibrary = importedBuilder.library; | |
764 } | |
765 if (importedLibrary != null) { | 759 if (importedLibrary != null) { |
766 library.addDependency(new LibraryDependency.import(importedLibrary, | 760 library.addDependency(new LibraryDependency.import(importedLibrary, |
767 name: import.prefix, | 761 name: import.prefix, |
768 combinators: toKernelCombinators(import.combinators))); | 762 combinators: toKernelCombinators(import.combinators))); |
769 } | 763 } |
770 } | 764 } |
771 | 765 |
772 for (Export export in exports) { | 766 for (Export export in exports) { |
773 var exportedBuilder = export.exported; | 767 Library exportedLibrary = export.exported.target; |
774 Library exportedLibrary; | |
775 if (exportedBuilder is DillLibraryBuilder) { | |
776 exportedLibrary = exportedBuilder.library; | |
777 } else if (exportedBuilder is KernelLibraryBuilder) { | |
778 exportedLibrary = exportedBuilder.library; | |
779 } | |
780 if (exportedLibrary != null) { | 768 if (exportedLibrary != null) { |
781 library.addDependency(new LibraryDependency.export(exportedLibrary, | 769 library.addDependency(new LibraryDependency.export(exportedLibrary, |
782 combinators: toKernelCombinators(export.combinators))); | 770 combinators: toKernelCombinators(export.combinators))); |
783 } | 771 } |
784 } | 772 } |
785 | 773 |
786 for (var part in parts) { | 774 for (var part in parts) { |
787 // TODO(scheglov): Add support for annotations, see | 775 // TODO(scheglov): Add support for annotations, see |
788 // https://github.com/dart-lang/sdk/issues/30284. | 776 // https://github.com/dart-lang/sdk/issues/30284. |
789 String fileUri = part.fileUri.toString(); | 777 String fileUri = part.fileUri.toString(); |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
956 mixinApplicationClasses.putIfAbsent(name, () => builder); | 944 mixinApplicationClasses.putIfAbsent(name, () => builder); |
957 if (existing != builder) { | 945 if (existing != builder) { |
958 part.scope.local.remove(name); | 946 part.scope.local.remove(name); |
959 } | 947 } |
960 }); | 948 }); |
961 super.includePart(part); | 949 super.includePart(part); |
962 nativeMethods.addAll(part.nativeMethods); | 950 nativeMethods.addAll(part.nativeMethods); |
963 boundlessTypeVariables.addAll(part.boundlessTypeVariables); | 951 boundlessTypeVariables.addAll(part.boundlessTypeVariables); |
964 } | 952 } |
965 } | 953 } |
OLD | NEW |