Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(237)

Side by Side Diff: pkg/analyzer/lib/src/summary/link.dart

Issue 1963593003: Implement 'instantiate to bounds' feature in resynthesizer. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 stack.add(enclosingClass.buildType((int i) {
2247 ? DynamicTypeImpl.instance 2248 TypeParameterElement typeParameter = enclosingClass.typeParameters[i];
2248 : unit._resolveTypeRef( 2249 if (linker.strongMode && typeParameter.bound != null) {
Paul Berry 2016/05/09 21:26:36 I don't think the logic is right here. Consider t
scheglov 2016/05/10 02:42:42 Fixed.
2249 ref.typeArguments[i], variable._typeParameterContext), 2250 return typeParameter.bound;
2250 const [])); 2251 }
2252 return i >= ref.typeArguments.length
2253 ? DynamicTypeImpl.instance
2254 : unit._resolveTypeRef(
2255 ref.typeArguments[i], variable._typeParameterContext);
2256 }, const []));
2251 } else { 2257 } else {
2252 stack.add(DynamicTypeImpl.instance); 2258 stack.add(DynamicTypeImpl.instance);
2253 } 2259 }
2254 } 2260 }
2255 2261
2256 void _doInvokeMethod() { 2262 void _doInvokeMethod() {
2257 int numNamed = unlinkedConst.ints[intPtr++]; 2263 int numNamed = unlinkedConst.ints[intPtr++];
2258 int numPositional = unlinkedConst.ints[intPtr++]; 2264 int numPositional = unlinkedConst.ints[intPtr++];
2259 List<String> namedArgNames = _getNextStrings(numNamed); 2265 List<String> namedArgNames = _getNextStrings(numNamed);
2260 List<DartType> namedArgTypeList = _popList(numNamed); 2266 List<DartType> namedArgTypeList = _popList(numNamed);
(...skipping 2023 matching lines...) Expand 10 before | Expand all | Expand 10 after
4284 * declared earlier in the file. 4290 * declared earlier in the file.
4285 */ 4291 */
4286 final int nestingLevel; 4292 final int nestingLevel;
4287 4293
4288 @override 4294 @override
4289 final TypeParameterizedElementForLink enclosingElement; 4295 final TypeParameterizedElementForLink enclosingElement;
4290 4296
4291 TypeParameterTypeImpl _type; 4297 TypeParameterTypeImpl _type;
4292 ElementLocation _location; 4298 ElementLocation _location;
4293 4299
4300 DartType _bound;
4301
4294 TypeParameterElementForLink( 4302 TypeParameterElementForLink(
4295 this.enclosingElement, this._unlinkedTypeParam, this.nestingLevel); 4303 this.enclosingElement, this._unlinkedTypeParam, this.nestingLevel);
4296 4304
4297 @override 4305 @override
4298 DartType get bound { 4306 DartType get bound {
4299 if (_unlinkedTypeParam.bound == null) { 4307 if (_unlinkedTypeParam.bound == null) {
4300 return null; 4308 return null;
4301 } 4309 }
4302 // TODO(scheglov) implement 4310 return _bound ??= enclosingElement.compilationUnit
4303 throw new UnimplementedError(); 4311 ._resolveTypeRef(_unlinkedTypeParam.bound, enclosingElement);
4304 } 4312 }
4305 4313
4306 @override 4314 @override
4307 String get identifier => name; 4315 String get identifier => name;
4308 4316
4309 @override 4317 @override
4310 ElementKind get kind => ElementKind.TYPE_PARAMETER; 4318 ElementKind get kind => ElementKind.TYPE_PARAMETER;
4311 4319
4312 @override 4320 @override
4313 ElementLocation get location => 4321 ElementLocation get location =>
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
4737 * there are no type parameters in scope. 4745 * there are no type parameters in scope.
4738 */ 4746 */
4739 TypeParameterizedElementForLink get _typeParameterContext; 4747 TypeParameterizedElementForLink get _typeParameterContext;
4740 4748
4741 @override 4749 @override
4742 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 4750 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
4743 4751
4744 @override 4752 @override
4745 String toString() => '$enclosingElement.$name'; 4753 String toString() => '$enclosingElement.$name';
4746 } 4754 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698