Chromium Code Reviews| 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.universe.use; | 5 library dart2js.universe.use; |
|
sigurdm
2015/11/02 14:34:56
Perhaps make a short library dartdoc explaining wh
Siggi Cherem (dart-lang)
2015/11/02 16:55:47
+1, let's also add the dartdoc to DynamicUse while
Johnni Winther
2015/11/04 10:08:26
Done.
Johnni Winther
2015/11/04 10:08:26
Done.
| |
| 6 | 6 |
| 7 import '../closure.dart' show | 7 import '../closure.dart' show |
| 8 BoxFieldElement; | 8 BoxFieldElement; |
| 9 import '../common.dart'; | 9 import '../common.dart'; |
| 10 import '../elements/elements.dart'; | 10 import '../elements/elements.dart'; |
| 11 import '../world.dart' show | |
| 12 ClassWorld; | |
| 11 import '../util/util.dart' show | 13 import '../util/util.dart' show |
| 12 Hashing; | 14 Hashing; |
| 13 | 15 |
| 14 import 'call_structure.dart' show | 16 import 'call_structure.dart' show |
| 15 CallStructure; | 17 CallStructure; |
| 18 import 'selector.dart' show | |
| 19 Selector; | |
| 20 import 'universe.dart' show | |
| 21 ReceiverConstraint; | |
| 22 | |
| 23 | |
| 24 enum DynamicUseKind { | |
| 25 INVOKE, | |
| 26 GET, | |
| 27 SET, | |
| 28 } | |
| 29 | |
| 30 class DynamicUse { | |
| 31 final Selector selector; | |
| 32 final ReceiverConstraint mask; | |
| 33 | |
| 34 DynamicUse(this.selector, this.mask); | |
| 35 | |
| 36 bool appliesUnnamed(Element element, ClassWorld world) { | |
| 37 return selector.appliesUnnamed(element, world) && | |
| 38 (mask == null || mask.canHit(element, selector, world)); | |
| 39 } | |
| 40 | |
| 41 DynamicUseKind get kind { | |
| 42 if (selector.isGetter) { | |
| 43 return DynamicUseKind.GET; | |
| 44 } else if (selector.isSetter) { | |
| 45 return DynamicUseKind.SET; | |
| 46 } else { | |
| 47 return DynamicUseKind.INVOKE; | |
| 48 } | |
| 49 } | |
| 50 | |
| 51 int get hashCode => selector.hashCode * 13 + mask.hashCode * 17; | |
| 52 | |
| 53 bool operator ==(other) { | |
| 54 if (identical(this, other)) return true; | |
| 55 if (other is! DynamicUse) return false; | |
| 56 return selector == other.selector && mask == other.mask; | |
| 57 } | |
| 58 | |
| 59 String toString() => '$selector,$mask'; | |
| 60 } | |
| 16 | 61 |
| 17 enum StaticUseKind { | 62 enum StaticUseKind { |
| 18 GENERAL, | 63 GENERAL, |
| 19 STATIC_TEAR_OFF, | 64 STATIC_TEAR_OFF, |
| 20 SUPER_TEAR_OFF, | 65 SUPER_TEAR_OFF, |
| 21 FIELD_GET, | 66 FIELD_GET, |
| 22 FIELD_SET, | 67 FIELD_SET, |
| 23 } | 68 } |
| 24 | 69 |
| 25 /// Statically known use of an [Element]. | 70 /// Statically known use of an [Element]. |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 189 bool operator ==(other) { | 234 bool operator ==(other) { |
| 190 if (identical(this, other)) return true; | 235 if (identical(this, other)) return true; |
| 191 if (other is! StaticUse) return false; | 236 if (other is! StaticUse) return false; |
| 192 return element == other.element && | 237 return element == other.element && |
| 193 kind == other.kind; | 238 kind == other.kind; |
| 194 } | 239 } |
| 195 | 240 |
| 196 String toString() => 'StaticUse($element,$kind)'; | 241 String toString() => 'StaticUse($element,$kind)'; |
| 197 } | 242 } |
| 198 | 243 |
| OLD | NEW |