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

Side by Side Diff: src/js/harmony-regexp.js

Issue 1546493003: Revert of Add web compat workarounds for ES2015 RegExp semantics (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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
« no previous file with comments | « include/v8.h ('k') | src/js/regexp.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 (function(global, utils) { 5 (function(global, utils) {
6 6
7 'use strict'; 7 'use strict';
8 8
9 %CheckIsBootstrapping(); 9 %CheckIsBootstrapping();
10 10
11 // ------------------------------------------------------------------- 11 // -------------------------------------------------------------------
12 // Imports 12 // Imports
13 13
14 var GlobalRegExp = global.RegExp; 14 var GlobalRegExp = global.RegExp;
15 var GlobalRegExpPrototype = GlobalRegExp.prototype;
16 var MakeTypeError; 15 var MakeTypeError;
17 var regExpFlagsSymbol = utils.ImportNow("regexp_flags_symbol"); 16 var regExpFlagsSymbol = utils.ImportNow("regexp_flags_symbol");
18 17
19 utils.Import(function(from) { 18 utils.Import(function(from) {
20 MakeTypeError = from.MakeTypeError; 19 MakeTypeError = from.MakeTypeError;
21 }); 20 });
22 21
23 // ------------------------------------------------------------------- 22 // -------------------------------------------------------------------
24 23
25 // ES6 draft 12-06-13, section 21.2.5.3 24 // ES6 draft 12-06-13, section 21.2.5.3
26 // + https://bugs.ecmascript.org/show_bug.cgi?id=3423 25 // + https://bugs.ecmascript.org/show_bug.cgi?id=3423
27 function RegExpGetFlags() { 26 function RegExpGetFlags() {
28 if (!IS_RECEIVER(this)) { 27 if (!IS_RECEIVER(this)) {
29 throw MakeTypeError( 28 throw MakeTypeError(
30 kRegExpNonObject, "RegExp.prototype.flags", TO_STRING(this)); 29 kRegExpNonObject, "RegExp.prototype.flags", TO_STRING(this));
31 } 30 }
32 var result = ''; 31 var result = '';
33 if (this.global) result += 'g'; 32 if (this.global) result += 'g';
34 if (this.ignoreCase) result += 'i'; 33 if (this.ignoreCase) result += 'i';
35 if (this.multiline) result += 'm'; 34 if (this.multiline) result += 'm';
36 if (this.unicode) result += 'u'; 35 if (this.unicode) result += 'u';
37 if (this.sticky) result += 'y'; 36 if (this.sticky) result += 'y';
38 return result; 37 return result;
39 } 38 }
40 39
41 const kRegExpPrototypeStickyGetter = 11;
42 40
43 // ES6 21.2.5.12. 41 // ES6 21.2.5.12.
44 function RegExpGetSticky() { 42 function RegExpGetSticky() {
45 if (!IS_REGEXP(this)) { 43 if (!IS_REGEXP(this)) {
46 // Compat fix: RegExp.prototype.sticky == undefined; UseCounter tracks it
47 // TODO(littledan): Remove this workaround or standardize it
48 if (this === GlobalRegExpPrototype) {
49 %IncrementUseCounter(kRegExpPrototypeStickyGetter);
50 return UNDEFINED;
51 }
52 throw MakeTypeError(kRegExpNonRegExp, "RegExp.prototype.sticky"); 44 throw MakeTypeError(kRegExpNonRegExp, "RegExp.prototype.sticky");
53 } 45 }
54 return !!REGEXP_STICKY(this); 46 return !!REGEXP_STICKY(this);
55 } 47 }
56 %FunctionSetName(RegExpGetSticky, "RegExp.prototype.sticky"); 48 %FunctionSetName(RegExpGetSticky, "RegExp.prototype.sticky");
57 %SetNativeFlag(RegExpGetSticky); 49 %SetNativeFlag(RegExpGetSticky);
58 50
59 51
60 // ES6 21.2.5.15. 52 // ES6 21.2.5.15.
61 function RegExpGetUnicode() { 53 function RegExpGetUnicode() {
62 if (!IS_REGEXP(this)) { 54 if (!IS_REGEXP(this)) {
63 throw MakeTypeError(kRegExpNonRegExp, "RegExp.prototype.unicode"); 55 throw MakeTypeError(kRegExpNonRegExp, "RegExp.prototype.unicode");
64 } 56 }
65 return !!REGEXP_UNICODE(this); 57 return !!REGEXP_UNICODE(this);
66 } 58 }
67 %FunctionSetName(RegExpGetUnicode, "RegExp.prototype.unicode"); 59 %FunctionSetName(RegExpGetUnicode, "RegExp.prototype.unicode");
68 %SetNativeFlag(RegExpGetUnicode); 60 %SetNativeFlag(RegExpGetUnicode);
69 61
70 utils.InstallGetter(GlobalRegExp.prototype, 'flags', RegExpGetFlags); 62 utils.InstallGetter(GlobalRegExp.prototype, 'flags', RegExpGetFlags);
71 utils.InstallGetter(GlobalRegExp.prototype, 'sticky', RegExpGetSticky); 63 utils.InstallGetter(GlobalRegExp.prototype, 'sticky', RegExpGetSticky);
72 utils.InstallGetter(GlobalRegExp.prototype, 'unicode', RegExpGetUnicode); 64 utils.InstallGetter(GlobalRegExp.prototype, 'unicode', RegExpGetUnicode);
73 65
74 }) 66 })
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/js/regexp.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698