Chromium Code Reviews| 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 3106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3117 */ | 3117 */ |
| 3118 bool get isEvaluated; | 3118 bool get isEvaluated; |
| 3119 | 3119 |
| 3120 /** | 3120 /** |
| 3121 * Compute the dependencies of this node. | 3121 * Compute the dependencies of this node. |
| 3122 */ | 3122 */ |
| 3123 List<NodeType> computeDependencies(); | 3123 List<NodeType> computeDependencies(); |
| 3124 } | 3124 } |
| 3125 | 3125 |
| 3126 /** | 3126 /** |
| 3127 * Element used for references that result from trying to access a nonstatic | 3127 * Element used for references that result from trying to access a non-static |
| 3128 * member of an element that is not a container (e.g. accessing the "length" | 3128 * member of an element that is not a container (e.g. accessing the "length" |
| 3129 * property of a constant). | 3129 * property of a constant). |
| 3130 */ | 3130 */ |
| 3131 class NonstaticMemberElementForLink implements ReferenceableElementForLink { | 3131 class NonstaticMemberElementForLink implements ReferenceableElementForLink { |
| 3132 /** | 3132 /** |
| 3133 * The non-static element of this link element. | |
| 3134 */ | |
| 3135 final Element element; | |
| 3136 | |
| 3137 /** | |
| 3133 * If the thing from which a member was accessed is a constant, the | 3138 * If the thing from which a member was accessed is a constant, the |
| 3134 * associated [ConstNode]. Otherwise `null`. | 3139 * associated [ConstNode]. Otherwise `null`. |
| 3135 */ | 3140 */ |
| 3136 final ConstVariableNode _constNode; | 3141 final ConstVariableNode _constNode; |
| 3137 | 3142 |
| 3138 NonstaticMemberElementForLink(this._constNode); | 3143 NonstaticMemberElementForLink(this.element, this._constNode); |
| 3139 | 3144 |
| 3140 @override | 3145 @override |
| 3141 ConstructorElementForLink get asConstructor => null; | 3146 ConstructorElementForLink get asConstructor => null; |
| 3142 | 3147 |
| 3143 @override | 3148 @override |
| 3144 ConstVariableNode get asConstVariable => _constNode; | 3149 ConstVariableNode get asConstVariable => _constNode; |
| 3145 | 3150 |
| 3146 @override | 3151 @override |
| 3147 DartType get asStaticType { | 3152 DartType get asStaticType { |
| 3153 Element element = this.element; | |
| 3154 if (element is PropertyAccessorElement && element.isGetter) { | |
| 3155 return element.returnType; | |
| 3156 } | |
| 3148 // TODO(paulberry): implement. | 3157 // TODO(paulberry): implement. |
| 3149 return DynamicTypeImpl.instance; | 3158 return DynamicTypeImpl.instance; |
| 3150 } | 3159 } |
| 3151 | 3160 |
| 3152 @override | 3161 @override |
| 3153 TypeInferenceNode get asTypeInferenceNode { | 3162 TypeInferenceNode get asTypeInferenceNode { |
| 3154 // TODO(paulberry): implement. | 3163 // TODO(paulberry): implement. |
| 3155 return null; | 3164 return null; |
| 3156 } | 3165 } |
| 3157 | 3166 |
| 3158 @override | 3167 @override |
| 3159 DartType buildType(DartType getTypeArgument(int i), | 3168 DartType buildType(DartType getTypeArgument(int i), |
| 3160 List<int> implicitFunctionTypeIndices) => | 3169 List<int> implicitFunctionTypeIndices) => |
| 3161 DynamicTypeImpl.instance; | 3170 DynamicTypeImpl.instance; |
| 3162 | 3171 |
| 3163 @override | 3172 @override |
| 3164 ReferenceableElementForLink getContainedName(String name) => this; | 3173 ReferenceableElementForLink getContainedName(String name) { |
| 3174 if (element != null) { | |
| 3175 DartType type = asStaticType; | |
| 3176 if (type is InterfaceType) { | |
| 3177 PropertyAccessorElement getter = | |
| 3178 type.lookUpGetter(name, element.library); | |
| 3179 if (getter != null) { | |
| 3180 return new NonstaticMemberElementForLink(getter, _constNode); | |
| 3181 } | |
|
Paul Berry
2016/04/16 14:50:09
else {
return new NonStaticMemberElementForLink(
scheglov
2016/04/17 02:38:26
Done.
| |
| 3182 } | |
| 3183 } | |
| 3184 return this; | |
| 3185 } | |
| 3165 } | 3186 } |
| 3166 | 3187 |
| 3167 /** | 3188 /** |
| 3168 * Element representing a function or method parameter resynthesized | 3189 * Element representing a function or method parameter resynthesized |
| 3169 * from a summary during linking. | 3190 * from a summary during linking. |
| 3170 */ | 3191 */ |
| 3171 class ParameterElementForLink implements ParameterElementImpl { | 3192 class ParameterElementForLink implements ParameterElementImpl { |
| 3172 /** | 3193 /** |
| 3173 * The unlinked representation of the parameter in the summary. | 3194 * The unlinked representation of the parameter in the summary. |
| 3174 */ | 3195 */ |
| (...skipping 952 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4127 * there are no type parameters in scope. | 4148 * there are no type parameters in scope. |
| 4128 */ | 4149 */ |
| 4129 TypeParameterizedElementForLink get _typeParameterContext; | 4150 TypeParameterizedElementForLink get _typeParameterContext; |
| 4130 | 4151 |
| 4131 @override | 4152 @override |
| 4132 DartType buildType(DartType getTypeArgument(int i), | 4153 DartType buildType(DartType getTypeArgument(int i), |
| 4133 List<int> implicitFunctionTypeIndices) => | 4154 List<int> implicitFunctionTypeIndices) => |
| 4134 DynamicTypeImpl.instance; | 4155 DynamicTypeImpl.instance; |
| 4135 | 4156 |
| 4136 ReferenceableElementForLink getContainedName(String name) { | 4157 ReferenceableElementForLink getContainedName(String name) { |
| 4137 return new NonstaticMemberElementForLink(_constNode); | 4158 Element element = _getContainedElement(name); |
| 4159 return new NonstaticMemberElementForLink(element, _constNode); | |
| 4138 } | 4160 } |
| 4139 | 4161 |
| 4140 @override | 4162 @override |
| 4141 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 4163 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 4164 | |
| 4165 /** | |
| 4166 * Return the contained element with the given [name], or `null` if the lookup | |
| 4167 * fails. | |
|
Paul Berry
2016/04/16 14:50:09
Comment should reflect the fact that we don't do t
scheglov
2016/04/17 02:38:26
Done.
| |
| 4168 */ | |
| 4169 Element _getContainedElement(String name) { | |
| 4170 Linker linker = compilationUnit.library._linker; | |
| 4171 if (linker.strongMode) { | |
| 4172 DartType type = asStaticType; | |
| 4173 if (type is InterfaceType) { | |
| 4174 return type.lookUpGetter(name, compilationUnit.library); | |
| 4175 } | |
| 4176 } | |
| 4177 return null; | |
| 4178 } | |
| 4142 } | 4179 } |
| OLD | NEW |