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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 // 20 is the maximum value for this argument, which we use since YAML | 142 // 20 is the maximum value for this argument, which we use since YAML |
143 // doesn't specify a maximum. | 143 // doesn't specify a maximum. |
144 return value.toStringAsExponential(20). | 144 return value.toStringAsExponential(20). |
145 replaceFirst(new RegExp("0+e"), "e"); | 145 replaceFirst(new RegExp("0+e"), "e"); |
146 } | 146 } |
147 | 147 |
148 if (value is String) { | 148 if (value is String) { |
149 // TODO(nweiz): This could be faster if we used a RegExp to check for | 149 // TODO(nweiz): This could be faster if we used a RegExp to check for |
150 // special characters and short-circuited if they didn't exist. | 150 // special characters and short-circuited if they didn't exist. |
151 | 151 |
152 var escapedValue = value.charCodes.map((c) { | 152 var escapedValue = value.codeUnits.map((c) { |
153 switch (c) { | 153 switch (c) { |
154 case _Parser.TAB: return "\\t"; | 154 case _Parser.TAB: return "\\t"; |
155 case _Parser.LF: return "\\n"; | 155 case _Parser.LF: return "\\n"; |
156 case _Parser.CR: return "\\r"; | 156 case _Parser.CR: return "\\r"; |
157 case _Parser.DOUBLE_QUOTE: return '\\"'; | 157 case _Parser.DOUBLE_QUOTE: return '\\"'; |
158 case _Parser.NULL: return "\\0"; | 158 case _Parser.NULL: return "\\0"; |
159 case _Parser.BELL: return "\\a"; | 159 case _Parser.BELL: return "\\a"; |
160 case _Parser.BACKSPACE: return "\\b"; | 160 case _Parser.BACKSPACE: return "\\b"; |
161 case _Parser.VERTICAL_TAB: return "\\v"; | 161 case _Parser.VERTICAL_TAB: return "\\v"; |
162 case _Parser.FORM_FEED: return "\\f"; | 162 case _Parser.FORM_FEED: return "\\f"; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 var strContent = content.keys | 224 var strContent = content.keys |
225 .map((k) => '${k}: ${content[k]}') | 225 .map((k) => '${k}: ${content[k]}') |
226 .join(', '); | 226 .join(', '); |
227 return '$tag {$strContent}'; | 227 return '$tag {$strContent}'; |
228 } | 228 } |
229 | 229 |
230 int get hashCode => super.hashCode ^ _hashCode(content); | 230 int get hashCode => super.hashCode ^ _hashCode(content); |
231 | 231 |
232 visit(_Visitor v) => v.visitMapping(this); | 232 visit(_Visitor v) => v.visitMapping(this); |
233 } | 233 } |
OLD | NEW |