Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Side by Side Diff: frog/leg/scanner/byte_strings.dart

Issue 9204006: Make SourceString Iterable<int>. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | frog/leg/scanner/string_scanner.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 toString() => new Utf8Decoder(bytes, offset, length).toString(); 18 String toString() => new String.fromCharCodes(
19 new Utf8Decoder(bytes, offset, length).decodeRest());
19 20
20 bool operator ==(other) { 21 bool operator ==(other) {
21 throw "should be overridden in subclass"; 22 throw "should be overridden in subclass";
22 } 23 }
23 24
25 Iterator<int> iterator() => new Utf8Decoder(bytes, offset, length);
26
24 int hashCode() { 27 int hashCode() {
25 if (_hashCode === null) { 28 if (_hashCode === null) {
26 _hashCode = computeHashCode(); 29 _hashCode = computeHashCode();
27 } 30 }
28 return _hashCode; 31 return _hashCode;
29 } 32 }
30 33
31 int computeHashCode() { 34 int computeHashCode() {
32 int code = 1; 35 int code = 1;
33 int end = offset + length; 36 int end = offset + length;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 * A ByteString-valued token. 87 * A ByteString-valued token.
85 */ 88 */
86 class ByteStringToken extends Token { 89 class ByteStringToken extends Token {
87 final ByteString value; 90 final ByteString value;
88 91
89 ByteStringToken(PrecedenceInfo info, ByteString this.value, int charOffset) 92 ByteStringToken(PrecedenceInfo info, ByteString this.value, int charOffset)
90 : super(info, charOffset); 93 : super(info, charOffset);
91 94
92 String toString() => value.toString(); 95 String toString() => value.toString();
93 } 96 }
OLDNEW
« no previous file with comments | « no previous file | frog/leg/scanner/string_scanner.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698