blob: a1b32ab2385fff00609428934e6ee21ac140f75b [file] [log] [blame]
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001// 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
5'use strict';
6
7var $RegExp = global.RegExp;
8
9// -------------------------------------------------------------------
10
11// ES6 draft 12-06-13, section 21.2.5.3
12// + https://bugs.ecmascript.org/show_bug.cgi?id=3423
13function RegExpGetFlags() {
14 if (!IS_SPEC_OBJECT(this)) {
15 throw MakeTypeError('flags_getter_non_object',
16 [%ToString(this)]);
17 }
18 var result = '';
19 if (this.global) result += 'g';
20 if (this.ignoreCase) result += 'i';
21 if (this.multiline) result += 'm';
22 if (this.unicode) result += 'u';
23 if (this.sticky) result += 'y';
24 return result;
25}
26
27function ExtendRegExpPrototype() {
28 %CheckIsBootstrapping();
29
30 %DefineAccessorPropertyUnchecked($RegExp.prototype, 'flags', RegExpGetFlags,
31 null, DONT_ENUM);
32 %SetNativeFlag(RegExpGetFlags);
33}
34
35ExtendRegExpPrototype();