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

Side by Side Diff: src/v8natives.js

Issue 10916114: Fix binding in new Function(). (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 years, 3 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/new-function.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 1636 matching lines...) Expand 10 before | Expand all | Expand 10 after
1647 // If the formal parameters string include ) - an illegal 1647 // If the formal parameters string include ) - an illegal
1648 // character - it may make the combined function expression 1648 // character - it may make the combined function expression
1649 // compile. We avoid this problem by checking for this early on. 1649 // compile. We avoid this problem by checking for this early on.
1650 if (p.indexOf(')') != -1) throw MakeSyntaxError('unable_to_parse',[]); 1650 if (p.indexOf(')') != -1) throw MakeSyntaxError('unable_to_parse',[]);
1651 } 1651 }
1652 var body = (n > 0) ? ToString(%_Arguments(n - 1)) : ''; 1652 var body = (n > 0) ? ToString(%_Arguments(n - 1)) : '';
1653 var source = '(function(' + p + ') {\n' + body + '\n})'; 1653 var source = '(function(' + p + ') {\n' + body + '\n})';
1654 1654
1655 // The call to SetNewFunctionAttributes will ensure the prototype 1655 // The call to SetNewFunctionAttributes will ensure the prototype
1656 // property of the resulting function is enumerable (ECMA262, 15.3.5.2). 1656 // property of the resulting function is enumerable (ECMA262, 15.3.5.2).
1657 var f = %CompileString(source)(); 1657 var global_receiver = %GlobalReceiver(global);
1658 var f = %_CallFunction(global_receiver, %CompileString(source));
1659
1658 %FunctionMarkNameShouldPrintAsAnonymous(f); 1660 %FunctionMarkNameShouldPrintAsAnonymous(f);
1659 return %SetNewFunctionAttributes(f); 1661 return %SetNewFunctionAttributes(f);
1660 } 1662 }
1661 1663
1662 %SetCode($Function, NewFunction); 1664 %SetCode($Function, NewFunction);
1663 1665
1664 // ---------------------------------------------------------------------------- 1666 // ----------------------------------------------------------------------------
1665 1667
1666 function SetUpFunction() { 1668 function SetUpFunction() {
1667 %CheckIsBootstrapping(); 1669 %CheckIsBootstrapping();
1668 InstallFunctions($Function.prototype, DONT_ENUM, $Array( 1670 InstallFunctions($Function.prototype, DONT_ENUM, $Array(
1669 "bind", FunctionBind, 1671 "bind", FunctionBind,
1670 "toString", FunctionToString 1672 "toString", FunctionToString
1671 )); 1673 ));
1672 } 1674 }
1673 1675
1674 SetUpFunction(); 1676 SetUpFunction();
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/new-function.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698