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 /** | 5 /** |
6 * An abstract string representation. | 6 * An abstract string representation. |
7 */ | 7 */ |
8 class ByteString implements SourceString { | 8 class ByteString implements SourceString { |
9 final List<int> bytes; | 9 final List<int> bytes; |
10 final int offset; | 10 final int offset; |
11 final int length; | 11 final int length; |
12 int _hashCode; | 12 int _hashCode; |
13 | 13 |
14 ByteString(List<int> this.bytes, int this.offset, int this.length); | 14 ByteString(List<int> this.bytes, int this.offset, int this.length); |
15 | 15 |
16 abstract String get charset(); | 16 abstract String get charset; |
17 | 17 |
18 String slowToString() => new String.fromCharCodes( | 18 String slowToString() => new String.fromCharCodes( |
19 new Utf8Decoder(bytes, offset, length).decodeRest()); | 19 new Utf8Decoder(bytes, offset, length).decodeRest()); |
20 | 20 |
21 String toString() => "ByteString(${slowToString()})"; | 21 String toString() => "ByteString(${slowToString()})"; |
22 | 22 |
23 bool operator ==(other) { | 23 bool operator ==(other) { |
24 throw "should be overridden in subclass"; | 24 throw "should be overridden in subclass"; |
25 } | 25 } |
26 | 26 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 * A ByteString-valued token. | 135 * A ByteString-valued token. |
136 */ | 136 */ |
137 class ByteStringToken extends Token { | 137 class ByteStringToken extends Token { |
138 final ByteString value; | 138 final ByteString value; |
139 | 139 |
140 ByteStringToken(PrecedenceInfo info, ByteString this.value, int charOffset) | 140 ByteStringToken(PrecedenceInfo info, ByteString this.value, int charOffset) |
141 : super(info, charOffset); | 141 : super(info, charOffset); |
142 | 142 |
143 String toString() => value.toString(); | 143 String toString() => value.toString(); |
144 } | 144 } |
OLD | NEW |