harmony-regexp.js 1.08 KB
Newer Older
1 2 3 4
// 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.

5
(function(global, utils) {
6

7 8
'use strict';

9 10
%CheckIsBootstrapping();

11 12 13
// -------------------------------------------------------------------
// Imports

14
var GlobalRegExp = global.RegExp;
15 16 17 18 19
var ToString;

utils.Import(function(from) {
  ToString = from.ToString;
});
20 21 22 23 24 25 26

// -------------------------------------------------------------------

// ES6 draft 12-06-13, section 21.2.5.3
// + https://bugs.ecmascript.org/show_bug.cgi?id=3423
function RegExpGetFlags() {
  if (!IS_SPEC_OBJECT(this)) {
27
    throw MakeTypeError(kFlagsGetterNonObject, ToString(this));
28 29 30 31 32 33 34 35 36 37
  }
  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;
}

38 39 40
%DefineAccessorPropertyUnchecked(GlobalRegExp.prototype, 'flags',
                                 RegExpGetFlags, null, DONT_ENUM);
%SetNativeFlag(RegExpGetFlags);
41

42
})