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

Unified Diff: src/harmony-regexp.js

Issue 770333005: Implement the `RegExp.prototype.flags` getter (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Move to separate harmony-regexp.js file Created 6 years 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
Index: src/harmony-regexp.js
diff --git a/src/harmony-regexp.js b/src/harmony-regexp.js
new file mode 100644
index 0000000000000000000000000000000000000000..6c2822b5b6b46877e9ea0bd6214d7f3e47fa137f
--- /dev/null
+++ b/src/harmony-regexp.js
@@ -0,0 +1,35 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var $RegExp = global.RegExp;
+
+// -------------------------------------------------------------------
+
+function ExtendRegExpPrototype() {
+ var NoOpSetter = function(ignored) {};
+
+
+ // ES6 draft 12-06-13, section 21.2.5.3
+ // + https://bugs.ecmascript.org/show_bug.cgi?id=3423
+ var RegExpGetFlags = function() {
arv (Not doing code reviews) 2014/12/10 02:54:50 Move this out of ExtendRegExpPrototype.
+ if (!IS_SPEC_OBJECT(this)) {
+ throw MakeTypeError('home_object_non_object',
Dmitry Lomov (no reviews) 2014/12/09 23:39:13 Wrong error message.
+ 'RegExp.prototype.flags',
+ [%ToString(this)]);
+ }
+ var result = '';
+ if (this.global) result += 'g';
+ if (this.ignoreCase) result += 'i';
+ if (this.multiline) result += 'm';
+ if (this.unicode) result += 'u';
+ if (this.sticky) result += 'y';
+ return result;
+ };
+
+ %DefineAccessorPropertyUnchecked($RegExp.prototype, 'flags', RegExpGetFlags,
Dmitry Lomov (no reviews) 2014/12/09 23:39:13 You should pass 'undefined' here instead of NoOpSe
+ NoOpSetter, DONT_DELETE);
+ %SetNativeFlag(RegExpGetFlags);
+}
+
+ExtendRegExpPrototype();

Powered by Google App Engine
This is Rietveld 408576698