Chromium Code Reviews| Index: src/v8natives.js |
| diff --git a/src/v8natives.js b/src/v8natives.js |
| index f295c3a6de37d0f4fdc4d3aab65a854784d1e035..4f358372fe767c642f9de05d10c8f5f5bf4f3745 100644 |
| --- a/src/v8natives.js |
| +++ b/src/v8natives.js |
| @@ -174,7 +174,7 @@ function GlobalEval(x) { |
| 'be the global object from which eval originated'); |
| } |
| - var f = %CompileString(x); |
| + var f = %CompileString(x, false); |
| if (!IS_FUNCTION(f)) return f; |
| return %_CallFunction(global_receiver, f); |
| @@ -1704,14 +1704,18 @@ function NewFunction(arg1) { // length == 1 |
| // character - it may make the combined function expression |
| // compile. We avoid this problem by checking for this early on. |
| if (p.indexOf(')') != -1) throw MakeSyntaxError('unable_to_parse',[]); |
| + // If the formal parameters include an unbalanced block comment, the |
| + // function must be rejected. Since JavaScript does not allow nested |
| + // comments we can include a trailing block comment to catch this. |
| + p += '\n\x2f\x2a*/'; |
|
rossberg
2013/03/07 15:08:18
It would be more readable if you simply wrote '\n/
Michael Starzinger
2013/03/07 15:37:36
Done. Yeah, you should definitely do that! ;)
|
| } |
| var body = (n > 0) ? ToString(%_Arguments(n - 1)) : ''; |
| - var source = '(function(' + p + ') {\n' + body + '\n})'; |
| + var source = '(function(\n' + p + '\n){\n' + body + '\n})'; |
| // The call to SetNewFunctionAttributes will ensure the prototype |
| // property of the resulting function is enumerable (ECMA262, 15.3.5.2). |
| var global_receiver = %GlobalReceiver(global); |
| - var f = %_CallFunction(global_receiver, %CompileString(source)); |
| + var f = %_CallFunction(global_receiver, %CompileString(source, true)); |
| %FunctionMarkNameShouldPrintAsAnonymous(f); |
| return %SetNewFunctionAttributes(f); |