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

Unified Diff: sdk/lib/_internal/compiler/implementation/lib/regexp_helper.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/lib/regexp_helper.dart
diff --git a/sdk/lib/_internal/compiler/implementation/lib/regexp_helper.dart b/sdk/lib/_internal/compiler/implementation/lib/regexp_helper.dart
index 336664e712c743e70020a13aac30b16e1217cdd8..b62b0b5c5b46e2d45906f891556561f8d88101ae 100644
--- a/sdk/lib/_internal/compiler/implementation/lib/regexp_helper.dart
+++ b/sdk/lib/_internal/compiler/implementation/lib/regexp_helper.dart
@@ -30,12 +30,12 @@ regExpAttachGlobalNative(JSSyntaxRegExp regExp) {
regExpMakeNative(JSSyntaxRegExp regExp, {bool global: false}) {
String pattern = regExp.pattern;
- bool multiLine = regExp.multiLine;
- bool ignoreCase = regExp.ignoreCase;
+ bool isMultiLine = regExp.isMultiLine;
+ bool isCaseSensitive = regExp.isCaseSensitive;
checkString(pattern);
StringBuffer sb = new StringBuffer();
- if (multiLine) sb.add('m');
- if (ignoreCase) sb.add('i');
+ if (isMultiLine) sb.add('m');
+ if (!isCaseSensitive) sb.add('i');
if (global) sb.add('g');
try {
return JS('var', r'new RegExp(#, #)', pattern, sb.toString());
@@ -49,15 +49,15 @@ int regExpMatchStart(m) => JS('int', r'#.index', m);
class JSSyntaxRegExp implements RegExp {
final String _pattern;
- final bool _multiLine;
- final bool _ignoreCase;
+ final bool _isMultiLine;
+ final bool _isCaseSensitive;
const JSSyntaxRegExp(String pattern,
{bool multiLine: false,
- bool ignoreCase: false})
+ bool caseSensitive: true})
: _pattern = pattern,
- _multiLine = multiLine,
- _ignoreCase = ignoreCase;
+ _isMultiLine = multiLine,
+ _isCaseSensitive = caseSensitive;
Match firstMatch(String str) {
List<String> m = regExpExec(this, checkString(str));
@@ -81,13 +81,14 @@ class JSSyntaxRegExp implements RegExp {
}
String get pattern => _pattern;
- bool get multiLine => _multiLine;
- bool get ignoreCase => _ignoreCase;
+ bool get isMultiLine => _isMultiLine;
+ bool get isCaseSensitive => _isCaseSensitive;
static JSSyntaxRegExp _globalVersionOf(JSSyntaxRegExp other) {
- JSSyntaxRegExp re = new JSSyntaxRegExp(other.pattern,
- multiLine: other.multiLine,
- ignoreCase: other.ignoreCase);
+ JSSyntaxRegExp re =
+ new JSSyntaxRegExp(other.pattern,
+ multiLine: other.isMultiLine,
+ caseSensitive: other.isCaseSensitive);
regExpAttachGlobalNative(re);
return re;
}
@@ -122,50 +123,29 @@ class _MatchImplementation implements Match {
}
}
-class _AllMatchesIterable implements Iterable<Match> {
+class _AllMatchesIterable extends Iterable<Match> {
final JSSyntaxRegExp _re;
final String _str;
const _AllMatchesIterable(this._re, this._str);
- Iterator<Match> iterator() => new _AllMatchesIterator(_re, _str);
+ Iterator<Match> get iterator => new _AllMatchesIterator(_re, _str);
}
class _AllMatchesIterator implements Iterator<Match> {
final RegExp _re;
final String _str;
- Match _next;
- bool _done;
+ Match _current;
_AllMatchesIterator(JSSyntaxRegExp re, String this._str)
- : _done = false, _re = JSSyntaxRegExp._globalVersionOf(re);
+ : _re = JSSyntaxRegExp._globalVersionOf(re);
- Match next() {
- if (!hasNext) {
- throw new StateError("No more elements");
- }
-
- // _next is set by [hasNext].
- var next = _next;
- _next = null;
- return next;
- }
-
- bool get hasNext {
- if (_done) {
- return false;
- } else if (_next != null) {
- return true;
- }
+ Match get current => _current;
+ bool moveNext() {
// firstMatch actually acts as nextMatch because of
// hidden global flag.
- _next = _re.firstMatch(_str);
- if (_next == null) {
- _done = true;
- return false;
- } else {
- return true;
- }
+ _current = _re.firstMatch(_str);
+ return _current != null;
}
}

Powered by Google App Engine
This is Rietveld 408576698