| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import '../closure.dart'; | 5 import '../closure.dart'; |
| 6 import '../common.dart'; | 6 import '../common.dart'; |
| 7 import '../common_elements.dart'; | 7 import '../common_elements.dart'; |
| 8 import '../compiler.dart'; | 8 import '../compiler.dart'; |
| 9 import '../constants/values.dart'; | 9 import '../constants/values.dart'; |
| 10 import '../elements/elements.dart'; | 10 import '../elements/elements.dart'; |
| (...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 for (LocalFunctionElement closure in worldBuilder.localFunctions) { | 548 for (LocalFunctionElement closure in worldBuilder.localFunctions) { |
| 549 closureMap.putIfAbsent(closure.enclosingClass, () => []).add(closure); | 549 closureMap.putIfAbsent(closure.enclosingClass, () => []).add(closure); |
| 550 } | 550 } |
| 551 bool foundClosure = false; | 551 bool foundClosure = false; |
| 552 for (ClassElement cls in worldBuilder.directlyInstantiatedClasses) { | 552 for (ClassElement cls in worldBuilder.directlyInstantiatedClasses) { |
| 553 // Do not process internal classes. | 553 // Do not process internal classes. |
| 554 if (cls.library.isInternalLibrary || cls.isInjected) continue; | 554 if (cls.library.isInternalLibrary || cls.isInjected) continue; |
| 555 if (isClassReferencedFromMirrorSystem(cls)) { | 555 if (isClassReferencedFromMirrorSystem(cls)) { |
| 556 Set<Name> memberNames = new Set<Name>(); | 556 Set<Name> memberNames = new Set<Name>(); |
| 557 // 1) the class (should be resolved) | 557 // 1) the class (should be resolved) |
| 558 assert(invariant(cls, cls.isResolved)); | 558 assert(cls.isResolved, failedAt(cls)); |
| 559 _classesNeededForReflection.add(cls); | 559 _classesNeededForReflection.add(cls); |
| 560 // 2) its constructors (if resolved) | 560 // 2) its constructors (if resolved) |
| 561 cls.constructors.forEach((ConstructorElement constructor) { | 561 cls.constructors.forEach((ConstructorElement constructor) { |
| 562 if (worldBuilder.isMemberUsed(constructor)) { | 562 if (worldBuilder.isMemberUsed(constructor)) { |
| 563 _membersNeededForReflection.add(constructor); | 563 _membersNeededForReflection.add(constructor); |
| 564 } | 564 } |
| 565 }); | 565 }); |
| 566 // 3) all members, including fields via getter/setters (if resolved) | 566 // 3) all members, including fields via getter/setters (if resolved) |
| 567 cls.forEachClassMember((Member member) { | 567 cls.forEachClassMember((Member member) { |
| 568 MemberElement element = member.element; | 568 MemberElement element = member.element; |
| 569 if (worldBuilder.isMemberUsed(element)) { | 569 if (worldBuilder.isMemberUsed(element)) { |
| 570 memberNames.add(member.name); | 570 memberNames.add(member.name); |
| 571 _membersNeededForReflection.add(element); | 571 _membersNeededForReflection.add(element); |
| 572 element.nestedClosures | 572 element.nestedClosures |
| 573 .forEach((SynthesizedCallMethodElementX callFunction) { | 573 .forEach((SynthesizedCallMethodElementX callFunction) { |
| 574 _membersNeededForReflection.add(callFunction); | 574 _membersNeededForReflection.add(callFunction); |
| 575 _classesNeededForReflection.add(callFunction.closureClass); | 575 _classesNeededForReflection.add(callFunction.closureClass); |
| 576 }); | 576 }); |
| 577 } | 577 } |
| 578 }); | 578 }); |
| 579 // 4) all overriding members of subclasses/subtypes (should be resolved) | 579 // 4) all overriding members of subclasses/subtypes (should be resolved) |
| 580 if (closedWorld.hasAnyStrictSubtype(cls)) { | 580 if (closedWorld.hasAnyStrictSubtype(cls)) { |
| 581 closedWorld.forEachStrictSubtypeOf(cls, (ClassElement subcls) { | 581 closedWorld.forEachStrictSubtypeOf(cls, (ClassElement subcls) { |
| 582 subcls.forEachClassMember((Member member) { | 582 subcls.forEachClassMember((Member member) { |
| 583 if (memberNames.contains(member.name)) { | 583 if (memberNames.contains(member.name)) { |
| 584 // TODO(20993): find out why this assertion fails. | 584 // TODO(20993): find out why this assertion fails. |
| 585 // assert(invariant(member.element, | 585 // assert(worldBuilder.isMemberUsed(member.element), |
| 586 // worldBuilder.isMemberUsed(member.element))); | 586 // failedAt(member.element)); |
| 587 if (worldBuilder.isMemberUsed(member.element)) { | 587 if (worldBuilder.isMemberUsed(member.element)) { |
| 588 _membersNeededForReflection.add(member.element); | 588 _membersNeededForReflection.add(member.element); |
| 589 } | 589 } |
| 590 } | 590 } |
| 591 }); | 591 }); |
| 592 }); | 592 }); |
| 593 } | 593 } |
| 594 // 5) all its closures | 594 // 5) all its closures |
| 595 List<LocalFunctionElement> closures = closureMap[cls]; | 595 List<LocalFunctionElement> closures = closureMap[cls]; |
| 596 if (closures != null) { | 596 if (closures != null) { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 } | 690 } |
| 691 | 691 |
| 692 /// Called when `const Symbol(name)` is seen. | 692 /// Called when `const Symbol(name)` is seen. |
| 693 void registerConstSymbol(String name) { | 693 void registerConstSymbol(String name) { |
| 694 symbolsUsed.add(name); | 694 symbolsUsed.add(name); |
| 695 if (name.endsWith('=')) { | 695 if (name.endsWith('=')) { |
| 696 symbolsUsed.add(name.substring(0, name.length - 1)); | 696 symbolsUsed.add(name.substring(0, name.length - 1)); |
| 697 } | 697 } |
| 698 } | 698 } |
| 699 } | 699 } |
| OLD | NEW |