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 1740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1751 } | 1751 } |
1752 | 1752 |
1753 if (%FunctionIsArrow(func)) { | 1753 if (%FunctionIsArrow(func)) { |
1754 return source; | 1754 return source; |
1755 } | 1755 } |
1756 | 1756 |
1757 var name = %FunctionNameShouldPrintAsAnonymous(func) | 1757 var name = %FunctionNameShouldPrintAsAnonymous(func) |
1758 ? 'anonymous' | 1758 ? 'anonymous' |
1759 : %FunctionGetName(func); | 1759 : %FunctionGetName(func); |
1760 | 1760 |
1761 // TODO(arv): Handle concise generator methods. | 1761 var isGenerator = %FunctionIsGenerator(func); |
1762 | |
1763 var head = %FunctionIsConciseMethod(func) | 1762 var head = %FunctionIsConciseMethod(func) |
1764 ? '' | 1763 ? (isGenerator ? '*' : '') |
1765 : %FunctionIsGenerator(func) ? 'function* ' : 'function '; | 1764 : (isGenerator ? 'function* ' : 'function '); |
1766 return head + name + source; | 1765 return head + name + source; |
1767 } | 1766 } |
1768 | 1767 |
1769 | 1768 |
1770 function FunctionToString() { | 1769 function FunctionToString() { |
1771 return FunctionSourceString(this); | 1770 return FunctionSourceString(this); |
1772 } | 1771 } |
1773 | 1772 |
1774 | 1773 |
1775 // ES5 15.3.4.5 | 1774 // ES5 15.3.4.5 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1906 } | 1905 } |
1907 if (!IS_SPEC_FUNCTION(method)) { | 1906 if (!IS_SPEC_FUNCTION(method)) { |
1908 throw MakeTypeError('not_iterable', [obj]); | 1907 throw MakeTypeError('not_iterable', [obj]); |
1909 } | 1908 } |
1910 var iterator = %_CallFunction(obj, method); | 1909 var iterator = %_CallFunction(obj, method); |
1911 if (!IS_SPEC_OBJECT(iterator)) { | 1910 if (!IS_SPEC_OBJECT(iterator)) { |
1912 throw MakeTypeError('not_an_iterator', [iterator]); | 1911 throw MakeTypeError('not_an_iterator', [iterator]); |
1913 } | 1912 } |
1914 return iterator; | 1913 return iterator; |
1915 } | 1914 } |
OLD | NEW |