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 /** | 7 /** |
8 * This writes out the state of the objects to an external format. It holds | 8 * This writes out the state of the objects to an external format. It holds |
9 * all of the intermediate state needed. The primary API for it is the | 9 * all of the intermediate state needed. The primary API for it is the |
10 * [write] method. | 10 * [write] method. |
(...skipping 22 matching lines...) Expand all Loading... |
33 | 33 |
34 final Format format; | 34 final Format format; |
35 | 35 |
36 /** | 36 /** |
37 * Objects that cannot be represented in-place in the serialized form need | 37 * Objects that cannot be represented in-place in the serialized form need |
38 * to have references to them stored. The [Reference] objects are computed | 38 * to have references to them stored. The [Reference] objects are computed |
39 * once and stored here for each object. This provides some space-saving, | 39 * once and stored here for each object. This provides some space-saving, |
40 * but also serves to record which objects we have already seen. | 40 * but also serves to record which objects we have already seen. |
41 */ | 41 */ |
42 final Map<dynamic, Reference> references = | 42 final Map<dynamic, Reference> references = |
43 new HashMap<Object, Reference>(equals: identical); | 43 new IdentityMap<Object, Reference>(); |
44 | 44 |
45 /** | 45 /** |
46 * The state of objects that need to be serialized is stored here. | 46 * The state of objects that need to be serialized is stored here. |
47 * Each rule has a number, and rules keep track of the objects that they | 47 * Each rule has a number, and rules keep track of the objects that they |
48 * serialize, in order. So the state of any object can be found by indexing | 48 * serialize, in order. So the state of any object can be found by indexing |
49 * from the rule number and the object number within the rule. | 49 * from the rule number and the object number within the rule. |
50 * The actual representation of the state is determined by the rule. Lists | 50 * The actual representation of the state is determined by the rule. Lists |
51 * and Maps are common, but it is arbitrary. | 51 * and Maps are common, but it is arbitrary. |
52 */ | 52 */ |
53 final List<List> states = new List<List>(); | 53 final List<List> states = new List<List>(); |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 * for an example. It knows how to return its object and how to filter. | 614 * for an example. It knows how to return its object and how to filter. |
615 */ | 615 */ |
616 class DesignatedRuleForObject { | 616 class DesignatedRuleForObject { |
617 final Function rulePredicate; | 617 final Function rulePredicate; |
618 final target; | 618 final target; |
619 | 619 |
620 DesignatedRuleForObject(this.target, this.rulePredicate); | 620 DesignatedRuleForObject(this.target, this.rulePredicate); |
621 | 621 |
622 List possibleRules(List rules) => rules.where(rulePredicate).toList(); | 622 List possibleRules(List rules) => rules.where(rulePredicate).toList(); |
623 } | 623 } |
OLD | NEW |