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 /// This file contains the node classes for the internal representations of YAML | 5 /// This file contains the node classes for the internal representations of YAML |
6 /// documents. These nodes are used for both the serialization tree and the | 6 /// documents. These nodes are used for both the serialization tree and the |
7 /// representation graph. | 7 /// representation graph. |
8 library yaml.model; | 8 library yaml.model; |
9 | 9 |
10 import 'package:source_maps/source_maps.dart'; | 10 import 'package:source_maps/source_maps.dart'; |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 } else if (c >= 0x10000) { | 201 } else if (c >= 0x10000) { |
202 return "\\u${zeroPad(c.toRadixString(16).toUpperCase(), 8)}"; | 202 return "\\u${zeroPad(c.toRadixString(16).toUpperCase(), 8)}"; |
203 } else { | 203 } else { |
204 return new String.fromCharCodes([c]); | 204 return new String.fromCharCodes([c]); |
205 } | 205 } |
206 } | 206 } |
207 }); | 207 }); |
208 return '"${escapedValue.join()}"'; | 208 return '"${escapedValue.join()}"'; |
209 } | 209 } |
210 | 210 |
211 throw new YamlException('Unknown scalar value: "$value".'); | 211 throw new YamlException('Unknown scalar value.', span); |
212 } | 212 } |
213 | 213 |
214 String toString() => '$tag "$content"'; | 214 String toString() => '$tag "$content"'; |
215 | 215 |
216 /// Left-pads [str] with zeros so that it's at least [length] characters | 216 /// Left-pads [str] with zeros so that it's at least [length] characters |
217 /// long. | 217 /// long. |
218 String zeroPad(String str, int length) { | 218 String zeroPad(String str, int length) { |
219 assert(length >= str.length); | 219 assert(length >= str.length); |
220 var prefix = new List.filled(length - str.length, '0'); | 220 var prefix = new List.filled(length - str.length, '0'); |
221 return '${prefix.join()}$str'; | 221 return '${prefix.join()}$str'; |
(...skipping 28 matching lines...) Expand all Loading... |
250 var strContent = content.keys | 250 var strContent = content.keys |
251 .map((k) => '${k}: ${content[k]}') | 251 .map((k) => '${k}: ${content[k]}') |
252 .join(', '); | 252 .join(', '); |
253 return '$tag {$strContent}'; | 253 return '$tag {$strContent}'; |
254 } | 254 } |
255 | 255 |
256 int get hashCode => super.hashCode ^ deepHashCode(content); | 256 int get hashCode => super.hashCode ^ deepHashCode(content); |
257 | 257 |
258 visit(Visitor v) => v.visitMapping(this); | 258 visit(Visitor v) => v.visitMapping(this); |
259 } | 259 } |
OLD | NEW |