| 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 | 110 |
| 111 | 111 |
| 112 function GlobalEval(x) { | 112 function GlobalEval(x) { |
| 113 if (!IS_STRING(x)) return x; | 113 if (!IS_STRING(x)) return x; |
| 114 | 114 |
| 115 var global_proxy = %GlobalProxy(GlobalEval); | 115 var global_proxy = %GlobalProxy(GlobalEval); |
| 116 | 116 |
| 117 var f = %CompileString(x, false); | 117 var f = %CompileString(x, false); |
| 118 if (!IS_FUNCTION(f)) return f; | 118 if (!IS_FUNCTION(f)) return f; |
| 119 | 119 |
| 120 return %_CallFunction(global_proxy, f); | 120 return %_Call(f, global_proxy); |
| 121 } | 121 } |
| 122 | 122 |
| 123 | 123 |
| 124 // ---------------------------------------------------------------------------- | 124 // ---------------------------------------------------------------------------- |
| 125 | 125 |
| 126 // Set up global object. | 126 // Set up global object. |
| 127 var attributes = DONT_ENUM | DONT_DELETE | READ_ONLY; | 127 var attributes = DONT_ENUM | DONT_DELETE | READ_ONLY; |
| 128 | 128 |
| 129 utils.InstallConstants(global, [ | 129 utils.InstallConstants(global, [ |
| 130 // ECMA 262 - 15.1.1.1. | 130 // ECMA 262 - 15.1.1.1. |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 } | 547 } |
| 548 trap = defaultTrap; | 548 trap = defaultTrap; |
| 549 } else if (!IS_CALLABLE(trap)) { | 549 } else if (!IS_CALLABLE(trap)) { |
| 550 throw MakeTypeError(kProxyHandlerTrapMustBeCallable, handler, name); | 550 throw MakeTypeError(kProxyHandlerTrapMustBeCallable, handler, name); |
| 551 } | 551 } |
| 552 return trap; | 552 return trap; |
| 553 } | 553 } |
| 554 | 554 |
| 555 | 555 |
| 556 function CallTrap0(handler, name, defaultTrap) { | 556 function CallTrap0(handler, name, defaultTrap) { |
| 557 return %_CallFunction(handler, GetTrap(handler, name, defaultTrap)); | 557 return %_Call(GetTrap(handler, name, defaultTrap), handler); |
| 558 } | 558 } |
| 559 | 559 |
| 560 | 560 |
| 561 function CallTrap1(handler, name, defaultTrap, x) { | 561 function CallTrap1(handler, name, defaultTrap, x) { |
| 562 return %_CallFunction(handler, x, GetTrap(handler, name, defaultTrap)); | 562 return %_Call(GetTrap(handler, name, defaultTrap), handler, x); |
| 563 } | 563 } |
| 564 | 564 |
| 565 | 565 |
| 566 function CallTrap2(handler, name, defaultTrap, x, y) { | 566 function CallTrap2(handler, name, defaultTrap, x, y) { |
| 567 return %_CallFunction(handler, x, y, GetTrap(handler, name, defaultTrap)); | 567 return %_Call(GetTrap(handler, name, defaultTrap), handler, x, y); |
| 568 } | 568 } |
| 569 | 569 |
| 570 | 570 |
| 571 // ES5 section 8.12.1. | 571 // ES5 section 8.12.1. |
| 572 function GetOwnPropertyJS(obj, v) { | 572 function GetOwnPropertyJS(obj, v) { |
| 573 var p = TO_NAME(v); | 573 var p = TO_NAME(v); |
| 574 if (%_IsJSProxy(obj)) { | 574 if (%_IsJSProxy(obj)) { |
| 575 // TODO(rossberg): adjust once there is a story for symbols vs proxies. | 575 // TODO(rossberg): adjust once there is a story for symbols vs proxies. |
| 576 if (IS_SYMBOL(v)) return UNDEFINED; | 576 if (IS_SYMBOL(v)) return UNDEFINED; |
| 577 | 577 |
| (...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1456 // Convert the radix to an integer and check the range. | 1456 // Convert the radix to an integer and check the range. |
| 1457 radix = TO_INTEGER(radix); | 1457 radix = TO_INTEGER(radix); |
| 1458 if (radix < 2 || radix > 36) throw MakeRangeError(kToRadixFormatRange); | 1458 if (radix < 2 || radix > 36) throw MakeRangeError(kToRadixFormatRange); |
| 1459 // Convert the number to a string in the given radix. | 1459 // Convert the number to a string in the given radix. |
| 1460 return %NumberToRadixString(number, radix); | 1460 return %NumberToRadixString(number, radix); |
| 1461 } | 1461 } |
| 1462 | 1462 |
| 1463 | 1463 |
| 1464 // ECMA-262 section 15.7.4.3 | 1464 // ECMA-262 section 15.7.4.3 |
| 1465 function NumberToLocaleString() { | 1465 function NumberToLocaleString() { |
| 1466 return %_CallFunction(this, NumberToStringJS); | 1466 return %_Call(NumberToStringJS, this); |
| 1467 } | 1467 } |
| 1468 | 1468 |
| 1469 | 1469 |
| 1470 // ECMA-262 section 15.7.4.4 | 1470 // ECMA-262 section 15.7.4.4 |
| 1471 function NumberValueOf() { | 1471 function NumberValueOf() { |
| 1472 // NOTE: Both Number objects and values can enter here as | 1472 // NOTE: Both Number objects and values can enter here as |
| 1473 // 'this'. This is not as dictated by ECMA-262. | 1473 // 'this'. This is not as dictated by ECMA-262. |
| 1474 if (!IS_NUMBER(this) && !IS_NUMBER_WRAPPER(this)) { | 1474 if (!IS_NUMBER(this) && !IS_NUMBER_WRAPPER(this)) { |
| 1475 throw MakeTypeError(kNotGeneric, 'Number.prototype.valueOf'); | 1475 throw MakeTypeError(kNotGeneric, 'Number.prototype.valueOf'); |
| 1476 } | 1476 } |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1760 var n = args.length; | 1760 var n = args.length; |
| 1761 var p = ''; | 1761 var p = ''; |
| 1762 if (n > 1) { | 1762 if (n > 1) { |
| 1763 p = TO_STRING(args[0]); | 1763 p = TO_STRING(args[0]); |
| 1764 for (var i = 1; i < n - 1; i++) { | 1764 for (var i = 1; i < n - 1; i++) { |
| 1765 p += ',' + TO_STRING(args[i]); | 1765 p += ',' + TO_STRING(args[i]); |
| 1766 } | 1766 } |
| 1767 // If the formal parameters string include ) - an illegal | 1767 // If the formal parameters string include ) - an illegal |
| 1768 // character - it may make the combined function expression | 1768 // character - it may make the combined function expression |
| 1769 // compile. We avoid this problem by checking for this early on. | 1769 // compile. We avoid this problem by checking for this early on. |
| 1770 if (%_CallFunction(p, ')', StringIndexOf) != -1) { | 1770 if (%_Call(StringIndexOf, p, ')') != -1) { |
| 1771 throw MakeSyntaxError(kParenthesisInArgString); | 1771 throw MakeSyntaxError(kParenthesisInArgString); |
| 1772 } | 1772 } |
| 1773 // If the formal parameters include an unbalanced block comment, the | 1773 // If the formal parameters include an unbalanced block comment, the |
| 1774 // function must be rejected. Since JavaScript does not allow nested | 1774 // function must be rejected. Since JavaScript does not allow nested |
| 1775 // comments we can include a trailing block comment to catch this. | 1775 // comments we can include a trailing block comment to catch this. |
| 1776 p += '\n/' + '**/'; | 1776 p += '\n/' + '**/'; |
| 1777 } | 1777 } |
| 1778 var body = (n > 0) ? TO_STRING(args[n - 1]) : ''; | 1778 var body = (n > 0) ? TO_STRING(args[n - 1]) : ''; |
| 1779 return '(' + function_token + '(' + p + ') {\n' + body + '\n})'; | 1779 return '(' + function_token + '(' + p + ') {\n' + body + '\n})'; |
| 1780 } | 1780 } |
| 1781 | 1781 |
| 1782 | 1782 |
| 1783 function FunctionConstructor(arg1) { // length == 1 | 1783 function FunctionConstructor(arg1) { // length == 1 |
| 1784 var source = NewFunctionString(arguments, 'function'); | 1784 var source = NewFunctionString(arguments, 'function'); |
| 1785 var global_proxy = %GlobalProxy(FunctionConstructor); | 1785 var global_proxy = %GlobalProxy(FunctionConstructor); |
| 1786 // Compile the string in the constructor and not a helper so that errors | 1786 // Compile the string in the constructor and not a helper so that errors |
| 1787 // appear to come from here. | 1787 // appear to come from here. |
| 1788 var func = %_CallFunction(global_proxy, %CompileString(source, true)); | 1788 var func = %_Call(%CompileString(source, true), global_proxy); |
| 1789 // Set name-should-print-as-anonymous flag on the ShareFunctionInfo and | 1789 // Set name-should-print-as-anonymous flag on the ShareFunctionInfo and |
| 1790 // ensure that |func| uses correct initial map from |new.target| if | 1790 // ensure that |func| uses correct initial map from |new.target| if |
| 1791 // it's available. | 1791 // it's available. |
| 1792 return %CompleteFunctionConstruction(func, GlobalFunction, new.target); | 1792 return %CompleteFunctionConstruction(func, GlobalFunction, new.target); |
| 1793 } | 1793 } |
| 1794 | 1794 |
| 1795 | 1795 |
| 1796 // ---------------------------------------------------------------------------- | 1796 // ---------------------------------------------------------------------------- |
| 1797 | 1797 |
| 1798 %SetCode(GlobalFunction, FunctionConstructor); | 1798 %SetCode(GlobalFunction, FunctionConstructor); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1809 | 1809 |
| 1810 // ES6 rev 33, 2015-02-12 | 1810 // ES6 rev 33, 2015-02-12 |
| 1811 // 7.4.1 GetIterator ( obj, method ) | 1811 // 7.4.1 GetIterator ( obj, method ) |
| 1812 function GetIterator(obj, method) { | 1812 function GetIterator(obj, method) { |
| 1813 if (IS_UNDEFINED(method)) { | 1813 if (IS_UNDEFINED(method)) { |
| 1814 method = obj[iteratorSymbol]; | 1814 method = obj[iteratorSymbol]; |
| 1815 } | 1815 } |
| 1816 if (!IS_CALLABLE(method)) { | 1816 if (!IS_CALLABLE(method)) { |
| 1817 throw MakeTypeError(kNotIterable, obj); | 1817 throw MakeTypeError(kNotIterable, obj); |
| 1818 } | 1818 } |
| 1819 var iterator = %_CallFunction(obj, method); | 1819 var iterator = %_Call(method, obj); |
| 1820 if (!IS_SPEC_OBJECT(iterator)) { | 1820 if (!IS_SPEC_OBJECT(iterator)) { |
| 1821 throw MakeTypeError(kNotAnIterator, iterator); | 1821 throw MakeTypeError(kNotAnIterator, iterator); |
| 1822 } | 1822 } |
| 1823 return iterator; | 1823 return iterator; |
| 1824 } | 1824 } |
| 1825 | 1825 |
| 1826 // ---------------------------------------------------------------------------- | 1826 // ---------------------------------------------------------------------------- |
| 1827 // Exports | 1827 // Exports |
| 1828 | 1828 |
| 1829 utils.Export(function(to) { | 1829 utils.Export(function(to) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1848 | 1848 |
| 1849 %InstallToContext([ | 1849 %InstallToContext([ |
| 1850 "global_eval_fun", GlobalEval, | 1850 "global_eval_fun", GlobalEval, |
| 1851 "object_value_of", ObjectValueOf, | 1851 "object_value_of", ObjectValueOf, |
| 1852 "object_to_string", ObjectToString, | 1852 "object_to_string", ObjectToString, |
| 1853 "object_get_own_property_descriptor", ObjectGetOwnPropertyDescriptor, | 1853 "object_get_own_property_descriptor", ObjectGetOwnPropertyDescriptor, |
| 1854 "to_complete_property_descriptor", ToCompletePropertyDescriptor, | 1854 "to_complete_property_descriptor", ToCompletePropertyDescriptor, |
| 1855 ]); | 1855 ]); |
| 1856 | 1856 |
| 1857 }) | 1857 }) |
| OLD | NEW |