| 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 952 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 963 LinkedReference linkedReference = _linkedUnit.references[index]; | 963 LinkedReference linkedReference = _linkedUnit.references[index]; |
| 964 String name = unlinkedReference == null | 964 String name = unlinkedReference == null |
| 965 ? linkedReference.name | 965 ? linkedReference.name |
| 966 : unlinkedReference.name; | 966 : unlinkedReference.name; |
| 967 int containingReference = unlinkedReference == null | 967 int containingReference = unlinkedReference == null |
| 968 ? linkedReference.containingReference | 968 ? linkedReference.containingReference |
| 969 : unlinkedReference.prefixReference; | 969 : unlinkedReference.prefixReference; |
| 970 if (containingReference != 0 && | 970 if (containingReference != 0 && |
| 971 _linkedUnit.references[containingReference].kind != | 971 _linkedUnit.references[containingReference].kind != |
| 972 ReferenceKind.prefix) { | 972 ReferenceKind.prefix) { |
| 973 _references[index] = | 973 if (linkedReference.kind == ReferenceKind.function) { |
| 974 _resolveRef(containingReference).getContainedName(name); | 974 // Local function |
| 975 _references[index] = _resolveRef(containingReference) |
| 976 .getLocalFunction(linkedReference.localIndex); |
| 977 } else { |
| 978 _references[index] = |
| 979 _resolveRef(containingReference).getContainedName(name); |
| 980 } |
| 975 } else if (linkedReference.dependency == 0) { | 981 } else if (linkedReference.dependency == 0) { |
| 976 if (name == 'void') { | 982 if (name == 'void') { |
| 977 _references[index] = enclosingElement._linker.voidElement; | 983 _references[index] = enclosingElement._linker.voidElement; |
| 978 } else if (name == '*bottom*') { | 984 } else if (name == '*bottom*') { |
| 979 _references[index] = enclosingElement._linker.bottomElement; | 985 _references[index] = enclosingElement._linker.bottomElement; |
| 980 } else if (name == 'dynamic') { | 986 } else if (name == 'dynamic') { |
| 981 _references[index] = enclosingElement._linker.dynamicElement; | 987 _references[index] = enclosingElement._linker.dynamicElement; |
| 982 } else { | 988 } else { |
| 983 _references[index] = enclosingElement.getContainedName(name); | 989 _references[index] = enclosingElement.getContainedName(name); |
| 984 } | 990 } |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1119 return addRawReference(element.name, | 1125 return addRawReference(element.name, |
| 1120 dependency: library.addDependency(element.library), | 1126 dependency: library.addDependency(element.library), |
| 1121 numTypeParameters: element.typeParameters.length, | 1127 numTypeParameters: element.typeParameters.length, |
| 1122 unitNum: element.enclosingElement.unitNum); | 1128 unitNum: element.enclosingElement.unitNum); |
| 1123 } else if (element is FunctionTypeAliasElementForLink) { | 1129 } else if (element is FunctionTypeAliasElementForLink) { |
| 1124 return addRawReference(element.name, | 1130 return addRawReference(element.name, |
| 1125 dependency: library.addDependency(element.library), | 1131 dependency: library.addDependency(element.library), |
| 1126 numTypeParameters: element.typeParameters.length, | 1132 numTypeParameters: element.typeParameters.length, |
| 1127 unitNum: element.enclosingElement.unitNum, | 1133 unitNum: element.enclosingElement.unitNum, |
| 1128 kind: ReferenceKind.typedef); | 1134 kind: ReferenceKind.typedef); |
| 1135 } else if (element is FunctionElementForLink_Initializer) { |
| 1136 return addRawReference('', |
| 1137 containingReference: addReference(element.enclosingElement), |
| 1138 kind: ReferenceKind.function, |
| 1139 localIndex: 0); |
| 1140 } else if (element is FunctionElementForLink_Local_NonSynthetic) { |
| 1141 ExecutableElementForLink parent = element.enclosingElement; |
| 1142 int localIndex = parent.functions.indexOf(element); |
| 1143 assert(localIndex != -1); |
| 1144 return addRawReference(element.name, |
| 1145 containingReference: addReference(parent), |
| 1146 kind: ReferenceKind.function, |
| 1147 localIndex: localIndex); |
| 1129 } else if (element is ExecutableElementForLink_NonLocal) { | 1148 } else if (element is ExecutableElementForLink_NonLocal) { |
| 1130 ClassElementForLink_Class enclosingClass = element.enclosingClass; | 1149 ClassElementForLink_Class enclosingClass = element.enclosingClass; |
| 1131 ReferenceKind kind; | 1150 ReferenceKind kind; |
| 1132 switch (element._unlinkedExecutable.kind) { | 1151 switch (element._unlinkedExecutable.kind) { |
| 1133 case UnlinkedExecutableKind.functionOrMethod: | 1152 case UnlinkedExecutableKind.functionOrMethod: |
| 1134 kind = enclosingClass != null | 1153 kind = enclosingClass != null |
| 1135 ? ReferenceKind.method | 1154 ? ReferenceKind.method |
| 1136 : ReferenceKind.topLevelFunction; | 1155 : ReferenceKind.topLevelFunction; |
| 1137 break; | 1156 break; |
| 1138 case UnlinkedExecutableKind.setter: | 1157 case UnlinkedExecutableKind.setter: |
| 1139 kind = ReferenceKind.propertyAccessor; | 1158 kind = ReferenceKind.propertyAccessor; |
| 1140 break; | 1159 break; |
| 1141 default: | 1160 default: |
| 1142 // TODO(paulberry): implement other cases as necessary | 1161 // TODO(paulberry): implement other cases as necessary |
| 1143 throw new UnimplementedError('${element._unlinkedExecutable.kind}'); | 1162 throw new UnimplementedError('${element._unlinkedExecutable.kind}'); |
| 1144 } | 1163 } |
| 1145 return addRawReference(element.name, | 1164 return addRawReference(element.name, |
| 1146 numTypeParameters: element.typeParameters.length, | 1165 numTypeParameters: element.typeParameters.length, |
| 1147 containingReference: | 1166 containingReference: |
| 1148 enclosingClass != null ? addReference(enclosingClass) : null, | 1167 enclosingClass != null ? addReference(enclosingClass) : null, |
| 1149 dependency: enclosingClass != null | 1168 dependency: enclosingClass != null |
| 1150 ? null | 1169 ? null |
| 1151 : library.addDependency(element.library), | 1170 : library.addDependency(element.library), |
| 1152 kind: kind); | 1171 kind: kind); |
| 1153 } else if (element is FunctionElementForLink_Local) { | |
| 1154 FunctionElementImpl parent = element.enclosingElement; | |
| 1155 int localIndex = parent.functions.indexOf(element); | |
| 1156 assert(localIndex != -1); | |
| 1157 return addRawReference(element.name, | |
| 1158 containingReference: addReference(parent), | |
| 1159 kind: ReferenceKind.function, | |
| 1160 localIndex: localIndex); | |
| 1161 } else if (element is FunctionElementForLink_Initializer) { | 1172 } else if (element is FunctionElementForLink_Initializer) { |
| 1162 return addRawReference('', | 1173 return addRawReference('', |
| 1163 containingReference: addReference(element.enclosingElement), | 1174 containingReference: addReference(element.enclosingElement), |
| 1164 kind: ReferenceKind.function); | 1175 kind: ReferenceKind.function); |
| 1165 } else if (element is TopLevelVariableElementForLink) { | 1176 } else if (element is TopLevelVariableElementForLink) { |
| 1166 return addRawReference(element.name, | 1177 return addRawReference(element.name, |
| 1167 dependency: library.addDependency(element.library), | 1178 dependency: library.addDependency(element.library), |
| 1168 kind: ReferenceKind.topLevelPropertyAccessor); | 1179 kind: ReferenceKind.topLevelPropertyAccessor); |
| 1169 } else if (element is FieldElementForLink_ClassField) { | 1180 } else if (element is FieldElementForLink_ClassField) { |
| 1170 ClassElementForLink_Class enclosingClass = element.enclosingElement; | 1181 ClassElementForLink_Class enclosingClass = element.enclosingElement; |
| (...skipping 1535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2706 @override | 2717 @override |
| 2707 List<TypeParameterElement> get typeParameters => const []; | 2718 List<TypeParameterElement> get typeParameters => const []; |
| 2708 | 2719 |
| 2709 @override | 2720 @override |
| 2710 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 2721 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 2711 } | 2722 } |
| 2712 | 2723 |
| 2713 /** | 2724 /** |
| 2714 * Element representing the initializer expression of a variable. | 2725 * Element representing the initializer expression of a variable. |
| 2715 */ | 2726 */ |
| 2716 class FunctionElementForLink_Initializer implements FunctionElementImpl { | 2727 class FunctionElementForLink_Initializer extends Object |
| 2728 with ReferenceableElementForLink |
| 2729 implements FunctionElementForLink_Local { |
| 2717 /** | 2730 /** |
| 2718 * The variable for which this element is the initializer. | 2731 * The variable for which this element is the initializer. |
| 2719 */ | 2732 */ |
| 2720 final VariableElementForLink _variable; | 2733 final VariableElementForLink _variable; |
| 2721 | 2734 |
| 2722 List<FunctionElementForLink_Local> _functions; | 2735 List<FunctionElementForLink_Local_NonSynthetic> _functions; |
| 2723 | 2736 |
| 2724 FunctionElementForLink_Initializer(this._variable); | 2737 FunctionElementForLink_Initializer(this._variable); |
| 2725 | 2738 |
| 2726 @override | 2739 @override |
| 2727 VariableElementForLink get enclosingElement => _variable; | 2740 VariableElementForLink get enclosingElement => _variable; |
| 2728 | 2741 |
| 2742 TypeParameterizedElementForLink get enclosingTypeParameterContext => |
| 2743 _variable.enclosingElement is ClassElementForLink |
| 2744 ? _variable.enclosingElement |
| 2745 : null; |
| 2746 |
| 2729 @override | 2747 @override |
| 2730 List<FunctionElementForLink_Local> get functions => _functions ??= _variable | 2748 List<FunctionElementForLink_Local_NonSynthetic> get functions => |
| 2731 .unlinkedVariable.initializer.localFunctions | 2749 _functions ??= _variable.unlinkedVariable.initializer.localFunctions |
| 2732 .map((UnlinkedExecutable ex) => | 2750 .map((UnlinkedExecutable ex) => |
| 2733 new FunctionElementForLink_Local(_variable.compilationUnit, this, ex)) | 2751 new FunctionElementForLink_Local_NonSynthetic( |
| 2734 .toList(); | 2752 _variable.compilationUnit, this, ex)) |
| 2753 .toList(); |
| 2735 | 2754 |
| 2736 @override | 2755 @override |
| 2737 DartType get returnType { | 2756 DartType get returnType { |
| 2738 // If this is a variable whose type needs inferring, infer it. | 2757 // If this is a variable whose type needs inferring, infer it. |
| 2739 if (_variable.hasImplicitType) { | 2758 if (_variable.hasImplicitType) { |
| 2740 return _variable.inferredType; | 2759 return _variable.inferredType; |
| 2741 } else { | 2760 } else { |
| 2742 // There's no reason linking should need to access the type of | 2761 // There's no reason linking should need to access the type of |
| 2743 // this FunctionElement, since the variable doesn't need its | 2762 // this FunctionElement, since the variable doesn't need its |
| 2744 // type inferred. | 2763 // type inferred. |
| 2745 assert(false); | 2764 assert(false); |
| 2746 // But for robustness, return the dynamic type. | 2765 // But for robustness, return the dynamic type. |
| 2747 return DynamicTypeImpl.instance; | 2766 return DynamicTypeImpl.instance; |
| 2748 } | 2767 } |
| 2749 } | 2768 } |
| 2750 | 2769 |
| 2751 @override | 2770 @override |
| 2752 void set returnType(DartType newType) { | 2771 void set returnType(DartType newType) { |
| 2753 // InstanceMemberInferrer stores the new type both here and on the variable | 2772 // InstanceMemberInferrer stores the new type both here and on the variable |
| 2754 // element. We don't need to record both values, so we ignore it here. | 2773 // element. We don't need to record both values, so we ignore it here. |
| 2755 } | 2774 } |
| 2756 | 2775 |
| 2757 @override | 2776 @override |
| 2777 int get typeParameterNestingLevel => |
| 2778 enclosingTypeParameterContext?.typeParameterNestingLevel ?? 0; |
| 2779 |
| 2780 List<TypeParameterElement> get typeParameters => const []; |
| 2781 |
| 2782 @override |
| 2783 FunctionElementForLink_Local getLocalFunction(int index) { |
| 2784 List<FunctionElementForLink_Local_NonSynthetic> functions = this.functions; |
| 2785 return index < functions.length ? functions[index] : null; |
| 2786 } |
| 2787 |
| 2788 @override |
| 2758 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 2789 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 2759 } | 2790 } |
| 2760 | 2791 |
| 2761 /** | 2792 /** |
| 2793 * Element representing a local function (possibly a closure). |
| 2794 */ |
| 2795 abstract class FunctionElementForLink_Local |
| 2796 implements |
| 2797 ExecutableElementForLink, |
| 2798 FunctionElementImpl, |
| 2799 ReferenceableElementForLink {} |
| 2800 |
| 2801 /** |
| 2762 * Element representing a local function (possibly a closure) inside another | 2802 * Element representing a local function (possibly a closure) inside another |
| 2763 * executable. | 2803 * executable. |
| 2764 */ | 2804 */ |
| 2765 class FunctionElementForLink_Local extends ExecutableElementForLink | 2805 class FunctionElementForLink_Local_NonSynthetic extends ExecutableElementForLink |
| 2766 implements FunctionElementImpl { | 2806 with ReferenceableElementForLink |
| 2807 implements FunctionElementForLink_Local { |
| 2767 @override | 2808 @override |
| 2768 final FunctionElementImpl enclosingElement; | 2809 final ExecutableElementForLink enclosingElement; |
| 2769 | 2810 |
| 2770 FunctionElementForLink_Local(CompilationUnitElementForLink compilationUnit, | 2811 FunctionElementForLink_Local_NonSynthetic( |
| 2771 this.enclosingElement, UnlinkedExecutable unlinkedExecutable) | 2812 CompilationUnitElementForLink compilationUnit, |
| 2813 this.enclosingElement, |
| 2814 UnlinkedExecutable unlinkedExecutable) |
| 2772 : super(compilationUnit, unlinkedExecutable); | 2815 : super(compilationUnit, unlinkedExecutable); |
| 2773 | 2816 |
| 2774 @override | 2817 @override |
| 2818 TypeParameterizedElementForLink get enclosingTypeParameterContext => |
| 2819 enclosingElement; |
| 2820 |
| 2821 @override |
| 2822 DartType buildType( |
| 2823 DartType getTypeArgument(int i), List<int> implicitFunctionTypeIndices) { |
| 2824 assert(implicitFunctionTypeIndices.isEmpty); |
| 2825 return type; |
| 2826 } |
| 2827 |
| 2828 @override |
| 2829 FunctionElementForLink_Local getLocalFunction(int index) { |
| 2830 // TODO(paulberry): implement. |
| 2831 throw new UnimplementedError(); |
| 2832 } |
| 2833 |
| 2834 @override |
| 2775 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 2835 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 2776 } | 2836 } |
| 2777 | 2837 |
| 2778 /** | 2838 /** |
| 2779 * Element representing a typedef resynthesized from a summary during linking. | 2839 * Element representing a typedef resynthesized from a summary during linking. |
| 2780 */ | 2840 */ |
| 2781 class FunctionTypeAliasElementForLink extends Object | 2841 class FunctionTypeAliasElementForLink extends Object |
| 2782 with | 2842 with |
| 2783 TypeParameterizedElementForLink, | 2843 TypeParameterizedElementForLink, |
| 2784 ParameterParentElementForLink, | 2844 ParameterParentElementForLink, |
| (...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3413 @override | 3473 @override |
| 3414 DartType get asStaticType => type; | 3474 DartType get asStaticType => type; |
| 3415 | 3475 |
| 3416 @override | 3476 @override |
| 3417 String get identifier => name; | 3477 String get identifier => name; |
| 3418 | 3478 |
| 3419 @override | 3479 @override |
| 3420 ElementKind get kind => ElementKind.METHOD; | 3480 ElementKind get kind => ElementKind.METHOD; |
| 3421 | 3481 |
| 3422 @override | 3482 @override |
| 3483 FunctionElementForLink_Local getLocalFunction(int index) { |
| 3484 // TODO(paulberry): implement. |
| 3485 return null; |
| 3486 } |
| 3487 |
| 3488 @override |
| 3423 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 3489 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 3424 | 3490 |
| 3425 @override | 3491 @override |
| 3426 String toString() => '$enclosingElement.$name'; | 3492 String toString() => '$enclosingElement.$name'; |
| 3427 } | 3493 } |
| 3428 | 3494 |
| 3429 /** | 3495 /** |
| 3430 * Instances of [Node] represent nodes in a dependency graph. The | 3496 * Instances of [Node] represent nodes in a dependency graph. The |
| 3431 * type parameter, [NodeType], is the derived type (this affords some | 3497 * type parameter, [NodeType], is the derived type (this affords some |
| 3432 * extra type safety by making it difficult to accidentally construct | 3498 * extra type safety by making it difficult to accidentally construct |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3773 | 3839 |
| 3774 @override | 3840 @override |
| 3775 List<TypeParameterElement> get typeParameters => const []; | 3841 List<TypeParameterElement> get typeParameters => const []; |
| 3776 | 3842 |
| 3777 @override | 3843 @override |
| 3778 ReferenceableElementForLink getContainedName(String name) { | 3844 ReferenceableElementForLink getContainedName(String name) { |
| 3779 return new NonstaticMemberElementForLink(library, this, name); | 3845 return new NonstaticMemberElementForLink(library, this, name); |
| 3780 } | 3846 } |
| 3781 | 3847 |
| 3782 @override | 3848 @override |
| 3849 FunctionElementForLink_Local getLocalFunction(int index) { |
| 3850 // TODO(paulberry): implement (should return the synthetic function element |
| 3851 // for the enum field's initializer). |
| 3852 return null; |
| 3853 } |
| 3854 |
| 3855 @override |
| 3783 bool isAccessibleIn(LibraryElement library) => | 3856 bool isAccessibleIn(LibraryElement library) => |
| 3784 !Identifier.isPrivateName(name) || identical(this.library, library); | 3857 !Identifier.isPrivateName(name) || identical(this.library, library); |
| 3785 | 3858 |
| 3786 @override | 3859 @override |
| 3787 void link(CompilationUnitElementInBuildUnit compilationUnit) {} | 3860 void link(CompilationUnitElementInBuildUnit compilationUnit) {} |
| 3788 | 3861 |
| 3789 @override | 3862 @override |
| 3790 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 3863 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 3791 | 3864 |
| 3792 @override | 3865 @override |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3829 @override | 3902 @override |
| 3830 ElementKind get kind => _unlinkedExecutable.kind == | 3903 ElementKind get kind => _unlinkedExecutable.kind == |
| 3831 UnlinkedExecutableKind.getter ? ElementKind.GETTER : ElementKind.SETTER; | 3904 UnlinkedExecutableKind.getter ? ElementKind.GETTER : ElementKind.SETTER; |
| 3832 | 3905 |
| 3833 @override | 3906 @override |
| 3834 ReferenceableElementForLink getContainedName(String name) { | 3907 ReferenceableElementForLink getContainedName(String name) { |
| 3835 return new NonstaticMemberElementForLink(library, this, name); | 3908 return new NonstaticMemberElementForLink(library, this, name); |
| 3836 } | 3909 } |
| 3837 | 3910 |
| 3838 @override | 3911 @override |
| 3912 FunctionElementForLink_Local getLocalFunction(int index) { |
| 3913 // TODO(paulberry): implement |
| 3914 return null; |
| 3915 } |
| 3916 |
| 3917 @override |
| 3839 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 3918 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 3840 | 3919 |
| 3841 @override | 3920 @override |
| 3842 String toString() => '$enclosingElement.$name'; | 3921 String toString() => '$enclosingElement.$name'; |
| 3843 } | 3922 } |
| 3844 | 3923 |
| 3845 /** | 3924 /** |
| 3846 * Specialization of [PropertyAccessorElementForLink] for synthetic accessors | 3925 * Specialization of [PropertyAccessorElementForLink] for synthetic accessors |
| 3847 * implied by a field or variable declaration. | 3926 * implied by a field or variable declaration. |
| 3848 */ | 3927 */ |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3935 return variable.type; | 4014 return variable.type; |
| 3936 } | 4015 } |
| 3937 } | 4016 } |
| 3938 | 4017 |
| 3939 @override | 4018 @override |
| 3940 ReferenceableElementForLink getContainedName(String name) { | 4019 ReferenceableElementForLink getContainedName(String name) { |
| 3941 return new NonstaticMemberElementForLink(library, this, name); | 4020 return new NonstaticMemberElementForLink(library, this, name); |
| 3942 } | 4021 } |
| 3943 | 4022 |
| 3944 @override | 4023 @override |
| 4024 FunctionElementForLink_Local getLocalFunction(int index) { |
| 4025 if (index == 0) { |
| 4026 return variable.initializer; |
| 4027 } else { |
| 4028 return null; |
| 4029 } |
| 4030 } |
| 4031 |
| 4032 @override |
| 3945 bool isAccessibleIn(LibraryElement library) => | 4033 bool isAccessibleIn(LibraryElement library) => |
| 3946 !Identifier.isPrivateName(name) || identical(this.library, library); | 4034 !Identifier.isPrivateName(name) || identical(this.library, library); |
| 3947 | 4035 |
| 3948 @override | 4036 @override |
| 3949 void link(CompilationUnitElementInBuildUnit compilationUnit) {} | 4037 void link(CompilationUnitElementInBuildUnit compilationUnit) {} |
| 3950 | 4038 |
| 3951 @override | 4039 @override |
| 3952 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 4040 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 3953 | 4041 |
| 3954 @override | 4042 @override |
| 3955 String toString() => '$enclosingElement.$name'; | 4043 String toString() => '$enclosingElement.$name'; |
| 3956 } | 4044 } |
| 3957 | 4045 |
| 3958 /** | 4046 /** |
| 3959 * Base class representing an element which can be the target of a reference. | 4047 * Base class representing an element which can be the target of a reference. |
| 3960 * When used as a mixin, implements the default behavior shared by most | 4048 * When used as a mixin, implements the default behavior shared by most |
| 3961 * elements. | 4049 * elements. |
| 3962 */ | 4050 */ |
| 3963 abstract class ReferenceableElementForLink { | 4051 class ReferenceableElementForLink { |
| 3964 /** | 4052 /** |
| 3965 * If this element can be used in a constructor invocation context, | 4053 * If this element can be used in a constructor invocation context, |
| 3966 * return the associated constructor (which may be `this` or some | 4054 * return the associated constructor (which may be `this` or some |
| 3967 * other element). Otherwise return `null`. | 4055 * other element). Otherwise return `null`. |
| 3968 */ | 4056 */ |
| 3969 ConstructorElementForLink get asConstructor => null; | 4057 ConstructorElementForLink get asConstructor => null; |
| 3970 | 4058 |
| 3971 /** | 4059 /** |
| 3972 * If this element can be used in a getter context to refer to a | 4060 * If this element can be used in a getter context to refer to a |
| 3973 * constant variable, return the [ConstVariableNode] for the | 4061 * constant variable, return the [ConstVariableNode] for the |
| (...skipping 27 matching lines...) Expand all Loading... |
| 4001 * If this element contains other named elements, return the | 4089 * If this element contains other named elements, return the |
| 4002 * contained element having the given [name]. If this element can't | 4090 * contained element having the given [name]. If this element can't |
| 4003 * contain other named elements, or it doesn't contain an element | 4091 * contain other named elements, or it doesn't contain an element |
| 4004 * with the given name, return the singleton of | 4092 * with the given name, return the singleton of |
| 4005 * [UndefinedElementForLink]. | 4093 * [UndefinedElementForLink]. |
| 4006 */ | 4094 */ |
| 4007 ReferenceableElementForLink getContainedName(String name) { | 4095 ReferenceableElementForLink getContainedName(String name) { |
| 4008 // TODO(paulberry): handle references to `call` for function types. | 4096 // TODO(paulberry): handle references to `call` for function types. |
| 4009 return UndefinedElementForLink.instance; | 4097 return UndefinedElementForLink.instance; |
| 4010 } | 4098 } |
| 4099 |
| 4100 /** |
| 4101 * If this element contains local functions, return the contained local |
| 4102 * function having the given [index]. If this element doesn't contain local |
| 4103 * functions, or the index is out of range, return `null`. |
| 4104 */ |
| 4105 FunctionElementForLink_Local getLocalFunction(int index) => null; |
| 4011 } | 4106 } |
| 4012 | 4107 |
| 4013 /** | 4108 /** |
| 4014 * Element used for references to special types such as `void`. | 4109 * Element used for references to special types such as `void`. |
| 4015 */ | 4110 */ |
| 4016 class SpecialTypeElementForLink extends Object | 4111 class SpecialTypeElementForLink extends Object |
| 4017 with ReferenceableElementForLink { | 4112 with ReferenceableElementForLink { |
| 4018 final Linker linker; | 4113 final Linker linker; |
| 4019 final DartType type; | 4114 final DartType type; |
| 4020 | 4115 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4066 CompilationUnitElementForLink enclosingUnit, UnlinkedExecutable _buf) | 4161 CompilationUnitElementForLink enclosingUnit, UnlinkedExecutable _buf) |
| 4067 : super(enclosingUnit, null, _buf); | 4162 : super(enclosingUnit, null, _buf); |
| 4068 | 4163 |
| 4069 @override | 4164 @override |
| 4070 DartType get asStaticType => type; | 4165 DartType get asStaticType => type; |
| 4071 | 4166 |
| 4072 @override | 4167 @override |
| 4073 ElementKind get kind => ElementKind.FUNCTION; | 4168 ElementKind get kind => ElementKind.FUNCTION; |
| 4074 | 4169 |
| 4075 @override | 4170 @override |
| 4171 FunctionElementForLink_Local getLocalFunction(int index) { |
| 4172 // TODO(paulberry): implement. |
| 4173 return null; |
| 4174 } |
| 4175 |
| 4176 @override |
| 4076 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 4177 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 4077 } | 4178 } |
| 4078 | 4179 |
| 4079 /** | 4180 /** |
| 4080 * Element representing a top level variable resynthesized from a | 4181 * Element representing a top level variable resynthesized from a |
| 4081 * summary during linking. | 4182 * summary during linking. |
| 4082 */ | 4183 */ |
| 4083 class TopLevelVariableElementForLink extends VariableElementForLink | 4184 class TopLevelVariableElementForLink extends VariableElementForLink |
| 4084 implements TopLevelVariableElement { | 4185 implements TopLevelVariableElement { |
| 4085 TopLevelVariableElementForLink(CompilationUnitElementForLink enclosingElement, | 4186 TopLevelVariableElementForLink(CompilationUnitElementForLink enclosingElement, |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4675 * there are no type parameters in scope. | 4776 * there are no type parameters in scope. |
| 4676 */ | 4777 */ |
| 4677 TypeParameterizedElementForLink get _typeParameterContext; | 4778 TypeParameterizedElementForLink get _typeParameterContext; |
| 4678 | 4779 |
| 4679 @override | 4780 @override |
| 4680 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 4781 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 4681 | 4782 |
| 4682 @override | 4783 @override |
| 4683 String toString() => '$enclosingElement.$name'; | 4784 String toString() => '$enclosingElement.$name'; |
| 4684 } | 4785 } |
| OLD | NEW |