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

Unified Diff: runtime/lib/regexp_patch.dart

Issue 11365196: Move JSSyntaxRegExp to core as a private member. This removes the last refrences to dart:coreimpl. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix two pending TODO's. Created 8 years, 1 month 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: runtime/lib/regexp_patch.dart
diff --git a/runtime/lib/regexp_patch.dart b/runtime/lib/regexp_patch.dart
index d44c24e18023ec5d5cfd0923a3a6a856fc7cd66e..d6e830c95048ee4186f1799c7e1fd7d2cf887719 100644
--- a/runtime/lib/regexp_patch.dart
+++ b/runtime/lib/regexp_patch.dart
@@ -2,6 +2,16 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+patch class RegExp {
+ /* patch */ factory RegExp(String pattern,
+ {bool multiLine: false,
+ bool ignoreCase: false}) {
+ return new _JSSyntaxRegExp(pattern,
+ multiLine: multiLine,
+ ignoreCase: ignoreCase);
+ }
+}
+
class _JSRegExpMatch implements Match {
_JSRegExpMatch(this.regexp, this.str, this._match);
@@ -26,8 +36,7 @@ class _JSRegExpMatch implements Match {
assert(endIndex == -1);
return null;
}
- // TODO(ajohnsen): Use _substringUnchecked when regexp is in core.
- return str.substring(startIndex, endIndex);
+ return str._substringUnchecked(startIndex, endIndex);
}
String operator [](int groupIdx) {
@@ -53,13 +62,13 @@ class _JSRegExpMatch implements Match {
}
-patch class JSSyntaxRegExp {
- /* patch */ factory JSSyntaxRegExp(
+class _JSSyntaxRegExp implements RegExp {
+ factory _JSSyntaxRegExp(
String pattern,
{bool multiLine: false,
bool ignoreCase: false}) native "JSSyntaxRegExp_factory";
- /* patch */ Match firstMatch(String str) {
+ Match firstMatch(String str) {
List match = _ExecuteMatch(str, 0);
if (match == null) {
return null;
@@ -67,7 +76,7 @@ patch class JSSyntaxRegExp {
return new _JSRegExpMatch(this, str, match);
}
- /* patch */ Iterable<Match> allMatches(String str) {
+ Iterable<Match> allMatches(String str) {
List<Match> result = new List<Match>();
int length = str.length;
int startIndex = 0;
@@ -89,25 +98,24 @@ patch class JSSyntaxRegExp {
return result;
}
- /* patch */ bool hasMatch(String str) {
+ bool hasMatch(String str) {
List match = _ExecuteMatch(str, 0);
return (match == null) ? false : true;
}
- /* patch */ String stringMatch(String str) {
+ String stringMatch(String str) {
List match = _ExecuteMatch(str, 0);
if (match == null) {
return null;
}
- // TODO(ajohnsen): Use _substringUnchecked when regexp is in core.
- return str.substring(match[0], match[1]);
+ return str._substringUnchecked(match[0], match[1]);
}
- /* patch */ String get pattern native "JSSyntaxRegExp_getPattern";
+ String get pattern native "JSSyntaxRegExp_getPattern";
- /* patch */ bool get multiLine native "JSSyntaxRegExp_multiLine";
+ bool get multiLine native "JSSyntaxRegExp_multiLine";
- /* patch */ bool get ignoreCase native "JSSyntaxRegExp_ignoreCase";
+ bool get ignoreCase native "JSSyntaxRegExp_ignoreCase";
int get _groupCount native "JSSyntaxRegExp_getGroupCount";

Powered by Google App Engine
This is Rietveld 408576698