| 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 | 8 |
| 9 /** A tag that indicates the type of a YAML node. */ | 9 /** A tag that indicates the type of a YAML node. */ |
| 10 class _Tag implements Hashable { | 10 class _Tag implements Hashable { |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 bool operator ==(other) { | 126 bool operator ==(other) { |
| 127 // Should be super != other; bug 2554 | 127 // Should be super != other; bug 2554 |
| 128 if (!(super == other) || other is! _ScalarNode) return false; | 128 if (!(super == other) || other is! _ScalarNode) return false; |
| 129 return content == other.content; | 129 return content == other.content; |
| 130 } | 130 } |
| 131 | 131 |
| 132 /** | 132 /** |
| 133 * Returns the string representation of the scalar. After composition, this is | 133 * Returns the string representation of the scalar. After composition, this is |
| 134 * equal to the canonical serialization of the value of the scalar. | 134 * equal to the canonical serialization of the value of the scalar. |
| 135 */ | 135 */ |
| 136 String get content() => _content != null ? _content : canonicalContent; | 136 String get content => _content != null ? _content : canonicalContent; |
| 137 | 137 |
| 138 /** | 138 /** |
| 139 * Returns the canonical serialization of the value of the scalar. If the | 139 * Returns the canonical serialization of the value of the scalar. If the |
| 140 * value isn't given, the result of this will be "null". | 140 * value isn't given, the result of this will be "null". |
| 141 */ | 141 */ |
| 142 String get canonicalContent() { | 142 String get canonicalContent { |
| 143 if (value == null || value is bool || value is int) return '$value'; | 143 if (value == null || value is bool || value is int) return '$value'; |
| 144 | 144 |
| 145 if (value is num) { | 145 if (value is num) { |
| 146 // 20 is the maximum value for this argument, which we use since YAML | 146 // 20 is the maximum value for this argument, which we use since YAML |
| 147 // doesn't specify a maximum. | 147 // doesn't specify a maximum. |
| 148 return value.toStringAsExponential(20). | 148 return value.toStringAsExponential(20). |
| 149 replaceFirst(const RegExp("0+e"), "e"); | 149 replaceFirst(const RegExp("0+e"), "e"); |
| 150 } | 150 } |
| 151 | 151 |
| 152 if (value is String) { | 152 if (value is String) { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 String toString() { | 229 String toString() { |
| 230 var strContent = Strings.join(content.getKeys(). | 230 var strContent = Strings.join(content.getKeys(). |
| 231 map((k) => '${k}: ${content[k]}'), ', '); | 231 map((k) => '${k}: ${content[k]}'), ', '); |
| 232 return '$tag {$strContent}'; | 232 return '$tag {$strContent}'; |
| 233 } | 233 } |
| 234 | 234 |
| 235 int hashCode() => super.hashCode() ^ _hashCode(content); | 235 int hashCode() => super.hashCode() ^ _hashCode(content); |
| 236 | 236 |
| 237 visit(_Visitor v) => v.visitMapping(this); | 237 visit(_Visitor v) => v.visitMapping(this); |
| 238 } | 238 } |
| OLD | NEW |