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