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

Unified Diff: src/js/harmony-regexp.js

Issue 1419823010: Implement flag and source getters on RegExp.prototype. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@rproto
Patch Set: new webkit expectations 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
« src/bootstrapper.cc ('K') | « src/heap/heap.h ('k') | src/js/macros.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/js/harmony-regexp.js
diff --git a/src/js/harmony-regexp.js b/src/js/harmony-regexp.js
index 033ee2c9a513abecf05a9dbc4b67571fb3a3d516..54a96bc972c762aa2042891d6a469d63ffeb22fc 100644
--- a/src/js/harmony-regexp.js
+++ b/src/js/harmony-regexp.js
@@ -13,6 +13,7 @@
var GlobalRegExp = global.RegExp;
var MakeTypeError;
+var regExpFlagsSymbol = utils.ImportNow("regexp_flags_symbol");
utils.Import(function(from) {
MakeTypeError = from.MakeTypeError;
@@ -24,7 +25,8 @@ utils.Import(function(from) {
// + https://bugs.ecmascript.org/show_bug.cgi?id=3423
function RegExpGetFlags() {
if (!IS_SPEC_OBJECT(this)) {
- throw MakeTypeError(kFlagsGetterNonObject, TO_STRING(this));
+ throw MakeTypeError(
+ kRegExpNonObject, "RegExp.prototype.flags", TO_STRING(this));
}
var result = '';
if (this.global) result += 'g';
@@ -34,9 +36,37 @@ function RegExpGetFlags() {
if (this.sticky) result += 'y';
return result;
}
-
-%DefineAccessorPropertyUnchecked(GlobalRegExp.prototype, 'flags',
- RegExpGetFlags, null, DONT_ENUM);
+%FunctionSetName(RegExpGetFlags, "RegExp.prototype.flags");
%SetNativeFlag(RegExpGetFlags);
+
+// ES6 21.2.5.12.
+function RegExpGetSticky() {
+ if (!IS_REGEXP(this)) {
+ throw MakeTypeError(kRegExpNonRegExp, "RegExp.prototype.sticky");
+ }
+ return !!REGEXP_STICKY(this);
+}
+%FunctionSetName(RegExpGetSticky, "RegExp.prototype.sticky");
+%SetNativeFlag(RegExpGetSticky);
+
+
+// ES6 21.2.5.15.
+function RegExpGetUnicode() {
+ if (!IS_REGEXP(this)) {
+ throw MakeTypeError(kRegExpNonRegExp, "RegExp.prototype.unicode");
+ }
+ return !!REGEXP_UNICODE(this);
+}
+%FunctionSetName(RegExpGetUnicode, "RegExp.prototype.unicode");
+%SetNativeFlag(RegExpGetUnicode);
+
+%DefineGetterPropertyUnchecked(GlobalRegExp.prototype, 'flags',
+ RegExpGetFlags, DONT_ENUM);
+
+%DefineGetterPropertyUnchecked(GlobalRegExp.prototype, "sticky",
+ RegExpGetSticky, DONT_ENUM);
+
+%DefineGetterPropertyUnchecked(GlobalRegExp.prototype, "unicode",
+ RegExpGetUnicode, DONT_ENUM);
})
« src/bootstrapper.cc ('K') | « src/heap/heap.h ('k') | src/js/macros.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698