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, extrasUtils) { | 5 (function(global, utils, extrasUtils) { |
6 | 6 |
7 "use strict"; | 7 "use strict"; |
8 | 8 |
9 %CheckIsBootstrapping(); | 9 %CheckIsBootstrapping(); |
10 | 10 |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 var e = array[i]; | 207 var e = array[i]; |
208 if (!IS_STRING(e)) e = convert(e); | 208 if (!IS_STRING(e)) e = convert(e); |
209 elements[elements_length++] = e; | 209 elements[elements_length++] = e; |
210 } | 210 } |
211 elements.length = elements_length; | 211 elements.length = elements_length; |
212 return %StringBuilderConcat(elements, elements_length, ''); | 212 return %StringBuilderConcat(elements, elements_length, ''); |
213 } | 213 } |
214 // Non-empty separator case. | 214 // Non-empty separator case. |
215 // If the first element is a number then use the heuristic that the | 215 // If the first element is a number then use the heuristic that the |
216 // remaining elements are also likely to be numbers. | 216 // remaining elements are also likely to be numbers. |
217 if (!IS_NUMBER(array[0])) { | 217 var e = array[0]; |
218 for (var i = 0; i < length; i++) { | 218 if (!IS_NUMBER(e)) { |
219 var e = array[i]; | 219 if (!IS_STRING(e)) e = convert(e); |
| 220 elements[0] = e; |
| 221 for (var i = 1; i < length; i++) { |
| 222 e = array[i]; |
220 if (!IS_STRING(e)) e = convert(e); | 223 if (!IS_STRING(e)) e = convert(e); |
221 elements[i] = e; | 224 elements[i] = e; |
222 } | 225 } |
223 } else { | 226 } else { |
224 for (var i = 0; i < length; i++) { | 227 elements[0] = %_NumberToString(e); |
225 var e = array[i]; | 228 for (var i = 1; i < length; i++) { |
| 229 e = array[i]; |
226 if (IS_NUMBER(e)) { | 230 if (IS_NUMBER(e)) { |
227 e = %_NumberToString(e); | 231 e = %_NumberToString(e); |
228 } else if (!IS_STRING(e)) { | 232 } else if (!IS_STRING(e)) { |
229 e = convert(e); | 233 e = convert(e); |
230 } | 234 } |
231 elements[i] = e; | 235 elements[i] = e; |
232 } | 236 } |
233 } | 237 } |
234 return %StringBuilderJoin(elements, length, separator); | 238 return %StringBuilderJoin(elements, length, separator); |
235 } finally { | 239 } finally { |
(...skipping 1724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1960 %InstallToContext([ | 1964 %InstallToContext([ |
1961 "array_pop", ArrayPop, | 1965 "array_pop", ArrayPop, |
1962 "array_push", ArrayPush, | 1966 "array_push", ArrayPush, |
1963 "array_shift", ArrayShift, | 1967 "array_shift", ArrayShift, |
1964 "array_splice", ArraySplice, | 1968 "array_splice", ArraySplice, |
1965 "array_slice", ArraySlice, | 1969 "array_slice", ArraySlice, |
1966 "array_unshift", ArrayUnshift, | 1970 "array_unshift", ArrayUnshift, |
1967 ]); | 1971 ]); |
1968 | 1972 |
1969 }); | 1973 }); |
OLD | NEW |