| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 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 | 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 /// Indexed entity interfaces for modeling elements derived from Kernel IR. | 5 /// Indexed entity interfaces for modeling elements derived from Kernel IR. |
| 6 | 6 |
| 7 import '../elements/entities.dart'; | 7 import '../elements/entities.dart'; |
| 8 | 8 |
| 9 abstract class _Indexed { | 9 abstract class _Indexed { |
| 10 int _index; | 10 int _index; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 implements TypeVariableEntity { | 37 implements TypeVariableEntity { |
| 38 /// Type variable index used for fast lookup in [KernelToElementMapBase]. | 38 /// Type variable index used for fast lookup in [KernelToElementMapBase]. |
| 39 int get typeVariableIndex => _index; | 39 int get typeVariableIndex => _index; |
| 40 } | 40 } |
| 41 | 41 |
| 42 abstract class IndexedTypedef extends _Indexed implements TypedefEntity { | 42 abstract class IndexedTypedef extends _Indexed implements TypedefEntity { |
| 43 /// Typedef index used for fast lookup in [KernelToElementMapBase]. | 43 /// Typedef index used for fast lookup in [KernelToElementMapBase]. |
| 44 int get typedefIndex => _index; | 44 int get typedefIndex => _index; |
| 45 } | 45 } |
| 46 | 46 |
| 47 abstract class IndexedLocal extends _Indexed implements Local { |
| 48 int get localIndex => _index; |
| 49 } |
| 50 |
| 47 /// Base implementation for an index based map of entities of type [E]. | 51 /// Base implementation for an index based map of entities of type [E]. |
| 48 abstract class EntityMapBase<E extends _Indexed> { | 52 abstract class EntityMapBase<E extends _Indexed> { |
| 49 List<E> _list = <E>[]; | 53 List<E> _list = <E>[]; |
| 50 | 54 |
| 51 /// Returns the [index]th entity in the map. | 55 /// Returns the [index]th entity in the map. |
| 52 E getEntity(int index) => _list[index]; | 56 E getEntity(int index) => _list[index]; |
| 53 | 57 |
| 54 /// Returns the number entities in the map. | 58 /// Returns the number entities in the map. |
| 55 int get length => _list.length; | 59 int get length => _list.length; |
| 56 } | 60 } |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 assert(entity._index == null); | 142 assert(entity._index == null); |
| 139 entity._index = _list.length; | 143 entity._index = _list.length; |
| 140 _list.add(entity); | 144 _list.add(entity); |
| 141 assert(data != null); | 145 assert(data != null); |
| 142 _data.add(data); | 146 _data.add(data); |
| 143 assert(env != null); | 147 assert(env != null); |
| 144 _env.add(env); | 148 _env.add(env); |
| 145 return entity; | 149 return entity; |
| 146 } | 150 } |
| 147 } | 151 } |
| OLD | NEW |