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 part of serialization; | 5 part of serialization; |
6 | 6 |
7 // TODO(alanknight): Figure out how to reasonably separate out the things | 7 // TODO(alanknight): Figure out how to reasonably separate out the things |
8 // that require reflection without making the API more awkward. Or if that is | 8 // that require reflection without making the API more awkward. Or if that is |
9 // in fact necessary. Maybe the tree-shaking will just remove it if unused. | 9 // in fact necessary. Maybe the tree-shaking will just remove it if unused. |
10 | 10 |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 // TODO(alanknight): This, and other places, rely on synchronous access to | 264 // TODO(alanknight): This, and other places, rely on synchronous access to |
265 // mirrors. Should be changed to use a synchronous API once one is available, | 265 // mirrors. Should be changed to use a synchronous API once one is available, |
266 // or to be async, but that would be extremely ugly. | 266 // or to be async, but that would be extremely ugly. |
267 _value(InstanceMirror mirror, _Field field) => field.valueIn(mirror); | 267 _value(InstanceMirror mirror, _Field field) => field.valueIn(mirror); |
268 } | 268 } |
269 | 269 |
270 /** | 270 /** |
271 * This represents a field in an object. It is intended to be used as part of | 271 * This represents a field in an object. It is intended to be used as part of |
272 * a [_FieldList]. | 272 * a [_FieldList]. |
273 */ | 273 */ |
274 abstract class _Field implements Comparable { | 274 abstract class _Field implements Comparable<_Field> { |
275 | 275 |
276 /** The FieldList that contains us. */ | 276 /** The FieldList that contains us. */ |
277 final _FieldList fieldList; | 277 final _FieldList fieldList; |
278 | 278 |
279 /** | 279 /** |
280 * Our position in the [contents] collection of [fieldList]. This is used | 280 * Our position in the [contents] collection of [fieldList]. This is used |
281 * to index into the state, so it's extremely important. | 281 * to index into the state, so it's extremely important. |
282 */ | 282 */ |
283 int index; | 283 int index; |
284 | 284 |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 _MapWrapper(this.fieldList) : _map = new Map(); | 623 _MapWrapper(this.fieldList) : _map = new Map(); |
624 _MapWrapper.fromMap(this._map, this.fieldList); | 624 _MapWrapper.fromMap(this._map, this.fieldList); |
625 | 625 |
626 operator [](key) => _map[fieldList[key].name]; | 626 operator [](key) => _map[fieldList[key].name]; |
627 | 627 |
628 operator []=(key, value) { _map[fieldList[key].name] = value; } | 628 operator []=(key, value) { _map[fieldList[key].name] = value; } |
629 get length => _map.length; | 629 get length => _map.length; |
630 | 630 |
631 asMap() => _map; | 631 asMap() => _map; |
632 } | 632 } |
OLD | NEW |