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

Unified Diff: sdk/lib/_internal/compiler/implementation/scanner/byte_strings.dart

Issue 11783009: Big merge from experimental to bleeding edge. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/compiler/implementation/scanner/byte_strings.dart
diff --git a/sdk/lib/_internal/compiler/implementation/scanner/byte_strings.dart b/sdk/lib/_internal/compiler/implementation/scanner/byte_strings.dart
index f6c220f4aa42daaf52449659506f19fedcc1ea11..4d7989872f37d7e18d02f132b8ee51a5da32b0ed 100644
--- a/sdk/lib/_internal/compiler/implementation/scanner/byte_strings.dart
+++ b/sdk/lib/_internal/compiler/implementation/scanner/byte_strings.dart
@@ -5,7 +5,7 @@
/**
* An abstract string representation.
*/
-class ByteString implements SourceString {
+abstract class ByteString extends Iterable<int> implements SourceString {
final List<int> bytes;
final int offset;
final int length;
@@ -24,7 +24,7 @@ class ByteString implements SourceString {
throw "should be overridden in subclass";
}
- Iterator<int> iterator() => new Utf8Decoder(bytes, offset, length);
+ Iterator<int> get iterator => new Utf8Decoder(bytes, offset, length);
int get hashCode {
if (_hashCode == null) {
@@ -66,7 +66,7 @@ class AsciiString extends ByteString {
return string;
}
- Iterator<int> iterator() => new AsciiStringIterator(bytes);
+ Iterator<int> get iterator => new AsciiStringIterator(bytes);
SourceString copyWithoutQuotes(int initial, int terminal) {
return new AsciiString(bytes, offset + initial,
@@ -85,12 +85,22 @@ class AsciiStringIterator implements Iterator<int> {
final List<int> bytes;
int offset;
final int end;
+ int _current;
+
AsciiStringIterator(List<int> bytes)
: this.bytes = bytes, offset = 0, end = bytes.length;
AsciiStringIterator.range(List<int> bytes, int from, int length)
: this.bytes = bytes, offset = from, end = from + length;
- bool get hasNext => offset < end;
- int next() => bytes[offset++];
+
+ int get current => _current;
+ bool moveNext() {
+ if (offset < end) {
+ _current = bytes[offset++];
+ return true;
+ }
+ _current = null;
+ return false;
+ }
}
@@ -111,7 +121,7 @@ class Utf8String extends ByteString {
throw "not implemented yet";
}
- Iterator<int> iterator() => new Utf8Decoder(bytes, 0, length);
+ Iterator<int> get iterator => new Utf8Decoder(bytes, 0, length);
SourceString copyWithoutQuotes(int initial, int terminal) {
assert((){

Powered by Google App Engine
This is Rietveld 408576698