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

Unified Diff: sdk/lib/_internal/lib/regexp_helper.dart

Issue 250573002: Change the badly named RegExp.pattern to return the original source. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update date. Created 6 years, 8 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/core/regexp.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/lib/regexp_helper.dart
diff --git a/sdk/lib/_internal/lib/regexp_helper.dart b/sdk/lib/_internal/lib/regexp_helper.dart
index 1409c9b692322f78b3c18c79f4ccb88937112388..2e7f0f9f46883277ad7fe5d9d40026a48d069133 100644
--- a/sdk/lib/_internal/lib/regexp_helper.dart
+++ b/sdk/lib/_internal/lib/regexp_helper.dart
@@ -23,19 +23,22 @@ regExpGetGlobalNative(JSSyntaxRegExp regexp) {
}
class JSSyntaxRegExp implements RegExp {
+ final String pattern;
final _nativeRegExp;
var _nativeGlobalRegExp;
var _nativeAnchoredRegExp;
- JSSyntaxRegExp(String pattern,
+
+ JSSyntaxRegExp(String source,
{ bool multiLine: false,
bool caseSensitive: true })
- : this._nativeRegExp =
- makeNative(pattern, multiLine, caseSensitive, false);
+ : this.pattern = source,
+ this._nativeRegExp =
+ makeNative(source, multiLine, caseSensitive, false);
get _nativeGlobalVersion {
if (_nativeGlobalRegExp != null) return _nativeGlobalRegExp;
- return _nativeGlobalRegExp = makeNative(_pattern,
+ return _nativeGlobalRegExp = makeNative(pattern,
_isMultiLine,
_isCaseSensitive,
true);
@@ -48,19 +51,18 @@ class JSSyntaxRegExp implements RegExp {
// that it tries, and you can see if the original regexp matched, or it
// was the added zero-width match that matched, by looking at the last
// capture. If it is a String, the match participated, otherwise it didn't.
- return _nativeAnchoredRegExp = makeNative("$_pattern|()",
+ return _nativeAnchoredRegExp = makeNative("$pattern|()",
_isMultiLine,
_isCaseSensitive,
true);
}
- String get _pattern => JS("String", "#.source", _nativeRegExp);
bool get _isMultiLine => JS("bool", "#.multiline", _nativeRegExp);
bool get _isCaseSensitive => JS("bool", "!#.ignoreCase", _nativeRegExp);
static makeNative(
- String pattern, bool multiLine, bool caseSensitive, bool global) {
- checkString(pattern);
+ String source, bool multiLine, bool caseSensitive, bool global) {
+ checkString(source);
String m = multiLine ? 'm' : '';
String i = caseSensitive ? '' : 'i';
String g = global ? 'g' : '';
@@ -74,13 +76,13 @@ class JSSyntaxRegExp implements RegExp {
'} catch (e) {'
'return e;'
'}'
- '})()', pattern, m, i, g);
+ '})()', source, m, i, g);
if (JS('bool', '# instanceof RegExp', regexp)) return regexp;
// The returned value is the JavaScript exception. Turn it into a
// Dart exception.
String errorMessage = JS('String', r'String(#)', regexp);
throw new FormatException(
- "Illegal RegExp pattern: $pattern, $errorMessage");
+ "Illegal RegExp pattern: $source, $errorMessage");
}
Match firstMatch(String str) {
@@ -134,7 +136,6 @@ class JSSyntaxRegExp implements RegExp {
return _execAnchored(string, start);
}
- String get pattern => _pattern;
bool get isMultiLine => _isMultiLine;
bool get isCaseSensitive => _isCaseSensitive;
}
« no previous file with comments | « no previous file | sdk/lib/core/regexp.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698