| 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 1763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1774 var argv = new InternalArray(bound_argc + argc); | 1774 var argv = new InternalArray(bound_argc + argc); |
| 1775 for (var i = 0; i < bound_argc; i++) { | 1775 for (var i = 0; i < bound_argc; i++) { |
| 1776 argv[i] = bindings[i + 2]; | 1776 argv[i] = bindings[i + 2]; |
| 1777 } | 1777 } |
| 1778 for (var j = 0; j < argc; j++) { | 1778 for (var j = 0; j < argc; j++) { |
| 1779 argv[i++] = %_Arguments(j); | 1779 argv[i++] = %_Arguments(j); |
| 1780 } | 1780 } |
| 1781 return %Apply(bindings[0], bindings[1], argv, 0, bound_argc + argc); | 1781 return %Apply(bindings[0], bindings[1], argv, 0, bound_argc + argc); |
| 1782 }; | 1782 }; |
| 1783 | 1783 |
| 1784 %FunctionRemovePrototype(boundFunction); | |
| 1785 var new_length = 0; | 1784 var new_length = 0; |
| 1786 if (%_ClassOf(this) == "Function") { | 1785 var old_length = this.length; |
| 1787 // Function or FunctionProxy. | 1786 // FunctionProxies might provide a non-UInt32 value. If so, ignore it. |
| 1788 var old_length = this.length; | 1787 if ((typeof old_length === "number") && |
| 1789 // FunctionProxies might provide a non-UInt32 value. If so, ignore it. | 1788 ((old_length >>> 0) === old_length)) { |
| 1790 if ((typeof old_length === "number") && | 1789 var argc = %_ArgumentsLength(); |
| 1791 ((old_length >>> 0) === old_length)) { | 1790 if (argc > 0) argc--; // Don't count the thisArg as parameter. |
| 1792 var argc = %_ArgumentsLength(); | 1791 new_length = old_length - argc; |
| 1793 if (argc > 0) argc--; // Don't count the thisArg as parameter. | 1792 if (new_length < 0) new_length = 0; |
| 1794 new_length = old_length - argc; | |
| 1795 if (new_length < 0) new_length = 0; | |
| 1796 } | |
| 1797 } | 1793 } |
| 1798 // This runtime function finds any remaining arguments on the stack, | 1794 // This runtime function finds any remaining arguments on the stack, |
| 1799 // so we don't pass the arguments object. | 1795 // so we don't pass the arguments object. |
| 1800 var result = %FunctionBindArguments(boundFunction, this, | 1796 var result = %FunctionBindArguments(boundFunction, this, |
| 1801 this_arg, new_length); | 1797 this_arg, new_length); |
| 1802 | 1798 |
| 1803 // We already have caller and arguments properties on functions, | 1799 // We already have caller and arguments properties on functions, |
| 1804 // which are non-configurable. It therefore makes no sence to | 1800 // which are non-configurable. It therefore makes no sence to |
| 1805 // try to redefine these as defined by the spec. The spec says | 1801 // try to redefine these as defined by the spec. The spec says |
| 1806 // that bind should make these throw a TypeError if get or set | 1802 // that bind should make these throw a TypeError if get or set |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1856 %SetCode($Function, FunctionConstructor); | 1852 %SetCode($Function, FunctionConstructor); |
| 1857 %SetProperty($Function.prototype, "constructor", $Function, DONT_ENUM); | 1853 %SetProperty($Function.prototype, "constructor", $Function, DONT_ENUM); |
| 1858 | 1854 |
| 1859 InstallFunctions($Function.prototype, DONT_ENUM, $Array( | 1855 InstallFunctions($Function.prototype, DONT_ENUM, $Array( |
| 1860 "bind", FunctionBind, | 1856 "bind", FunctionBind, |
| 1861 "toString", FunctionToString | 1857 "toString", FunctionToString |
| 1862 )); | 1858 )); |
| 1863 } | 1859 } |
| 1864 | 1860 |
| 1865 SetUpFunction(); | 1861 SetUpFunction(); |
| OLD | NEW |