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 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 575 | 575 |
| 576 @override | 576 @override |
| 577 List<UnlinkedTypeParam> get _unlinkedTypeParams => | 577 List<UnlinkedTypeParam> get _unlinkedTypeParams => |
| 578 _unlinkedClass.typeParameters; | 578 _unlinkedClass.typeParameters; |
| 579 | 579 |
| 580 @override | 580 @override |
| 581 DartType buildType( | 581 DartType buildType( |
| 582 DartType getTypeArgument(int i), List<int> implicitFunctionTypeIndices) { | 582 DartType getTypeArgument(int i), List<int> implicitFunctionTypeIndices) { |
| 583 int numTypeParameters = _unlinkedClass.typeParameters.length; | 583 int numTypeParameters = _unlinkedClass.typeParameters.length; |
| 584 if (numTypeParameters != 0) { | 584 if (numTypeParameters != 0) { |
| 585 List<DartType> typeArguments = new List<DartType>(numTypeParameters); | 585 return new InterfaceTypeImpl.elementWithNameAndArgs(this, name, () { |
| 586 for (int i = 0; i < numTypeParameters; i++) { | 586 List<DartType> typeArguments = new List<DartType>(numTypeParameters); |
| 587 typeArguments[i] = getTypeArgument(i); | 587 for (int i = 0; i < numTypeParameters; i++) { |
| 588 } | 588 typeArguments[i] = getTypeArgument(i); |
| 589 return new InterfaceTypeImpl.elementWithNameAndArgs( | 589 } |
| 590 this, name, typeArguments); | 590 return typeArguments; |
| 591 }); | |
| 591 } else { | 592 } else { |
| 592 return _type ??= new InterfaceTypeImpl(this); | 593 return _type ??= new InterfaceTypeImpl(this); |
| 593 } | 594 } |
| 594 } | 595 } |
| 595 | 596 |
| 596 @override | 597 @override |
| 597 PropertyAccessorElement getGetter(String getterName) { | 598 PropertyAccessorElement getGetter(String getterName) { |
| 598 for (PropertyAccessorElement accessor in accessors) { | 599 for (PropertyAccessorElement accessor in accessors) { |
| 599 if (accessor.isGetter && accessor.name == getterName) { | 600 if (accessor.isGetter && accessor.name == getterName) { |
| 600 return accessor; | 601 return accessor; |
| (...skipping 1634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2235 int numNamed = _getNextInt(); | 2236 int numNamed = _getNextInt(); |
| 2236 int numPositional = _getNextInt(); | 2237 int numPositional = _getNextInt(); |
| 2237 // TODO(paulberry): don't just pop the args; use their types | 2238 // TODO(paulberry): don't just pop the args; use their types |
| 2238 // to infer the type of type arguments. | 2239 // to infer the type of type arguments. |
| 2239 stack.length -= numNamed + numPositional; | 2240 stack.length -= numNamed + numPositional; |
| 2240 strPtr += numNamed; | 2241 strPtr += numNamed; |
| 2241 EntityRef ref = _getNextRef(); | 2242 EntityRef ref = _getNextRef(); |
| 2242 ConstructorElementForLink element = | 2243 ConstructorElementForLink element = |
| 2243 unit._resolveRef(ref.reference).asConstructor; | 2244 unit._resolveRef(ref.reference).asConstructor; |
| 2244 if (element != null) { | 2245 if (element != null) { |
| 2245 stack.add(element.enclosingClass.buildType( | 2246 ClassElementForLink_Class enclosingClass = element.enclosingClass; |
| 2246 (int i) => i >= ref.typeArguments.length | 2247 int numTypeParameters = enclosingClass.typeParameters.length; |
| 2247 ? DynamicTypeImpl.instance | 2248 int numTypeArguments = ref.typeArguments.length; |
| 2248 : unit._resolveTypeRef( | 2249 stack.add(enclosingClass.buildType((int i) { |
| 2249 ref.typeArguments[i], variable._typeParameterContext), | 2250 if (linker.strongMode && |
| 2250 const [])); | 2251 numTypeArguments != numTypeParameters && |
| 2252 i < numTypeParameters) { | |
|
Paul Berry
2016/05/10 15:55:59
I *think* this will work, but the logic seems stra
| |
| 2253 TypeParameterElement typeParameter = enclosingClass.typeParameters[i]; | |
| 2254 return typeParameter.bound ?? DynamicTypeImpl.instance; | |
| 2255 } | |
| 2256 return i >= numTypeArguments | |
| 2257 ? DynamicTypeImpl.instance | |
| 2258 : unit._resolveTypeRef( | |
| 2259 ref.typeArguments[i], variable._typeParameterContext); | |
| 2260 }, const [])); | |
| 2251 } else { | 2261 } else { |
| 2252 stack.add(DynamicTypeImpl.instance); | 2262 stack.add(DynamicTypeImpl.instance); |
| 2253 } | 2263 } |
| 2254 } | 2264 } |
| 2255 | 2265 |
| 2256 void _doInvokeMethod() { | 2266 void _doInvokeMethod() { |
| 2257 int numNamed = unlinkedConst.ints[intPtr++]; | 2267 int numNamed = unlinkedConst.ints[intPtr++]; |
| 2258 int numPositional = unlinkedConst.ints[intPtr++]; | 2268 int numPositional = unlinkedConst.ints[intPtr++]; |
| 2259 List<String> namedArgNames = _getNextStrings(numNamed); | 2269 List<String> namedArgNames = _getNextStrings(numNamed); |
| 2260 List<DartType> namedArgTypeList = _popList(numNamed); | 2270 List<DartType> namedArgTypeList = _popList(numNamed); |
| (...skipping 2023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4284 * declared earlier in the file. | 4294 * declared earlier in the file. |
| 4285 */ | 4295 */ |
| 4286 final int nestingLevel; | 4296 final int nestingLevel; |
| 4287 | 4297 |
| 4288 @override | 4298 @override |
| 4289 final TypeParameterizedElementForLink enclosingElement; | 4299 final TypeParameterizedElementForLink enclosingElement; |
| 4290 | 4300 |
| 4291 TypeParameterTypeImpl _type; | 4301 TypeParameterTypeImpl _type; |
| 4292 ElementLocation _location; | 4302 ElementLocation _location; |
| 4293 | 4303 |
| 4304 DartType _bound; | |
| 4305 | |
| 4294 TypeParameterElementForLink( | 4306 TypeParameterElementForLink( |
| 4295 this.enclosingElement, this._unlinkedTypeParam, this.nestingLevel); | 4307 this.enclosingElement, this._unlinkedTypeParam, this.nestingLevel); |
| 4296 | 4308 |
| 4297 @override | 4309 @override |
| 4298 DartType get bound { | 4310 DartType get bound { |
| 4299 if (_unlinkedTypeParam.bound == null) { | 4311 if (_unlinkedTypeParam.bound == null) { |
| 4300 return null; | 4312 return null; |
| 4301 } | 4313 } |
| 4302 // TODO(scheglov) implement | 4314 return _bound ??= enclosingElement.compilationUnit |
| 4303 throw new UnimplementedError(); | 4315 ._resolveTypeRef(_unlinkedTypeParam.bound, enclosingElement); |
| 4304 } | 4316 } |
| 4305 | 4317 |
| 4306 @override | 4318 @override |
| 4307 String get identifier => name; | 4319 String get identifier => name; |
| 4308 | 4320 |
| 4309 @override | 4321 @override |
| 4310 ElementKind get kind => ElementKind.TYPE_PARAMETER; | 4322 ElementKind get kind => ElementKind.TYPE_PARAMETER; |
| 4311 | 4323 |
| 4312 @override | 4324 @override |
| 4313 ElementLocation get location => | 4325 ElementLocation get location => |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4737 * there are no type parameters in scope. | 4749 * there are no type parameters in scope. |
| 4738 */ | 4750 */ |
| 4739 TypeParameterizedElementForLink get _typeParameterContext; | 4751 TypeParameterizedElementForLink get _typeParameterContext; |
| 4740 | 4752 |
| 4741 @override | 4753 @override |
| 4742 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 4754 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 4743 | 4755 |
| 4744 @override | 4756 @override |
| 4745 String toString() => '$enclosingElement.$name'; | 4757 String toString() => '$enclosingElement.$name'; |
| 4746 } | 4758 } |
| OLD | NEW |