| 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 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 _containedNames[accessor.name] = accessor; | 409 _containedNames[accessor.name] = accessor; |
| 410 } | 410 } |
| 411 for (MethodElementForLink method in methods) { | 411 for (MethodElementForLink method in methods) { |
| 412 _containedNames[method.name] = method; | 412 _containedNames[method.name] = method; |
| 413 } | 413 } |
| 414 } | 414 } |
| 415 return _containedNames.putIfAbsent( | 415 return _containedNames.putIfAbsent( |
| 416 name, () => UndefinedElementForLink.instance); | 416 name, () => UndefinedElementForLink.instance); |
| 417 } | 417 } |
| 418 | 418 |
| 419 @override |
| 420 FieldElement getField(String name) { |
| 421 for (FieldElement fieldElement in fields) { |
| 422 if (name == fieldElement.name) { |
| 423 return fieldElement; |
| 424 } |
| 425 } |
| 426 return null; |
| 427 } |
| 428 |
| 419 /** | 429 /** |
| 420 * Perform type inference and cycle detection on this class and | 430 * Perform type inference and cycle detection on this class and |
| 421 * store the resulting information in [compilationUnit]. | 431 * store the resulting information in [compilationUnit]. |
| 422 */ | 432 */ |
| 423 void link(CompilationUnitElementInBuildUnit compilationUnit); | 433 void link(CompilationUnitElementInBuildUnit compilationUnit); |
| 424 | 434 |
| 425 @override | 435 @override |
| 426 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 436 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 427 } | 437 } |
| 428 | 438 |
| (...skipping 2367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2796 ? enclosingElement.valuesType | 2806 ? enclosingElement.valuesType |
| 2797 : enclosingElement.type; | 2807 : enclosingElement.type; |
| 2798 | 2808 |
| 2799 @override | 2809 @override |
| 2800 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 2810 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 2801 | 2811 |
| 2802 @override | 2812 @override |
| 2803 String toString() => '$enclosingElement.$name'; | 2813 String toString() => '$enclosingElement.$name'; |
| 2804 } | 2814 } |
| 2805 | 2815 |
| 2816 class FieldFormalParameterElementForLink extends ParameterElementForLink |
| 2817 implements FieldFormalParameterElement { |
| 2818 FieldElement _field; |
| 2819 DartType _type; |
| 2820 |
| 2821 FieldFormalParameterElementForLink( |
| 2822 ParameterParentElementForLink enclosingElement, |
| 2823 UnlinkedParam unlinkedParam, |
| 2824 TypeParameterizedElementMixin typeParameterContext, |
| 2825 CompilationUnitElementForLink compilationUnit, |
| 2826 int parameterIndex) |
| 2827 : super(enclosingElement, unlinkedParam, typeParameterContext, |
| 2828 compilationUnit, parameterIndex); |
| 2829 |
| 2830 @override |
| 2831 FieldElement get field { |
| 2832 if (_field == null) { |
| 2833 Element enclosingConstructor = enclosingElement; |
| 2834 if (enclosingConstructor is ConstructorElement) { |
| 2835 Element enclosingClass = enclosingConstructor.enclosingElement; |
| 2836 if (enclosingClass is ClassElement) { |
| 2837 FieldElement field = enclosingClass.getField(_unlinkedParam.name); |
| 2838 if (field != null && !field.isSynthetic) { |
| 2839 _field = field; |
| 2840 } |
| 2841 } |
| 2842 } |
| 2843 } |
| 2844 return _field; |
| 2845 } |
| 2846 |
| 2847 @override |
| 2848 bool get isInitializingFormal => true; |
| 2849 |
| 2850 @override |
| 2851 DartType get type { |
| 2852 return _type ??= field?.type ?? DynamicTypeImpl.instance; |
| 2853 } |
| 2854 } |
| 2855 |
| 2806 /** | 2856 /** |
| 2807 * Element representing a function-typed parameter resynthesied from a summary | 2857 * Element representing a function-typed parameter resynthesied from a summary |
| 2808 * during linking. | 2858 * during linking. |
| 2809 */ | 2859 */ |
| 2810 class FunctionElementForLink_FunctionTypedParam extends Object | 2860 class FunctionElementForLink_FunctionTypedParam extends Object |
| 2811 with ParameterParentElementForLink | 2861 with ParameterParentElementForLink |
| 2812 implements FunctionElement { | 2862 implements FunctionElement { |
| 2813 @override | 2863 @override |
| 2814 final ParameterElementForLink enclosingElement; | 2864 final ParameterElementForLink enclosingElement; |
| 2815 | 2865 |
| (...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3915 DartType _declaredType; | 3965 DartType _declaredType; |
| 3916 bool _inheritsCovariant = false; | 3966 bool _inheritsCovariant = false; |
| 3917 | 3967 |
| 3918 ParameterElementForLink(this.enclosingElement, this._unlinkedParam, | 3968 ParameterElementForLink(this.enclosingElement, this._unlinkedParam, |
| 3919 this._typeParameterContext, this.compilationUnit, this._parameterIndex) { | 3969 this._typeParameterContext, this.compilationUnit, this._parameterIndex) { |
| 3920 if (_unlinkedParam.initializer?.bodyExpr != null) { | 3970 if (_unlinkedParam.initializer?.bodyExpr != null) { |
| 3921 _constNode = new ConstParameterNode(this); | 3971 _constNode = new ConstParameterNode(this); |
| 3922 } | 3972 } |
| 3923 } | 3973 } |
| 3924 | 3974 |
| 3975 factory ParameterElementForLink.forFactory( |
| 3976 ParameterParentElementForLink enclosingElement, |
| 3977 UnlinkedParam unlinkedParameter, |
| 3978 TypeParameterizedElementMixin typeParameterContext, |
| 3979 CompilationUnitElementForLink compilationUnit, |
| 3980 int parameterIndex) { |
| 3981 if (unlinkedParameter.isInitializingFormal) { |
| 3982 return new FieldFormalParameterElementForLink( |
| 3983 enclosingElement, |
| 3984 unlinkedParameter, |
| 3985 typeParameterContext, |
| 3986 typeParameterContext.enclosingUnit.resynthesizerContext |
| 3987 as CompilationUnitElementForLink, |
| 3988 parameterIndex); |
| 3989 } else { |
| 3990 return new ParameterElementForLink( |
| 3991 enclosingElement, |
| 3992 unlinkedParameter, |
| 3993 typeParameterContext, |
| 3994 typeParameterContext.enclosingUnit.resynthesizerContext |
| 3995 as CompilationUnitElementForLink, |
| 3996 parameterIndex); |
| 3997 } |
| 3998 } |
| 3999 |
| 3925 @override | 4000 @override |
| 3926 String get displayName => _unlinkedParam.name; | 4001 String get displayName => _unlinkedParam.name; |
| 3927 | 4002 |
| 3928 @override | 4003 @override |
| 3929 bool get hasImplicitType => | 4004 bool get hasImplicitType => |
| 3930 !_unlinkedParam.isFunctionTyped && _unlinkedParam.type == null; | 4005 !_unlinkedParam.isFunctionTyped && _unlinkedParam.type == null; |
| 3931 | 4006 |
| 3932 @override | 4007 @override |
| 3933 bool get inheritsCovariant => _inheritsCovariant; | 4008 bool get inheritsCovariant => _inheritsCovariant; |
| 3934 | 4009 |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4077 /** | 4152 /** |
| 4078 * Get all the parameters of this element. | 4153 * Get all the parameters of this element. |
| 4079 */ | 4154 */ |
| 4080 List<ParameterElement> get parameters { | 4155 List<ParameterElement> get parameters { |
| 4081 if (_parameters == null) { | 4156 if (_parameters == null) { |
| 4082 List<UnlinkedParam> unlinkedParameters = this.unlinkedParameters; | 4157 List<UnlinkedParam> unlinkedParameters = this.unlinkedParameters; |
| 4083 int numParameters = unlinkedParameters.length; | 4158 int numParameters = unlinkedParameters.length; |
| 4084 _parameters = new List<ParameterElement>(numParameters); | 4159 _parameters = new List<ParameterElement>(numParameters); |
| 4085 for (int i = 0; i < numParameters; i++) { | 4160 for (int i = 0; i < numParameters; i++) { |
| 4086 UnlinkedParam unlinkedParam = unlinkedParameters[i]; | 4161 UnlinkedParam unlinkedParam = unlinkedParameters[i]; |
| 4087 _parameters[i] = new ParameterElementForLink( | 4162 _parameters[i] = new ParameterElementForLink.forFactory( |
| 4088 this, | 4163 this, |
| 4089 unlinkedParam, | 4164 unlinkedParam, |
| 4090 typeParameterContext, | 4165 typeParameterContext, |
| 4091 typeParameterContext.enclosingUnit.resynthesizerContext | 4166 typeParameterContext.enclosingUnit.resynthesizerContext |
| 4092 as CompilationUnitElementForLink, | 4167 as CompilationUnitElementForLink, |
| 4093 i); | 4168 i); |
| 4094 } | 4169 } |
| 4095 } | 4170 } |
| 4096 return _parameters; | 4171 return _parameters; |
| 4097 } | 4172 } |
| (...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5056 * there are no type parameters in scope. | 5131 * there are no type parameters in scope. |
| 5057 */ | 5132 */ |
| 5058 TypeParameterizedElementMixin get _typeParameterContext; | 5133 TypeParameterizedElementMixin get _typeParameterContext; |
| 5059 | 5134 |
| 5060 @override | 5135 @override |
| 5061 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 5136 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 5062 | 5137 |
| 5063 @override | 5138 @override |
| 5064 String toString() => '$enclosingElement.$name'; | 5139 String toString() => '$enclosingElement.$name'; |
| 5065 } | 5140 } |
| OLD | NEW |