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

Side by Side 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: 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
Dmitry Lomov (no reviews) 2014/12/10 16:06:29 style nit: 'use strict'
5 var $RegExp = global.RegExp;
6
7 // -------------------------------------------------------------------
8
9 // ES6 draft 12-06-13, section 21.2.5.3
10 // + https://bugs.ecmascript.org/show_bug.cgi?id=3423
11 var RegExpGetFlags = function() {
Dmitry Lomov (no reviews) 2014/12/10 16:06:29 style nit: just use function RegExpGetFlags here.
12 if (!IS_SPEC_OBJECT(this)) {
13 throw MakeTypeError('flags_getter_non_object',
14 [%ToString(this)]);
15 }
16 var result = '';
17 if (this.global) result += 'g';
18 if (this.ignoreCase) result += 'i';
19 if (this.multiline) result += 'm';
20 if (this.unicode) result += 'u';
21 if (this.sticky) result += 'y';
22 return result;
23 };
24
25 function ExtendRegExpPrototype() {
26 %CheckIsBootstrapping();
27
28 %DefineAccessorPropertyUnchecked($RegExp.prototype, 'flags', RegExpGetFlags,
29 null, DONT_ENUM | DONT_DELETE);
30 %SetNativeFlag(RegExpGetFlags);
31 }
32
33 ExtendRegExpPrototype();
OLDNEW
« no previous file with comments | « src/bootstrapper.cc ('k') | src/messages.js » ('j') | test/mjsunit/harmony/regexp-flags.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698