| Index: src/js/regexp.js
|
| diff --git a/src/js/regexp.js b/src/js/regexp.js
|
| index b9d0f50b244345c52e73e1cb33fdbe09d7c3c6f6..3053ce67c6831aca5371ee6b4f8f1a5033d93fa9 100644
|
| --- a/src/js/regexp.js
|
| +++ b/src/js/regexp.js
|
| @@ -24,6 +24,7 @@ var searchSymbol = utils.ImportNow("search_symbol");
|
| var speciesSymbol = utils.ImportNow("species_symbol");
|
| var splitSymbol = utils.ImportNow("split_symbol");
|
| var SpeciesConstructor;
|
| +var RegExpSubclassExecJS;
|
|
|
| utils.Import(function(from) {
|
| ExpandReplacement = from.ExpandReplacement;
|
| @@ -102,66 +103,6 @@ macro RETURN_NEW_RESULT_FROM_MATCH_INFO(MATCHINFO, STRING)
|
| endmacro
|
|
|
|
|
| -function RegExpExecNoTests(regexp, string, start) {
|
| - // Must be called with RegExp, string and positive integer as arguments.
|
| - var matchInfo = %_RegExpExec(regexp, string, start, RegExpLastMatchInfo);
|
| - if (matchInfo !== null) {
|
| - // ES6 21.2.5.2.2 step 18.
|
| - if (REGEXP_STICKY(regexp)) regexp.lastIndex = matchInfo[CAPTURE1];
|
| - RETURN_NEW_RESULT_FROM_MATCH_INFO(matchInfo, string);
|
| - }
|
| - regexp.lastIndex = 0;
|
| - return null;
|
| -}
|
| -
|
| -
|
| -// ES#sec-regexp.prototype.exec
|
| -// RegExp.prototype.exec ( string )
|
| -function RegExpSubclassExecJS(string) {
|
| - if (!IS_REGEXP(this)) {
|
| - throw %make_type_error(kIncompatibleMethodReceiver,
|
| - 'RegExp.prototype.exec', this);
|
| - }
|
| -
|
| - string = TO_STRING(string);
|
| - var lastIndex = this.lastIndex;
|
| -
|
| - // Conversion is required by the ES2015 specification (RegExpBuiltinExec
|
| - // algorithm, step 4) even if the value is discarded for non-global RegExps.
|
| - var i = TO_LENGTH(lastIndex);
|
| -
|
| - var global = TO_BOOLEAN(REGEXP_GLOBAL(this));
|
| - var sticky = TO_BOOLEAN(REGEXP_STICKY(this));
|
| - var updateLastIndex = global || sticky;
|
| - if (updateLastIndex) {
|
| - if (i > string.length) {
|
| - this.lastIndex = 0;
|
| - return null;
|
| - }
|
| - } else {
|
| - i = 0;
|
| - }
|
| -
|
| - // matchIndices is either null or the RegExpLastMatchInfo array.
|
| - // TODO(littledan): Whether a RegExp is sticky is compiled into the RegExp
|
| - // itself, but ES2015 allows monkey-patching this property to differ from
|
| - // the internal flags. If it differs, recompile a different RegExp?
|
| - var matchIndices = %_RegExpExec(this, string, i, RegExpLastMatchInfo);
|
| -
|
| - if (IS_NULL(matchIndices)) {
|
| - this.lastIndex = 0;
|
| - return null;
|
| - }
|
| -
|
| - // Successful match.
|
| - if (updateLastIndex) {
|
| - this.lastIndex = RegExpLastMatchInfo[CAPTURE1];
|
| - }
|
| - RETURN_NEW_RESULT_FROM_MATCH_INFO(matchIndices, string);
|
| -}
|
| -%FunctionRemovePrototype(RegExpSubclassExecJS);
|
| -
|
| -
|
| // ES#sec-regexpexec Runtime Semantics: RegExpExec ( R, S )
|
| // Also takes an optional exec method in case our caller
|
| // has already fetched exec.
|
| @@ -181,19 +122,6 @@ function RegExpSubclassExec(regexp, string, exec) {
|
| %SetForceInlineFlag(RegExpSubclassExec);
|
|
|
|
|
| -// ES#sec-regexp.prototype.test RegExp.prototype.test ( S )
|
| -function RegExpSubclassTest(string) {
|
| - if (!IS_RECEIVER(this)) {
|
| - throw %make_type_error(kIncompatibleMethodReceiver,
|
| - 'RegExp.prototype.test', this);
|
| - }
|
| - string = TO_STRING(string);
|
| - var match = RegExpSubclassExec(this, string);
|
| - return !IS_NULL(match);
|
| -}
|
| -%FunctionRemovePrototype(RegExpSubclassTest);
|
| -
|
| -
|
| function AtSurrogatePair(subject, index) {
|
| if (index + 1 >= subject.length) return false;
|
| var first = %_StringCharCodeAt(subject, index);
|
| @@ -354,39 +282,6 @@ function RegExpSubclassSplit(string, limit) {
|
| %FunctionRemovePrototype(RegExpSubclassSplit);
|
|
|
|
|
| -// ES#sec-regexp.prototype-@@match
|
| -// RegExp.prototype [ @@match ] ( string )
|
| -function RegExpSubclassMatch(string) {
|
| - if (!IS_RECEIVER(this)) {
|
| - throw %make_type_error(kIncompatibleMethodReceiver,
|
| - "RegExp.prototype.@@match", this);
|
| - }
|
| - string = TO_STRING(string);
|
| - var global = this.global;
|
| - if (!global) return RegExpSubclassExec(this, string);
|
| - var unicode = this.unicode;
|
| - this.lastIndex = 0;
|
| - var array = new InternalArray();
|
| - var n = 0;
|
| - var result;
|
| - while (true) {
|
| - result = RegExpSubclassExec(this, string);
|
| - if (IS_NULL(result)) {
|
| - if (n === 0) return null;
|
| - break;
|
| - }
|
| - var matchStr = TO_STRING(result[0]);
|
| - array[n] = matchStr;
|
| - if (matchStr === "") SetAdvancedStringIndex(this, string, unicode);
|
| - n++;
|
| - }
|
| - var resultArray = [];
|
| - %MoveArrayContents(array, resultArray);
|
| - return resultArray;
|
| -}
|
| -%FunctionRemovePrototype(RegExpSubclassMatch);
|
| -
|
| -
|
| // Legacy implementation of RegExp.prototype[Symbol.replace] which
|
| // doesn't properly call the underlying exec method.
|
|
|
| @@ -753,38 +648,18 @@ function RegExpSubclassReplace(string, replace) {
|
| %FunctionRemovePrototype(RegExpSubclassReplace);
|
|
|
|
|
| -// ES#sec-regexp.prototype-@@search
|
| -// RegExp.prototype [ @@search ] ( string )
|
| -function RegExpSubclassSearch(string) {
|
| - if (!IS_RECEIVER(this)) {
|
| - throw %make_type_error(kIncompatibleMethodReceiver,
|
| - "RegExp.prototype.@@search", this);
|
| - }
|
| - string = TO_STRING(string);
|
| - var previousLastIndex = this.lastIndex;
|
| - this.lastIndex = 0;
|
| - var result = RegExpSubclassExec(this, string);
|
| - this.lastIndex = previousLastIndex;
|
| - if (IS_NULL(result)) return -1;
|
| - return result.index;
|
| -}
|
| -%FunctionRemovePrototype(RegExpSubclassSearch);
|
| -
|
| -
|
| // -------------------------------------------------------------------
|
|
|
| utils.InstallFunctions(GlobalRegExp.prototype, DONT_ENUM, [
|
| - "exec", RegExpSubclassExecJS,
|
| - "test", RegExpSubclassTest,
|
| - matchSymbol, RegExpSubclassMatch,
|
| replaceSymbol, RegExpSubclassReplace,
|
| - searchSymbol, RegExpSubclassSearch,
|
| splitSymbol, RegExpSubclassSplit,
|
| ]);
|
|
|
| // Temporary until all RegExpLastMatchInfo accesses are ported to C++.
|
| SET_PRIVATE(GlobalRegExp, lastMatchInfoSymbol, RegExpLastMatchInfo);
|
|
|
| +var RegExpSubclassExecJS = GlobalRegExp.prototype.exec;
|
| +
|
| // -------------------------------------------------------------------
|
| // Internal
|
|
|
|
|