| 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/export.dart'; |
| 8 import 'package:front_end/src/fasta/import.dart'; | 9 import 'package:front_end/src/fasta/import.dart'; |
| 9 import 'package:kernel/ast.dart'; | 10 import 'package:kernel/ast.dart'; |
| 10 | 11 |
| 11 import 'package:kernel/clone.dart' show CloneVisitor; | 12 import 'package:kernel/clone.dart' show CloneVisitor; |
| 12 | 13 |
| 13 import '../../scanner/token.dart' show Token; | 14 import '../../scanner/token.dart' show Token; |
| 14 | 15 |
| 15 import '../fasta_codes.dart' | 16 import '../fasta_codes.dart' |
| 16 show | 17 show |
| 17 Message, | 18 Message, |
| (...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 if (importedBuilder is DillLibraryBuilder) { | 725 if (importedBuilder is DillLibraryBuilder) { |
| 725 importedLibrary = importedBuilder.library; | 726 importedLibrary = importedBuilder.library; |
| 726 } else if (importedBuilder is KernelLibraryBuilder) { | 727 } else if (importedBuilder is KernelLibraryBuilder) { |
| 727 importedLibrary = importedBuilder.library; | 728 importedLibrary = importedBuilder.library; |
| 728 } | 729 } |
| 729 if (importedLibrary != null) { | 730 if (importedLibrary != null) { |
| 730 library.addDependency( | 731 library.addDependency( |
| 731 new LibraryDependency.import(importedLibrary, name: import.prefix)); | 732 new LibraryDependency.import(importedLibrary, name: import.prefix)); |
| 732 } | 733 } |
| 733 } | 734 } |
| 735 for (Export import in exports) { |
| 736 var exportedBuilder = import.exported; |
| 737 Library exportedLibrary; |
| 738 if (exportedBuilder is DillLibraryBuilder) { |
| 739 exportedLibrary = exportedBuilder.library; |
| 740 } else if (exportedBuilder is KernelLibraryBuilder) { |
| 741 exportedLibrary = exportedBuilder.library; |
| 742 } |
| 743 if (exportedLibrary != null) { |
| 744 library.addDependency(new LibraryDependency.export(exportedLibrary)); |
| 745 } |
| 746 } |
| 734 library.name = name; | 747 library.name = name; |
| 735 library.procedures.sort(compareProcedures); | 748 library.procedures.sort(compareProcedures); |
| 736 return library; | 749 return library; |
| 737 } | 750 } |
| 738 | 751 |
| 739 @override | 752 @override |
| 740 Builder buildAmbiguousBuilder( | 753 Builder buildAmbiguousBuilder( |
| 741 String name, Builder builder, Builder other, int charOffset, | 754 String name, Builder builder, Builder other, int charOffset, |
| 742 {bool isExport: false, bool isImport: false}) { | 755 {bool isExport: false, bool isImport: false}) { |
| 743 // TODO(ahe): Can I move this to Scope or Prefix? | 756 // TODO(ahe): Can I move this to Scope or Prefix? |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 addNit(template.withArguments(name, preferredUri, hiddenUri), | 800 addNit(template.withArguments(name, preferredUri, hiddenUri), |
| 788 charOffset, fileUri); | 801 charOffset, fileUri); |
| 789 } | 802 } |
| 790 return preferred; | 803 return preferred; |
| 791 } | 804 } |
| 792 if (builder.next == null && other.next == null) { | 805 if (builder.next == null && other.next == null) { |
| 793 if (isImport && builder is PrefixBuilder && other is PrefixBuilder) { | 806 if (isImport && builder is PrefixBuilder && other is PrefixBuilder) { |
| 794 // Handles the case where the same prefix is used for different | 807 // Handles the case where the same prefix is used for different |
| 795 // imports. | 808 // imports. |
| 796 return builder | 809 return builder |
| 797 ..exports.merge(other.exports, | 810 ..exportScope.merge(other.exportScope, |
| 798 (String name, Builder existing, Builder member) { | 811 (String name, Builder existing, Builder member) { |
| 799 return buildAmbiguousBuilder(name, existing, member, charOffset, | 812 return buildAmbiguousBuilder(name, existing, member, charOffset, |
| 800 isExport: isExport, isImport: isImport); | 813 isExport: isExport, isImport: isImport); |
| 801 }); | 814 }); |
| 802 } | 815 } |
| 803 } | 816 } |
| 804 var template = | 817 var template = |
| 805 isExport ? templateDuplicatedExport : templateDuplicatedImport; | 818 isExport ? templateDuplicatedExport : templateDuplicatedImport; |
| 806 Message message = template.withArguments(name, uri, otherUri); | 819 Message message = template.withArguments(name, uri, otherUri); |
| 807 addNit(message, charOffset, fileUri); | 820 addNit(message, charOffset, fileUri); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 897 mixinApplicationClasses.putIfAbsent(name, () => builder); | 910 mixinApplicationClasses.putIfAbsent(name, () => builder); |
| 898 if (existing != builder) { | 911 if (existing != builder) { |
| 899 part.scope.local.remove(name); | 912 part.scope.local.remove(name); |
| 900 } | 913 } |
| 901 }); | 914 }); |
| 902 super.includePart(part); | 915 super.includePart(part); |
| 903 nativeMethods.addAll(part.nativeMethods); | 916 nativeMethods.addAll(part.nativeMethods); |
| 904 boundlessTypeVariables.addAll(part.boundlessTypeVariables); | 917 boundlessTypeVariables.addAll(part.boundlessTypeVariables); |
| 905 } | 918 } |
| 906 } | 919 } |
| OLD | NEW |