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 var $innerArrayCopyWithin; |
| 6 |
5 (function(global, exports) { | 7 (function(global, exports) { |
6 | 8 |
7 'use strict'; | 9 'use strict'; |
8 | 10 |
9 %CheckIsBootstrapping(); | 11 %CheckIsBootstrapping(); |
10 | 12 |
11 var GlobalArray = global.Array; | 13 var GlobalArray = global.Array; |
12 var GlobalSymbol = global.Symbol; | 14 var GlobalSymbol = global.Symbol; |
13 | 15 |
14 // ------------------------------------------------------------------- | 16 // ------------------------------------------------------------------- |
15 | 17 |
16 // ES6 draft 03-17-15, section 22.1.3.3 | 18 function InnerArrayCopyWithin(target, start, end, array, length) { |
17 function ArrayCopyWithin(target, start, end) { | |
18 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.copyWithin"); | |
19 | |
20 var array = TO_OBJECT_INLINE(this); | |
21 var length = $toLength(array.length); | |
22 | |
23 target = TO_INTEGER(target); | 19 target = TO_INTEGER(target); |
24 var to; | 20 var to; |
25 if (target < 0) { | 21 if (target < 0) { |
26 to = $max(length + target, 0); | 22 to = $max(length + target, 0); |
27 } else { | 23 } else { |
28 to = $min(target, length); | 24 to = $min(target, length); |
29 } | 25 } |
30 | 26 |
31 start = TO_INTEGER(start); | 27 start = TO_INTEGER(start); |
32 var from; | 28 var from; |
(...skipping 25 matching lines...) Expand all Loading... |
58 } else { | 54 } else { |
59 delete array[to]; | 55 delete array[to]; |
60 } | 56 } |
61 from = from + direction; | 57 from = from + direction; |
62 to = to + direction; | 58 to = to + direction; |
63 count--; | 59 count--; |
64 } | 60 } |
65 | 61 |
66 return array; | 62 return array; |
67 } | 63 } |
| 64 $innerArrayCopyWithin = InnerArrayCopyWithin; |
| 65 |
| 66 // ES6 draft 03-17-15, section 22.1.3.3 |
| 67 function ArrayCopyWithin(target, start, end) { |
| 68 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.copyWithin"); |
| 69 |
| 70 var array = TO_OBJECT_INLINE(this); |
| 71 var length = $toLength(array.length); |
| 72 |
| 73 return InnerArrayCopyWithin(target, start, end, array, length); |
| 74 } |
68 | 75 |
69 // ES6 draft 07-15-13, section 15.4.3.23 | 76 // ES6 draft 07-15-13, section 15.4.3.23 |
70 function ArrayFind(predicate /* thisArg */) { // length == 1 | 77 function ArrayFind(predicate /* thisArg */) { // length == 1 |
71 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.find"); | 78 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.find"); |
72 | 79 |
73 var array = $toObject(this); | 80 var array = $toObject(this); |
74 var length = $toInteger(array.length); | 81 var length = $toInteger(array.length); |
75 | 82 |
76 if (!IS_SPEC_FUNCTION(predicate)) { | 83 if (!IS_SPEC_FUNCTION(predicate)) { |
77 throw MakeTypeError(kCalledNonCallable, predicate); | 84 throw MakeTypeError(kCalledNonCallable, predicate); |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 | 288 |
282 // Set up the non-enumerable functions on the Array prototype object. | 289 // Set up the non-enumerable functions on the Array prototype object. |
283 $installFunctions(GlobalArray.prototype, DONT_ENUM, [ | 290 $installFunctions(GlobalArray.prototype, DONT_ENUM, [ |
284 "copyWithin", ArrayCopyWithin, | 291 "copyWithin", ArrayCopyWithin, |
285 "find", ArrayFind, | 292 "find", ArrayFind, |
286 "findIndex", ArrayFindIndex, | 293 "findIndex", ArrayFindIndex, |
287 "fill", ArrayFill | 294 "fill", ArrayFill |
288 ]); | 295 ]); |
289 | 296 |
290 }) | 297 }) |
OLD | NEW |