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) { | 5 (function(global, utils) { |
6 | 6 |
7 %CheckIsBootstrapping(); | 7 %CheckIsBootstrapping(); |
8 | 8 |
9 // ---------------------------------------------------------------------------- | 9 // ---------------------------------------------------------------------------- |
10 // Imports | 10 // Imports |
(...skipping 1768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1779 var body = (n > 0) ? TO_STRING(args[n - 1]) : ''; | 1779 var body = (n > 0) ? TO_STRING(args[n - 1]) : ''; |
1780 return '(' + function_token + '(' + p + ') {\n' + body + '\n})'; | 1780 return '(' + function_token + '(' + p + ') {\n' + body + '\n})'; |
1781 } | 1781 } |
1782 | 1782 |
1783 | 1783 |
1784 function FunctionConstructor(arg1) { // length == 1 | 1784 function FunctionConstructor(arg1) { // length == 1 |
1785 var source = NewFunctionString(arguments, 'function'); | 1785 var source = NewFunctionString(arguments, 'function'); |
1786 var global_proxy = %GlobalProxy(FunctionConstructor); | 1786 var global_proxy = %GlobalProxy(FunctionConstructor); |
1787 // Compile the string in the constructor and not a helper so that errors | 1787 // Compile the string in the constructor and not a helper so that errors |
1788 // appear to come from here. | 1788 // appear to come from here. |
1789 var f = %_CallFunction(global_proxy, %CompileString(source, true)); | 1789 var func = %_CallFunction(global_proxy, %CompileString(source, true)); |
1790 %FunctionMarkNameShouldPrintAsAnonymous(f); | 1790 // Set name-should-print-as-anonymous flag on the ShareFunctionInfo and |
1791 return f; | 1791 // ensure that |func| uses correct initial map from |new.target| if |
| 1792 // it's available. |
| 1793 return %CompleteFunctionConstruction(func, GlobalFunction, new.target); |
1792 } | 1794 } |
1793 | 1795 |
1794 | 1796 |
1795 // ---------------------------------------------------------------------------- | 1797 // ---------------------------------------------------------------------------- |
1796 | 1798 |
1797 %SetCode(GlobalFunction, FunctionConstructor); | 1799 %SetCode(GlobalFunction, FunctionConstructor); |
1798 %AddNamedProperty(GlobalFunction.prototype, "constructor", GlobalFunction, | 1800 %AddNamedProperty(GlobalFunction.prototype, "constructor", GlobalFunction, |
1799 DONT_ENUM); | 1801 DONT_ENUM); |
1800 | 1802 |
1801 utils.InstallFunctions(GlobalFunction.prototype, DONT_ENUM, [ | 1803 utils.InstallFunctions(GlobalFunction.prototype, DONT_ENUM, [ |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1847 | 1849 |
1848 %InstallToContext([ | 1850 %InstallToContext([ |
1849 "global_eval_fun", GlobalEval, | 1851 "global_eval_fun", GlobalEval, |
1850 "object_value_of", ObjectValueOf, | 1852 "object_value_of", ObjectValueOf, |
1851 "object_to_string", ObjectToString, | 1853 "object_to_string", ObjectToString, |
1852 "object_get_own_property_descriptor", ObjectGetOwnPropertyDescriptor, | 1854 "object_get_own_property_descriptor", ObjectGetOwnPropertyDescriptor, |
1853 "to_complete_property_descriptor", ToCompletePropertyDescriptor, | 1855 "to_complete_property_descriptor", ToCompletePropertyDescriptor, |
1854 ]); | 1856 ]); |
1855 | 1857 |
1856 }) | 1858 }) |
OLD | NEW |