| 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 // is not mandated by the spec. | 167 // is not mandated by the spec. |
| 168 // We only throw if the global has been detached, since we need the | 168 // We only throw if the global has been detached, since we need the |
| 169 // receiver as this-value for the call. | 169 // receiver as this-value for the call. |
| 170 if (!%IsAttachedGlobal(global)) { | 170 if (!%IsAttachedGlobal(global)) { |
| 171 throw new $EvalError('The "this" value passed to eval must ' + | 171 throw new $EvalError('The "this" value passed to eval must ' + |
| 172 'be the global object from which eval originated'); | 172 'be the global object from which eval originated'); |
| 173 } | 173 } |
| 174 | 174 |
| 175 var global_proxy = %GlobalProxy(global); | 175 var global_proxy = %GlobalProxy(global); |
| 176 | 176 |
| 177 var f = %CompileString(x, false); | 177 var f = %CompileString(x, global_proxy, false); |
| 178 if (!IS_FUNCTION(f)) return f; | 178 if (!IS_FUNCTION(f)) return f; |
| 179 | 179 |
| 180 return %_CallFunction(global_proxy, f); | 180 return %_CallFunction(global_proxy, f); |
| 181 } | 181 } |
| 182 | 182 |
| 183 | 183 |
| 184 // ---------------------------------------------------------------------------- | 184 // ---------------------------------------------------------------------------- |
| 185 | 185 |
| 186 // Set up global object. | 186 // Set up global object. |
| 187 function SetUpGlobal() { | 187 function SetUpGlobal() { |
| (...skipping 1639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1827 var body = (n > 0) ? ToString(arguments[n - 1]) : ''; | 1827 var body = (n > 0) ? ToString(arguments[n - 1]) : ''; |
| 1828 return '(' + function_token + '(' + p + ') {\n' + body + '\n})'; | 1828 return '(' + function_token + '(' + p + ') {\n' + body + '\n})'; |
| 1829 } | 1829 } |
| 1830 | 1830 |
| 1831 | 1831 |
| 1832 function FunctionConstructor(arg1) { // length == 1 | 1832 function FunctionConstructor(arg1) { // length == 1 |
| 1833 var source = NewFunctionString(arguments, 'function'); | 1833 var source = NewFunctionString(arguments, 'function'); |
| 1834 var global_proxy = %GlobalProxy(global); | 1834 var global_proxy = %GlobalProxy(global); |
| 1835 // Compile the string in the constructor and not a helper so that errors | 1835 // Compile the string in the constructor and not a helper so that errors |
| 1836 // appear to come from here. | 1836 // appear to come from here. |
| 1837 var f = %CompileString(source, true); | 1837 var f = %CompileString(source, global_proxy, true); |
| 1838 if (!IS_FUNCTION(f)) return f; | 1838 if (!IS_FUNCTION(f)) return f; |
| 1839 f = %_CallFunction(global_proxy, f); | 1839 f = %_CallFunction(global_proxy, f); |
| 1840 %FunctionMarkNameShouldPrintAsAnonymous(f); | 1840 %FunctionMarkNameShouldPrintAsAnonymous(f); |
| 1841 return f; | 1841 return f; |
| 1842 } | 1842 } |
| 1843 | 1843 |
| 1844 | 1844 |
| 1845 // ---------------------------------------------------------------------------- | 1845 // ---------------------------------------------------------------------------- |
| 1846 | 1846 |
| 1847 function SetUpFunction() { | 1847 function SetUpFunction() { |
| 1848 %CheckIsBootstrapping(); | 1848 %CheckIsBootstrapping(); |
| 1849 | 1849 |
| 1850 %SetCode($Function, FunctionConstructor); | 1850 %SetCode($Function, FunctionConstructor); |
| 1851 %AddProperty($Function.prototype, "constructor", $Function, DONT_ENUM); | 1851 %AddProperty($Function.prototype, "constructor", $Function, DONT_ENUM); |
| 1852 | 1852 |
| 1853 InstallFunctions($Function.prototype, DONT_ENUM, $Array( | 1853 InstallFunctions($Function.prototype, DONT_ENUM, $Array( |
| 1854 "bind", FunctionBind, | 1854 "bind", FunctionBind, |
| 1855 "toString", FunctionToString | 1855 "toString", FunctionToString |
| 1856 )); | 1856 )); |
| 1857 } | 1857 } |
| 1858 | 1858 |
| 1859 SetUpFunction(); | 1859 SetUpFunction(); |
| OLD | NEW |