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 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
775 var n = %_ArgumentsLength(); | 775 var n = %_ArgumentsLength(); |
776 if (n == 1) { | 776 if (n == 1) { |
777 if (!%_IsSmi(code)) code = TO_NUMBER(code); | 777 if (!%_IsSmi(code)) code = TO_NUMBER(code); |
778 return %_StringCharFromCode(code & 0xffff); | 778 return %_StringCharFromCode(code & 0xffff); |
779 } | 779 } |
780 | 780 |
781 var one_byte = %NewString(n, NEW_ONE_BYTE_STRING); | 781 var one_byte = %NewString(n, NEW_ONE_BYTE_STRING); |
782 var i; | 782 var i; |
783 for (i = 0; i < n; i++) { | 783 for (i = 0; i < n; i++) { |
784 var code = %_Arguments(i); | 784 var code = %_Arguments(i); |
785 if (!%_IsSmi(code)) code = TO_NUMBER(code) & 0xffff; | 785 if (!%_IsSmi(code)) code = TO_NUMBER(code); |
Benedikt Meurer
2015/11/09 07:50:12
As discussed offline: Please do not do this %_IsSm
| |
786 if (code < 0) code = code & 0xffff; | 786 code = code & 0xffff; |
787 if (code > 0xff) break; | 787 if (code > 0xff) break; |
788 %_OneByteSeqStringSetChar(i, code, one_byte); | 788 %_OneByteSeqStringSetChar(i, code, one_byte); |
789 } | 789 } |
790 if (i == n) return one_byte; | 790 if (i == n) return one_byte; |
791 one_byte = %TruncateString(one_byte, i); | 791 one_byte = %TruncateString(one_byte, i); |
792 | 792 |
793 var two_byte = %NewString(n - i, NEW_TWO_BYTE_STRING); | 793 var two_byte = %NewString(n - i, NEW_TWO_BYTE_STRING); |
794 for (var j = 0; i < n; i++, j++) { | 794 for (var j = 0; i < n; i++, j++) { |
795 var code = %_Arguments(i); | 795 var code = %_Arguments(i); |
796 if (!%_IsSmi(code)) code = TO_NUMBER(code) & 0xffff; | 796 if (!%_IsSmi(code)) code = TO_NUMBER(code) & 0xffff; |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1169 to.StringLastIndexOf = StringLastIndexOfJS; | 1169 to.StringLastIndexOf = StringLastIndexOfJS; |
1170 to.StringMatch = StringMatchJS; | 1170 to.StringMatch = StringMatchJS; |
1171 to.StringReplace = StringReplace; | 1171 to.StringReplace = StringReplace; |
1172 to.StringSlice = StringSlice; | 1172 to.StringSlice = StringSlice; |
1173 to.StringSplit = StringSplitJS; | 1173 to.StringSplit = StringSplitJS; |
1174 to.StringSubstr = StringSubstr; | 1174 to.StringSubstr = StringSubstr; |
1175 to.StringSubstring = StringSubstring; | 1175 to.StringSubstring = StringSubstring; |
1176 }); | 1176 }); |
1177 | 1177 |
1178 }) | 1178 }) |
OLD | NEW |