| 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 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 return %StringTrim(TO_STRING(this), true, false); | 533 return %StringTrim(TO_STRING(this), true, false); |
| 534 } | 534 } |
| 535 | 535 |
| 536 function StringTrimRight() { | 536 function StringTrimRight() { |
| 537 CHECK_OBJECT_COERCIBLE(this, "String.prototype.trimRight"); | 537 CHECK_OBJECT_COERCIBLE(this, "String.prototype.trimRight"); |
| 538 | 538 |
| 539 return %StringTrim(TO_STRING(this), false, true); | 539 return %StringTrim(TO_STRING(this), false, true); |
| 540 } | 540 } |
| 541 | 541 |
| 542 | 542 |
| 543 // ECMA-262, section 15.5.3.2 | |
| 544 function StringFromCharCode(_) { // length == 1 | |
| 545 "use strict"; | |
| 546 var s = ""; | |
| 547 var n = arguments.length; | |
| 548 for (var i = 0; i < n; ++i) { | |
| 549 s += %_StringCharFromCode(arguments[i] & 0xffff); | |
| 550 } | |
| 551 return s; | |
| 552 } | |
| 553 | |
| 554 | |
| 555 // ES6 draft, revision 26 (2014-07-18), section B.2.3.2.1 | 543 // ES6 draft, revision 26 (2014-07-18), section B.2.3.2.1 |
| 556 function HtmlEscape(str) { | 544 function HtmlEscape(str) { |
| 557 return %_Call(StringReplace, TO_STRING(str), /"/g, """); | 545 return %_Call(StringReplace, TO_STRING(str), /"/g, """); |
| 558 } | 546 } |
| 559 | 547 |
| 560 | 548 |
| 561 // ES6 draft, revision 26 (2014-07-18), section B.2.3.2 | 549 // ES6 draft, revision 26 (2014-07-18), section B.2.3.2 |
| 562 function StringAnchor(name) { | 550 function StringAnchor(name) { |
| 563 CHECK_OBJECT_COERCIBLE(this, "String.prototype.anchor"); | 551 CHECK_OBJECT_COERCIBLE(this, "String.prototype.anchor"); |
| 564 return "<a name=\"" + HtmlEscape(name) + "\">" + TO_STRING(this) + | 552 return "<a name=\"" + HtmlEscape(name) + "\">" + TO_STRING(this) + |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 result += TO_STRING(raw[i]); | 816 result += TO_STRING(raw[i]); |
| 829 } | 817 } |
| 830 | 818 |
| 831 return result; | 819 return result; |
| 832 } | 820 } |
| 833 | 821 |
| 834 // ------------------------------------------------------------------- | 822 // ------------------------------------------------------------------- |
| 835 | 823 |
| 836 // Set up the non-enumerable functions on the String object. | 824 // Set up the non-enumerable functions on the String object. |
| 837 utils.InstallFunctions(GlobalString, DONT_ENUM, [ | 825 utils.InstallFunctions(GlobalString, DONT_ENUM, [ |
| 838 "fromCharCode", StringFromCharCode, | |
| 839 "fromCodePoint", StringFromCodePoint, | 826 "fromCodePoint", StringFromCodePoint, |
| 840 "raw", StringRaw | 827 "raw", StringRaw |
| 841 ]); | 828 ]); |
| 842 | 829 |
| 843 // Set up the non-enumerable functions on the String prototype object. | 830 // Set up the non-enumerable functions on the String prototype object. |
| 844 utils.InstallFunctions(GlobalString.prototype, DONT_ENUM, [ | 831 utils.InstallFunctions(GlobalString.prototype, DONT_ENUM, [ |
| 845 "valueOf", StringValueOf, | 832 "valueOf", StringValueOf, |
| 846 "toString", StringToString, | 833 "toString", StringToString, |
| 847 "codePointAt", StringCodePointAt, | 834 "codePointAt", StringCodePointAt, |
| 848 "concat", StringConcat, | 835 "concat", StringConcat, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 893 to.StringLastIndexOf = StringLastIndexOf; | 880 to.StringLastIndexOf = StringLastIndexOf; |
| 894 to.StringMatch = StringMatchJS; | 881 to.StringMatch = StringMatchJS; |
| 895 to.StringReplace = StringReplace; | 882 to.StringReplace = StringReplace; |
| 896 to.StringSlice = StringSlice; | 883 to.StringSlice = StringSlice; |
| 897 to.StringSplit = StringSplitJS; | 884 to.StringSplit = StringSplitJS; |
| 898 to.StringSubstr = StringSubstr; | 885 to.StringSubstr = StringSubstr; |
| 899 to.StringSubstring = StringSubstring; | 886 to.StringSubstring = StringSubstring; |
| 900 }); | 887 }); |
| 901 | 888 |
| 902 }) | 889 }) |
| OLD | NEW |