| 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 FunctionSet allFunctions; | 9 final FunctionSet allFunctions; |
| 10 final Set<Element> functionsCalledInLoop = new Set<Element>(); | 10 final Set<Element> functionsCalledInLoop = new Set<Element>(); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 | 145 |
| 146 bool hasAnyUserDefinedGetter(Selector selector) { | 146 bool hasAnyUserDefinedGetter(Selector selector) { |
| 147 return allFunctions.filter(selector).any((each) => each.isGetter()); | 147 return allFunctions.filter(selector).any((each) => each.isGetter()); |
| 148 } | 148 } |
| 149 | 149 |
| 150 bool hasAnyUserDefinedSetter(Selector selector) { | 150 bool hasAnyUserDefinedSetter(Selector selector) { |
| 151 return allFunctions.filter(selector).any((each) => each.isSetter()); | 151 return allFunctions.filter(selector).any((each) => each.isSetter()); |
| 152 } | 152 } |
| 153 | 153 |
| 154 // Returns whether a subclass of [superclass] implements [type]. | 154 // Returns whether a subclass of [superclass] implements [type]. |
| 155 bool hasAnySubclassThatImplements(ClassElement superclass, DartType type) { | 155 bool hasAnySubclassThatImplements(ClassElement superclass, |
| 156 ClassElement type) { |
| 156 Set<ClassElement> subclasses = typesImplementedBySubclassesOf(superclass); | 157 Set<ClassElement> subclasses = typesImplementedBySubclassesOf(superclass); |
| 157 if (subclasses == null) return false; | 158 if (subclasses == null) return false; |
| 158 return subclasses.contains(type.element); | 159 return subclasses.contains(type); |
| 159 } | 160 } |
| 160 | 161 |
| 161 // Returns whether a subclass of any mixin application of [cls] implements | 162 // Returns whether a subclass of any mixin application of [cls] implements |
| 162 // [type]. | 163 // [type]. |
| 163 bool hasAnySubclassOfMixinUseThatImplements(ClassElement cls, DartType type) { | 164 bool hasAnySubclassOfMixinUseThatImplements(ClassElement cls, |
| 165 ClassElement type) { |
| 164 Set<MixinApplicationElement> uses = mixinUses[cls]; | 166 Set<MixinApplicationElement> uses = mixinUses[cls]; |
| 165 if (uses == null || uses.isEmpty) return false; | 167 if (uses == null || uses.isEmpty) return false; |
| 166 return uses.any((use) => hasAnySubclassThatImplements(use, type)); | 168 return uses.any((use) => hasAnySubclassThatImplements(use, type)); |
| 167 } | 169 } |
| 168 | 170 |
| 169 // Returns whether a subclass of [superclass] mixes in [other]. | 171 // Returns whether a subclass of [superclass] mixes in [other]. |
| 170 bool hasAnySubclassThatMixes(ClassElement superclass, ClassElement other) { | 172 bool hasAnySubclassThatMixes(ClassElement superclass, ClassElement other) { |
| 171 Set<MixinApplicationElement> uses = mixinUses[other]; | 173 Set<MixinApplicationElement> uses = mixinUses[other]; |
| 172 return (uses != null) | 174 return (uses != null) |
| 173 ? uses.any((each) => each.isSubclassOf(superclass)) | 175 ? uses.any((each) => each.isSubclassOf(superclass)) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 185 } | 187 } |
| 186 } | 188 } |
| 187 | 189 |
| 188 VariableElement locateSingleField(Selector selector) { | 190 VariableElement locateSingleField(Selector selector) { |
| 189 Element result = locateSingleElement(selector); | 191 Element result = locateSingleElement(selector); |
| 190 return (result != null && result.isField()) ? result : null; | 192 return (result != null && result.isField()) ? result : null; |
| 191 } | 193 } |
| 192 | 194 |
| 193 Element locateSingleElement(Selector selector) { | 195 Element locateSingleElement(Selector selector) { |
| 194 ti.TypeMask mask = selector.mask == null | 196 ti.TypeMask mask = selector.mask == null |
| 195 ? new ti.TypeMask.subclass(compiler.objectClass.rawType) | 197 ? new ti.TypeMask.subclass(compiler.objectClass) |
| 196 : selector.mask; | 198 : selector.mask; |
| 197 return mask.locateSingleElement(selector, compiler); | 199 return mask.locateSingleElement(selector, compiler); |
| 198 } | 200 } |
| 199 | 201 |
| 200 bool hasSingleMatch(Selector selector) { | 202 bool hasSingleMatch(Selector selector) { |
| 201 Iterable<Element> targets = allFunctions.filter(selector); | 203 Iterable<Element> targets = allFunctions.filter(selector); |
| 202 return targets.length == 1; | 204 return targets.length == 1; |
| 203 } | 205 } |
| 204 | 206 |
| 205 Iterable<ClassElement> locateNoSuchMethodHolders(Selector selector) { | 207 Iterable<ClassElement> locateNoSuchMethodHolders(Selector selector) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 sideEffects.setDependsOnInstancePropertyStore(); | 254 sideEffects.setDependsOnInstancePropertyStore(); |
| 253 } else if (selector.isSetter()) { | 255 } else if (selector.isSetter()) { |
| 254 sideEffects.setChangesInstanceProperty(); | 256 sideEffects.setChangesInstanceProperty(); |
| 255 } | 257 } |
| 256 } | 258 } |
| 257 sideEffects.add(getSideEffectsOfElement(e)); | 259 sideEffects.add(getSideEffectsOfElement(e)); |
| 258 } | 260 } |
| 259 return sideEffects; | 261 return sideEffects; |
| 260 } | 262 } |
| 261 } | 263 } |
| OLD | NEW |