| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 class World { | 5 class World { |
| 6 Compiler compiler; // Set in populate(). | 6 Compiler compiler; // Set in populate(). |
| 7 final Map<ClassElement, Set<ClassElement>> subtypes; | 7 final Map<ClassElement, Set<ClassElement>> subtypes; |
| 8 | 8 |
| 9 World() : subtypes = new Map<ClassElement, Set<ClassElement>>(); | 9 World() : subtypes = new Map<ClassElement, Set<ClassElement>>(); |
| 10 | 10 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 } else { | 65 } else { |
| 66 nonFieldCount++; | 66 nonFieldCount++; |
| 67 } | 67 } |
| 68 }); | 68 }); |
| 69 return (fieldCount == 1 && nonFieldCount == 0) ? field : null; | 69 return (fieldCount == 1 && nonFieldCount == 0) ? field : null; |
| 70 } | 70 } |
| 71 | 71 |
| 72 Set<ClassElement> findNoSuchMethodHolders(Type type) { | 72 Set<ClassElement> findNoSuchMethodHolders(Type type) { |
| 73 Set<ClassElement> result = new Set<ClassElement>(); | 73 Set<ClassElement> result = new Set<ClassElement>(); |
| 74 MemberSet memberSet = _memberSetFor(type, Compiler.NO_SUCH_METHOD); | 74 MemberSet memberSet = _memberSetFor(type, Compiler.NO_SUCH_METHOD); |
| 75 Selector noSuchMethodSelector = new Selector.noSuchMethod(); |
| 75 for (Element element in memberSet.elements) { | 76 for (Element element in memberSet.elements) { |
| 76 ClassElement holder = element.getEnclosingClass(); | 77 ClassElement holder = element.getEnclosingClass(); |
| 77 if (holder !== compiler.objectClass && | 78 if (holder !== compiler.objectClass && |
| 78 Selector.INVOCATION_2.applies(element, compiler)) { | 79 noSuchMethodSelector.applies(element, compiler)) { |
| 79 result.add(holder); | 80 result.add(holder); |
| 80 } | 81 } |
| 81 } | 82 } |
| 82 return result; | 83 return result; |
| 83 } | 84 } |
| 84 } | 85 } |
| 85 | 86 |
| 86 /** | 87 /** |
| 87 * A [MemberSet] contains all the possible targets for a selector. | 88 * A [MemberSet] contains all the possible targets for a selector. |
| 88 */ | 89 */ |
| 89 class MemberSet { | 90 class MemberSet { |
| 90 final Set<Element> elements; | 91 final Set<Element> elements; |
| 91 final SourceString name; | 92 final SourceString name; |
| 92 | 93 |
| 93 MemberSet(SourceString this.name) : elements = new Set<Element>(); | 94 MemberSet(SourceString this.name) : elements = new Set<Element>(); |
| 94 | 95 |
| 95 void add(Element element) { | 96 void add(Element element) { |
| 96 elements.add(element); | 97 elements.add(element); |
| 97 } | 98 } |
| 98 | 99 |
| 99 bool isEmpty() => elements.isEmpty(); | 100 bool isEmpty() => elements.isEmpty(); |
| 100 } | 101 } |
| OLD | NEW |