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

Unified Diff: runtime/lib/regexp_patch.dart

Issue 16206008: Fix-up RegExp implementations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Renaming startIndex to index. Add comment. Created 7 years, 6 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
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/lib/js_string.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/regexp_patch.dart
diff --git a/runtime/lib/regexp_patch.dart b/runtime/lib/regexp_patch.dart
index e365f30e5bb7356b983b7fb503cd1707dc223e4c..d82e3305d981a098d003823cc8d5df4369bcb8f4 100644
--- a/runtime/lib/regexp_patch.dart
+++ b/runtime/lib/regexp_patch.dart
@@ -13,21 +13,21 @@ patch class RegExp {
}
class _JSRegExpMatch implements Match {
- _JSRegExpMatch(this.regexp, this.str, this._match);
+ _JSRegExpMatch(this._regexp, this.str, this._match);
int get start => _start(0);
int get end => _end(0);
int _start(int groupIdx) {
- return _match[(groupIdx * MATCH_PAIR)];
+ return _match[(groupIdx * _MATCH_PAIR)];
}
int _end(int groupIdx) {
- return _match[(groupIdx * MATCH_PAIR) + 1];
+ return _match[(groupIdx * _MATCH_PAIR) + 1];
}
String group(int groupIdx) {
- if (groupIdx < 0 || groupIdx > regexp._groupCount) {
+ if (groupIdx < 0 || groupIdx > _regexp._groupCount) {
throw new RangeError.value(groupIdx);
}
int startIndex = _start(groupIdx);
@@ -51,14 +51,14 @@ class _JSRegExpMatch implements Match {
return groupsList;
}
- int get groupCount => regexp._groupCount;
+ int get groupCount => _regexp._groupCount;
- String get pattern => regexp.pattern;
+ Pattern get pattern => _regexp;
- final RegExp regexp;
+ final RegExp _regexp;
final String str;
final List<int> _match;
- static const int MATCH_PAIR = 2;
+ static const int _MATCH_PAIR = 2;
}
@@ -80,20 +80,21 @@ class _JSSyntaxRegExp implements RegExp {
if (str is! String) throw new ArgumentError(str);
List<Match> result = new List<Match>();
int length = str.length;
- int startIndex = 0;
+ int index = 0;
while (true) {
- List match = _ExecuteMatch(str, startIndex);
+ List match = _ExecuteMatch(str, index);
if (match == null) {
break;
}
result.add(new _JSRegExpMatch(this, str, match));
- int endIndex = match[1];
- if (endIndex == length) {
- break;
- } else if (match[0] == endIndex) {
- ++startIndex; // empty match, advance and restart
- } else {
- startIndex = endIndex;
+ // Find the index at which to start searching for the next match.
+ index = match[1];
+ if (match[0] == index) {
+ // Zero-length match.
+ if (index == length) {
+ break;
+ }
+ index++;
}
}
return result;
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/lib/js_string.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698