OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 |
| 5 import 'package:compiler/src/resolution/access_semantics.dart'; |
| 6 import 'package:compiler/src/resolution/send_structure.dart'; |
| 7 import 'package:compiler/src/resolution/tree_elements.dart'; |
| 8 import 'package:compiler/src/tree/nodes.dart' as ast; |
| 9 |
| 10 /// Id for a code point with type inference information. |
| 11 // TODO(johnniwinther): Create an [Id]-based equivalence with the kernel IR. |
| 12 class Id { |
| 13 final int value; |
| 14 |
| 15 const Id(this.value); |
| 16 |
| 17 int get hashCode => value.hashCode; |
| 18 |
| 19 bool operator ==(other) { |
| 20 if (identical(this, other)) return true; |
| 21 if (other is! Id) return false; |
| 22 return value == other.value; |
| 23 } |
| 24 |
| 25 String toString() => value.toString(); |
| 26 } |
| 27 |
| 28 abstract class AstEnumeratorMixin { |
| 29 TreeElements get elements; |
| 30 |
| 31 Id computeAccessId(ast.Send node, AccessSemantics access) { |
| 32 switch (access.kind) { |
| 33 case AccessKind.DYNAMIC_PROPERTY: |
| 34 return new Id(node.selector.getBeginToken().charOffset); |
| 35 default: |
| 36 return new Id(node.getBeginToken().charOffset); |
| 37 } |
| 38 } |
| 39 |
| 40 Id computeId(ast.Send node) { |
| 41 var sendStructure = elements.getSendStructure(node); |
| 42 if (sendStructure == null) return null; |
| 43 switch (sendStructure.kind) { |
| 44 case SendStructureKind.GET: |
| 45 case SendStructureKind.INVOKE: |
| 46 case SendStructureKind.INCOMPATIBLE_INVOKE: |
| 47 return computeAccessId(node, sendStructure.semantics); |
| 48 default: |
| 49 return new Id(node.getBeginToken().charOffset); |
| 50 } |
| 51 } |
| 52 } |
OLD | NEW |