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 yaml; | 5 part of yaml; |
6 | 6 |
7 // This file contains the node classes for the internal representations of YAML | 7 // This file contains the node classes for the internal representations of YAML |
8 // documents. These nodes are used for both the serialization tree and the | 8 // documents. These nodes are used for both the serialization tree and the |
9 // representation graph. | 9 // representation graph. |
10 | 10 |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 | 183 |
184 throw new YamlException("unknown scalar value: $value"); | 184 throw new YamlException("unknown scalar value: $value"); |
185 } | 185 } |
186 | 186 |
187 String toString() => '$tag "$content"'; | 187 String toString() => '$tag "$content"'; |
188 | 188 |
189 /// Left-pads [str] with zeros so that it's at least [length] characters | 189 /// Left-pads [str] with zeros so that it's at least [length] characters |
190 /// long. | 190 /// long. |
191 String zeroPad(String str, int length) { | 191 String zeroPad(String str, int length) { |
192 assert(length >= str.length); | 192 assert(length >= str.length); |
193 var prefix = []; | 193 var prefix = new List.filled(length - str.length, '0'); |
194 prefix.insertRange(0, length - str.length, '0'); | |
195 return '${prefix.join()}$str'; | 194 return '${prefix.join()}$str'; |
196 } | 195 } |
197 | 196 |
198 int get hashCode => super.hashCode ^ content.hashCode; | 197 int get hashCode => super.hashCode ^ content.hashCode; |
199 | 198 |
200 visit(_Visitor v) => v.visitScalar(this); | 199 visit(_Visitor v) => v.visitScalar(this); |
201 } | 200 } |
202 | 201 |
203 /// A mapping node represents an unordered map of nodes to nodes. | 202 /// A mapping node represents an unordered map of nodes to nodes. |
204 class _MappingNode extends _Node { | 203 class _MappingNode extends _Node { |
(...skipping 19 matching lines...) Expand all Loading... |
224 var strContent = content.keys | 223 var strContent = content.keys |
225 .map((k) => '${k}: ${content[k]}') | 224 .map((k) => '${k}: ${content[k]}') |
226 .join(', '); | 225 .join(', '); |
227 return '$tag {$strContent}'; | 226 return '$tag {$strContent}'; |
228 } | 227 } |
229 | 228 |
230 int get hashCode => super.hashCode ^ _hashCode(content); | 229 int get hashCode => super.hashCode ^ _hashCode(content); |
231 | 230 |
232 visit(_Visitor v) => v.visitMapping(this); | 231 visit(_Visitor v) => v.visitMapping(this); |
233 } | 232 } |
OLD | NEW |