| 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 library dart2js.world; | 5 library dart2js.world; |
| 6 | 6 |
| 7 import 'closure.dart' show ClosureClassElement, SynthesizedCallMethodElementX; | 7 import 'closure.dart' show ClosureClassElement, SynthesizedCallMethodElementX; |
| 8 import 'common/backend_api.dart' show BackendClasses; | 8 import 'common/backend_api.dart' show BackendClasses; |
| 9 import 'common.dart'; | 9 import 'common.dart'; |
| 10 import 'constants/constant_system.dart'; | 10 import 'constants/constant_system.dart'; |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 /// Return the cached mask for [base] with the given flags, or | 245 /// Return the cached mask for [base] with the given flags, or |
| 246 /// calls [createMask] to create the mask and cache it. | 246 /// calls [createMask] to create the mask and cache it. |
| 247 // TODO(johnniwinther): Find a better strategy for caching these? | 247 // TODO(johnniwinther): Find a better strategy for caching these? |
| 248 TypeMask getCachedMask(ClassElement base, int flags, TypeMask createMask()); | 248 TypeMask getCachedMask(ClassElement base, int flags, TypeMask createMask()); |
| 249 | 249 |
| 250 /// Returns the [FunctionSet] containing all live functions in the closed | 250 /// Returns the [FunctionSet] containing all live functions in the closed |
| 251 /// world. | 251 /// world. |
| 252 FunctionSet get allFunctions; | 252 FunctionSet get allFunctions; |
| 253 | 253 |
| 254 /// Returns `true` if the field [element] is known to be effectively final. | 254 /// Returns `true` if the field [element] is known to be effectively final. |
| 255 bool fieldNeverChanges(Element element); | 255 bool fieldNeverChanges(MemberElement element); |
| 256 | 256 |
| 257 /// Extends the receiver type [mask] for calling [selector] to take live | 257 /// Extends the receiver type [mask] for calling [selector] to take live |
| 258 /// `noSuchMethod` handlers into account. | 258 /// `noSuchMethod` handlers into account. |
| 259 TypeMask extendMaskIfReachesAll(Selector selector, TypeMask mask); | 259 TypeMask extendMaskIfReachesAll(Selector selector, TypeMask mask); |
| 260 | 260 |
| 261 /// Returns all resolved typedefs. | 261 /// Returns all resolved typedefs. |
| 262 Iterable<TypedefElement> get allTypedefs; | 262 Iterable<TypedefElement> get allTypedefs; |
| 263 | 263 |
| 264 /// Returns the single [Element] that matches a call to [selector] on a | 264 /// Returns the single [Element] that matches a call to [selector] on a |
| 265 /// receiver of type [mask]. If multiple targets exist, `null` is returned. | 265 /// receiver of type [mask]. If multiple targets exist, `null` is returned. |
| 266 Element locateSingleElement(Selector selector, TypeMask mask); | 266 MemberElement locateSingleElement(Selector selector, TypeMask mask); |
| 267 | 267 |
| 268 /// Returns the single field that matches a call to [selector] on a | 268 /// Returns the single field that matches a call to [selector] on a |
| 269 /// receiver of type [mask]. If multiple targets exist or the single target | 269 /// receiver of type [mask]. If multiple targets exist or the single target |
| 270 /// is not a field, `null` is returned. | 270 /// is not a field, `null` is returned. |
| 271 FieldElement locateSingleField(Selector selector, TypeMask mask); | 271 FieldElement locateSingleField(Selector selector, TypeMask mask); |
| 272 | 272 |
| 273 /// Returns the side effects of executing [element]. | 273 /// Returns the side effects of executing [element]. |
| 274 SideEffects getSideEffectsOfElement(Element element); | 274 SideEffects getSideEffectsOfElement(Element element); |
| 275 | 275 |
| 276 /// Returns the side effects of calling [selector] on a receiver of type | 276 /// Returns the side effects of calling [selector] on a receiver of type |
| (...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1006 } | 1006 } |
| 1007 | 1007 |
| 1008 void addFunctionCalledInLoop(Element element) { | 1008 void addFunctionCalledInLoop(Element element) { |
| 1009 functionsCalledInLoop.add(element.declaration); | 1009 functionsCalledInLoop.add(element.declaration); |
| 1010 } | 1010 } |
| 1011 | 1011 |
| 1012 bool isCalledInLoop(Element element) { | 1012 bool isCalledInLoop(Element element) { |
| 1013 return functionsCalledInLoop.contains(element.declaration); | 1013 return functionsCalledInLoop.contains(element.declaration); |
| 1014 } | 1014 } |
| 1015 | 1015 |
| 1016 bool fieldNeverChanges(Element element) { | 1016 bool fieldNeverChanges(MemberElement element) { |
| 1017 if (!element.isField) return false; | 1017 if (!element.isField) return false; |
| 1018 if (_backend.isNative(element)) { | 1018 if (_backend.isNative(element)) { |
| 1019 // Some native fields are views of data that may be changed by operations. | 1019 // Some native fields are views of data that may be changed by operations. |
| 1020 // E.g. node.firstChild depends on parentNode.removeBefore(n1, n2). | 1020 // E.g. node.firstChild depends on parentNode.removeBefore(n1, n2). |
| 1021 // TODO(sra): Refine the effect classification so that native effects are | 1021 // TODO(sra): Refine the effect classification so that native effects are |
| 1022 // distinct from ordinary Dart effects. | 1022 // distinct from ordinary Dart effects. |
| 1023 return false; | 1023 return false; |
| 1024 } | 1024 } |
| 1025 | 1025 |
| 1026 if (element.isFinal || element.isConst) { | 1026 if (element.isFinal || element.isConst) { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1109 return getMightBePassedToApply(element.expression); | 1109 return getMightBePassedToApply(element.expression); |
| 1110 } | 1110 } |
| 1111 return functionsThatMightBePassedToApply.contains(element); | 1111 return functionsThatMightBePassedToApply.contains(element); |
| 1112 } | 1112 } |
| 1113 | 1113 |
| 1114 @override | 1114 @override |
| 1115 bool getCurrentlyKnownMightBePassedToApply(Element element) { | 1115 bool getCurrentlyKnownMightBePassedToApply(Element element) { |
| 1116 return getMightBePassedToApply(element); | 1116 return getMightBePassedToApply(element); |
| 1117 } | 1117 } |
| 1118 } | 1118 } |
| OLD | NEW |