OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 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 (function(global, utils) { | |
6 "use strict"; | |
7 | |
8 %CheckIsBootstrapping(); | |
9 | |
10 var GlobalString = global.String; | |
11 var OverrideFunction = utils.OverrideFunction; | |
12 var MakeTypeError; | |
13 var LocaleConvertCase = utils.ImportNow("LocaleConvertCase"); | |
Dan Ehrenberg
2016/05/04 00:13:08
Rather than using ImportNow (generally dispreferre
jungshik at Google
2016/05/04 19:02:58
Done.
| |
14 | |
15 utils.Import(function(from) { | |
16 MakeTypeError = from.MakeTypeError; | |
17 }); | |
18 | |
19 OverrideFunction(GlobalString.prototype, 'toLowerCase', function() { | |
jungshik at Google
2016/05/04 19:02:58
offline, you're worried about actually defining fu
Dan Ehrenberg
2016/05/04 19:06:37
That's what I was suggesting, though if you found
| |
20 if (!IS_UNDEFINED(new.target)) { | |
21 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); | |
22 } | |
23 CHECK_OBJECT_COERCIBLE(this, "String.prototype.toLowerCase"); | |
24 var s = TO_STRING(this); | |
25 return %StringToLowerCaseI18N(s); | |
26 } | |
27 ); | |
28 | |
29 OverrideFunction(GlobalString.prototype, 'toUpperCase', function() { | |
30 if (!IS_UNDEFINED(new.target)) { | |
31 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); | |
32 } | |
33 CHECK_OBJECT_COERCIBLE(this, "String.prototype.toLowerCase"); | |
34 var s = TO_STRING(this); | |
35 return %StringToUpperCaseI18N(s); | |
36 } | |
37 ); | |
38 | |
39 OverrideFunction(GlobalString.prototype, 'toLocaleLowerCase', function() { | |
40 if (!IS_UNDEFINED(new.target)) { | |
41 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); | |
42 } | |
43 CHECK_OBJECT_COERCIBLE(this, "String.prototype.toLocaleLowerCase"); | |
44 return LocaleConvertCase(TO_STRING(this), arguments[0], false); | |
45 } | |
46 ); | |
47 | |
48 OverrideFunction(GlobalString.prototype, 'toLocaleUpperCase', function() { | |
49 if (!IS_UNDEFINED(new.target)) { | |
50 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); | |
51 } | |
52 CHECK_OBJECT_COERCIBLE(this, "String.prototype.toLocaleUpperCase"); | |
53 return LocaleConvertCase(TO_STRING(this), arguments[0], true); | |
54 } | |
55 ); | |
56 | |
57 }) | |
OLD | NEW |