| OLD | NEW |
| 1 part of serialization; | 1 part of serialization; |
| 2 | 2 |
| 3 /** | 3 /** |
| 4 * An abstract class for serialization formats. Subclasses define how data | 4 * An abstract class for serialization formats. Subclasses define how data |
| 5 * is read or written to a particular output mechanism. | 5 * is read or written to a particular output mechanism. |
| 6 */ | 6 */ |
| 7 abstract class Format { | 7 abstract class Format { |
| 8 | 8 |
| 9 const Format(); | 9 const Format(); |
| 10 | 10 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 }; | 60 }; |
| 61 return result; | 61 return result; |
| 62 } | 62 } |
| 63 | 63 |
| 64 /** | 64 /** |
| 65 * Read serialized data written from this format | 65 * Read serialized data written from this format |
| 66 * and return the nested Map representation described in [generateOutput]. If | 66 * and return the nested Map representation described in [generateOutput]. If |
| 67 * the data also includes rule definitions, then these will replace the rules | 67 * the data also includes rule definitions, then these will replace the rules |
| 68 * in the [Serialization] for [reader]. | 68 * in the [Serialization] for [reader]. |
| 69 */ | 69 */ |
| 70 Map<String, dynamic> read(topLevel, Reader reader) { | 70 Map<String, dynamic> read(Map<String, dynamic> topLevel, Reader reader) { |
| 71 var ruleString = topLevel["rules"]; | 71 var ruleString = topLevel["rules"]; |
| 72 reader.readRules(ruleString); | 72 reader.readRules(ruleString); |
| 73 reader._data = topLevel["data"]; | 73 reader._data = topLevel["data"]; |
| 74 topLevel["roots"] = topLevel["roots"]; | 74 topLevel["roots"] = topLevel["roots"]; |
| 75 return topLevel; | 75 return topLevel; |
| 76 } | 76 } |
| 77 } | 77 } |
| 78 | 78 |
| 79 /** | 79 /** |
| 80 * A format that stores the data in maps which can be converted into a JSON | 80 * A format that stores the data in maps which can be converted into a JSON |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 */ | 143 */ |
| 144 Reference mapToReference(ReaderOrWriter parent, Map<String, int> ref) => | 144 Reference mapToReference(ReaderOrWriter parent, Map<String, int> ref) => |
| 145 ref == null ? null : new Reference(parent, ref["rule"], ref["object"]); | 145 ref == null ? null : new Reference(parent, ref["rule"], ref["object"]); |
| 146 | 146 |
| 147 /** | 147 /** |
| 148 * Read serialized data written in this format | 148 * Read serialized data written in this format |
| 149 * and return the nested Map representation described in [generateOutput]. If | 149 * and return the nested Map representation described in [generateOutput]. If |
| 150 * the data also includes rule definitions, then these will replace the rules | 150 * the data also includes rule definitions, then these will replace the rules |
| 151 * in the [Serialization] for [reader]. | 151 * in the [Serialization] for [reader]. |
| 152 */ | 152 */ |
| 153 Map<String, dynamic> read(topLevel, Reader reader) { | 153 Map<String, dynamic> read(Map<String, dynamic> topLevel, Reader reader) { |
| 154 super.read(topLevel, reader); | 154 super.read(topLevel, reader); |
| 155 forAllStates(reader, | 155 forAllStates(reader, |
| 156 (ref) => ref is Map && ref["__Ref"] != null, | 156 (ref) => ref is Map && ref["__Ref"] != null, |
| 157 (ref) => mapToReference(reader, ref)); | 157 (ref) => mapToReference(reader, ref)); |
| 158 topLevel["roots"] = topLevel["roots"] | 158 topLevel["roots"] = topLevel["roots"] |
| 159 .map((x) => x is Map<String, int> ? mapToReference(reader, x) : x) | 159 .map((x) => x is Map<String, int> ? mapToReference(reader, x) : x) |
| 160 .toList(); | 160 .toList(); |
| 161 return topLevel; | 161 return topLevel; |
| 162 } | 162 } |
| 163 } | 163 } |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 return new Reference(r, a, b); | 552 return new Reference(r, a, b); |
| 553 } | 553 } |
| 554 } | 554 } |
| 555 | 555 |
| 556 /** Return the next element from the input. */ | 556 /** Return the next element from the input. */ |
| 557 _next(Iterator input) { | 557 _next(Iterator input) { |
| 558 input.moveNext(); | 558 input.moveNext(); |
| 559 return input.current; | 559 return input.current; |
| 560 } | 560 } |
| 561 } | 561 } |
| OLD | NEW |