| 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 1721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1732 | 1732 |
| 1733 function FunctionSourceString(func) { | 1733 function FunctionSourceString(func) { |
| 1734 while (%IsJSFunctionProxy(func)) { | 1734 while (%IsJSFunctionProxy(func)) { |
| 1735 func = %GetCallTrap(func); | 1735 func = %GetCallTrap(func); |
| 1736 } | 1736 } |
| 1737 | 1737 |
| 1738 if (!IS_FUNCTION(func)) { | 1738 if (!IS_FUNCTION(func)) { |
| 1739 throw new $TypeError('Function.prototype.toString is not generic'); | 1739 throw new $TypeError('Function.prototype.toString is not generic'); |
| 1740 } | 1740 } |
| 1741 | 1741 |
| 1742 var classSource = %ClassGetSourceCode(func); |
| 1743 if (IS_STRING(classSource)) { |
| 1744 return classSource; |
| 1745 } |
| 1746 |
| 1742 var source = %FunctionGetSourceCode(func); | 1747 var source = %FunctionGetSourceCode(func); |
| 1743 if (!IS_STRING(source) || %FunctionIsBuiltin(func)) { | 1748 if (!IS_STRING(source) || %FunctionIsBuiltin(func)) { |
| 1744 var name = %FunctionGetName(func); | 1749 var name = %FunctionGetName(func); |
| 1745 if (name) { | 1750 if (name) { |
| 1746 // Mimic what KJS does. | 1751 // Mimic what KJS does. |
| 1747 return 'function ' + name + '() { [native code] }'; | 1752 return 'function ' + name + '() { [native code] }'; |
| 1748 } else { | 1753 } else { |
| 1749 return 'function () { [native code] }'; | 1754 return 'function () { [native code] }'; |
| 1750 } | 1755 } |
| 1751 } | 1756 } |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1903 } | 1908 } |
| 1904 if (!IS_SPEC_FUNCTION(method)) { | 1909 if (!IS_SPEC_FUNCTION(method)) { |
| 1905 throw MakeTypeError('not_iterable', [obj]); | 1910 throw MakeTypeError('not_iterable', [obj]); |
| 1906 } | 1911 } |
| 1907 var iterator = %_CallFunction(obj, method); | 1912 var iterator = %_CallFunction(obj, method); |
| 1908 if (!IS_SPEC_OBJECT(iterator)) { | 1913 if (!IS_SPEC_OBJECT(iterator)) { |
| 1909 throw MakeTypeError('not_an_iterator', [iterator]); | 1914 throw MakeTypeError('not_an_iterator', [iterator]); |
| 1910 } | 1915 } |
| 1911 return iterator; | 1916 return iterator; |
| 1912 } | 1917 } |
| OLD | NEW |