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 // Patch file for dart:coreimpl classes. | 5 // Patch file for dart:coreimpl classes. |
6 | 6 |
7 // Patch for String implementation. | 7 // Patch for String implementation. |
8 // TODO(ager): Split out into date_patch.dart and allow #source | 8 // TODO(ager): Split out into date_patch.dart and allow #source |
9 // in patch files? | 9 // in patch files? |
10 patch class StringImplementation { | 10 patch class StringImplementation { |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 class _AllMatchesIterator implements Iterator<Match> { | 229 class _AllMatchesIterator implements Iterator<Match> { |
230 final RegExp _re; | 230 final RegExp _re; |
231 final String _str; | 231 final String _str; |
232 Match _next; | 232 Match _next; |
233 bool _done; | 233 bool _done; |
234 | 234 |
235 _AllMatchesIterator(JSSyntaxRegExp re, String this._str) | 235 _AllMatchesIterator(JSSyntaxRegExp re, String this._str) |
236 : _done = false, _re = JSSyntaxRegExp._globalVersionOf(re); | 236 : _done = false, _re = JSSyntaxRegExp._globalVersionOf(re); |
237 | 237 |
238 Match next() { | 238 Match next() { |
239 if (!hasNext()) { | 239 if (!hasNext) { |
240 throw const NoMoreElementsException(); | 240 throw const NoMoreElementsException(); |
241 } | 241 } |
242 | 242 |
243 // _next is set by [hasNext]. | 243 // _next is set by [hasNext]. |
244 var next = _next; | 244 var next = _next; |
245 _next = null; | 245 _next = null; |
246 return next; | 246 return next; |
247 } | 247 } |
248 | 248 |
249 bool hasNext() { | 249 bool get hasNext { |
250 if (_done) { | 250 if (_done) { |
251 return false; | 251 return false; |
252 } else if (_next != null) { | 252 } else if (_next != null) { |
253 return true; | 253 return true; |
254 } | 254 } |
255 | 255 |
256 // firstMatch actually acts as nextMatch because of | 256 // firstMatch actually acts as nextMatch because of |
257 // hidden global flag. | 257 // hidden global flag. |
258 _next = _re.firstMatch(_str); | 258 _next = _re.firstMatch(_str); |
259 if (_next == null) { | 259 if (_next == null) { |
260 _done = true; | 260 _done = true; |
261 return false; | 261 return false; |
262 } else { | 262 } else { |
263 return true; | 263 return true; |
264 } | 264 } |
265 } | 265 } |
266 } | 266 } |
OLD | NEW |