| 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 defines individual world impacts. | 5 /// This library defines individual world impacts. |
| 6 /// | 6 /// |
| 7 /// We call these building blocks `uses`. Each `use` is a single impact of the | 7 /// We call these building blocks `uses`. Each `use` is a single impact of the |
| 8 /// world. Some example uses are: | 8 /// world. Some example uses are: |
| 9 /// | 9 /// |
| 10 /// * an invocation of a top level function | 10 /// * an invocation of a top level function |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 enum StaticUseKind { | 66 enum StaticUseKind { |
| 67 GENERAL, | 67 GENERAL, |
| 68 STATIC_TEAR_OFF, | 68 STATIC_TEAR_OFF, |
| 69 SUPER_TEAR_OFF, | 69 SUPER_TEAR_OFF, |
| 70 SUPER_FIELD_SET, | 70 SUPER_FIELD_SET, |
| 71 FIELD_GET, | 71 FIELD_GET, |
| 72 FIELD_SET, | 72 FIELD_SET, |
| 73 CLOSURE, | 73 CLOSURE, |
| 74 CONSTRUCTOR_INVOKE, | 74 CONSTRUCTOR_INVOKE, |
| 75 CONST_CONSTRUCTOR_INVOKE, | 75 CONST_CONSTRUCTOR_INVOKE, |
| 76 REDIRECTION, |
| 76 DIRECT_INVOKE, | 77 DIRECT_INVOKE, |
| 77 } | 78 } |
| 78 | 79 |
| 79 /// Statically known use of an [Element]. | 80 /// Statically known use of an [Element]. |
| 80 // TODO(johnniwinther): Create backend-specific implementations with better | 81 // TODO(johnniwinther): Create backend-specific implementations with better |
| 81 // invariants. | 82 // invariants. |
| 82 class StaticUse { | 83 class StaticUse { |
| 83 final Element element; | 84 final Element element; |
| 84 final StaticUseKind kind; | 85 final StaticUseKind kind; |
| 85 final int hashCode; | 86 final int hashCode; |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 /// [callStructure] on [type]. | 260 /// [callStructure] on [type]. |
| 260 factory StaticUse.constConstructorInvoke( | 261 factory StaticUse.constConstructorInvoke( |
| 261 ConstructorElement element, CallStructure callStructure, DartType type) { | 262 ConstructorElement element, CallStructure callStructure, DartType type) { |
| 262 assert(invariant(element, type != null, | 263 assert(invariant(element, type != null, |
| 263 message: "No type provided for constructor invocation.")); | 264 message: "No type provided for constructor invocation.")); |
| 264 // TODO(johnniwinther): Use the [callStructure]. | 265 // TODO(johnniwinther): Use the [callStructure]. |
| 265 return new StaticUse.internal( | 266 return new StaticUse.internal( |
| 266 element, StaticUseKind.CONST_CONSTRUCTOR_INVOKE, type); | 267 element, StaticUseKind.CONST_CONSTRUCTOR_INVOKE, type); |
| 267 } | 268 } |
| 268 | 269 |
| 269 /// Constructor redirection to [element]. | 270 /// Constructor redirection to [element] on [type]. |
| 270 factory StaticUse.constructorRedirect(ConstructorElement element) { | 271 factory StaticUse.constructorRedirect( |
| 271 return new StaticUse.internal(element, StaticUseKind.GENERAL); | 272 ConstructorElement element, InterfaceType type) { |
| 273 assert(invariant(element, type != null, |
| 274 message: "No type provided for constructor invocation.")); |
| 275 return new StaticUse.internal(element, StaticUseKind.REDIRECTION, type); |
| 272 } | 276 } |
| 273 | 277 |
| 274 /// Initialization of an instance field [element]. | 278 /// Initialization of an instance field [element]. |
| 275 factory StaticUse.fieldInit(FieldElement element) { | 279 factory StaticUse.fieldInit(FieldElement element) { |
| 276 assert(invariant(element, element.isInstanceMember, | 280 assert(invariant(element, element.isInstanceMember, |
| 277 message: "Field init element $element must be an instance field.")); | 281 message: "Field init element $element must be an instance field.")); |
| 278 return new StaticUse.internal(element, StaticUseKind.GENERAL); | 282 return new StaticUse.internal(element, StaticUseKind.GENERAL); |
| 279 } | 283 } |
| 280 | 284 |
| 281 /// Read access of an instance field or boxed field [element]. | 285 /// Read access of an instance field or boxed field [element]. |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 } | 383 } |
| 380 | 384 |
| 381 bool operator ==(other) { | 385 bool operator ==(other) { |
| 382 if (identical(this, other)) return true; | 386 if (identical(this, other)) return true; |
| 383 if (other is! TypeUse) return false; | 387 if (other is! TypeUse) return false; |
| 384 return type == other.type && kind == other.kind; | 388 return type == other.type && kind == other.kind; |
| 385 } | 389 } |
| 386 | 390 |
| 387 String toString() => 'TypeUse($type,$kind)'; | 391 String toString() => 'TypeUse($type,$kind)'; |
| 388 } | 392 } |
| OLD | NEW |