| Index: sdk/lib/_internal/compiler/js_lib/regexp_helper.dart
|
| diff --git a/sdk/lib/_internal/compiler/js_lib/regexp_helper.dart b/sdk/lib/_internal/compiler/js_lib/regexp_helper.dart
|
| index 7f930ebf170db0e25da4322808c609eb09090e11..4bdf754f718bd2d2aa1f7d328b7b53c0bcfd6ae1 100644
|
| --- a/sdk/lib/_internal/compiler/js_lib/regexp_helper.dart
|
| +++ b/sdk/lib/_internal/compiler/js_lib/regexp_helper.dart
|
| @@ -22,12 +22,31 @@ regExpGetGlobalNative(JSSyntaxRegExp regexp) {
|
| return nativeRegexp;
|
| }
|
|
|
| +/**
|
| + * Computes the number of captures in a regexp.
|
| + *
|
| + * This currently involves creating a new RegExp object with a different
|
| + * source and running it against the empty string (the last part is usually
|
| + * fast).
|
| + *
|
| + * The JSSyntaxRegExp could cache the result, and set the cache any time
|
| + * it finds a match.
|
| + */
|
| +int regExpCaptureCount(JSSyntaxRegExp regexp) {
|
| + var nativeAnchoredRegExp = regexp._nativeAnchoredVersion;
|
| + var match = JS('JSExtendableArray', "#.exec('')", nativeAnchoredRegExp);
|
| + // The native-anchored regexp always have one capture more than the original,
|
| + // and always matches the empty string.
|
| + return match.length - 2;
|
| +}
|
| +
|
| class JSSyntaxRegExp implements RegExp {
|
| final String pattern;
|
| final _nativeRegExp;
|
| var _nativeGlobalRegExp;
|
| var _nativeAnchoredRegExp;
|
|
|
| + String toString() => "RegExp/$pattern/";
|
|
|
| JSSyntaxRegExp(String source,
|
| { bool multiLine: false,
|
|
|