| 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 1822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1833 var body = (n > 0) ? ToString(arguments[n - 1]) : ''; | 1833 var body = (n > 0) ? ToString(arguments[n - 1]) : ''; |
| 1834 return '(' + function_token + '(' + p + ') {\n' + body + '\n})'; | 1834 return '(' + function_token + '(' + p + ') {\n' + body + '\n})'; |
| 1835 } | 1835 } |
| 1836 | 1836 |
| 1837 | 1837 |
| 1838 function FunctionConstructor(arg1) { // length == 1 | 1838 function FunctionConstructor(arg1) { // length == 1 |
| 1839 var source = NewFunctionString(arguments, 'function'); | 1839 var source = NewFunctionString(arguments, 'function'); |
| 1840 var global_receiver = %GlobalReceiver(global); | 1840 var global_receiver = %GlobalReceiver(global); |
| 1841 // Compile the string in the constructor and not a helper so that errors | 1841 // Compile the string in the constructor and not a helper so that errors |
| 1842 // appear to come from here. | 1842 // appear to come from here. |
| 1843 var f = %_CallFunction(global_receiver, %CompileString(source, true)); | 1843 var f = %CompileString(source, true); |
| 1844 if (!IS_FUNCTION(f)) return f; |
| 1845 f = %_CallFunction(global_receiver, f); |
| 1844 %FunctionMarkNameShouldPrintAsAnonymous(f); | 1846 %FunctionMarkNameShouldPrintAsAnonymous(f); |
| 1845 return f; | 1847 return f; |
| 1846 } | 1848 } |
| 1847 | 1849 |
| 1848 | 1850 |
| 1849 // ---------------------------------------------------------------------------- | 1851 // ---------------------------------------------------------------------------- |
| 1850 | 1852 |
| 1851 function SetUpFunction() { | 1853 function SetUpFunction() { |
| 1852 %CheckIsBootstrapping(); | 1854 %CheckIsBootstrapping(); |
| 1853 | 1855 |
| 1854 %SetCode($Function, FunctionConstructor); | 1856 %SetCode($Function, FunctionConstructor); |
| 1855 %SetProperty($Function.prototype, "constructor", $Function, DONT_ENUM); | 1857 %SetProperty($Function.prototype, "constructor", $Function, DONT_ENUM); |
| 1856 | 1858 |
| 1857 InstallFunctions($Function.prototype, DONT_ENUM, $Array( | 1859 InstallFunctions($Function.prototype, DONT_ENUM, $Array( |
| 1858 "bind", FunctionBind, | 1860 "bind", FunctionBind, |
| 1859 "toString", FunctionToString | 1861 "toString", FunctionToString |
| 1860 )); | 1862 )); |
| 1861 } | 1863 } |
| 1862 | 1864 |
| 1863 SetUpFunction(); | 1865 SetUpFunction(); |
| OLD | NEW |