| 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 // This file relies on the fact that the following declaration has been made | 5 // This file relies on the fact that the following declaration has been made |
| 6 // in runtime.js: | 6 // in runtime.js: |
| 7 // var $String = global.String; | 7 // var $String = global.String; |
| 8 | 8 |
| 9 // ------------------------------------------------------------------- | 9 // ------------------------------------------------------------------- |
| 10 | 10 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 | 54 |
| 55 var result = %_StringCharCodeAt(this, pos); | 55 var result = %_StringCharCodeAt(this, pos); |
| 56 if (!%_IsSmi(result)) { | 56 if (!%_IsSmi(result)) { |
| 57 result = %_StringCharCodeAt(TO_STRING_INLINE(this), TO_INTEGER(pos)); | 57 result = %_StringCharCodeAt(TO_STRING_INLINE(this), TO_INTEGER(pos)); |
| 58 } | 58 } |
| 59 return result; | 59 return result; |
| 60 } | 60 } |
| 61 | 61 |
| 62 | 62 |
| 63 // ECMA-262, section 15.5.4.6 | 63 // ECMA-262, section 15.5.4.6 |
| 64 function StringConcat() { | 64 function StringConcat(other /* and more */) { // length == 1 |
| 65 CHECK_OBJECT_COERCIBLE(this, "String.prototype.concat"); | 65 CHECK_OBJECT_COERCIBLE(this, "String.prototype.concat"); |
| 66 | 66 |
| 67 var len = %_ArgumentsLength(); | 67 var len = %_ArgumentsLength(); |
| 68 var this_as_string = TO_STRING_INLINE(this); | 68 var this_as_string = TO_STRING_INLINE(this); |
| 69 if (len === 1) { | 69 if (len === 1) { |
| 70 return this_as_string + %_Arguments(0); | 70 return this_as_string + other; |
| 71 } | 71 } |
| 72 var parts = new InternalArray(len + 1); | 72 var parts = new InternalArray(len + 1); |
| 73 parts[0] = this_as_string; | 73 parts[0] = this_as_string; |
| 74 for (var i = 0; i < len; i++) { | 74 for (var i = 0; i < len; i++) { |
| 75 var part = %_Arguments(i); | 75 var part = %_Arguments(i); |
| 76 parts[i + 1] = TO_STRING_INLINE(part); | 76 parts[i + 1] = TO_STRING_INLINE(part); |
| 77 } | 77 } |
| 78 return %StringBuilderConcat(parts, len + 1, ""); | 78 return %StringBuilderConcat(parts, len + 1, ""); |
| 79 } | 79 } |
| 80 | 80 |
| 81 // Match ES3 and Safari | |
| 82 %FunctionSetLength(StringConcat, 1); | |
| 83 | |
| 84 | 81 |
| 85 // ECMA-262 section 15.5.4.7 | 82 // ECMA-262 section 15.5.4.7 |
| 86 function StringIndexOfJS(pattern /* position */) { // length == 1 | 83 function StringIndexOfJS(pattern /* position */) { // length == 1 |
| 87 CHECK_OBJECT_COERCIBLE(this, "String.prototype.indexOf"); | 84 CHECK_OBJECT_COERCIBLE(this, "String.prototype.indexOf"); |
| 88 | 85 |
| 89 var subject = TO_STRING_INLINE(this); | 86 var subject = TO_STRING_INLINE(this); |
| 90 pattern = TO_STRING_INLINE(pattern); | 87 pattern = TO_STRING_INLINE(pattern); |
| 91 var index = 0; | 88 var index = 0; |
| 92 if (%_ArgumentsLength() > 1) { | 89 if (%_ArgumentsLength() > 1) { |
| 93 index = %_Arguments(1); // position | 90 index = %_Arguments(1); // position |
| (...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 957 "fixed", StringFixed, | 954 "fixed", StringFixed, |
| 958 "italics", StringItalics, | 955 "italics", StringItalics, |
| 959 "small", StringSmall, | 956 "small", StringSmall, |
| 960 "strike", StringStrike, | 957 "strike", StringStrike, |
| 961 "sub", StringSub, | 958 "sub", StringSub, |
| 962 "sup", StringSup | 959 "sup", StringSup |
| 963 )); | 960 )); |
| 964 } | 961 } |
| 965 | 962 |
| 966 SetUpString(); | 963 SetUpString(); |
| OLD | NEW |