| 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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 final CompilationUnitElementForLink enclosingElement; | 264 final CompilationUnitElementForLink enclosingElement; |
| 265 | 265 |
| 266 @override | 266 @override |
| 267 bool hasBeenInferred; | 267 bool hasBeenInferred; |
| 268 | 268 |
| 269 ClassElementForLink(CompilationUnitElementForLink enclosingElement) | 269 ClassElementForLink(CompilationUnitElementForLink enclosingElement) |
| 270 : enclosingElement = enclosingElement, | 270 : enclosingElement = enclosingElement, |
| 271 hasBeenInferred = !enclosingElement.isInBuildUnit; | 271 hasBeenInferred = !enclosingElement.isInBuildUnit; |
| 272 | 272 |
| 273 @override | 273 @override |
| 274 List<PropertyAccessorElementForLink> get accessors; |
| 275 |
| 276 @override |
| 274 ConstructorElementForLink get asConstructor => unnamedConstructor; | 277 ConstructorElementForLink get asConstructor => unnamedConstructor; |
| 275 | 278 |
| 276 @override | 279 @override |
| 277 ConstVariableNode get asConstVariable { | 280 ConstVariableNode get asConstVariable { |
| 278 // When a class name is used as a constant variable, it doesn't depend on | 281 // When a class name is used as a constant variable, it doesn't depend on |
| 279 // anything, so it is not necessary to include it in the constant | 282 // anything, so it is not necessary to include it in the constant |
| 280 // dependency graph. | 283 // dependency graph. |
| 281 return null; | 284 return null; |
| 282 } | 285 } |
| 283 | 286 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 for (ConstructorElementForLink constructor in constructors) { | 319 for (ConstructorElementForLink constructor in constructors) { |
| 317 _containedNames[constructor.name] = constructor; | 320 _containedNames[constructor.name] = constructor; |
| 318 } | 321 } |
| 319 for (FieldElementForLink field in fields) { | 322 for (FieldElementForLink field in fields) { |
| 320 // TODO(paulberry): do we need to handle nonstatic fields for | 323 // TODO(paulberry): do we need to handle nonstatic fields for |
| 321 // consistent behavior with erroneous code? | 324 // consistent behavior with erroneous code? |
| 322 if (field.isStatic) { | 325 if (field.isStatic) { |
| 323 _containedNames[field.name] = field; | 326 _containedNames[field.name] = field; |
| 324 } | 327 } |
| 325 } | 328 } |
| 329 for (PropertyAccessorElementForLink accessor in accessors) { |
| 330 if (accessor.isStatic && !accessor.isSynthetic) { |
| 331 // TODO(paulberry): add synthetic elements too? |
| 332 _containedNames[accessor.name] = accessor; |
| 333 } |
| 334 } |
| 326 // TODO(paulberry): add methods. | 335 // TODO(paulberry): add methods. |
| 327 } | 336 } |
| 328 return _containedNames.putIfAbsent( | 337 return _containedNames.putIfAbsent( |
| 329 name, () => UndefinedElementForLink.instance); | 338 name, () => UndefinedElementForLink.instance); |
| 330 } | 339 } |
| 331 | 340 |
| 332 /** | 341 /** |
| 333 * Perform type inference and cycle detection on this class and | 342 * Perform type inference and cycle detection on this class and |
| 334 * store the resulting information in [compilationUnit]. | 343 * store the resulting information in [compilationUnit]. |
| 335 */ | 344 */ |
| (...skipping 3118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3454 * Get the list of unlinked parameters of this element. | 3463 * Get the list of unlinked parameters of this element. |
| 3455 */ | 3464 */ |
| 3456 List<UnlinkedParam> get unlinkedParameters; | 3465 List<UnlinkedParam> get unlinkedParameters; |
| 3457 } | 3466 } |
| 3458 | 3467 |
| 3459 /** | 3468 /** |
| 3460 * Element representing a getter or setter resynthesized from a summary during | 3469 * Element representing a getter or setter resynthesized from a summary during |
| 3461 * linking. | 3470 * linking. |
| 3462 */ | 3471 */ |
| 3463 abstract class PropertyAccessorElementForLink | 3472 abstract class PropertyAccessorElementForLink |
| 3464 implements PropertyAccessorElementImpl { | 3473 implements PropertyAccessorElementImpl, ReferenceableElementForLink { |
| 3465 void link(CompilationUnitElementInBuildUnit compilationUnit); | 3474 void link(CompilationUnitElementInBuildUnit compilationUnit); |
| 3466 } | 3475 } |
| 3467 | 3476 |
| 3468 /** | 3477 /** |
| 3469 * Specialization of [PropertyAccessorElementForLink] for non-synthetic | 3478 * Specialization of [PropertyAccessorElementForLink] for non-synthetic |
| 3470 * accessors explicitly declared in the source code. | 3479 * accessors explicitly declared in the source code. |
| 3471 */ | 3480 */ |
| 3472 class PropertyAccessorElementForLink_Executable extends ExecutableElementForLink | 3481 class PropertyAccessorElementForLink_Executable extends ExecutableElementForLink |
| 3473 implements PropertyAccessorElementForLink { | 3482 implements PropertyAccessorElementForLink { |
| 3474 @override | 3483 @override |
| 3475 SyntheticVariableElementForLink variable; | 3484 SyntheticVariableElementForLink variable; |
| 3476 | 3485 |
| 3477 PropertyAccessorElementForLink_Executable( | 3486 PropertyAccessorElementForLink_Executable( |
| 3478 ClassElementForLink_Class enclosingClass, | 3487 ClassElementForLink_Class enclosingClass, |
| 3479 UnlinkedExecutable unlinkedExecutable, | 3488 UnlinkedExecutable unlinkedExecutable, |
| 3480 this.variable) | 3489 this.variable) |
| 3481 : super(enclosingClass.enclosingElement, enclosingClass, | 3490 : super(enclosingClass.enclosingElement, enclosingClass, |
| 3482 unlinkedExecutable); | 3491 unlinkedExecutable); |
| 3483 | 3492 |
| 3484 @override | 3493 @override |
| 3494 ConstructorElementForLink get asConstructor => null; |
| 3495 |
| 3496 @override |
| 3497 ConstVariableNode get asConstVariable => null; |
| 3498 |
| 3499 @override |
| 3500 DartType get asStaticType => returnType; |
| 3501 |
| 3502 @override |
| 3503 TypeInferenceNode get asTypeInferenceNode => null; |
| 3504 |
| 3505 @override |
| 3485 PropertyAccessorElementForLink_Executable get correspondingGetter => | 3506 PropertyAccessorElementForLink_Executable get correspondingGetter => |
| 3486 variable.getter; | 3507 variable.getter; |
| 3487 | 3508 |
| 3488 @override | 3509 @override |
| 3489 bool get isGetter => | 3510 bool get isGetter => |
| 3490 _unlinkedExecutable.kind == UnlinkedExecutableKind.getter; | 3511 _unlinkedExecutable.kind == UnlinkedExecutableKind.getter; |
| 3491 | 3512 |
| 3492 @override | 3513 @override |
| 3493 bool get isSetter => | 3514 bool get isSetter => |
| 3494 _unlinkedExecutable.kind == UnlinkedExecutableKind.setter; | 3515 _unlinkedExecutable.kind == UnlinkedExecutableKind.setter; |
| 3495 | 3516 |
| 3496 @override | 3517 @override |
| 3497 ElementKind get kind => _unlinkedExecutable.kind == | 3518 ElementKind get kind => _unlinkedExecutable.kind == |
| 3498 UnlinkedExecutableKind.getter ? ElementKind.GETTER : ElementKind.SETTER; | 3519 UnlinkedExecutableKind.getter ? ElementKind.GETTER : ElementKind.SETTER; |
| 3499 | 3520 |
| 3500 @override | 3521 @override |
| 3522 DartType buildType(DartType getTypeArgument(int i), |
| 3523 List<int> implicitFunctionTypeIndices) => |
| 3524 DynamicTypeImpl.instance; |
| 3525 |
| 3526 @override |
| 3527 ReferenceableElementForLink getContainedName(String name) => |
| 3528 UndefinedElementForLink.instance; |
| 3529 |
| 3530 @override |
| 3501 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 3531 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 3502 | 3532 |
| 3503 @override | 3533 @override |
| 3504 String toString() => '$enclosingElement.$name'; | 3534 String toString() => '$enclosingElement.$name'; |
| 3505 } | 3535 } |
| 3506 | 3536 |
| 3507 /** | 3537 /** |
| 3508 * Specialization of [PropertyAccessorElementForLink] for synthetic accessors | 3538 * Specialization of [PropertyAccessorElementForLink] for synthetic accessors |
| 3509 * implied by a field or variable declaration. | 3539 * implied by a field or variable declaration. |
| 3510 */ | 3540 */ |
| (...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4364 if (type is InterfaceType) { | 4394 if (type is InterfaceType) { |
| 4365 Element result = type.lookUpGetter(name, compilationUnit.library); | 4395 Element result = type.lookUpGetter(name, compilationUnit.library); |
| 4366 result ??= type.lookUpMethod(name, compilationUnit.library); | 4396 result ??= type.lookUpMethod(name, compilationUnit.library); |
| 4367 return result; | 4397 return result; |
| 4368 } | 4398 } |
| 4369 } | 4399 } |
| 4370 // TODO(scheglov): implement for propagated types | 4400 // TODO(scheglov): implement for propagated types |
| 4371 return null; | 4401 return null; |
| 4372 } | 4402 } |
| 4373 } | 4403 } |
| OLD | NEW |