| 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 part of dart2js; | 5 part of dart2js; |
| 6 | 6 |
| 7 class World { | 7 class World { |
| 8 final Compiler compiler; | 8 final Compiler compiler; |
| 9 final Map<ClassElement, Set<MixinApplicationElement>> mixinUses; | 9 final Map<ClassElement, Set<MixinApplicationElement>> mixinUses; |
| 10 final Map<ClassElement, Set<ClassElement>> typesImplementedBySubclasses; | 10 final Map<ClassElement, Set<ClassElement>> typesImplementedBySubclasses; |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 allFunctions.add(element); | 142 allFunctions.add(element); |
| 143 } | 143 } |
| 144 } | 144 } |
| 145 | 145 |
| 146 VariableElement locateSingleField(Selector selector) { | 146 VariableElement locateSingleField(Selector selector) { |
| 147 Element result = locateSingleElement(selector); | 147 Element result = locateSingleElement(selector); |
| 148 return (result != null && result.isField()) ? result : null; | 148 return (result != null && result.isField()) ? result : null; |
| 149 } | 149 } |
| 150 | 150 |
| 151 Element locateSingleElement(Selector selector) { | 151 Element locateSingleElement(Selector selector) { |
| 152 Iterable<Element> targets = allFunctions.filter(selector); | 152 ti.TypeMask mask = selector.mask == null |
| 153 if (targets.length != 1) return null; | 153 ? new ti.TypeMask.subclass(compiler.objectClass.rawType) |
| 154 Element result = targets.first; | 154 : selector.mask; |
| 155 ClassElement enclosing = result.getEnclosingClass(); | 155 return mask.locateSingleElement(selector, compiler); |
| 156 // TODO(kasperl): Move this code to the type mask. | |
| 157 ti.TypeMask mask = selector.mask; | |
| 158 ClassElement receiverTypeElement = (mask == null || mask.base == null) | |
| 159 ? compiler.objectClass | |
| 160 : mask.base.element; | |
| 161 // We only return the found element if it is guaranteed to be | |
| 162 // implemented on the exact receiver type. It could be found in a | |
| 163 // subclass or in an inheritance-wise unrelated class in case of | |
| 164 // subtype selectors. | |
| 165 return (receiverTypeElement.isSubclassOf(enclosing)) ? result : null; | |
| 166 } | 156 } |
| 167 | 157 |
| 168 bool hasSingleMatch(Selector selector) { | 158 bool hasSingleMatch(Selector selector) { |
| 169 Iterable<Element> targets = allFunctions.filter(selector); | 159 Iterable<Element> targets = allFunctions.filter(selector); |
| 170 return targets.length == 1; | 160 return targets.length == 1; |
| 171 } | 161 } |
| 172 | 162 |
| 173 Iterable<ClassElement> locateNoSuchMethodHolders(Selector selector) { | 163 Iterable<ClassElement> locateNoSuchMethodHolders(Selector selector) { |
| 174 Selector noSuchMethodSelector = compiler.noSuchMethodSelector; | 164 Selector noSuchMethodSelector = compiler.noSuchMethodSelector; |
| 175 ti.TypeMask mask = selector.mask; | 165 ti.TypeMask mask = selector.mask; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 sideEffects.setDependsOnInstancePropertyStore(); | 203 sideEffects.setDependsOnInstancePropertyStore(); |
| 214 } else if (selector.isSetter()) { | 204 } else if (selector.isSetter()) { |
| 215 sideEffects.setChangesInstanceProperty(); | 205 sideEffects.setChangesInstanceProperty(); |
| 216 } | 206 } |
| 217 } | 207 } |
| 218 sideEffects.add(getSideEffectsOfElement(e)); | 208 sideEffects.add(getSideEffectsOfElement(e)); |
| 219 } | 209 } |
| 220 return sideEffects; | 210 return sideEffects; |
| 221 } | 211 } |
| 222 } | 212 } |
| OLD | NEW |