| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 'use strict'; | 7 'use strict'; |
| 8 | 8 |
| 9 %CheckIsBootstrapping(); | 9 %CheckIsBootstrapping(); |
| 10 | 10 |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 result.length = k; | 231 result.length = k; |
| 232 return result; | 232 return result; |
| 233 } | 233 } |
| 234 | 234 |
| 235 nextValue = next.value; | 235 nextValue = next.value; |
| 236 if (mapping) { | 236 if (mapping) { |
| 237 mappedValue = %_CallFunction(receiver, nextValue, k, mapfn); | 237 mappedValue = %_CallFunction(receiver, nextValue, k, mapfn); |
| 238 } else { | 238 } else { |
| 239 mappedValue = nextValue; | 239 mappedValue = nextValue; |
| 240 } | 240 } |
| 241 %AddElement(result, k++, mappedValue, NONE); | 241 // TODO(verwaest): This should redefine rather than adding. |
| 242 %AddElement(result, k++, mappedValue); |
| 242 } | 243 } |
| 243 } else { | 244 } else { |
| 244 var len = $toLength(items.length); | 245 var len = $toLength(items.length); |
| 245 result = %IsConstructor(this) ? new this(len) : new GlobalArray(len); | 246 result = %IsConstructor(this) ? new this(len) : new GlobalArray(len); |
| 246 | 247 |
| 247 for (k = 0; k < len; ++k) { | 248 for (k = 0; k < len; ++k) { |
| 248 nextValue = items[k]; | 249 nextValue = items[k]; |
| 249 if (mapping) { | 250 if (mapping) { |
| 250 mappedValue = %_CallFunction(receiver, nextValue, k, mapfn); | 251 mappedValue = %_CallFunction(receiver, nextValue, k, mapfn); |
| 251 } else { | 252 } else { |
| 252 mappedValue = nextValue; | 253 mappedValue = nextValue; |
| 253 } | 254 } |
| 254 %AddElement(result, k, mappedValue, NONE); | 255 // TODO(verwaest): This should redefine rather than adding. |
| 256 %AddElement(result, k, mappedValue); |
| 255 } | 257 } |
| 256 | 258 |
| 257 result.length = k; | 259 result.length = k; |
| 258 return result; | 260 return result; |
| 259 } | 261 } |
| 260 } | 262 } |
| 261 | 263 |
| 262 // ES6, draft 05-22-14, section 22.1.2.3 | 264 // ES6, draft 05-22-14, section 22.1.2.3 |
| 263 function ArrayOf() { | 265 function ArrayOf() { |
| 264 var length = %_ArgumentsLength(); | 266 var length = %_ArgumentsLength(); |
| 265 var constructor = this; | 267 var constructor = this; |
| 266 // TODO: Implement IsConstructor (ES6 section 7.2.5) | 268 // TODO: Implement IsConstructor (ES6 section 7.2.5) |
| 267 var array = %IsConstructor(constructor) ? new constructor(length) : []; | 269 var array = %IsConstructor(constructor) ? new constructor(length) : []; |
| 268 for (var i = 0; i < length; i++) { | 270 for (var i = 0; i < length; i++) { |
| 269 %AddElement(array, i, %_Arguments(i), NONE); | 271 // TODO(verwaest): This should redefine rather than adding. |
| 272 %AddElement(array, i, %_Arguments(i)); |
| 270 } | 273 } |
| 271 array.length = length; | 274 array.length = length; |
| 272 return array; | 275 return array; |
| 273 } | 276 } |
| 274 | 277 |
| 275 // ------------------------------------------------------------------- | 278 // ------------------------------------------------------------------- |
| 276 | 279 |
| 277 utils.InstallConstants(GlobalSymbol, [ | 280 utils.InstallConstants(GlobalSymbol, [ |
| 278 // TODO(dslomov, caitp): Move to symbol.js when shipping | 281 // TODO(dslomov, caitp): Move to symbol.js when shipping |
| 279 "isConcatSpreadable", symbolIsConcatSpreadable | 282 "isConcatSpreadable", symbolIsConcatSpreadable |
| (...skipping 24 matching lines...) Expand all Loading... |
| 304 | 307 |
| 305 utils.Export(function(to) { | 308 utils.Export(function(to) { |
| 306 to.ArrayFrom = ArrayFrom; | 309 to.ArrayFrom = ArrayFrom; |
| 307 to.InnerArrayCopyWithin = InnerArrayCopyWithin; | 310 to.InnerArrayCopyWithin = InnerArrayCopyWithin; |
| 308 to.InnerArrayFill = InnerArrayFill; | 311 to.InnerArrayFill = InnerArrayFill; |
| 309 to.InnerArrayFind = InnerArrayFind; | 312 to.InnerArrayFind = InnerArrayFind; |
| 310 to.InnerArrayFindIndex = InnerArrayFindIndex; | 313 to.InnerArrayFindIndex = InnerArrayFindIndex; |
| 311 }); | 314 }); |
| 312 | 315 |
| 313 }) | 316 }) |
| OLD | NEW |