| 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 // This file relies on the fact that the following declarations have been made | 5 // This file relies on the fact that the following declarations have been made |
| 6 // in runtime.js: | 6 // in runtime.js: |
| 7 // var $Object = global.Object; | 7 // var $Object = global.Object; |
| 8 // var $Boolean = global.Boolean; | 8 // var $Boolean = global.Boolean; |
| 9 // var $Number = global.Number; | 9 // var $Number = global.Number; |
| 10 // var $Function = global.Function; | 10 // var $Function = global.Function; |
| (...skipping 1857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1868 %SetCode($Function, FunctionConstructor); | 1868 %SetCode($Function, FunctionConstructor); |
| 1869 %AddNamedProperty($Function.prototype, "constructor", $Function, DONT_ENUM); | 1869 %AddNamedProperty($Function.prototype, "constructor", $Function, DONT_ENUM); |
| 1870 | 1870 |
| 1871 InstallFunctions($Function.prototype, DONT_ENUM, $Array( | 1871 InstallFunctions($Function.prototype, DONT_ENUM, $Array( |
| 1872 "bind", FunctionBind, | 1872 "bind", FunctionBind, |
| 1873 "toString", FunctionToString | 1873 "toString", FunctionToString |
| 1874 )); | 1874 )); |
| 1875 } | 1875 } |
| 1876 | 1876 |
| 1877 SetUpFunction(); | 1877 SetUpFunction(); |
| 1878 |
| 1879 |
| 1880 // ---------------------------------------------------------------------------- |
| 1881 // Iterator related spec functions. |
| 1882 |
| 1883 // ES6 rev 26, 2014-07-18 |
| 1884 // 7.4.1 CheckIterable ( obj ) |
| 1885 function ToIterable(obj) { |
| 1886 if (!IS_SPEC_OBJECT(obj)) { |
| 1887 return UNDEFINED; |
| 1888 } |
| 1889 return obj[symbolIterator]; |
| 1890 } |
| 1891 |
| 1892 |
| 1893 // ES6 rev 26, 2014-07-18 |
| 1894 // 7.4.2 GetIterator ( obj, method ) |
| 1895 function GetIterator(obj, method) { |
| 1896 if (IS_UNDEFINED(method)) { |
| 1897 method = ToIterable(obj); |
| 1898 } |
| 1899 if (!IS_SPEC_FUNCTION(method)) { |
| 1900 throw MakeTypeError('not_iterable', [obj]); |
| 1901 } |
| 1902 var iterator = %_CallFunction(obj, method); |
| 1903 if (!IS_SPEC_OBJECT(iterator)) { |
| 1904 throw MakeTypeError('not_an_iterator', [iterator]); |
| 1905 } |
| 1906 return iterator; |
| 1907 } |
| OLD | NEW |