Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(645)

Side by Side Diff: src/v8natives.js

Issue 382893003: Implement basic code generation for arrow functions (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Test failures fixed, some minor corrections Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/runtime.cc ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1730 matching lines...) Expand 10 before | Expand all | Expand 10 after
1741 if (!IS_STRING(source) || %FunctionIsBuiltin(func)) { 1741 if (!IS_STRING(source) || %FunctionIsBuiltin(func)) {
1742 var name = %FunctionGetName(func); 1742 var name = %FunctionGetName(func);
1743 if (name) { 1743 if (name) {
1744 // Mimic what KJS does. 1744 // Mimic what KJS does.
1745 return 'function ' + name + '() { [native code] }'; 1745 return 'function ' + name + '() { [native code] }';
1746 } else { 1746 } else {
1747 return 'function () { [native code] }'; 1747 return 'function () { [native code] }';
1748 } 1748 }
1749 } 1749 }
1750 1750
1751 if (%FunctionIsArrow(func)) {
1752 return source;
1753 }
1754
1751 var name = %FunctionNameShouldPrintAsAnonymous(func) 1755 var name = %FunctionNameShouldPrintAsAnonymous(func)
1752 ? 'anonymous' 1756 ? 'anonymous'
1753 : %FunctionGetName(func); 1757 : %FunctionGetName(func);
1754 var head = %FunctionIsGenerator(func) ? 'function* ' : 'function '; 1758 var head = %FunctionIsGenerator(func) ? 'function* ' : 'function ';
1755 return head + name + source; 1759 return head + name + source;
1756 } 1760 }
1757 1761
1758 1762
1759 function FunctionToString() { 1763 function FunctionToString() {
1760 return FunctionSourceString(this); 1764 return FunctionSourceString(this);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1865 %SetCode($Function, FunctionConstructor); 1869 %SetCode($Function, FunctionConstructor);
1866 %AddNamedProperty($Function.prototype, "constructor", $Function, DONT_ENUM); 1870 %AddNamedProperty($Function.prototype, "constructor", $Function, DONT_ENUM);
1867 1871
1868 InstallFunctions($Function.prototype, DONT_ENUM, $Array( 1872 InstallFunctions($Function.prototype, DONT_ENUM, $Array(
1869 "bind", FunctionBind, 1873 "bind", FunctionBind,
1870 "toString", FunctionToString 1874 "toString", FunctionToString
1871 )); 1875 ));
1872 } 1876 }
1873 1877
1874 SetUpFunction(); 1878 SetUpFunction();
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698