| 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 1720 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1731  |  1731  | 
|  1732   %SetInlineBuiltinFlag(NumberIsNaN); |  1732   %SetInlineBuiltinFlag(NumberIsNaN); | 
|  1733 } |  1733 } | 
|  1734  |  1734  | 
|  1735 SetUpNumber(); |  1735 SetUpNumber(); | 
|  1736  |  1736  | 
|  1737  |  1737  | 
|  1738 // ---------------------------------------------------------------------------- |  1738 // ---------------------------------------------------------------------------- | 
|  1739 // Function |  1739 // Function | 
|  1740  |  1740  | 
 |  1741 function NativeCodeFunctionSourceString(func) { | 
 |  1742   var name = %FunctionGetName(func); | 
 |  1743   if (name) { | 
 |  1744     // Mimic what KJS does. | 
 |  1745     return 'function ' + name + '() { [native code] }'; | 
 |  1746   } | 
 |  1747  | 
 |  1748   return 'function () { [native code] }'; | 
 |  1749 } | 
 |  1750  | 
|  1741 function FunctionSourceString(func) { |  1751 function FunctionSourceString(func) { | 
|  1742   while (%IsJSFunctionProxy(func)) { |  1752   while (%IsJSFunctionProxy(func)) { | 
|  1743     func = %GetCallTrap(func); |  1753     func = %GetCallTrap(func); | 
|  1744   } |  1754   } | 
|  1745  |  1755  | 
|  1746   if (!IS_FUNCTION(func)) { |  1756   if (!IS_FUNCTION(func)) { | 
|  1747     throw MakeTypeError(kNotGeneric, 'Function.prototype.toString'); |  1757     throw MakeTypeError(kNotGeneric, 'Function.prototype.toString'); | 
|  1748   } |  1758   } | 
|  1749  |  1759  | 
 |  1760   if (%FunctionIsBuiltin(func)) { | 
 |  1761     return NativeCodeFunctionSourceString(func); | 
 |  1762   } | 
 |  1763  | 
|  1750   var classSource = %ClassGetSourceCode(func); |  1764   var classSource = %ClassGetSourceCode(func); | 
|  1751   if (IS_STRING(classSource)) { |  1765   if (IS_STRING(classSource)) { | 
|  1752     return classSource; |  1766     return classSource; | 
|  1753   } |  1767   } | 
|  1754  |  1768  | 
|  1755   var source = %FunctionGetSourceCode(func); |  1769   var source = %FunctionGetSourceCode(func); | 
|  1756   if (!IS_STRING(source) || %FunctionIsBuiltin(func)) { |  1770   if (!IS_STRING(source)) { | 
|  1757     var name = %FunctionGetName(func); |  1771     return NativeCodeFunctionSourceString(func); | 
|  1758     if (name) { |  | 
|  1759       // Mimic what KJS does. |  | 
|  1760       return 'function ' + name + '() { [native code] }'; |  | 
|  1761     } else { |  | 
|  1762       return 'function () { [native code] }'; |  | 
|  1763     } |  | 
|  1764   } |  1772   } | 
|  1765  |  1773  | 
|  1766   if (%FunctionIsArrow(func)) { |  1774   if (%FunctionIsArrow(func)) { | 
|  1767     return source; |  1775     return source; | 
|  1768   } |  1776   } | 
|  1769  |  1777  | 
|  1770   var name = %FunctionNameShouldPrintAsAnonymous(func) |  1778   var name = %FunctionNameShouldPrintAsAnonymous(func) | 
|  1771       ? 'anonymous' |  1779       ? 'anonymous' | 
|  1772       : %FunctionGetName(func); |  1780       : %FunctionGetName(func); | 
|  1773  |  1781  | 
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1905   } |  1913   } | 
|  1906   if (!IS_SPEC_FUNCTION(method)) { |  1914   if (!IS_SPEC_FUNCTION(method)) { | 
|  1907     throw MakeTypeError(kNotIterable, obj); |  1915     throw MakeTypeError(kNotIterable, obj); | 
|  1908   } |  1916   } | 
|  1909   var iterator = %_CallFunction(obj, method); |  1917   var iterator = %_CallFunction(obj, method); | 
|  1910   if (!IS_SPEC_OBJECT(iterator)) { |  1918   if (!IS_SPEC_OBJECT(iterator)) { | 
|  1911     throw MakeTypeError(kNotAnIterator, iterator); |  1919     throw MakeTypeError(kNotAnIterator, iterator); | 
|  1912   } |  1920   } | 
|  1913   return iterator; |  1921   return iterator; | 
|  1914 } |  1922 } | 
| OLD | NEW |