| OLD | NEW |
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 return fast_answer; | 80 return fast_answer; |
| 81 } | 81 } |
| 82 var subject = ToString(this); | 82 var subject = ToString(this); |
| 83 var index = TO_INTEGER(pos); | 83 var index = TO_INTEGER(pos); |
| 84 return %StringCharCodeAt(subject, index); | 84 return %StringCharCodeAt(subject, index); |
| 85 } | 85 } |
| 86 | 86 |
| 87 | 87 |
| 88 // ECMA-262, section 15.5.4.6 | 88 // ECMA-262, section 15.5.4.6 |
| 89 function StringConcat() { | 89 function StringConcat() { |
| 90 var len = %_ArgumentsLength(); | 90 var len = %_ArgumentsLength() + 1; |
| 91 var parts = new $Array(len + 1); | 91 var parts = new $Array(len); |
| 92 parts[0] = ToString(this); | 92 parts[0] = IS_STRING(this) ? this : ToString(this); |
| 93 for (var i = 0; i < len; i++) | 93 for (var i = 1; i < len; i++) { |
| 94 parts[i + 1] = ToString(%_Arguments(i)); | 94 var part = %_Arguments(i - 1); |
| 95 return parts.join(''); | 95 parts[i] = IS_STRING(part) ? part : ToString(part); |
| 96 } |
| 97 return %StringBuilderConcat(parts, len, ""); |
| 96 } | 98 } |
| 97 | 99 |
| 98 // Match ES3 and Safari | 100 // Match ES3 and Safari |
| 99 %FunctionSetLength(StringConcat, 1); | 101 %FunctionSetLength(StringConcat, 1); |
| 100 | 102 |
| 101 | 103 |
| 102 // ECMA-262 section 15.5.4.7 | 104 // ECMA-262 section 15.5.4.7 |
| 103 function StringIndexOf(searchString /* position */) { // length == 1 | 105 function StringIndexOf(searchString /* position */) { // length == 1 |
| 104 var subject_str = ToString(this); | 106 var subject_str = ToString(this); |
| 105 var pattern_str = ToString(searchString); | 107 var pattern_str = ToString(searchString); |
| (...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 889 "small", StringSmall, | 891 "small", StringSmall, |
| 890 "strike", StringStrike, | 892 "strike", StringStrike, |
| 891 "sub", StringSub, | 893 "sub", StringSub, |
| 892 "sup", StringSup, | 894 "sup", StringSup, |
| 893 "toJSON", StringToJSON | 895 "toJSON", StringToJSON |
| 894 )); | 896 )); |
| 895 } | 897 } |
| 896 | 898 |
| 897 | 899 |
| 898 SetupString(); | 900 SetupString(); |
| OLD | NEW |