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