| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 scanner; | 5 part of scanner; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Scanner that reads from a String and creates tokens that points to | 8 * Scanner that reads from a String and creates tokens that points to |
| 9 * substrings. | 9 * substrings. |
| 10 */ | 10 */ |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 cashedHash = slowToString().hashCode; | 68 cashedHash = slowToString().hashCode; |
| 69 } | 69 } |
| 70 return cashedHash; | 70 return cashedHash; |
| 71 } | 71 } |
| 72 | 72 |
| 73 bool operator ==(other) { | 73 bool operator ==(other) { |
| 74 return other is SourceString && slowToString() == other.slowToString(); | 74 return other is SourceString && slowToString() == other.slowToString(); |
| 75 } | 75 } |
| 76 | 76 |
| 77 void printOn(StringBuffer sb) { | 77 void printOn(StringBuffer sb) { |
| 78 sb.add(internalString.substring(begin, end)); | 78 sb.write(internalString.substring(begin, end)); |
| 79 } | 79 } |
| 80 | 80 |
| 81 String slowToString() { | 81 String slowToString() { |
| 82 if (cachedSubString == null) { | 82 if (cachedSubString == null) { |
| 83 cachedSubString = internalString.substring(begin, end); | 83 cachedSubString = internalString.substring(begin, end); |
| 84 } | 84 } |
| 85 return cachedSubString; | 85 return cachedSubString; |
| 86 } | 86 } |
| 87 | 87 |
| 88 String toString() => "SubstringWrapper(${slowToString()})"; | 88 String toString() => "SubstringWrapper(${slowToString()})"; |
| 89 | 89 |
| 90 String get stringValue => null; | 90 String get stringValue => null; |
| 91 | 91 |
| 92 Iterator<int> get iterator => | 92 Iterator<int> get iterator => |
| 93 new StringCodeIterator.substring(internalString, begin, end); | 93 new StringCodeIterator.substring(internalString, begin, end); |
| 94 | 94 |
| 95 SourceString copyWithoutQuotes(int initial, int terminal) { | 95 SourceString copyWithoutQuotes(int initial, int terminal) { |
| 96 assert(0 <= initial); | 96 assert(0 <= initial); |
| 97 assert(0 <= terminal); | 97 assert(0 <= terminal); |
| 98 assert(initial + terminal <= internalString.length); | 98 assert(initial + terminal <= internalString.length); |
| 99 return new SubstringWrapper(internalString, | 99 return new SubstringWrapper(internalString, |
| 100 begin + initial, end - terminal); | 100 begin + initial, end - terminal); |
| 101 } | 101 } |
| 102 | 102 |
| 103 bool get isEmpty => begin == end; | 103 bool get isEmpty => begin == end; |
| 104 | 104 |
| 105 bool isPrivate() => !isEmpty && internalString.codeUnitAt(begin) == $_; | 105 bool isPrivate() => !isEmpty && internalString.codeUnitAt(begin) == $_; |
| 106 } | 106 } |
| OLD | NEW |