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

Side by Side Diff: src/v8natives.js

Issue 12687002: Restore Function()'s expected string representation. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 9 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 | « no previous file | test/mjsunit/regress/regress-2470.js » ('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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1692 matching lines...) Expand 10 before | Expand all | Expand 10 after
1703 // If the formal parameters string include ) - an illegal 1703 // If the formal parameters string include ) - an illegal
1704 // character - it may make the combined function expression 1704 // character - it may make the combined function expression
1705 // compile. We avoid this problem by checking for this early on. 1705 // compile. We avoid this problem by checking for this early on.
1706 if (p.indexOf(')') != -1) throw MakeSyntaxError('unable_to_parse',[]); 1706 if (p.indexOf(')') != -1) throw MakeSyntaxError('unable_to_parse',[]);
1707 // If the formal parameters include an unbalanced block comment, the 1707 // If the formal parameters include an unbalanced block comment, the
1708 // function must be rejected. Since JavaScript does not allow nested 1708 // function must be rejected. Since JavaScript does not allow nested
1709 // comments we can include a trailing block comment to catch this. 1709 // comments we can include a trailing block comment to catch this.
1710 p += '\n/' + '**/'; 1710 p += '\n/' + '**/';
1711 } 1711 }
1712 var body = (n > 0) ? ToString(%_Arguments(n - 1)) : ''; 1712 var body = (n > 0) ? ToString(%_Arguments(n - 1)) : '';
1713 var source = '(function(\n' + p + '\n) {\n' + body + '\n})'; 1713 var source = '(function(' + p + ') {\n' + body + '\n})';
1714 1714
1715 // The call to SetNewFunctionAttributes will ensure the prototype 1715 // The call to SetNewFunctionAttributes will ensure the prototype
1716 // property of the resulting function is enumerable (ECMA262, 15.3.5.2). 1716 // property of the resulting function is enumerable (ECMA262, 15.3.5.2).
1717 var global_receiver = %GlobalReceiver(global); 1717 var global_receiver = %GlobalReceiver(global);
1718 var f = %_CallFunction(global_receiver, %CompileString(source, true)); 1718 var f = %_CallFunction(global_receiver, %CompileString(source, true));
1719 1719
1720 %FunctionMarkNameShouldPrintAsAnonymous(f); 1720 %FunctionMarkNameShouldPrintAsAnonymous(f);
1721 return %SetNewFunctionAttributes(f); 1721 return %SetNewFunctionAttributes(f);
1722 } 1722 }
1723 1723
1724 %SetCode($Function, NewFunction); 1724 %SetCode($Function, NewFunction);
1725 1725
1726 // ---------------------------------------------------------------------------- 1726 // ----------------------------------------------------------------------------
1727 1727
1728 function SetUpFunction() { 1728 function SetUpFunction() {
1729 %CheckIsBootstrapping(); 1729 %CheckIsBootstrapping();
1730 InstallFunctions($Function.prototype, DONT_ENUM, $Array( 1730 InstallFunctions($Function.prototype, DONT_ENUM, $Array(
1731 "bind", FunctionBind, 1731 "bind", FunctionBind,
1732 "toString", FunctionToString 1732 "toString", FunctionToString
1733 )); 1733 ));
1734 } 1734 }
1735 1735
1736 SetUpFunction(); 1736 SetUpFunction();
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-2470.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698