| 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 11 matching lines...) Expand all Loading... |
| 22 new Map<ClassElement, Set<ClassElement>>(); | 22 new Map<ClassElement, Set<ClassElement>>(); |
| 23 final Map<ClassElement, Set<ClassElement>> _subtypes = | 23 final Map<ClassElement, Set<ClassElement>> _subtypes = |
| 24 new Map<ClassElement, Set<ClassElement>>(); | 24 new Map<ClassElement, Set<ClassElement>>(); |
| 25 final Map<ClassElement, Set<ClassElement>> _supertypes = | 25 final Map<ClassElement, Set<ClassElement>> _supertypes = |
| 26 new Map<ClassElement, Set<ClassElement>>(); | 26 new Map<ClassElement, Set<ClassElement>>(); |
| 27 | 27 |
| 28 final Set<Element> sideEffectsFreeElements = new Set<Element>(); | 28 final Set<Element> sideEffectsFreeElements = new Set<Element>(); |
| 29 | 29 |
| 30 final Set<Element> elementsThatCannotThrow = new Set<Element>(); | 30 final Set<Element> elementsThatCannotThrow = new Set<Element>(); |
| 31 | 31 |
| 32 final Set<Element> functionsThatMightBePassedToApply = |
| 33 new Set<FunctionElement>(); |
| 34 |
| 32 Set<ClassElement> subclassesOf(ClassElement cls) { | 35 Set<ClassElement> subclassesOf(ClassElement cls) { |
| 33 return _subclasses[cls.declaration]; | 36 return _subclasses[cls.declaration]; |
| 34 } | 37 } |
| 35 | 38 |
| 36 Set<ClassElement> subtypesOf(ClassElement cls) { | 39 Set<ClassElement> subtypesOf(ClassElement cls) { |
| 37 return _subtypes[cls.declaration]; | 40 return _subtypes[cls.declaration]; |
| 38 } | 41 } |
| 39 | 42 |
| 40 Set<ClassElement> supertypesOf(ClassElement cls) { | 43 Set<ClassElement> supertypesOf(ClassElement cls) { |
| 41 return _supertypes[cls.declaration]; | 44 return _supertypes[cls.declaration]; |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 } | 274 } |
| 272 | 275 |
| 273 bool getCannotThrow(Element element) { | 276 bool getCannotThrow(Element element) { |
| 274 return elementsThatCannotThrow.contains(element); | 277 return elementsThatCannotThrow.contains(element); |
| 275 } | 278 } |
| 276 | 279 |
| 277 void registerImplicitSuperCall(TreeElements elements, | 280 void registerImplicitSuperCall(TreeElements elements, |
| 278 FunctionElement superConstructor) { | 281 FunctionElement superConstructor) { |
| 279 elements.otherDependencies.add(superConstructor); | 282 elements.otherDependencies.add(superConstructor); |
| 280 } | 283 } |
| 284 |
| 285 void registerMightBePassedToApply(Element element) { |
| 286 functionsThatMightBePassedToApply.add(element); |
| 287 } |
| 288 |
| 289 bool getMightBePassedToApply(Element element) { |
| 290 // We have to check whether the element we look at was created after |
| 291 // type inference ran. This is currently only the case for the call |
| 292 // method of function classes that were generated for function |
| 293 // expressions. In such a case, we have to look at the original |
| 294 // function expressions's element. |
| 295 // TODO(herhut): Generate classes for function expressions earlier. |
| 296 if (element is SynthesizedCallMethodElementX) { |
| 297 return getMightBePassedToApply(element.expression); |
| 298 } |
| 299 return functionsThatMightBePassedToApply.contains(element); |
| 300 } |
| 281 } | 301 } |
| OLD | NEW |