| Index: src/js/string.js
|
| diff --git a/src/js/string.js b/src/js/string.js
|
| index d58a91883e6d30b01158a5ff3a6a15790a6c05af..c838064112f4543dda4e9dc2fb97c0b55d5f6bd3 100644
|
| --- a/src/js/string.js
|
| +++ b/src/js/string.js
|
| @@ -19,6 +19,7 @@ var MakeRangeError;
|
| var MakeTypeError;
|
| var MathMax;
|
| var MathMin;
|
| +var matchSymbol = utils.ImportNow("match_symbol");
|
| var RegExpExec;
|
| var RegExpExecNoTests;
|
| var RegExpLastMatchInfo;
|
| @@ -155,18 +156,23 @@ function StringLocaleCompareJS(other) {
|
|
|
|
|
| // ECMA-262 section 15.5.4.10
|
| -function StringMatchJS(regexp) {
|
| +function StringMatchJS(pattern) {
|
| CHECK_OBJECT_COERCIBLE(this, "String.prototype.match");
|
|
|
| - var subject = TO_STRING(this);
|
| - if (IS_REGEXP(regexp)) {
|
| - if (!REGEXP_GLOBAL(regexp)) return RegExpExecNoTests(regexp, subject, 0);
|
| - var result = %StringMatch(subject, regexp, RegExpLastMatchInfo);
|
| - regexp.lastIndex = 0;
|
| - return result;
|
| + if (!IS_NULL_OR_UNDEFINED(pattern)) {
|
| + var matcher = pattern[matchSymbol];
|
| + if (!IS_UNDEFINED(matcher)) {
|
| + if (!IS_CALLABLE(matcher)) {
|
| + throw MakeTypeError(kCalledNonCallable, matcher);
|
| + }
|
| + return %_Call(matcher, pattern, this);
|
| + }
|
| }
|
| +
|
| + var subject = TO_STRING(this);
|
| +
|
| // Non-regexp argument.
|
| - regexp = new GlobalRegExp(regexp);
|
| + var regexp = new GlobalRegExp(pattern);
|
| return RegExpExecNoTests(regexp, subject, 0);
|
| }
|
|
|
|
|