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

Unified Diff: src/js/regexp.js

Issue 1434523002: [es6] Implement @@match subclassing. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase Created 5 years, 1 month 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 | src/js/string.js » ('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 021e60b8b395e008926d5851b45d4e07769bfa60..889c6b0acfad5231e6f0e66f967acffaf7a56f81 100644
--- a/src/js/regexp.js
+++ b/src/js/regexp.js
@@ -15,8 +15,8 @@ var GlobalRegExp = global.RegExp;
var InternalArray = utils.InternalArray;
var InternalPackedArray = utils.InternalPackedArray;
var MakeTypeError;
+var matchSymbol = utils.ImportNow("match_symbol");
var splitSymbol = utils.ImportNow("split_symbol");
-var matchSymbol = utils.ImportNow("match_symbol");;
utils.ImportFromExperimental(function(from) {
FLAG_harmony_tolength = from.FLAG_harmony_tolength;
@@ -355,6 +355,21 @@ function RegExpSplit(string, limit) {
}
+// ES6 21.2.5.6.
+function RegExpMatch(string) {
+ if (!IS_REGEXP(this)) {
+ throw MakeTypeError(kIncompatibleMethodReceiver,
+ "RegExp.prototype.@@match", this);
+ }
+ var subject = TO_STRING(string);
+
+ if (!REGEXP_GLOBAL(this)) return RegExpExecNoTests(this, subject, 0);
+ this.lastIndex = 0;
+ var result = %StringMatch(subject, this, RegExpLastMatchInfo);
+ return result;
+}
+
+
// Getters for the static properties lastMatch, lastParen, leftContext, and
// rightContext of the RegExp constructor. The properties are computed based
// on the captures array of the last successful match and the subject string
@@ -472,6 +487,7 @@ utils.InstallFunctions(GlobalRegExp.prototype, DONT_ENUM, [
"test", RegExpTest,
"toString", RegExpToString,
"compile", RegExpCompileJS,
+ matchSymbol, RegExpMatch,
splitSymbol, RegExpSplit,
]);
« no previous file with comments | « no previous file | src/js/string.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698