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

Unified Diff: src/v8natives.js

Issue 4248: Make sure that the body of the function created by calling Function is... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 12 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime.cc ('k') | test/mjsunit/function.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/v8natives.js
===================================================================
--- src/v8natives.js (revision 369)
+++ src/v8natives.js (working copy)
@@ -201,7 +201,7 @@
%AddProperty(global, "eval", function(x) {
if (!IS_STRING(x)) return x;
- var f = %CompileString(x, true);
+ var f = %CompileString(x, 0, true);
if (!IS_FUNCTION(f)) return f;
return f.call(%EvalReceiver(this));
@@ -212,7 +212,7 @@
%AddProperty(global, "execScript", function(expr, lang) {
// NOTE: We don't care about the character casing.
if (!lang || /javascript/i.test(lang)) {
- var f = %CompileString(ToString(expr), false);
+ var f = %CompileString(ToString(expr), 0, false);
f.call(global);
}
return null;
@@ -406,11 +406,13 @@
if (p.indexOf(')') != -1) throw MakeSyntaxError('unable_to_parse',[]);
}
var body = (n > 0) ? ToString(%_Arguments(n - 1)) : '';
- var source = '(function anonymous(' + p + ') { ' + body + ' })';
+ var source = '(function(' + p + ') {\n' + body + '\n})';
// The call to SetNewFunctionAttributes will ensure the prototype
// property of the resulting function is enumerable (ECMA262, 15.3.5.2).
- return %SetNewFunctionAttributes(%CompileString(source, false)());
+ var f = %CompileString(source, -1, false)();
+ %FunctionSetName(f, "anonymous");
+ return %SetNewFunctionAttributes(f);
};
%SetCode($Function, NewFunction);
« no previous file with comments | « src/runtime.cc ('k') | test/mjsunit/function.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698