| 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 /** | 5 /** |
| 6 * The [DartString] type represents a Dart string value as a sequence of Unicode | 6 * The [DartString] type represents a Dart string value as a sequence of Unicode |
| 7 * Scalar Values. | 7 * Scalar Values. |
| 8 * After parsing, any valid [LiteralString] will contain a [DartString] | 8 * After parsing, any valid [LiteralString] will contain a [DartString] |
| 9 * representing its content after removing quotes and resolving escapes in | 9 * representing its content after removing quotes and resolving escapes in |
| 10 * its source. | 10 * its source. |
| 11 */ | 11 */ |
| 12 abstract class DartString implements Iterable<int> { | 12 abstract class DartString implements Iterable<int> { |
| 13 factory DartString.empty() => const LiteralDartString(""); | 13 factory DartString.empty() => const LiteralDartString(""); |
| 14 // This is a convenience constructor. If you need a const literal DartString, | 14 // This is a convenience constructor. If you need a const literal DartString, |
| 15 // use [const LiteralDartString(string)] directly. | 15 // use [const LiteralDartString(string)] directly. |
| 16 factory DartString.literal(String string) => new LiteralDartString(string); | 16 factory DartString.literal(String string) => new LiteralDartString(string); |
| 17 factory DartString.rawString(SourceString source, int length) => | 17 factory DartString.rawString(SourceString source, int length) => |
| 18 new RawSourceDartString(source, length); | 18 new RawSourceDartString(source, length); |
| 19 factory DartString.escapedString(SourceString source, int length) => | 19 factory DartString.escapedString(SourceString source, int length) => |
| 20 new EscapedSourceDartString(source, length); | 20 new EscapedSourceDartString(source, length); |
| 21 factory DartString.concat(DartString first, DartString second) { | 21 factory DartString.concat(DartString first, DartString second) { |
| 22 if (first.isEmpty()) return second; | 22 if (first.isEmpty) return second; |
| 23 if (second.isEmpty()) return first; | 23 if (second.isEmpty) return first; |
| 24 return new ConsDartString(first, second); | 24 return new ConsDartString(first, second); |
| 25 } | 25 } |
| 26 const DartString(); | 26 const DartString(); |
| 27 abstract int get length; | 27 abstract int get length; |
| 28 bool isEmpty() => length == 0; | 28 bool get isEmpty => length == 0; |
| 29 abstract Iterator<int> iterator(); | 29 abstract Iterator<int> iterator(); |
| 30 abstract String slowToString(); | 30 abstract String slowToString(); |
| 31 | 31 |
| 32 bool operator ==(var other) { | 32 bool operator ==(var other) { |
| 33 if (other is !DartString) return false; | 33 if (other is !DartString) return false; |
| 34 DartString otherString = other; | 34 DartString otherString = other; |
| 35 if (length != otherString.length) return false; | 35 if (length != otherString.length) return false; |
| 36 Iterator it1 = iterator(); | 36 Iterator it1 = iterator(); |
| 37 Iterator it2 = otherString.iterator(); | 37 Iterator it2 = otherString.iterator(); |
| 38 while (it1.hasNext) { | 38 while (it1.hasNext) { |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 for (int i = 0; i < 3; i++) { | 200 for (int i = 0; i < 3; i++) { |
| 201 code = source.next(); | 201 code = source.next(); |
| 202 value = value * 16 + hexDigitValue(code); | 202 value = value * 16 + hexDigitValue(code); |
| 203 } | 203 } |
| 204 return value; | 204 return value; |
| 205 } | 205 } |
| 206 return code; | 206 return code; |
| 207 } | 207 } |
| 208 } | 208 } |
| 209 | 209 |
| OLD | NEW |