| 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 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 @override | 419 @override |
| 420 FieldElement getField(String name) { | 420 FieldElement getField(String name) { |
| 421 for (FieldElement fieldElement in fields) { | 421 for (FieldElement fieldElement in fields) { |
| 422 if (name == fieldElement.name) { | 422 if (name == fieldElement.name) { |
| 423 return fieldElement; | 423 return fieldElement; |
| 424 } | 424 } |
| 425 } | 425 } |
| 426 return null; | 426 return null; |
| 427 } | 427 } |
| 428 | 428 |
| 429 @override |
| 430 PropertyAccessorElement getGetter(String getterName) { |
| 431 for (PropertyAccessorElement accessor in accessors) { |
| 432 if (accessor.isGetter && accessor.name == getterName) { |
| 433 return accessor; |
| 434 } |
| 435 } |
| 436 return null; |
| 437 } |
| 438 |
| 429 /** | 439 /** |
| 430 * Perform type inference and cycle detection on this class and | 440 * Perform type inference and cycle detection on this class and |
| 431 * store the resulting information in [compilationUnit]. | 441 * store the resulting information in [compilationUnit]. |
| 432 */ | 442 */ |
| 433 void link(CompilationUnitElementInBuildUnit compilationUnit); | 443 void link(CompilationUnitElementInBuildUnit compilationUnit); |
| 434 | 444 |
| 435 @override | 445 @override |
| 436 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 446 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 437 } | 447 } |
| 438 | 448 |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 627 } else { | 637 } else { |
| 628 return new InterfaceTypeImpl.elementWithNameAndArgs( | 638 return new InterfaceTypeImpl.elementWithNameAndArgs( |
| 629 this, name, () => typeArguments); | 639 this, name, () => typeArguments); |
| 630 } | 640 } |
| 631 } else { | 641 } else { |
| 632 return _type ??= new InterfaceTypeImpl(this); | 642 return _type ??= new InterfaceTypeImpl(this); |
| 633 } | 643 } |
| 634 } | 644 } |
| 635 | 645 |
| 636 @override | 646 @override |
| 637 PropertyAccessorElement getGetter(String getterName) { | |
| 638 for (PropertyAccessorElement accessor in accessors) { | |
| 639 if (accessor.isGetter && accessor.name == getterName) { | |
| 640 return accessor; | |
| 641 } | |
| 642 } | |
| 643 return null; | |
| 644 } | |
| 645 | |
| 646 @override | |
| 647 MethodElement getMethod(String methodName) { | 647 MethodElement getMethod(String methodName) { |
| 648 for (MethodElement method in methods) { | 648 for (MethodElement method in methods) { |
| 649 if (method.name == methodName) { | 649 if (method.name == methodName) { |
| 650 return method; | 650 return method; |
| 651 } | 651 } |
| 652 } | 652 } |
| 653 return null; | 653 return null; |
| 654 } | 654 } |
| 655 | 655 |
| 656 @override | 656 @override |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 697 * linking. | 697 * linking. |
| 698 */ | 698 */ |
| 699 class ClassElementForLink_Enum extends ClassElementForLink | 699 class ClassElementForLink_Enum extends ClassElementForLink |
| 700 implements EnumElementImpl { | 700 implements EnumElementImpl { |
| 701 /** | 701 /** |
| 702 * The unlinked representation of the enum in the summary. | 702 * The unlinked representation of the enum in the summary. |
| 703 */ | 703 */ |
| 704 final UnlinkedEnum _unlinkedEnum; | 704 final UnlinkedEnum _unlinkedEnum; |
| 705 | 705 |
| 706 InterfaceType _type; | 706 InterfaceType _type; |
| 707 List<FieldElementForLink_EnumField> _fields; | 707 List<FieldElementForLink> _fields; |
| 708 List<PropertyAccessorElementForLink> _accessors; | 708 List<PropertyAccessorElementForLink> _accessors; |
| 709 DartType _valuesType; | 709 DartType _valuesType; |
| 710 | 710 |
| 711 ClassElementForLink_Enum( | 711 ClassElementForLink_Enum( |
| 712 CompilationUnitElementForLink enclosingElement, this._unlinkedEnum) | 712 CompilationUnitElementForLink enclosingElement, this._unlinkedEnum) |
| 713 : super(enclosingElement); | 713 : super(enclosingElement); |
| 714 | 714 |
| 715 @override | 715 @override |
| 716 List<PropertyAccessorElementForLink> get accessors { | 716 List<PropertyAccessorElementForLink> get accessors { |
| 717 if (_accessors == null) { | 717 if (_accessors == null) { |
| 718 _accessors = <PropertyAccessorElementForLink>[]; | 718 _accessors = <PropertyAccessorElementForLink>[]; |
| 719 for (FieldElementForLink_EnumField field in fields) { | 719 for (FieldElementForLink field in fields) { |
| 720 _accessors.add(field.getter); | 720 _accessors.add(field.getter); |
| 721 } | 721 } |
| 722 } | 722 } |
| 723 return _accessors; | 723 return _accessors; |
| 724 } | 724 } |
| 725 | 725 |
| 726 @override | 726 @override |
| 727 List<ConstructorElementForLink> get constructors => const []; | 727 List<ConstructorElementForLink> get constructors => const []; |
| 728 | 728 |
| 729 @override | 729 @override |
| 730 String get displayName => _unlinkedEnum.name; | 730 String get displayName => _unlinkedEnum.name; |
| 731 | 731 |
| 732 @override | 732 @override |
| 733 List<FieldElementForLink_EnumField> get fields { | 733 List<FieldElementForLink> get fields { |
| 734 if (_fields == null) { | 734 if (_fields == null) { |
| 735 _fields = <FieldElementForLink_EnumField>[]; | 735 _fields = <FieldElementForLink>[]; |
| 736 _fields.add(new FieldElementForLink_EnumField(null, this)); | 736 _fields.add(new FieldElementForLink_EnumField_values(this)); |
| 737 for (UnlinkedEnumValue value in _unlinkedEnum.values) { | 737 for (UnlinkedEnumValue value in _unlinkedEnum.values) { |
| 738 _fields.add(new FieldElementForLink_EnumField(value, this)); | 738 _fields.add(new FieldElementForLink_EnumField_value(this, value)); |
| 739 } | 739 } |
| 740 _fields.add(new FieldElementForLink_EnumField_index(this)); |
| 740 } | 741 } |
| 741 return _fields; | 742 return _fields; |
| 742 } | 743 } |
| 743 | 744 |
| 744 @override | 745 @override |
| 745 List<InterfaceType> get interfaces => const []; | 746 List<InterfaceType> get interfaces => const []; |
| 746 | 747 |
| 747 @override | 748 @override |
| 748 bool get isEnum => true; | 749 bool get isEnum => true; |
| 749 | 750 |
| (...skipping 2024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2774 | 2775 |
| 2775 @override | 2776 @override |
| 2776 String toString() => '$enclosingElement.$name'; | 2777 String toString() => '$enclosingElement.$name'; |
| 2777 } | 2778 } |
| 2778 | 2779 |
| 2779 /** | 2780 /** |
| 2780 * Specialization of [FieldElementForLink] for enum fields. | 2781 * Specialization of [FieldElementForLink] for enum fields. |
| 2781 */ | 2782 */ |
| 2782 class FieldElementForLink_EnumField extends FieldElementForLink | 2783 class FieldElementForLink_EnumField extends FieldElementForLink |
| 2783 implements FieldElement { | 2784 implements FieldElement { |
| 2784 /** | |
| 2785 * The unlinked representation of the field in the summary, or `null` if this | |
| 2786 * is an enum's `values` field. | |
| 2787 */ | |
| 2788 final UnlinkedEnumValue unlinkedEnumValue; | |
| 2789 | |
| 2790 PropertyAccessorElementForLink_EnumField _getter; | 2785 PropertyAccessorElementForLink_EnumField _getter; |
| 2791 | 2786 |
| 2792 @override | 2787 @override |
| 2793 final ClassElementForLink_Enum enclosingElement; | 2788 final ClassElementForLink_Enum enclosingElement; |
| 2794 | 2789 |
| 2795 FieldElementForLink_EnumField(this.unlinkedEnumValue, this.enclosingElement); | 2790 FieldElementForLink_EnumField(this.enclosingElement); |
| 2796 | 2791 |
| 2797 @override | 2792 @override |
| 2798 PropertyAccessorElementForLink_EnumField get getter => | 2793 PropertyAccessorElementForLink_EnumField get getter => |
| 2799 _getter ??= new PropertyAccessorElementForLink_EnumField(this); | 2794 _getter ??= new PropertyAccessorElementForLink_EnumField(this); |
| 2800 | 2795 |
| 2801 @override | 2796 @override |
| 2802 bool get isStatic => true; | |
| 2803 | |
| 2804 @override | |
| 2805 bool get isSynthetic => false; | 2797 bool get isSynthetic => false; |
| 2806 | 2798 |
| 2807 @override | 2799 @override |
| 2808 String get name => | |
| 2809 unlinkedEnumValue == null ? 'values' : unlinkedEnumValue.name; | |
| 2810 | |
| 2811 @override | |
| 2812 DartType get type => unlinkedEnumValue == null | |
| 2813 ? enclosingElement.valuesType | |
| 2814 : enclosingElement.type; | |
| 2815 | |
| 2816 @override | |
| 2817 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 2800 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 2818 | 2801 |
| 2819 @override | 2802 @override |
| 2820 String toString() => '$enclosingElement.$name'; | 2803 String toString() => '$enclosingElement.$name'; |
| 2821 } | 2804 } |
| 2822 | 2805 |
| 2806 /** |
| 2807 * Specialization of [FieldElementForLink] for the 'index' enum field. |
| 2808 */ |
| 2809 class FieldElementForLink_EnumField_index |
| 2810 extends FieldElementForLink_EnumField { |
| 2811 FieldElementForLink_EnumField_index(ClassElementForLink_Enum enclosingElement) |
| 2812 : super(enclosingElement); |
| 2813 |
| 2814 @override |
| 2815 bool get isStatic => false; |
| 2816 |
| 2817 @override |
| 2818 String get name => 'index'; |
| 2819 |
| 2820 @override |
| 2821 DartType get type => |
| 2822 enclosingElement.enclosingElement.library._linker.typeProvider.intType; |
| 2823 } |
| 2824 |
| 2825 /** |
| 2826 * Specialization of [FieldElementForLink] for enum fields. |
| 2827 */ |
| 2828 class FieldElementForLink_EnumField_value |
| 2829 extends FieldElementForLink_EnumField { |
| 2830 /** |
| 2831 * The unlinked representation of the field in the summary. |
| 2832 */ |
| 2833 final UnlinkedEnumValue unlinkedEnumValue; |
| 2834 |
| 2835 FieldElementForLink_EnumField_value( |
| 2836 ClassElementForLink_Enum enclosingElement, this.unlinkedEnumValue) |
| 2837 : super(enclosingElement); |
| 2838 |
| 2839 @override |
| 2840 bool get isStatic => true; |
| 2841 |
| 2842 @override |
| 2843 String get name => unlinkedEnumValue.name; |
| 2844 |
| 2845 @override |
| 2846 DartType get type => enclosingElement.type; |
| 2847 } |
| 2848 |
| 2849 /** |
| 2850 * Specialization of [FieldElementForLink] for the 'values' enum field. |
| 2851 */ |
| 2852 class FieldElementForLink_EnumField_values |
| 2853 extends FieldElementForLink_EnumField { |
| 2854 FieldElementForLink_EnumField_values( |
| 2855 ClassElementForLink_Enum enclosingElement) |
| 2856 : super(enclosingElement); |
| 2857 |
| 2858 @override |
| 2859 bool get isStatic => true; |
| 2860 |
| 2861 @override |
| 2862 String get name => 'values'; |
| 2863 |
| 2864 @override |
| 2865 DartType get type => enclosingElement.valuesType; |
| 2866 } |
| 2867 |
| 2823 class FieldFormalParameterElementForLink extends ParameterElementForLink | 2868 class FieldFormalParameterElementForLink extends ParameterElementForLink |
| 2824 implements FieldFormalParameterElement { | 2869 implements FieldFormalParameterElement { |
| 2825 FieldElement _field; | 2870 FieldElement _field; |
| 2826 DartType _type; | 2871 DartType _type; |
| 2827 | 2872 |
| 2828 FieldFormalParameterElementForLink( | 2873 FieldFormalParameterElementForLink( |
| 2829 ParameterParentElementForLink enclosingElement, | 2874 ParameterParentElementForLink enclosingElement, |
| 2830 UnlinkedParam unlinkedParam, | 2875 UnlinkedParam unlinkedParam, |
| 2831 TypeParameterizedElementMixin typeParameterContext, | 2876 TypeParameterizedElementMixin typeParameterContext, |
| 2832 CompilationUnitElementForLink compilationUnit, | 2877 CompilationUnitElementForLink compilationUnit, |
| (...skipping 2305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5138 * there are no type parameters in scope. | 5183 * there are no type parameters in scope. |
| 5139 */ | 5184 */ |
| 5140 TypeParameterizedElementMixin get _typeParameterContext; | 5185 TypeParameterizedElementMixin get _typeParameterContext; |
| 5141 | 5186 |
| 5142 @override | 5187 @override |
| 5143 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 5188 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 5144 | 5189 |
| 5145 @override | 5190 @override |
| 5146 String toString() => '$enclosingElement.$name'; | 5191 String toString() => '$enclosingElement.$name'; |
| 5147 } | 5192 } |
| OLD | NEW |