| 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 /// This library defined `uses`. A `use` is a single impact of the world, for | 5 /// This library defined `uses`. A `use` is a single impact of the world, for |
| 6 /// instance an invocation of a top level function or a call to the `foo()` | 6 /// instance an invocation of a top level function or a call to the `foo()` |
| 7 /// method on an unknown class. | 7 /// method on an unknown class. |
| 8 library dart2js.universe.use; | 8 library dart2js.universe.use; |
| 9 | 9 |
| 10 import '../closure.dart' show | 10 import '../closure.dart' show |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 return selector == other.selector && mask == other.mask; | 63 return selector == other.selector && mask == other.mask; |
| 64 } | 64 } |
| 65 | 65 |
| 66 String toString() => '$selector,$mask'; | 66 String toString() => '$selector,$mask'; |
| 67 } | 67 } |
| 68 | 68 |
| 69 enum StaticUseKind { | 69 enum StaticUseKind { |
| 70 GENERAL, | 70 GENERAL, |
| 71 STATIC_TEAR_OFF, | 71 STATIC_TEAR_OFF, |
| 72 SUPER_TEAR_OFF, | 72 SUPER_TEAR_OFF, |
| 73 SUPER_FIELD_SET, |
| 73 FIELD_GET, | 74 FIELD_GET, |
| 74 FIELD_SET, | 75 FIELD_SET, |
| 75 CLOSURE, | 76 CLOSURE, |
| 76 } | 77 } |
| 77 | 78 |
| 78 /// Statically known use of an [Element]. | 79 /// Statically known use of an [Element]. |
| 79 // TODO(johnniwinther): Create backend-specific implementations with better | 80 // TODO(johnniwinther): Create backend-specific implementations with better |
| 80 // invariants. | 81 // invariants. |
| 81 class StaticUse { | 82 class StaticUse { |
| 82 final Element element; | 83 final Element element; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 | 154 |
| 154 /// Read access of a super field or getter [element]. | 155 /// Read access of a super field or getter [element]. |
| 155 factory StaticUse.superGet(MemberElement element) { | 156 factory StaticUse.superGet(MemberElement element) { |
| 156 assert(invariant(element, element.isInstanceMember, | 157 assert(invariant(element, element.isInstanceMember, |
| 157 message: "Super get element $element must be an instance method.")); | 158 message: "Super get element $element must be an instance method.")); |
| 158 assert(invariant(element, element.isField || element.isGetter, | 159 assert(invariant(element, element.isField || element.isGetter, |
| 159 message: "Super get element $element must be a field or a getter.")); | 160 message: "Super get element $element must be a field or a getter.")); |
| 160 return new StaticUse._(element, StaticUseKind.GENERAL); | 161 return new StaticUse._(element, StaticUseKind.GENERAL); |
| 161 } | 162 } |
| 162 | 163 |
| 163 /// Write access of a super field or setter [element]. | 164 /// Write access of a super field [element]. |
| 164 factory StaticUse.superSet(Element element) { | 165 factory StaticUse.superFieldSet(FieldElement element) { |
| 165 assert(invariant(element, element.isInstanceMember, | 166 assert(invariant(element, element.isInstanceMember, |
| 166 message: "Super set element $element must be an instance method.")); | 167 message: "Super set element $element must be an instance method.")); |
| 167 assert(invariant(element, element.isField || element.isSetter, | 168 assert(invariant(element, element.isField, |
| 168 message: "Super set element $element must be a field or a setter.")); | 169 message: "Super set element $element must be a field.")); |
| 170 return new StaticUse._(element, StaticUseKind.SUPER_FIELD_SET); |
| 171 } |
| 172 |
| 173 /// Write access of a super setter [element]. |
| 174 factory StaticUse.superSetterSet(SetterElement element) { |
| 175 assert(invariant(element, element.isInstanceMember, |
| 176 message: "Super set element $element must be an instance method.")); |
| 177 assert(invariant(element, element.isSetter, |
| 178 message: "Super set element $element must be a setter.")); |
| 169 return new StaticUse._(element, StaticUseKind.GENERAL); | 179 return new StaticUse._(element, StaticUseKind.GENERAL); |
| 170 } | 180 } |
| 171 | 181 |
| 172 /// Closurization of a super method [element]. | 182 /// Closurization of a super method [element]. |
| 173 factory StaticUse.superTearOff(MethodElement element) { | 183 factory StaticUse.superTearOff(MethodElement element) { |
| 174 assert(invariant(element, element.isInstanceMember && element.isFunction, | 184 assert(invariant(element, element.isInstanceMember && element.isFunction, |
| 175 message: "Super invoke element $element must be an instance method.")); | 185 message: "Super invoke element $element must be an instance method.")); |
| 176 return new StaticUse._(element, StaticUseKind.SUPER_TEAR_OFF); | 186 return new StaticUse._(element, StaticUseKind.SUPER_TEAR_OFF); |
| 177 } | 187 } |
| 178 | 188 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 | 316 |
| 307 bool operator ==(other) { | 317 bool operator ==(other) { |
| 308 if (identical(this, other)) return true; | 318 if (identical(this, other)) return true; |
| 309 if (other is! TypeUse) return false; | 319 if (other is! TypeUse) return false; |
| 310 return type == other.type && | 320 return type == other.type && |
| 311 kind == other.kind; | 321 kind == other.kind; |
| 312 } | 322 } |
| 313 | 323 |
| 314 String toString() => 'TypeUse($type,$kind)'; | 324 String toString() => 'TypeUse($type,$kind)'; |
| 315 } | 325 } |
| OLD | NEW |