| 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 /** | 5 /** |
| 6 * This library is capable of producing linked summaries from unlinked | 6 * This library is capable of producing linked summaries from unlinked |
| 7 * ones (or prelinked ones). It functions by building a miniature | 7 * ones (or prelinked ones). It functions by building a miniature |
| 8 * element model to represent the contents of the summaries, and then | 8 * element model to represent the contents of the summaries, and then |
| 9 * scanning the element model to gather linked information and adding | 9 * scanning the element model to gather linked information and adding |
| 10 * it to the summary data structures. | 10 * it to the summary data structures. |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 if (_fields == null) { | 412 if (_fields == null) { |
| 413 _fields = <FieldElementForLink_ClassField>[]; | 413 _fields = <FieldElementForLink_ClassField>[]; |
| 414 for (UnlinkedVariable field in _unlinkedClass.fields) { | 414 for (UnlinkedVariable field in _unlinkedClass.fields) { |
| 415 _fields.add(new FieldElementForLink_ClassField(this, field)); | 415 _fields.add(new FieldElementForLink_ClassField(this, field)); |
| 416 } | 416 } |
| 417 } | 417 } |
| 418 return _fields; | 418 return _fields; |
| 419 } | 419 } |
| 420 | 420 |
| 421 @override | 421 @override |
| 422 String get identifier => name; |
| 423 |
| 424 @override |
| 422 List<InterfaceType> get interfaces => _interfaces ??= | 425 List<InterfaceType> get interfaces => _interfaces ??= |
| 423 _unlinkedClass.interfaces.map(_computeInterfaceType).toList(); | 426 _unlinkedClass.interfaces.map(_computeInterfaceType).toList(); |
| 424 | 427 |
| 425 @override | 428 @override |
| 426 bool get isObject => _unlinkedClass.hasNoSupertype; | 429 bool get isObject => _unlinkedClass.hasNoSupertype; |
| 427 | 430 |
| 428 @override | 431 @override |
| 429 LibraryElementForLink get library => enclosingElement.library; | 432 LibraryElementForLink get library => enclosingElement.library; |
| 430 | 433 |
| 431 @override | 434 @override |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 void link(CompilationUnitElementInBuildUnit compilationUnit) {} | 635 void link(CompilationUnitElementInBuildUnit compilationUnit) {} |
| 633 | 636 |
| 634 @override | 637 @override |
| 635 String toString() => '$enclosingElement.$name'; | 638 String toString() => '$enclosingElement.$name'; |
| 636 } | 639 } |
| 637 | 640 |
| 638 /** | 641 /** |
| 639 * Element representing a compilation unit resynthesized from a | 642 * Element representing a compilation unit resynthesized from a |
| 640 * summary during linking. | 643 * summary during linking. |
| 641 */ | 644 */ |
| 642 abstract class CompilationUnitElementForLink implements CompilationUnitElement { | 645 abstract class CompilationUnitElementForLink |
| 646 implements CompilationUnitElementImpl { |
| 643 /** | 647 /** |
| 644 * The unlinked representation of the compilation unit in the | 648 * The unlinked representation of the compilation unit in the |
| 645 * summary. | 649 * summary. |
| 646 */ | 650 */ |
| 647 final UnlinkedUnit _unlinkedUnit; | 651 final UnlinkedUnit _unlinkedUnit; |
| 648 | 652 |
| 649 /** | 653 /** |
| 650 * For each entry in [UnlinkedUnit.references], the element referred | 654 * For each entry in [UnlinkedUnit.references], the element referred |
| 651 * to by the reference, or `null` if it hasn't been located yet. | 655 * to by the reference, or `null` if it hasn't been located yet. |
| 652 */ | 656 */ |
| 653 final List<ReferenceableElementForLink> _references; | 657 final List<ReferenceableElementForLink> _references; |
| 654 | 658 |
| 659 /** |
| 660 * The absolute URI of this compilation unit. |
| 661 */ |
| 662 final String _absoluteUri; |
| 663 |
| 655 List<ClassElementForLink_Class> _types; | 664 List<ClassElementForLink_Class> _types; |
| 656 Map<String, ReferenceableElementForLink> _containedNames; | 665 Map<String, ReferenceableElementForLink> _containedNames; |
| 657 List<TopLevelVariableElementForLink> _topLevelVariables; | 666 List<TopLevelVariableElementForLink> _topLevelVariables; |
| 658 List<ClassElementForLink_Enum> _enums; | 667 List<ClassElementForLink_Enum> _enums; |
| 659 | 668 |
| 660 /** | 669 /** |
| 661 * Index of this unit in the list of units in the enclosing library. | 670 * Index of this unit in the list of units in the enclosing library. |
| 662 */ | 671 */ |
| 663 final int unitNum; | 672 final int unitNum; |
| 664 | 673 |
| 665 CompilationUnitElementForLink( | 674 CompilationUnitElementForLink(UnlinkedUnit unlinkedUnit, this.unitNum, |
| 666 UnlinkedUnit unlinkedUnit, this.unitNum, int numReferences) | 675 int numReferences, this._absoluteUri) |
| 667 : _references = new List<ReferenceableElementForLink>(numReferences), | 676 : _references = new List<ReferenceableElementForLink>(numReferences), |
| 668 _unlinkedUnit = unlinkedUnit; | 677 _unlinkedUnit = unlinkedUnit; |
| 669 | 678 |
| 670 @override | 679 @override |
| 671 LibraryElementForLink get enclosingElement; | 680 LibraryElementForLink get enclosingElement; |
| 672 | 681 |
| 673 @override | 682 @override |
| 674 List<ClassElementForLink_Enum> get enums { | 683 List<ClassElementForLink_Enum> get enums { |
| 675 if (_enums == null) { | 684 if (_enums == null) { |
| 676 _enums = <ClassElementForLink_Enum>[]; | 685 _enums = <ClassElementForLink_Enum>[]; |
| 677 for (UnlinkedEnum unlinkedEnum in _unlinkedUnit.enums) { | 686 for (UnlinkedEnum unlinkedEnum in _unlinkedUnit.enums) { |
| 678 _enums.add(new ClassElementForLink_Enum(this, unlinkedEnum)); | 687 _enums.add(new ClassElementForLink_Enum(this, unlinkedEnum)); |
| 679 } | 688 } |
| 680 } | 689 } |
| 681 return _enums; | 690 return _enums; |
| 682 } | 691 } |
| 683 | 692 |
| 693 @override |
| 694 String get identifier => _absoluteUri; |
| 695 |
| 684 /** | 696 /** |
| 685 * Indicates whether this compilation element is part of the build unit | 697 * Indicates whether this compilation element is part of the build unit |
| 686 * currently being linked. | 698 * currently being linked. |
| 687 */ | 699 */ |
| 688 bool get isInBuildUnit; | 700 bool get isInBuildUnit; |
| 689 | 701 |
| 690 /** | 702 /** |
| 691 * Determine whether type inference is complete in this compilation unit. | 703 * Determine whether type inference is complete in this compilation unit. |
| 692 */ | 704 */ |
| 693 bool get isTypeInferenceComplete { | 705 bool get isTypeInferenceComplete { |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 855 * Element representing a compilation unit which is part of the build | 867 * Element representing a compilation unit which is part of the build |
| 856 * unit being linked. | 868 * unit being linked. |
| 857 */ | 869 */ |
| 858 class CompilationUnitElementInBuildUnit extends CompilationUnitElementForLink { | 870 class CompilationUnitElementInBuildUnit extends CompilationUnitElementForLink { |
| 859 @override | 871 @override |
| 860 final LinkedUnitBuilder _linkedUnit; | 872 final LinkedUnitBuilder _linkedUnit; |
| 861 | 873 |
| 862 @override | 874 @override |
| 863 final LibraryElementInBuildUnit enclosingElement; | 875 final LibraryElementInBuildUnit enclosingElement; |
| 864 | 876 |
| 865 CompilationUnitElementInBuildUnit(this.enclosingElement, | 877 CompilationUnitElementInBuildUnit( |
| 866 UnlinkedUnit unlinkedUnit, this._linkedUnit, int unitNum) | 878 this.enclosingElement, |
| 867 : super(unlinkedUnit, unitNum, unlinkedUnit.references.length); | 879 UnlinkedUnit unlinkedUnit, |
| 880 this._linkedUnit, |
| 881 int unitNum, |
| 882 String absoluteUri) |
| 883 : super( |
| 884 unlinkedUnit, unitNum, unlinkedUnit.references.length, absoluteUri); |
| 868 | 885 |
| 869 @override | 886 @override |
| 870 bool get isInBuildUnit => true; | 887 bool get isInBuildUnit => true; |
| 871 | 888 |
| 872 @override | 889 @override |
| 873 LibraryElementInBuildUnit get library => enclosingElement; | 890 LibraryElementInBuildUnit get library => enclosingElement; |
| 874 | 891 |
| 875 /** | 892 /** |
| 876 * If this compilation unit already has a reference in its references table | 893 * If this compilation unit already has a reference in its references table |
| 877 * matching [dependency], [name], [numTypeParameters], [unitNum], | 894 * matching [dependency], [name], [numTypeParameters], [unitNum], |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1021 */ | 1038 */ |
| 1022 class CompilationUnitElementInDependency extends CompilationUnitElementForLink { | 1039 class CompilationUnitElementInDependency extends CompilationUnitElementForLink { |
| 1023 @override | 1040 @override |
| 1024 final LinkedUnit _linkedUnit; | 1041 final LinkedUnit _linkedUnit; |
| 1025 | 1042 |
| 1026 List<EntityRef> _linkedTypeRefs; | 1043 List<EntityRef> _linkedTypeRefs; |
| 1027 | 1044 |
| 1028 @override | 1045 @override |
| 1029 final LibraryElementInDependency enclosingElement; | 1046 final LibraryElementInDependency enclosingElement; |
| 1030 | 1047 |
| 1031 CompilationUnitElementInDependency(this.enclosingElement, | 1048 CompilationUnitElementInDependency( |
| 1032 UnlinkedUnit unlinkedUnit, LinkedUnit linkedUnit, int unitNum) | 1049 this.enclosingElement, |
| 1050 UnlinkedUnit unlinkedUnit, |
| 1051 LinkedUnit linkedUnit, |
| 1052 int unitNum, |
| 1053 String absoluteUri) |
| 1033 : _linkedUnit = linkedUnit, | 1054 : _linkedUnit = linkedUnit, |
| 1034 super(unlinkedUnit, unitNum, linkedUnit.references.length) { | 1055 super( |
| 1056 unlinkedUnit, unitNum, linkedUnit.references.length, absoluteUri) { |
| 1035 // Make one pass through the linked types to determine the lengths for | 1057 // Make one pass through the linked types to determine the lengths for |
| 1036 // _linkedTypeRefs and _linkedTypes. TODO(paulberry): add an int to the | 1058 // _linkedTypeRefs and _linkedTypes. TODO(paulberry): add an int to the |
| 1037 // summary to make this unnecessary. | 1059 // summary to make this unnecessary. |
| 1038 int maxLinkedTypeSlot = 0; | 1060 int maxLinkedTypeSlot = 0; |
| 1039 for (EntityRef ref in _linkedUnit.types) { | 1061 for (EntityRef ref in _linkedUnit.types) { |
| 1040 if (ref.slot > maxLinkedTypeSlot) { | 1062 if (ref.slot > maxLinkedTypeSlot) { |
| 1041 maxLinkedTypeSlot = ref.slot; | 1063 maxLinkedTypeSlot = ref.slot; |
| 1042 } | 1064 } |
| 1043 } | 1065 } |
| 1044 // Initialize _linkedTypeRefs. | 1066 // Initialize _linkedTypeRefs. |
| (...skipping 1554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2599 } | 2621 } |
| 2600 } | 2622 } |
| 2601 | 2623 |
| 2602 /** | 2624 /** |
| 2603 * Element representing a library resynthesied from a summary during | 2625 * Element representing a library resynthesied from a summary during |
| 2604 * linking. The type parameter, [UnitElement], represents the type | 2626 * linking. The type parameter, [UnitElement], represents the type |
| 2605 * that will be used for the compilation unit elements. | 2627 * that will be used for the compilation unit elements. |
| 2606 */ | 2628 */ |
| 2607 abstract class LibraryElementForLink< | 2629 abstract class LibraryElementForLink< |
| 2608 UnitElement extends CompilationUnitElementForLink> | 2630 UnitElement extends CompilationUnitElementForLink> |
| 2609 implements LibraryElement { | 2631 implements LibraryElementImpl { |
| 2610 /** | 2632 /** |
| 2611 * Pointer back to the linker. | 2633 * Pointer back to the linker. |
| 2612 */ | 2634 */ |
| 2613 final Linker _linker; | 2635 final Linker _linker; |
| 2614 | 2636 |
| 2615 /** | 2637 /** |
| 2616 * The absolute URI of this library. | 2638 * The absolute URI of this library. |
| 2617 */ | 2639 */ |
| 2618 final Uri _absoluteUri; | 2640 final Uri _absoluteUri; |
| 2619 | 2641 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2638 _definingUnlinkedUnit ??= _linker.getUnit(_absoluteUri.toString()); | 2660 _definingUnlinkedUnit ??= _linker.getUnit(_absoluteUri.toString()); |
| 2639 | 2661 |
| 2640 @override | 2662 @override |
| 2641 Element get enclosingElement => null; | 2663 Element get enclosingElement => null; |
| 2642 | 2664 |
| 2643 @override | 2665 @override |
| 2644 List<LibraryElementForLink> get exportedLibraries => _exportedLibraries ??= | 2666 List<LibraryElementForLink> get exportedLibraries => _exportedLibraries ??= |
| 2645 _linkedLibrary.exportDependencies.map(_getDependency).toList(); | 2667 _linkedLibrary.exportDependencies.map(_getDependency).toList(); |
| 2646 | 2668 |
| 2647 @override | 2669 @override |
| 2670 String get identifier => _absoluteUri.toString(); |
| 2671 |
| 2672 @override |
| 2648 List<LibraryElementForLink> get importedLibraries => _importedLibraries ??= | 2673 List<LibraryElementForLink> get importedLibraries => _importedLibraries ??= |
| 2649 _linkedLibrary.importDependencies.map(_getDependency).toList(); | 2674 _linkedLibrary.importDependencies.map(_getDependency).toList(); |
| 2650 | 2675 |
| 2651 /** | 2676 /** |
| 2652 * If this library is part of the build unit being linked, return the library | 2677 * If this library is part of the build unit being linked, return the library |
| 2653 * cycle it is part of. Otherwise return `null`. | 2678 * cycle it is part of. Otherwise return `null`. |
| 2654 */ | 2679 */ |
| 2655 LibraryCycleForLink get libraryCycleForLink; | 2680 LibraryCycleForLink get libraryCycleForLink; |
| 2656 | 2681 |
| 2657 @override | 2682 @override |
| 2658 List<UnitElement> get units { | 2683 List<UnitElement> get units { |
| 2659 if (_units == null) { | 2684 if (_units == null) { |
| 2660 UnlinkedUnit definingUnit = definingUnlinkedUnit; | 2685 UnlinkedUnit definingUnit = definingUnlinkedUnit; |
| 2661 _units = <UnitElement>[_makeUnitElement(definingUnit, 0)]; | 2686 _units = <UnitElement>[ |
| 2687 _makeUnitElement(definingUnit, 0, _absoluteUri.toString()) |
| 2688 ]; |
| 2662 int numParts = definingUnit.parts.length; | 2689 int numParts = definingUnit.parts.length; |
| 2663 for (int i = 0; i < numParts; i++) { | 2690 for (int i = 0; i < numParts; i++) { |
| 2664 // TODO(paulberry): make sure we handle the case where Uri.parse fails. | 2691 // TODO(paulberry): make sure we handle the case where Uri.parse fails. |
| 2665 // TODO(paulberry): make sure we handle the case where | 2692 // TODO(paulberry): make sure we handle the case where |
| 2666 // resolveRelativeUri fails. | 2693 // resolveRelativeUri fails. |
| 2667 UnlinkedUnit partUnit = _linker.getUnit(resolveRelativeUri( | 2694 String partAbsoluteUri = resolveRelativeUri( |
| 2668 _absoluteUri, Uri.parse(definingUnit.publicNamespace.parts[i])) | 2695 _absoluteUri, Uri.parse(definingUnit.publicNamespace.parts[i])) |
| 2669 .toString()); | 2696 .toString(); |
| 2670 _units.add( | 2697 UnlinkedUnit partUnit = _linker.getUnit(partAbsoluteUri); |
| 2671 _makeUnitElement(partUnit ?? new UnlinkedUnitBuilder(), i + 1)); | 2698 _units.add(_makeUnitElement( |
| 2699 partUnit ?? new UnlinkedUnitBuilder(), i + 1, partAbsoluteUri)); |
| 2672 } | 2700 } |
| 2673 } | 2701 } |
| 2674 return _units; | 2702 return _units; |
| 2675 } | 2703 } |
| 2676 | 2704 |
| 2677 /** | 2705 /** |
| 2678 * The linked representation of the library in the summary. | 2706 * The linked representation of the library in the summary. |
| 2679 */ | 2707 */ |
| 2680 LinkedLibrary get _linkedLibrary; | 2708 LinkedLibrary get _linkedLibrary; |
| 2681 | 2709 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2706 */ | 2734 */ |
| 2707 LibraryElementForLink _getDependency(int index) { | 2735 LibraryElementForLink _getDependency(int index) { |
| 2708 return _dependencies[index] ??= _linker.getLibrary(resolveRelativeUri( | 2736 return _dependencies[index] ??= _linker.getLibrary(resolveRelativeUri( |
| 2709 _absoluteUri, Uri.parse(_linkedLibrary.dependencies[index].uri))); | 2737 _absoluteUri, Uri.parse(_linkedLibrary.dependencies[index].uri))); |
| 2710 } | 2738 } |
| 2711 | 2739 |
| 2712 /** | 2740 /** |
| 2713 * Create a [UnitElement] for one of the library's compilation | 2741 * Create a [UnitElement] for one of the library's compilation |
| 2714 * units. | 2742 * units. |
| 2715 */ | 2743 */ |
| 2716 UnitElement _makeUnitElement(UnlinkedUnit unlinkedUnit, int i); | 2744 UnitElement _makeUnitElement( |
| 2745 UnlinkedUnit unlinkedUnit, int i, String absoluteUri); |
| 2717 } | 2746 } |
| 2718 | 2747 |
| 2719 /** | 2748 /** |
| 2720 * Element representing a library which is part of the build unit | 2749 * Element representing a library which is part of the build unit |
| 2721 * being linked. | 2750 * being linked. |
| 2722 */ | 2751 */ |
| 2723 class LibraryElementInBuildUnit | 2752 class LibraryElementInBuildUnit |
| 2724 extends LibraryElementForLink<CompilationUnitElementInBuildUnit> { | 2753 extends LibraryElementForLink<CompilationUnitElementInBuildUnit> { |
| 2725 @override | 2754 @override |
| 2726 final LinkedLibraryBuilder _linkedLibrary; | 2755 final LinkedLibraryBuilder _linkedLibrary; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2787 void unlink() { | 2816 void unlink() { |
| 2788 _linkedLibrary.dependencies.length = | 2817 _linkedLibrary.dependencies.length = |
| 2789 _linkedLibrary.numPrelinkedDependencies; | 2818 _linkedLibrary.numPrelinkedDependencies; |
| 2790 for (CompilationUnitElementInBuildUnit unit in units) { | 2819 for (CompilationUnitElementInBuildUnit unit in units) { |
| 2791 unit.unlink(); | 2820 unit.unlink(); |
| 2792 } | 2821 } |
| 2793 } | 2822 } |
| 2794 | 2823 |
| 2795 @override | 2824 @override |
| 2796 CompilationUnitElementInBuildUnit _makeUnitElement( | 2825 CompilationUnitElementInBuildUnit _makeUnitElement( |
| 2797 UnlinkedUnit unlinkedUnit, int i) => | 2826 UnlinkedUnit unlinkedUnit, int i, String absoluteUri) => |
| 2798 new CompilationUnitElementInBuildUnit( | 2827 new CompilationUnitElementInBuildUnit( |
| 2799 this, unlinkedUnit, _linkedLibrary.units[i], i); | 2828 this, unlinkedUnit, _linkedLibrary.units[i], i, absoluteUri); |
| 2800 } | 2829 } |
| 2801 | 2830 |
| 2802 /** | 2831 /** |
| 2803 * Element representing a library which is depended upon (either | 2832 * Element representing a library which is depended upon (either |
| 2804 * directly or indirectly) by the build unit being linked. | 2833 * directly or indirectly) by the build unit being linked. |
| 2805 */ | 2834 */ |
| 2806 class LibraryElementInDependency | 2835 class LibraryElementInDependency |
| 2807 extends LibraryElementForLink<CompilationUnitElementInDependency> { | 2836 extends LibraryElementForLink<CompilationUnitElementInDependency> { |
| 2808 @override | 2837 @override |
| 2809 final LinkedLibrary _linkedLibrary; | 2838 final LinkedLibrary _linkedLibrary; |
| 2810 | 2839 |
| 2811 LibraryElementInDependency( | 2840 LibraryElementInDependency( |
| 2812 Linker linker, Uri absoluteUri, this._linkedLibrary) | 2841 Linker linker, Uri absoluteUri, this._linkedLibrary) |
| 2813 : super(linker, absoluteUri); | 2842 : super(linker, absoluteUri); |
| 2814 | 2843 |
| 2815 @override | 2844 @override |
| 2816 LibraryCycleForLink get libraryCycleForLink => null; | 2845 LibraryCycleForLink get libraryCycleForLink => null; |
| 2817 | 2846 |
| 2818 @override | 2847 @override |
| 2819 CompilationUnitElementInDependency _makeUnitElement( | 2848 CompilationUnitElementInDependency _makeUnitElement( |
| 2820 UnlinkedUnit unlinkedUnit, int i) => | 2849 UnlinkedUnit unlinkedUnit, int i, String absoluteUri) => |
| 2821 new CompilationUnitElementInDependency( | 2850 new CompilationUnitElementInDependency( |
| 2822 this, unlinkedUnit, _linkedLibrary.units[i], i); | 2851 this, unlinkedUnit, _linkedLibrary.units[i], i, absoluteUri); |
| 2823 } | 2852 } |
| 2824 | 2853 |
| 2825 /** | 2854 /** |
| 2826 * Specialization of [Node] used to construct the library dependency graph. | 2855 * Specialization of [Node] used to construct the library dependency graph. |
| 2827 */ | 2856 */ |
| 2828 class LibraryNode extends Node<LibraryNode> { | 2857 class LibraryNode extends Node<LibraryNode> { |
| 2829 /** | 2858 /** |
| 2830 * The library this [Node] represents. | 2859 * The library this [Node] represents. |
| 2831 */ | 2860 */ |
| 2832 final LibraryElementInBuildUnit library; | 2861 final LibraryElementInBuildUnit library; |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2994 /** | 3023 /** |
| 2995 * Element representing a method resynthesized from a summary during linking. | 3024 * Element representing a method resynthesized from a summary during linking. |
| 2996 */ | 3025 */ |
| 2997 class MethodElementForLink extends ExecutableElementForLink | 3026 class MethodElementForLink extends ExecutableElementForLink |
| 2998 implements MethodElementImpl { | 3027 implements MethodElementImpl { |
| 2999 MethodElementForLink(ClassElementForLink_Class enclosingElement, | 3028 MethodElementForLink(ClassElementForLink_Class enclosingElement, |
| 3000 UnlinkedExecutable unlinkedExecutable) | 3029 UnlinkedExecutable unlinkedExecutable) |
| 3001 : super(enclosingElement, unlinkedExecutable); | 3030 : super(enclosingElement, unlinkedExecutable); |
| 3002 | 3031 |
| 3003 @override | 3032 @override |
| 3033 String get identifier => name; |
| 3034 |
| 3035 @override |
| 3004 ElementKind get kind => ElementKind.METHOD; | 3036 ElementKind get kind => ElementKind.METHOD; |
| 3005 | 3037 |
| 3006 @override | 3038 @override |
| 3007 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 3039 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 3040 |
| 3041 @override |
| 3042 String toString() => '$enclosingElement.$name'; |
| 3008 } | 3043 } |
| 3009 | 3044 |
| 3010 /** | 3045 /** |
| 3011 * Instances of [Node] represent nodes in a dependency graph. The | 3046 * Instances of [Node] represent nodes in a dependency graph. The |
| 3012 * type parameter, [NodeType], is the derived type (this affords some | 3047 * type parameter, [NodeType], is the derived type (this affords some |
| 3013 * extra type safety by making it difficult to accidentally construct | 3048 * extra type safety by making it difficult to accidentally construct |
| 3014 * bridges between unrelated dependency graphs). | 3049 * bridges between unrelated dependency graphs). |
| 3015 */ | 3050 */ |
| 3016 abstract class Node<NodeType> { | 3051 abstract class Node<NodeType> { |
| 3017 /** | 3052 /** |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3578 } else { | 3613 } else { |
| 3579 _inferredType = new ExprTypeComputer(variableElement).compute(); | 3614 _inferredType = new ExprTypeComputer(variableElement).compute(); |
| 3580 } | 3615 } |
| 3581 } | 3616 } |
| 3582 } | 3617 } |
| 3583 | 3618 |
| 3584 /** | 3619 /** |
| 3585 * Element representing a type parameter resynthesized from a summary during | 3620 * Element representing a type parameter resynthesized from a summary during |
| 3586 * linking. | 3621 * linking. |
| 3587 */ | 3622 */ |
| 3588 class TypeParameterElementForLink implements TypeParameterElement { | 3623 class TypeParameterElementForLink implements TypeParameterElementImpl { |
| 3589 /** | 3624 /** |
| 3590 * The unlinked representation of the type parameter in the summary. | 3625 * The unlinked representation of the type parameter in the summary. |
| 3591 */ | 3626 */ |
| 3592 final UnlinkedTypeParam _unlinkedTypeParam; | 3627 final UnlinkedTypeParam _unlinkedTypeParam; |
| 3593 | 3628 |
| 3594 /** | 3629 /** |
| 3595 * The number of type parameters whose scope overlaps this one, and which are | 3630 * The number of type parameters whose scope overlaps this one, and which are |
| 3596 * declared earlier in the file. | 3631 * declared earlier in the file. |
| 3597 */ | 3632 */ |
| 3598 final int nestingLevel; | 3633 final int nestingLevel; |
| 3599 | 3634 |
| 3635 @override |
| 3636 final TypeParameterizedElementForLink enclosingElement; |
| 3637 |
| 3600 TypeParameterTypeImpl _type; | 3638 TypeParameterTypeImpl _type; |
| 3639 ElementLocation _location; |
| 3601 | 3640 |
| 3602 TypeParameterElementForLink(this._unlinkedTypeParam, this.nestingLevel); | 3641 TypeParameterElementForLink( |
| 3642 this.enclosingElement, this._unlinkedTypeParam, this.nestingLevel); |
| 3603 | 3643 |
| 3604 @override | 3644 @override |
| 3605 DartType get bound { | 3645 DartType get bound { |
| 3606 if (_unlinkedTypeParam.bound == null) { | 3646 if (_unlinkedTypeParam.bound == null) { |
| 3607 return null; | 3647 return null; |
| 3608 } | 3648 } |
| 3609 // TODO(scheglov) implement | 3649 // TODO(scheglov) implement |
| 3610 throw new UnimplementedError(); | 3650 throw new UnimplementedError(); |
| 3611 } | 3651 } |
| 3612 | 3652 |
| 3613 @override | 3653 @override |
| 3654 String get identifier => name; |
| 3655 |
| 3656 @override |
| 3614 ElementKind get kind => ElementKind.TYPE_PARAMETER; | 3657 ElementKind get kind => ElementKind.TYPE_PARAMETER; |
| 3615 | 3658 |
| 3616 @override | 3659 @override |
| 3660 ElementLocation get location => |
| 3661 _location ??= new ElementLocationImpl.con1(this); |
| 3662 |
| 3663 @override |
| 3617 String get name => _unlinkedTypeParam.name; | 3664 String get name => _unlinkedTypeParam.name; |
| 3618 | 3665 |
| 3619 @override | 3666 @override |
| 3620 TypeParameterTypeImpl get type => _type ??= new TypeParameterTypeImpl(this); | 3667 TypeParameterTypeImpl get type => _type ??= new TypeParameterTypeImpl(this); |
| 3621 | 3668 |
| 3622 @override | 3669 @override |
| 3623 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 3670 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 3624 } | 3671 } |
| 3625 | 3672 |
| 3626 /** | 3673 /** |
| (...skipping 19 matching lines...) Expand all Loading... |
| 3646 | 3693 |
| 3647 List<TypeParameterElementForLink> get typeParameters { | 3694 List<TypeParameterElementForLink> get typeParameters { |
| 3648 if (_typeParameters == null) { | 3695 if (_typeParameters == null) { |
| 3649 int enclosingNestingLevel = | 3696 int enclosingNestingLevel = |
| 3650 enclosingTypeParameterContext?.typeParameterNestingLevel ?? 0; | 3697 enclosingTypeParameterContext?.typeParameterNestingLevel ?? 0; |
| 3651 int numTypeParameters = _unlinkedTypeParams.length; | 3698 int numTypeParameters = _unlinkedTypeParams.length; |
| 3652 _typeParameters = | 3699 _typeParameters = |
| 3653 new List<TypeParameterElementForLink>(numTypeParameters); | 3700 new List<TypeParameterElementForLink>(numTypeParameters); |
| 3654 for (int i = 0; i < numTypeParameters; i++) { | 3701 for (int i = 0; i < numTypeParameters; i++) { |
| 3655 _typeParameters[i] = new TypeParameterElementForLink( | 3702 _typeParameters[i] = new TypeParameterElementForLink( |
| 3656 _unlinkedTypeParams[i], enclosingNestingLevel + i); | 3703 this, _unlinkedTypeParams[i], enclosingNestingLevel + i); |
| 3657 } | 3704 } |
| 3658 } | 3705 } |
| 3659 return _typeParameters; | 3706 return _typeParameters; |
| 3660 } | 3707 } |
| 3661 | 3708 |
| 3662 /** | 3709 /** |
| 3663 * Get a list of [TypeParameterType] objects corresponding to the | 3710 * Get a list of [TypeParameterType] objects corresponding to the |
| 3664 * element's type parameters. | 3711 * element's type parameters. |
| 3665 */ | 3712 */ |
| 3666 List<TypeParameterType> get typeParameterTypes { | 3713 List<TypeParameterType> get typeParameterTypes { |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3987 List<int> implicitFunctionTypeIndices) => | 4034 List<int> implicitFunctionTypeIndices) => |
| 3988 DynamicTypeImpl.instance; | 4035 DynamicTypeImpl.instance; |
| 3989 | 4036 |
| 3990 ReferenceableElementForLink getContainedName(String name) { | 4037 ReferenceableElementForLink getContainedName(String name) { |
| 3991 return new NonstaticMemberElementForLink(_constNode); | 4038 return new NonstaticMemberElementForLink(_constNode); |
| 3992 } | 4039 } |
| 3993 | 4040 |
| 3994 @override | 4041 @override |
| 3995 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 4042 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 3996 } | 4043 } |
| OLD | NEW |