Chromium Code Reviews| 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 1758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1769 } | 1769 } |
| 1770 | 1770 |
| 1771 var iterable = GetMethod(items, iteratorSymbol); | 1771 var iterable = GetMethod(items, iteratorSymbol); |
| 1772 var k; | 1772 var k; |
| 1773 var result; | 1773 var result; |
| 1774 var mappedValue; | 1774 var mappedValue; |
| 1775 var nextValue; | 1775 var nextValue; |
| 1776 | 1776 |
| 1777 if (!IS_UNDEFINED(iterable)) { | 1777 if (!IS_UNDEFINED(iterable)) { |
| 1778 result = %IsConstructor(this) ? new this() : []; | 1778 result = %IsConstructor(this) ? new this() : []; |
| 1779 k = 0; | |
| 1779 | 1780 |
| 1780 var iterator = GetIterator(items, iterable); | 1781 for (nextValue of |
| 1781 | 1782 { [iteratorSymbol]() { return %_Call(iterable, items) } }) { |
|
neis
2016/02/10 08:38:28
Is there a good reason for using %_Call(...) inste
Dan Ehrenberg
2016/02/10 09:25:54
Nope. (I was somehow thinking that it would be red
| |
| 1782 k = 0; | |
| 1783 while (true) { | |
| 1784 var next = iterator.next(); | |
| 1785 | |
| 1786 if (!IS_RECEIVER(next)) { | |
| 1787 throw MakeTypeError(kIteratorResultNotAnObject, next); | |
| 1788 } | |
| 1789 | |
| 1790 if (next.done) { | |
| 1791 result.length = k; | |
| 1792 return result; | |
| 1793 } | |
| 1794 | |
| 1795 nextValue = next.value; | |
| 1796 if (mapping) { | 1783 if (mapping) { |
| 1797 mappedValue = %_Call(mapfn, receiver, nextValue, k); | 1784 mappedValue = %_Call(mapfn, receiver, nextValue, k); |
| 1798 } else { | 1785 } else { |
| 1799 mappedValue = nextValue; | 1786 mappedValue = nextValue; |
| 1800 } | 1787 } |
| 1801 AddArrayElement(this, result, k, mappedValue); | 1788 AddArrayElement(this, result, k, mappedValue); |
| 1802 k++; | 1789 k++; |
| 1803 } | 1790 } |
| 1791 result.length = k; | |
| 1792 return result; | |
| 1804 } else { | 1793 } else { |
| 1805 var len = TO_LENGTH(items.length); | 1794 var len = TO_LENGTH(items.length); |
| 1806 result = %IsConstructor(this) ? new this(len) : new GlobalArray(len); | 1795 result = %IsConstructor(this) ? new this(len) : new GlobalArray(len); |
| 1807 | 1796 |
| 1808 for (k = 0; k < len; ++k) { | 1797 for (k = 0; k < len; ++k) { |
| 1809 nextValue = items[k]; | 1798 nextValue = items[k]; |
| 1810 if (mapping) { | 1799 if (mapping) { |
| 1811 mappedValue = %_Call(mapfn, receiver, nextValue, k); | 1800 mappedValue = %_Call(mapfn, receiver, nextValue, k); |
| 1812 } else { | 1801 } else { |
| 1813 mappedValue = nextValue; | 1802 mappedValue = nextValue; |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1972 %InstallToContext([ | 1961 %InstallToContext([ |
| 1973 "array_pop", ArrayPop, | 1962 "array_pop", ArrayPop, |
| 1974 "array_push", ArrayPush, | 1963 "array_push", ArrayPush, |
| 1975 "array_shift", ArrayShift, | 1964 "array_shift", ArrayShift, |
| 1976 "array_splice", ArraySplice, | 1965 "array_splice", ArraySplice, |
| 1977 "array_slice", ArraySlice, | 1966 "array_slice", ArraySlice, |
| 1978 "array_unshift", ArrayUnshift, | 1967 "array_unshift", ArrayUnshift, |
| 1979 ]); | 1968 ]); |
| 1980 | 1969 |
| 1981 }); | 1970 }); |
| OLD | NEW |