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

Unified Diff: src/js/regexp.js

Issue 2394713003: [regexp] Port test, match, and search (Closed)
Patch Set: Rebaseline bytecode expectations Created 4 years, 2 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 | « src/heap-symbols.h ('k') | src/objects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/js/regexp.js
diff --git a/src/js/regexp.js b/src/js/regexp.js
index b5574877ec3a19f16dd1fdbd5efbe9762e05b99f..915a44f0b54daec86f4f005660aa9383c988e34d 100644
--- a/src/js/regexp.js
+++ b/src/js/regexp.js
@@ -103,7 +103,6 @@ macro RETURN_NEW_RESULT_FROM_MATCH_INFO(MATCHINFO, STRING)
endmacro
-
// ES#sec-regexpexec Runtime Semantics: RegExpExec ( R, S )
// Also takes an optional exec method in case our caller
// has already fetched exec.
@@ -123,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);
@@ -289,39 +275,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.
@@ -716,32 +669,11 @@ 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;
- if (previousLastIndex != 0) this.lastIndex = 0;
- var result = RegExpSubclassExec(this, string);
- var currentLastIndex = this.lastIndex;
- if (currentLastIndex != previousLastIndex) this.lastIndex = previousLastIndex;
- if (IS_NULL(result)) return -1;
- return result.index;
-}
-%FunctionRemovePrototype(RegExpSubclassSearch);
-
// -------------------------------------------------------------------
utils.InstallFunctions(GlobalRegExp.prototype, DONT_ENUM, [
- "test", RegExpSubclassTest,
- matchSymbol, RegExpSubclassMatch,
replaceSymbol, RegExpSubclassReplace,
- searchSymbol, RegExpSubclassSearch,
splitSymbol, RegExpSubclassSplit,
]);
« no previous file with comments | « src/heap-symbols.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698