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 |
11 // ------------------------------------------------------------------- | 11 // ------------------------------------------------------------------- |
12 // Imports | 12 // Imports |
13 | 13 |
14 var GetIterator; | 14 var GetIterator; |
15 var GetMethod; | 15 var GetMethod; |
16 var GlobalArray = global.Array; | 16 var GlobalArray = global.Array; |
17 var iteratorSymbol = utils.ImportNow("iterator_symbol"); | 17 var iteratorSymbol = utils.ImportNow("iterator_symbol"); |
18 var MathMax; | |
19 var MathMin; | |
20 var ObjectIsFrozen; | 18 var ObjectIsFrozen; |
21 var ObjectDefineProperty; | 19 var ObjectDefineProperty; |
22 | 20 |
23 utils.Import(function(from) { | 21 utils.Import(function(from) { |
24 GetIterator = from.GetIterator; | 22 GetIterator = from.GetIterator; |
25 GetMethod = from.GetMethod; | 23 GetMethod = from.GetMethod; |
26 MathMax = from.MathMax; | |
27 MathMin = from.MathMin; | |
28 ObjectIsFrozen = from.ObjectIsFrozen; | 24 ObjectIsFrozen = from.ObjectIsFrozen; |
29 ObjectDefineProperty = from.ObjectDefineProperty; | 25 ObjectDefineProperty = from.ObjectDefineProperty; |
30 }); | 26 }); |
31 | 27 |
32 // ------------------------------------------------------------------- | 28 // ------------------------------------------------------------------- |
33 | 29 |
34 function InnerArrayCopyWithin(target, start, end, array, length) { | 30 function InnerArrayCopyWithin(target, start, end, array, length) { |
35 target = TO_INTEGER(target); | 31 target = TO_INTEGER(target); |
36 var to; | 32 var to; |
37 if (target < 0) { | 33 if (target < 0) { |
38 to = MathMax(length + target, 0); | 34 to = MAX_SIMPLE(length + target, 0); |
39 } else { | 35 } else { |
40 to = MathMin(target, length); | 36 to = MIN_SIMPLE(target, length); |
41 } | 37 } |
42 | 38 |
43 start = TO_INTEGER(start); | 39 start = TO_INTEGER(start); |
44 var from; | 40 var from; |
45 if (start < 0) { | 41 if (start < 0) { |
46 from = MathMax(length + start, 0); | 42 from = MAX_SIMPLE(length + start, 0); |
47 } else { | 43 } else { |
48 from = MathMin(start, length); | 44 from = MIN_SIMPLE(start, length); |
49 } | 45 } |
50 | 46 |
51 end = IS_UNDEFINED(end) ? length : TO_INTEGER(end); | 47 end = IS_UNDEFINED(end) ? length : TO_INTEGER(end); |
52 var final; | 48 var final; |
53 if (end < 0) { | 49 if (end < 0) { |
54 final = MathMax(length + end, 0); | 50 final = MAX_SIMPLE(length + end, 0); |
55 } else { | 51 } else { |
56 final = MathMin(end, length); | 52 final = MIN_SIMPLE(end, length); |
57 } | 53 } |
58 | 54 |
59 var count = MathMin(final - from, length - to); | 55 var count = MIN_SIMPLE(final - from, length - to); |
60 var direction = 1; | 56 var direction = 1; |
61 if (from < to && to < (from + count)) { | 57 if (from < to && to < (from + count)) { |
62 direction = -1; | 58 direction = -1; |
63 from = from + count - 1; | 59 from = from + count - 1; |
64 to = to + count - 1; | 60 to = to + count - 1; |
65 } | 61 } |
66 | 62 |
67 while (count > 0) { | 63 while (count > 0) { |
68 if (from in array) { | 64 if (from in array) { |
69 array[to] = array[from]; | 65 array[to] = array[from]; |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 | 285 |
290 utils.Export(function(to) { | 286 utils.Export(function(to) { |
291 to.ArrayFrom = ArrayFrom; | 287 to.ArrayFrom = ArrayFrom; |
292 to.InnerArrayCopyWithin = InnerArrayCopyWithin; | 288 to.InnerArrayCopyWithin = InnerArrayCopyWithin; |
293 to.InnerArrayFill = InnerArrayFill; | 289 to.InnerArrayFill = InnerArrayFill; |
294 to.InnerArrayFind = InnerArrayFind; | 290 to.InnerArrayFind = InnerArrayFind; |
295 to.InnerArrayFindIndex = InnerArrayFindIndex; | 291 to.InnerArrayFindIndex = InnerArrayFindIndex; |
296 }); | 292 }); |
297 | 293 |
298 }) | 294 }) |
OLD | NEW |