| 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 |
| 11 /// * a call to the `foo()` method on an unknown class. | 11 /// * a call to the `foo()` method on an unknown class. |
| 12 /// * an instantiation of class T | 12 /// * an instantiation of class T |
| 13 /// | 13 /// |
| 14 /// The different compiler stages combine these uses into `WorldImpact` objects, | 14 /// The different compiler stages combine these uses into `WorldImpact` objects, |
| 15 /// which are later used to construct a closed-world understanding of the | 15 /// which are later used to construct a closed-world understanding of the |
| 16 /// program. | 16 /// program. |
| 17 library dart2js.universe.use; | 17 library dart2js.universe.use; |
| 18 | 18 |
| 19 import '../closure.dart' show BoxFieldElement; | 19 import '../closure.dart' show BoxFieldElement; |
| 20 import '../common.dart'; | 20 import '../common.dart'; |
| 21 import '../elements/types.dart'; | 21 import '../elements/types.dart'; |
| 22 import '../elements/elements.dart' | 22 import '../elements/elements.dart' show ConstructorBodyElement, Element; |
| 23 show | |
| 24 ConstructorBodyElement, | |
| 25 Element, | |
| 26 Entity, | |
| 27 LocalFunctionElement; | |
| 28 import '../elements/entities.dart'; | 23 import '../elements/entities.dart'; |
| 29 import '../util/util.dart' show Hashing; | 24 import '../util/util.dart' show Hashing; |
| 30 import '../world.dart' show World; | 25 import '../world.dart' show World; |
| 31 import 'call_structure.dart' show CallStructure; | 26 import 'call_structure.dart' show CallStructure; |
| 32 import 'selector.dart' show Selector; | 27 import 'selector.dart' show Selector; |
| 33 import 'world_builder.dart' show ReceiverConstraint; | 28 import 'world_builder.dart' show ReceiverConstraint; |
| 34 | 29 |
| 35 enum DynamicUseKind { | 30 enum DynamicUseKind { |
| 36 INVOKE, | 31 INVOKE, |
| 37 GET, | 32 GET, |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 /// Write access of an instance field or boxed field [element]. | 311 /// Write access of an instance field or boxed field [element]. |
| 317 factory StaticUse.fieldSet(FieldEntity element) { | 312 factory StaticUse.fieldSet(FieldEntity element) { |
| 318 assert(invariant( | 313 assert(invariant( |
| 319 element, element.isInstanceMember || element is BoxFieldElement, | 314 element, element.isInstanceMember || element is BoxFieldElement, |
| 320 message: "Field init element $element must be an instance " | 315 message: "Field init element $element must be an instance " |
| 321 "or boxed field.")); | 316 "or boxed field.")); |
| 322 return new StaticUse.internal(element, StaticUseKind.FIELD_SET); | 317 return new StaticUse.internal(element, StaticUseKind.FIELD_SET); |
| 323 } | 318 } |
| 324 | 319 |
| 325 /// Read of a local function [element]. | 320 /// Read of a local function [element]. |
| 326 factory StaticUse.closure(LocalFunctionElement element) { | 321 factory StaticUse.closure(Local element) { |
| 327 return new StaticUse.internal(element, StaticUseKind.CLOSURE); | 322 return new StaticUse.internal(element, StaticUseKind.CLOSURE); |
| 328 } | 323 } |
| 329 | 324 |
| 330 /// Unknown use of [element]. | 325 /// Unknown use of [element]. |
| 331 /// | 326 /// |
| 332 /// Avoid using this, if possible: Use one of the other constructor which more | 327 /// Avoid using this, if possible: Use one of the other constructor which more |
| 333 /// precisely capture why [element] is used. | 328 /// precisely capture why [element] is used. |
| 334 @deprecated | 329 @deprecated |
| 335 factory StaticUse.foreignUse(Entity element) { | 330 factory StaticUse.foreignUse(Entity element) { |
| 336 return new StaticUse.internal(element, StaticUseKind.GENERAL); | 331 return new StaticUse.internal(element, StaticUseKind.GENERAL); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 } | 408 } |
| 414 | 409 |
| 415 bool operator ==(other) { | 410 bool operator ==(other) { |
| 416 if (identical(this, other)) return true; | 411 if (identical(this, other)) return true; |
| 417 if (other is! TypeUse) return false; | 412 if (other is! TypeUse) return false; |
| 418 return type == other.type && kind == other.kind; | 413 return type == other.type && kind == other.kind; |
| 419 } | 414 } |
| 420 | 415 |
| 421 String toString() => 'TypeUse($type,$kind)'; | 416 String toString() => 'TypeUse($type,$kind)'; |
| 422 } | 417 } |
| OLD | NEW |