| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 %CheckIsBootstrapping(); | 7 %CheckIsBootstrapping(); |
| 8 | 8 |
| 9 // ------------------------------------------------------------------- | 9 // ------------------------------------------------------------------- |
| 10 // Imports | 10 // Imports |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 return %StringTrim(TO_STRING(this), true, false); | 551 return %StringTrim(TO_STRING(this), true, false); |
| 552 } | 552 } |
| 553 | 553 |
| 554 function StringTrimRight() { | 554 function StringTrimRight() { |
| 555 CHECK_OBJECT_COERCIBLE(this, "String.prototype.trimRight"); | 555 CHECK_OBJECT_COERCIBLE(this, "String.prototype.trimRight"); |
| 556 | 556 |
| 557 return %StringTrim(TO_STRING(this), false, true); | 557 return %StringTrim(TO_STRING(this), false, true); |
| 558 } | 558 } |
| 559 | 559 |
| 560 | 560 |
| 561 // ECMA-262, section 15.5.3.2 | |
| 562 function StringFromCharCode(_) { // length == 1 | |
| 563 "use strict"; | |
| 564 var s = ""; | |
| 565 var n = arguments.length; | |
| 566 for (var i = 0; i < n; ++i) { | |
| 567 s += %_StringCharFromCode(arguments[i] & 0xffff); | |
| 568 } | |
| 569 return s; | |
| 570 } | |
| 571 | |
| 572 | |
| 573 // ES6 draft, revision 26 (2014-07-18), section B.2.3.2.1 | 561 // ES6 draft, revision 26 (2014-07-18), section B.2.3.2.1 |
| 574 function HtmlEscape(str) { | 562 function HtmlEscape(str) { |
| 575 return %_Call(StringReplace, TO_STRING(str), /"/g, """); | 563 return %_Call(StringReplace, TO_STRING(str), /"/g, """); |
| 576 } | 564 } |
| 577 | 565 |
| 578 | 566 |
| 579 // ES6 draft, revision 26 (2014-07-18), section B.2.3.2 | 567 // ES6 draft, revision 26 (2014-07-18), section B.2.3.2 |
| 580 function StringAnchor(name) { | 568 function StringAnchor(name) { |
| 581 CHECK_OBJECT_COERCIBLE(this, "String.prototype.anchor"); | 569 CHECK_OBJECT_COERCIBLE(this, "String.prototype.anchor"); |
| 582 return "<a name=\"" + HtmlEscape(name) + "\">" + TO_STRING(this) + | 570 return "<a name=\"" + HtmlEscape(name) + "\">" + TO_STRING(this) + |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 853 | 841 |
| 854 // Set the String function and constructor. | 842 // Set the String function and constructor. |
| 855 %FunctionSetPrototype(GlobalString, new GlobalString()); | 843 %FunctionSetPrototype(GlobalString, new GlobalString()); |
| 856 | 844 |
| 857 // Set up the constructor property on the String prototype object. | 845 // Set up the constructor property on the String prototype object. |
| 858 %AddNamedProperty( | 846 %AddNamedProperty( |
| 859 GlobalString.prototype, "constructor", GlobalString, DONT_ENUM); | 847 GlobalString.prototype, "constructor", GlobalString, DONT_ENUM); |
| 860 | 848 |
| 861 // Set up the non-enumerable functions on the String object. | 849 // Set up the non-enumerable functions on the String object. |
| 862 utils.InstallFunctions(GlobalString, DONT_ENUM, [ | 850 utils.InstallFunctions(GlobalString, DONT_ENUM, [ |
| 863 "fromCharCode", StringFromCharCode, | |
| 864 "fromCodePoint", StringFromCodePoint, | 851 "fromCodePoint", StringFromCodePoint, |
| 865 "raw", StringRaw | 852 "raw", StringRaw |
| 866 ]); | 853 ]); |
| 867 | 854 |
| 868 // Set up the non-enumerable functions on the String prototype object. | 855 // Set up the non-enumerable functions on the String prototype object. |
| 869 utils.InstallFunctions(GlobalString.prototype, DONT_ENUM, [ | 856 utils.InstallFunctions(GlobalString.prototype, DONT_ENUM, [ |
| 870 "valueOf", StringValueOf, | 857 "valueOf", StringValueOf, |
| 871 "toString", StringToString, | 858 "toString", StringToString, |
| 872 "charAt", StringCharAtJS, | 859 "charAt", StringCharAtJS, |
| 873 "charCodeAt", StringCharCodeAtJS, | 860 "charCodeAt", StringCharCodeAtJS, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 921 to.StringLastIndexOf = StringLastIndexOf; | 908 to.StringLastIndexOf = StringLastIndexOf; |
| 922 to.StringMatch = StringMatchJS; | 909 to.StringMatch = StringMatchJS; |
| 923 to.StringReplace = StringReplace; | 910 to.StringReplace = StringReplace; |
| 924 to.StringSlice = StringSlice; | 911 to.StringSlice = StringSlice; |
| 925 to.StringSplit = StringSplitJS; | 912 to.StringSplit = StringSplitJS; |
| 926 to.StringSubstr = StringSubstr; | 913 to.StringSubstr = StringSubstr; |
| 927 to.StringSubstring = StringSubstring; | 914 to.StringSubstring = StringSubstring; |
| 928 }); | 915 }); |
| 929 | 916 |
| 930 }) | 917 }) |
| OLD | NEW |