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'; | 7 import 'package:front_end/src/fasta/dill/dill_library_builder.dart'; |
| 8 import 'package:front_end/src/fasta/combinator.dart' as fasta; |
8 import 'package:front_end/src/fasta/export.dart'; | 9 import 'package:front_end/src/fasta/export.dart'; |
9 import 'package:front_end/src/fasta/import.dart'; | 10 import 'package:front_end/src/fasta/import.dart'; |
10 import 'package:kernel/ast.dart'; | 11 import 'package:kernel/ast.dart'; |
11 | 12 |
12 import 'package:kernel/clone.dart' show CloneVisitor; | 13 import 'package:kernel/clone.dart' show CloneVisitor; |
13 | 14 |
14 import '../../scanner/token.dart' show Token; | 15 import '../../scanner/token.dart' show Token; |
15 | 16 |
16 import '../fasta_codes.dart' | 17 import '../fasta_codes.dart' |
17 show | 18 show |
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
726 // Nothing needed. | 727 // Nothing needed. |
727 } else { | 728 } else { |
728 unhandled("${builder.runtimeType}", "buildBuilder", builder.charOffset, | 729 unhandled("${builder.runtimeType}", "buildBuilder", builder.charOffset, |
729 builder.fileUri); | 730 builder.fileUri); |
730 } | 731 } |
731 } | 732 } |
732 | 733 |
733 @override | 734 @override |
734 Library build(LibraryBuilder coreLibrary) { | 735 Library build(LibraryBuilder coreLibrary) { |
735 super.build(coreLibrary); | 736 super.build(coreLibrary); |
| 737 |
| 738 List<Combinator> toKernelCombinators( |
| 739 Iterable<fasta.Combinator> fastaCombinators) { |
| 740 return fastaCombinators?.map((c) { |
| 741 List<String> nameList = c.names.toList(); |
| 742 return c.isShow |
| 743 ? new Combinator.show(nameList) |
| 744 : new Combinator.hide(nameList); |
| 745 })?.toList(); |
| 746 } |
| 747 |
736 for (Import import in imports) { | 748 for (Import import in imports) { |
737 var importedBuilder = import.imported; | 749 var importedBuilder = import.imported; |
738 Library importedLibrary; | 750 Library importedLibrary; |
739 if (importedBuilder is DillLibraryBuilder) { | 751 if (importedBuilder is DillLibraryBuilder) { |
740 importedLibrary = importedBuilder.library; | 752 importedLibrary = importedBuilder.library; |
741 } else if (importedBuilder is KernelLibraryBuilder) { | 753 } else if (importedBuilder is KernelLibraryBuilder) { |
742 importedLibrary = importedBuilder.library; | 754 importedLibrary = importedBuilder.library; |
743 } | 755 } |
744 if (importedLibrary != null) { | 756 if (importedLibrary != null) { |
745 library.addDependency( | 757 library.addDependency(new LibraryDependency.import(importedLibrary, |
746 new LibraryDependency.import(importedLibrary, name: import.prefix)); | 758 name: import.prefix, |
| 759 combinators: toKernelCombinators(import.combinators))); |
747 } | 760 } |
748 } | 761 } |
749 for (Export import in exports) { | 762 for (Export export in exports) { |
750 var exportedBuilder = import.exported; | 763 var exportedBuilder = export.exported; |
751 Library exportedLibrary; | 764 Library exportedLibrary; |
752 if (exportedBuilder is DillLibraryBuilder) { | 765 if (exportedBuilder is DillLibraryBuilder) { |
753 exportedLibrary = exportedBuilder.library; | 766 exportedLibrary = exportedBuilder.library; |
754 } else if (exportedBuilder is KernelLibraryBuilder) { | 767 } else if (exportedBuilder is KernelLibraryBuilder) { |
755 exportedLibrary = exportedBuilder.library; | 768 exportedLibrary = exportedBuilder.library; |
756 } | 769 } |
757 if (exportedLibrary != null) { | 770 if (exportedLibrary != null) { |
758 library.addDependency(new LibraryDependency.export(exportedLibrary)); | 771 library.addDependency(new LibraryDependency.export(exportedLibrary, |
| 772 combinators: toKernelCombinators(export.combinators))); |
759 } | 773 } |
760 } | 774 } |
761 library.name = name; | 775 library.name = name; |
762 library.procedures.sort(compareProcedures); | 776 library.procedures.sort(compareProcedures); |
763 return library; | 777 return library; |
764 } | 778 } |
765 | 779 |
766 @override | 780 @override |
767 Builder buildAmbiguousBuilder( | 781 Builder buildAmbiguousBuilder( |
768 String name, Builder builder, Builder other, int charOffset, | 782 String name, Builder builder, Builder other, int charOffset, |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
924 mixinApplicationClasses.putIfAbsent(name, () => builder); | 938 mixinApplicationClasses.putIfAbsent(name, () => builder); |
925 if (existing != builder) { | 939 if (existing != builder) { |
926 part.scope.local.remove(name); | 940 part.scope.local.remove(name); |
927 } | 941 } |
928 }); | 942 }); |
929 super.includePart(part); | 943 super.includePart(part); |
930 nativeMethods.addAll(part.nativeMethods); | 944 nativeMethods.addAll(part.nativeMethods); |
931 boundlessTypeVariables.addAll(part.boundlessTypeVariables); | 945 boundlessTypeVariables.addAll(part.boundlessTypeVariables); |
932 } | 946 } |
933 } | 947 } |
OLD | NEW |