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

Side by Side Diff: src/v8natives.js

Issue 701093003: Correctly compute line numbers in functions from the function constructor. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 1 month 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
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 1828 matching lines...) Expand 10 before | Expand all | Expand 10 after
1839 } 1839 }
1840 // If the formal parameters string include ) - an illegal 1840 // If the formal parameters string include ) - an illegal
1841 // character - it may make the combined function expression 1841 // character - it may make the combined function expression
1842 // compile. We avoid this problem by checking for this early on. 1842 // compile. We avoid this problem by checking for this early on.
1843 if (%_CallFunction(p, ')', StringIndexOfJS) != -1) { 1843 if (%_CallFunction(p, ')', StringIndexOfJS) != -1) {
1844 throw MakeSyntaxError('paren_in_arg_string', []); 1844 throw MakeSyntaxError('paren_in_arg_string', []);
1845 } 1845 }
1846 // If the formal parameters include an unbalanced block comment, the 1846 // If the formal parameters include an unbalanced block comment, the
1847 // function must be rejected. Since JavaScript does not allow nested 1847 // function must be rejected. Since JavaScript does not allow nested
1848 // comments we can include a trailing block comment to catch this. 1848 // comments we can include a trailing block comment to catch this.
1849 p += '\n/' + '**/'; 1849 p += '/**/';
1850 } 1850 }
1851 var body = (n > 0) ? ToString(arguments[n - 1]) : ''; 1851 var body = (n > 0) ? ToString(arguments[n - 1]) : '';
1852 return '(' + function_token + '(' + p + ') {\n' + body + '\n})'; 1852 return '(' + function_token + '(' + p + ') {\n' + body + '\n})';
1853 } 1853 }
1854 1854
1855 1855
1856 function FunctionConstructor(arg1) { // length == 1 1856 function FunctionConstructor(arg1) { // length == 1
1857 var source = NewFunctionString(arguments, 'function'); 1857 var source = NewFunctionString(arguments, 'function');
1858 var global_proxy = %GlobalProxy(global); 1858 var global_proxy = %GlobalProxy(global);
1859 // Compile the string in the constructor and not a helper so that errors 1859 // Compile the string in the constructor and not a helper so that errors
1860 // appear to come from here. 1860 // appear to come from here.
1861 var f = %_CallFunction(global_proxy, %CompileString(source, true)); 1861 var f = %_CallFunction(global_proxy, %CompileString(source, true));
1862 %FunctionMarkNameShouldPrintAsAnonymous(f);
aandrey 2014/11/10 20:38:18 you should also update src/generator.js
Yang 2014/11/11 09:51:55 Thanks for catching this!
1863 return f; 1862 return f;
1864 } 1863 }
1865 1864
1866 1865
1867 // ---------------------------------------------------------------------------- 1866 // ----------------------------------------------------------------------------
1868 1867
1869 function SetUpFunction() { 1868 function SetUpFunction() {
1870 %CheckIsBootstrapping(); 1869 %CheckIsBootstrapping();
1871 1870
1872 %SetCode($Function, FunctionConstructor); 1871 %SetCode($Function, FunctionConstructor);
(...skipping 29 matching lines...) Expand all
1902 } 1901 }
1903 if (!IS_SPEC_FUNCTION(method)) { 1902 if (!IS_SPEC_FUNCTION(method)) {
1904 throw MakeTypeError('not_iterable', [obj]); 1903 throw MakeTypeError('not_iterable', [obj]);
1905 } 1904 }
1906 var iterator = %_CallFunction(obj, method); 1905 var iterator = %_CallFunction(obj, method);
1907 if (!IS_SPEC_OBJECT(iterator)) { 1906 if (!IS_SPEC_OBJECT(iterator)) {
1908 throw MakeTypeError('not_an_iterator', [iterator]); 1907 throw MakeTypeError('not_an_iterator', [iterator]);
1909 } 1908 }
1910 return iterator; 1909 return iterator;
1911 } 1910 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698