| 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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 return result; | 183 return result; |
| 184 } else if (type is TypeParameterType) { | 184 } else if (type is TypeParameterType) { |
| 185 TypeParameterElementForLink element = type.element; | 185 TypeParameterElementForLink element = type.element; |
| 186 result.paramReference = | 186 result.paramReference = |
| 187 typeParameterContext.typeParameterNestingLevel - element.nestingLevel; | 187 typeParameterContext.typeParameterNestingLevel - element.nestingLevel; |
| 188 return result; | 188 return result; |
| 189 } else if (type is FunctionType) { | 189 } else if (type is FunctionType) { |
| 190 Element element = type.element; | 190 Element element = type.element; |
| 191 if (element is FunctionElementForLink_FunctionTypedParam) { | 191 if (element is FunctionElementForLink_FunctionTypedParam) { |
| 192 result.reference = | 192 result.reference = |
| 193 compilationUnit.addReference(element.enclosingExecutable); | 193 compilationUnit.addReference(element.innermostExecutable); |
| 194 result.implicitFunctionTypeIndices = element.implicitFunctionTypeIndices; | 194 result.implicitFunctionTypeIndices = element.implicitFunctionTypeIndices; |
| 195 if (type.typeArguments.isNotEmpty) { | 195 if (type.typeArguments.isNotEmpty) { |
| 196 result.typeArguments = type.typeArguments | 196 result.typeArguments = type.typeArguments |
| 197 .map((DartType t) => | 197 .map((DartType t) => |
| 198 _createLinkedType(t, compilationUnit, typeParameterContext)) | 198 _createLinkedType(t, compilationUnit, typeParameterContext)) |
| 199 .toList(); | 199 .toList(); |
| 200 } | 200 } |
| 201 return result; | 201 return result; |
| 202 } | 202 } |
| 203 if (element is TopLevelFunctionElementForLink) { | 203 if (element is TopLevelFunctionElementForLink) { |
| (...skipping 1375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1579 // Kick off the algorithm starting with the starting point. | 1579 // Kick off the algorithm starting with the starting point. |
| 1580 strongConnect(startingPoint); | 1580 strongConnect(startingPoint); |
| 1581 } | 1581 } |
| 1582 } | 1582 } |
| 1583 | 1583 |
| 1584 /** | 1584 /** |
| 1585 * Base class for executable elements resynthesized from a summary during | 1585 * Base class for executable elements resynthesized from a summary during |
| 1586 * linking. | 1586 * linking. |
| 1587 */ | 1587 */ |
| 1588 abstract class ExecutableElementForLink extends Object | 1588 abstract class ExecutableElementForLink extends Object |
| 1589 with TypeParameterizedElementForLink | 1589 with TypeParameterizedElementForLink, ParameterParentElementForLink |
| 1590 implements ExecutableElementImpl { | 1590 implements ExecutableElementImpl { |
| 1591 /** | 1591 /** |
| 1592 * The unlinked representation of the method in the summary. | 1592 * The unlinked representation of the method in the summary. |
| 1593 */ | 1593 */ |
| 1594 final UnlinkedExecutable _unlinkedExecutable; | 1594 final UnlinkedExecutable _unlinkedExecutable; |
| 1595 | 1595 |
| 1596 DartType _declaredReturnType; | 1596 DartType _declaredReturnType; |
| 1597 DartType _inferredReturnType; | 1597 DartType _inferredReturnType; |
| 1598 FunctionTypeImpl _type; | 1598 FunctionTypeImpl _type; |
| 1599 List<TypeParameterElementForLink> _typeParameters; | 1599 List<TypeParameterElementForLink> _typeParameters; |
| 1600 String _name; | 1600 String _name; |
| 1601 List<ParameterElementForLink> _parameters; | |
| 1602 String _displayName; | 1601 String _displayName; |
| 1603 | 1602 |
| 1604 /** | 1603 /** |
| 1605 * Return the class in which this executable appears, maybe `null` for a | 1604 * Return the class in which this executable appears, maybe `null` for a |
| 1606 * top-level function. | 1605 * top-level function. |
| 1607 */ | 1606 */ |
| 1608 final ClassElementForLink_Class enclosingClass; | 1607 final ClassElementForLink_Class enclosingClass; |
| 1609 | 1608 |
| 1610 /** | 1609 /** |
| 1611 * Return the compilation unit in which this executable appears. | 1610 * Return the compilation unit in which this executable appears. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1642 @override | 1641 @override |
| 1643 Element get enclosingElement => enclosingClass ?? enclosingUnit; | 1642 Element get enclosingElement => enclosingClass ?? enclosingUnit; |
| 1644 | 1643 |
| 1645 @override | 1644 @override |
| 1646 TypeParameterizedElementForLink get enclosingTypeParameterContext => | 1645 TypeParameterizedElementForLink get enclosingTypeParameterContext => |
| 1647 enclosingClass; | 1646 enclosingClass; |
| 1648 | 1647 |
| 1649 @override | 1648 @override |
| 1650 bool get hasImplicitReturnType => _unlinkedExecutable.returnType == null; | 1649 bool get hasImplicitReturnType => _unlinkedExecutable.returnType == null; |
| 1651 | 1650 |
| 1651 @override |
| 1652 List<int> get implicitFunctionTypeIndices => const <int>[]; |
| 1653 |
| 1652 /** | 1654 /** |
| 1653 * Return the inferred return type of the executable element. Should only be | 1655 * Return the inferred return type of the executable element. Should only be |
| 1654 * called if no return type was explicitly declared. | 1656 * called if no return type was explicitly declared. |
| 1655 */ | 1657 */ |
| 1656 DartType get inferredReturnType { | 1658 DartType get inferredReturnType { |
| 1657 // We should only try to infer a return type when none is explicitly | 1659 // We should only try to infer a return type when none is explicitly |
| 1658 // declared. | 1660 // declared. |
| 1659 assert(_unlinkedExecutable.returnType == null); | 1661 assert(_unlinkedExecutable.returnType == null); |
| 1660 if (Linker._initializerTypeInferenceCycle != null && | 1662 if (Linker._initializerTypeInferenceCycle != null && |
| 1661 Linker._initializerTypeInferenceCycle == | 1663 Linker._initializerTypeInferenceCycle == |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1672 _inferredReturnType = _computeDefaultReturnType(); | 1674 _inferredReturnType = _computeDefaultReturnType(); |
| 1673 } else { | 1675 } else { |
| 1674 _inferredReturnType = enclosingUnit.getLinkedType( | 1676 _inferredReturnType = enclosingUnit.getLinkedType( |
| 1675 _unlinkedExecutable.inferredReturnTypeSlot, this); | 1677 _unlinkedExecutable.inferredReturnTypeSlot, this); |
| 1676 } | 1678 } |
| 1677 } | 1679 } |
| 1678 return _inferredReturnType; | 1680 return _inferredReturnType; |
| 1679 } | 1681 } |
| 1680 | 1682 |
| 1681 @override | 1683 @override |
| 1684 ExecutableElementForLink get innermostExecutable => this; |
| 1685 |
| 1686 @override |
| 1682 bool get isStatic => _unlinkedExecutable.isStatic; | 1687 bool get isStatic => _unlinkedExecutable.isStatic; |
| 1683 | 1688 |
| 1684 @override | 1689 @override |
| 1685 bool get isSynthetic => false; | 1690 bool get isSynthetic => false; |
| 1686 | 1691 |
| 1687 @override | 1692 @override |
| 1688 LibraryElementForLink get library => enclosingElement.library; | 1693 LibraryElementForLink get library => enclosingElement.library; |
| 1689 | 1694 |
| 1690 @override | 1695 @override |
| 1691 String get name { | 1696 String get name { |
| 1692 if (_name == null) { | 1697 if (_name == null) { |
| 1693 _name = _unlinkedExecutable.name; | 1698 _name = _unlinkedExecutable.name; |
| 1694 if (_name == '-' && _unlinkedExecutable.parameters.isEmpty) { | 1699 if (_name == '-' && _unlinkedExecutable.parameters.isEmpty) { |
| 1695 _name = 'unary-'; | 1700 _name = 'unary-'; |
| 1696 } | 1701 } |
| 1697 } | 1702 } |
| 1698 return _name; | 1703 return _name; |
| 1699 } | 1704 } |
| 1700 | 1705 |
| 1701 @override | 1706 @override |
| 1702 List<ParameterElementForLink> get parameters { | |
| 1703 if (_parameters == null) { | |
| 1704 int numParameters = _unlinkedExecutable.parameters.length; | |
| 1705 _parameters = new List<ParameterElementForLink>(numParameters); | |
| 1706 for (int i = 0; i < numParameters; i++) { | |
| 1707 UnlinkedParam unlinkedParam = _unlinkedExecutable.parameters[i]; | |
| 1708 _parameters[i] = new ParameterElementForLink( | |
| 1709 this, unlinkedParam, this, enclosingUnit, i); | |
| 1710 } | |
| 1711 } | |
| 1712 return _parameters; | |
| 1713 } | |
| 1714 | |
| 1715 @override | |
| 1716 DartType get returnType => declaredReturnType ?? inferredReturnType; | 1707 DartType get returnType => declaredReturnType ?? inferredReturnType; |
| 1717 | 1708 |
| 1718 @override | 1709 @override |
| 1719 void set returnType(DartType inferredType) { | 1710 void set returnType(DartType inferredType) { |
| 1720 assert(_inferredReturnType == null); | 1711 assert(_inferredReturnType == null); |
| 1721 _inferredReturnType = inferredType; | 1712 _inferredReturnType = inferredType; |
| 1722 } | 1713 } |
| 1723 | 1714 |
| 1724 @override | 1715 @override |
| 1725 FunctionTypeImpl get type => _type ??= new FunctionTypeImpl(this); | 1716 FunctionTypeImpl get type => _type ??= new FunctionTypeImpl(this); |
| 1726 | 1717 |
| 1727 @override | 1718 @override |
| 1719 List<UnlinkedParam> get unlinkedParameters => _unlinkedExecutable.parameters; |
| 1720 |
| 1721 @override |
| 1728 List<UnlinkedTypeParam> get _unlinkedTypeParams => | 1722 List<UnlinkedTypeParam> get _unlinkedTypeParams => |
| 1729 _unlinkedExecutable.typeParameters; | 1723 _unlinkedExecutable.typeParameters; |
| 1730 | 1724 |
| 1731 @override | 1725 @override |
| 1732 bool isAccessibleIn(LibraryElement library) => | 1726 bool isAccessibleIn(LibraryElement library) => |
| 1733 !Identifier.isPrivateName(name) || identical(this.library, library); | 1727 !Identifier.isPrivateName(name) || identical(this.library, library); |
| 1734 | 1728 |
| 1735 /** | 1729 /** |
| 1736 * Store the results of type inference for this method in [compilationUnit]. | 1730 * Store the results of type inference for this method in [compilationUnit]. |
| 1737 */ | 1731 */ |
| (...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2509 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 2503 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 2510 | 2504 |
| 2511 @override | 2505 @override |
| 2512 String toString() => '$enclosingElement.$name'; | 2506 String toString() => '$enclosingElement.$name'; |
| 2513 } | 2507 } |
| 2514 | 2508 |
| 2515 /** | 2509 /** |
| 2516 * Element representing a function-typed parameter resynthesied from a summary | 2510 * Element representing a function-typed parameter resynthesied from a summary |
| 2517 * during linking. | 2511 * during linking. |
| 2518 */ | 2512 */ |
| 2519 class FunctionElementForLink_FunctionTypedParam implements FunctionElement { | 2513 class FunctionElementForLink_FunctionTypedParam extends Object |
| 2514 with ParameterParentElementForLink |
| 2515 implements FunctionElement { |
| 2520 @override | 2516 @override |
| 2521 final ParameterElementForLink enclosingElement; | 2517 final ParameterElementForLink enclosingElement; |
| 2522 | 2518 |
| 2523 /** | 2519 @override |
| 2524 * The executable element containing this function-typed parameter. | 2520 final ExecutableElementForLink innermostExecutable; |
| 2525 */ | |
| 2526 final Element enclosingExecutable; | |
| 2527 | 2521 |
| 2528 /** | 2522 @override |
| 2529 * The appropriate integer list to store in | 2523 final List<UnlinkedParam> unlinkedParameters; |
| 2530 * [EntityRef.implicitFunctionTypeIndices] to refer to this function-typed | |
| 2531 * parameter. | |
| 2532 */ | |
| 2533 final List<int> implicitFunctionTypeIndices; | |
| 2534 | 2524 |
| 2535 DartType _returnType; | 2525 DartType _returnType; |
| 2526 List<int> _implicitFunctionTypeIndices; |
| 2536 | 2527 |
| 2537 FunctionElementForLink_FunctionTypedParam(this.enclosingElement, | 2528 FunctionElementForLink_FunctionTypedParam( |
| 2538 this.enclosingExecutable, this.implicitFunctionTypeIndices); | 2529 this.enclosingElement, this.innermostExecutable, this.unlinkedParameters); |
| 2530 |
| 2531 @override |
| 2532 List<int> get implicitFunctionTypeIndices { |
| 2533 if (_implicitFunctionTypeIndices == null) { |
| 2534 _implicitFunctionTypeIndices = enclosingElement |
| 2535 .enclosingElement.implicitFunctionTypeIndices |
| 2536 .toList(); |
| 2537 _implicitFunctionTypeIndices.add(enclosingElement._parameterIndex); |
| 2538 } |
| 2539 return _implicitFunctionTypeIndices; |
| 2540 } |
| 2539 | 2541 |
| 2540 @override | 2542 @override |
| 2541 DartType get returnType { | 2543 DartType get returnType { |
| 2542 if (_returnType == null) { | 2544 if (_returnType == null) { |
| 2543 if (enclosingElement._unlinkedParam.type == null) { | 2545 if (enclosingElement._unlinkedParam.type == null) { |
| 2544 _returnType = DynamicTypeImpl.instance; | 2546 _returnType = DynamicTypeImpl.instance; |
| 2545 } else { | 2547 } else { |
| 2546 _returnType = enclosingElement.compilationUnit._resolveTypeRef( | 2548 _returnType = enclosingElement.compilationUnit._resolveTypeRef( |
| 2547 enclosingElement._unlinkedParam.type, | 2549 enclosingElement._unlinkedParam.type, innermostExecutable); |
| 2548 enclosingElement._typeParameterContext); | |
| 2549 } | 2550 } |
| 2550 } | 2551 } |
| 2551 return _returnType; | 2552 return _returnType; |
| 2552 } | 2553 } |
| 2553 | 2554 |
| 2554 @override | 2555 @override |
| 2555 List<TypeParameterElement> get typeParameters => const []; | 2556 List<TypeParameterElement> get typeParameters => const []; |
| 2556 | 2557 |
| 2557 @override | 2558 @override |
| 2558 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 2559 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| (...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3264 * Element representing a function or method parameter resynthesized | 3265 * Element representing a function or method parameter resynthesized |
| 3265 * from a summary during linking. | 3266 * from a summary during linking. |
| 3266 */ | 3267 */ |
| 3267 class ParameterElementForLink implements ParameterElementImpl { | 3268 class ParameterElementForLink implements ParameterElementImpl { |
| 3268 /** | 3269 /** |
| 3269 * The unlinked representation of the parameter in the summary. | 3270 * The unlinked representation of the parameter in the summary. |
| 3270 */ | 3271 */ |
| 3271 final UnlinkedParam _unlinkedParam; | 3272 final UnlinkedParam _unlinkedParam; |
| 3272 | 3273 |
| 3273 /** | 3274 /** |
| 3274 * The context in which type parameters should be interpreted. | 3275 * The innermost executable element containing this parameter. |
| 3275 */ | 3276 */ |
| 3276 final TypeParameterizedElementForLink _typeParameterContext; | 3277 final ExecutableElementForLink _innermostExecutable; |
| 3277 | 3278 |
| 3278 /** | 3279 /** |
| 3279 * If this parameter has a default value and the enclosing library | 3280 * If this parameter has a default value and the enclosing library |
| 3280 * is part of the build unit being linked, the parameter's node in | 3281 * is part of the build unit being linked, the parameter's node in |
| 3281 * the constant evaluation dependency graph. Otherwise `null`. | 3282 * the constant evaluation dependency graph. Otherwise `null`. |
| 3282 */ | 3283 */ |
| 3283 ConstNode _constNode; | 3284 ConstNode _constNode; |
| 3284 | 3285 |
| 3285 /** | 3286 /** |
| 3286 * The compilation unit in which this parameter appears. | 3287 * The compilation unit in which this parameter appears. |
| 3287 */ | 3288 */ |
| 3288 final CompilationUnitElementForLink compilationUnit; | 3289 final CompilationUnitElementForLink compilationUnit; |
| 3289 | 3290 |
| 3290 /** | 3291 /** |
| 3291 * The index of this parameter within [enclosingElement]'s parameter list. | 3292 * The index of this parameter within [enclosingElement]'s parameter list. |
| 3292 */ | 3293 */ |
| 3293 final int _parameterIndex; | 3294 final int _parameterIndex; |
| 3294 | 3295 |
| 3295 @override | 3296 @override |
| 3296 final ExecutableElementForLink enclosingElement; | 3297 final ParameterParentElementForLink enclosingElement; |
| 3297 | 3298 |
| 3298 DartType _inferredType; | 3299 DartType _inferredType; |
| 3299 DartType _declaredType; | 3300 DartType _declaredType; |
| 3300 | 3301 |
| 3301 ParameterElementForLink(this.enclosingElement, this._unlinkedParam, | 3302 ParameterElementForLink(this.enclosingElement, this._unlinkedParam, |
| 3302 this._typeParameterContext, this.compilationUnit, this._parameterIndex) { | 3303 this._innermostExecutable, this.compilationUnit, this._parameterIndex) { |
| 3303 if (_unlinkedParam.defaultValue != null) { | 3304 if (_unlinkedParam.defaultValue != null) { |
| 3304 _constNode = new ConstParameterNode(this); | 3305 _constNode = new ConstParameterNode(this); |
| 3305 } | 3306 } |
| 3306 } | 3307 } |
| 3307 | 3308 |
| 3308 @override | 3309 @override |
| 3309 bool get hasImplicitType => | 3310 bool get hasImplicitType => |
| 3310 !_unlinkedParam.isFunctionTyped && _unlinkedParam.type == null; | 3311 !_unlinkedParam.isFunctionTyped && _unlinkedParam.type == null; |
| 3311 | 3312 |
| 3312 @override | 3313 @override |
| (...skipping 12 matching lines...) Expand all Loading... |
| 3325 } | 3326 } |
| 3326 | 3327 |
| 3327 @override | 3328 @override |
| 3328 DartType get type { | 3329 DartType get type { |
| 3329 if (_inferredType != null) { | 3330 if (_inferredType != null) { |
| 3330 return _inferredType; | 3331 return _inferredType; |
| 3331 } else if (_declaredType == null) { | 3332 } else if (_declaredType == null) { |
| 3332 if (_unlinkedParam.isFunctionTyped) { | 3333 if (_unlinkedParam.isFunctionTyped) { |
| 3333 _declaredType = new FunctionTypeImpl( | 3334 _declaredType = new FunctionTypeImpl( |
| 3334 new FunctionElementForLink_FunctionTypedParam( | 3335 new FunctionElementForLink_FunctionTypedParam( |
| 3335 this, enclosingElement, <int>[_parameterIndex])); | 3336 this, _innermostExecutable, _unlinkedParam.parameters)); |
| 3336 } else if (_unlinkedParam.type == null) { | 3337 } else if (_unlinkedParam.type == null) { |
| 3337 if (!compilationUnit.isInBuildUnit) { | 3338 if (!compilationUnit.isInBuildUnit) { |
| 3338 _inferredType = compilationUnit.getLinkedType( | 3339 _inferredType = compilationUnit.getLinkedType( |
| 3339 _unlinkedParam.inferredTypeSlot, _typeParameterContext); | 3340 _unlinkedParam.inferredTypeSlot, _innermostExecutable); |
| 3340 return _inferredType; | 3341 return _inferredType; |
| 3341 } else { | 3342 } else { |
| 3342 _declaredType = DynamicTypeImpl.instance; | 3343 _declaredType = DynamicTypeImpl.instance; |
| 3343 } | 3344 } |
| 3344 } else { | 3345 } else { |
| 3345 _declaredType = compilationUnit._resolveTypeRef( | 3346 _declaredType = compilationUnit._resolveTypeRef( |
| 3346 _unlinkedParam.type, _typeParameterContext); | 3347 _unlinkedParam.type, _innermostExecutable); |
| 3347 } | 3348 } |
| 3348 } | 3349 } |
| 3349 return _declaredType; | 3350 return _declaredType; |
| 3350 } | 3351 } |
| 3351 | 3352 |
| 3352 @override | 3353 @override |
| 3353 void set type(DartType inferredType) { | 3354 void set type(DartType inferredType) { |
| 3354 assert(_inferredType == null); | 3355 assert(_inferredType == null); |
| 3355 _inferredType = inferredType; | 3356 _inferredType = inferredType; |
| 3356 } | 3357 } |
| 3357 | 3358 |
| 3358 /** | 3359 /** |
| 3359 * Store the results of type inference for this parameter in | 3360 * Store the results of type inference for this parameter in |
| 3360 * [compilationUnit]. | 3361 * [compilationUnit]. |
| 3361 */ | 3362 */ |
| 3362 void link(CompilationUnitElementInBuildUnit compilationUnit) { | 3363 void link(CompilationUnitElementInBuildUnit compilationUnit) { |
| 3363 compilationUnit._storeLinkedType( | 3364 compilationUnit._storeLinkedType( |
| 3364 _unlinkedParam.inferredTypeSlot, _inferredType, _typeParameterContext); | 3365 _unlinkedParam.inferredTypeSlot, _inferredType, _innermostExecutable); |
| 3365 } | 3366 } |
| 3366 | 3367 |
| 3367 @override | 3368 @override |
| 3368 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 3369 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 3369 } | 3370 } |
| 3370 | 3371 |
| 3371 /** | 3372 /** |
| 3372 * Element representing the parameter of a synthetic setter for a variable | 3373 * Element representing the parameter of a synthetic setter for a variable |
| 3373 * resynthesized during linking. | 3374 * resynthesized during linking. |
| 3374 */ | 3375 */ |
| (...skipping 13 matching lines...) Expand all Loading... |
| 3388 ParameterKind get parameterKind => ParameterKind.REQUIRED; | 3389 ParameterKind get parameterKind => ParameterKind.REQUIRED; |
| 3389 | 3390 |
| 3390 @override | 3391 @override |
| 3391 DartType get type => enclosingElement.computeVariableType(); | 3392 DartType get type => enclosingElement.computeVariableType(); |
| 3392 | 3393 |
| 3393 @override | 3394 @override |
| 3394 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 3395 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 3395 } | 3396 } |
| 3396 | 3397 |
| 3397 /** | 3398 /** |
| 3399 * Mixin used by elements that can have parameters. |
| 3400 */ |
| 3401 abstract class ParameterParentElementForLink implements Element { |
| 3402 List<ParameterElementForLink> _parameters; |
| 3403 |
| 3404 /** |
| 3405 * Get the appropriate integer list to store in |
| 3406 * [EntityRef.implicitFunctionTypeIndices] to refer to this element. For an |
| 3407 * element representing a function-typed parameter, this should return a |
| 3408 * non-empty list. For an element representing an executable, this should |
| 3409 * return the empty list. |
| 3410 */ |
| 3411 List<int> get implicitFunctionTypeIndices; |
| 3412 |
| 3413 /** |
| 3414 * Get the innermost enclosing ExecutableElement (which may be [this], or may |
| 3415 * be a parent when there are function-typed parameters). |
| 3416 */ |
| 3417 ExecutableElementForLink get innermostExecutable; |
| 3418 |
| 3419 /** |
| 3420 * Get all the parameters of this element. |
| 3421 */ |
| 3422 List<ParameterElementForLink> get parameters { |
| 3423 if (_parameters == null) { |
| 3424 List<UnlinkedParam> unlinkedParameters = this.unlinkedParameters; |
| 3425 int numParameters = unlinkedParameters.length; |
| 3426 _parameters = new List<ParameterElementForLink>(numParameters); |
| 3427 for (int i = 0; i < numParameters; i++) { |
| 3428 UnlinkedParam unlinkedParam = unlinkedParameters[i]; |
| 3429 _parameters[i] = new ParameterElementForLink(this, unlinkedParam, |
| 3430 innermostExecutable, innermostExecutable.enclosingUnit, i); |
| 3431 } |
| 3432 } |
| 3433 return _parameters; |
| 3434 } |
| 3435 |
| 3436 /** |
| 3437 * Get the list of unlinked parameters of this element. |
| 3438 */ |
| 3439 List<UnlinkedParam> get unlinkedParameters; |
| 3440 } |
| 3441 |
| 3442 /** |
| 3398 * Element representing a getter or setter resynthesized from a summary during | 3443 * Element representing a getter or setter resynthesized from a summary during |
| 3399 * linking. | 3444 * linking. |
| 3400 */ | 3445 */ |
| 3401 abstract class PropertyAccessorElementForLink | 3446 abstract class PropertyAccessorElementForLink |
| 3402 implements PropertyAccessorElementImpl { | 3447 implements PropertyAccessorElementImpl { |
| 3403 void link(CompilationUnitElementInBuildUnit compilationUnit); | 3448 void link(CompilationUnitElementInBuildUnit compilationUnit); |
| 3404 } | 3449 } |
| 3405 | 3450 |
| 3406 /** | 3451 /** |
| 3407 * Specialization of [PropertyAccessorElementForLink] for non-synthetic | 3452 * Specialization of [PropertyAccessorElementForLink] for non-synthetic |
| (...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4302 if (type is InterfaceType) { | 4347 if (type is InterfaceType) { |
| 4303 Element result = type.lookUpGetter(name, compilationUnit.library); | 4348 Element result = type.lookUpGetter(name, compilationUnit.library); |
| 4304 result ??= type.lookUpMethod(name, compilationUnit.library); | 4349 result ??= type.lookUpMethod(name, compilationUnit.library); |
| 4305 return result; | 4350 return result; |
| 4306 } | 4351 } |
| 4307 } | 4352 } |
| 4308 // TODO(scheglov): implement for propagated types | 4353 // TODO(scheglov): implement for propagated types |
| 4309 return null; | 4354 return null; |
| 4310 } | 4355 } |
| 4311 } | 4356 } |
| OLD | NEW |