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

Side by Side Diff: src/v8natives.js

Issue 7583037: Merge r8858 to the 3.4 branch. (Closed) Base URL: https://v8.googlecode.com/svn/branches/3.4
Patch Set: Created 9 years, 4 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 | « src/runtime.cc ('k') | src/version.cc » ('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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2011 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
11 // with the distribution. 11 // with the distribution.
(...skipping 1396 matching lines...) Expand 10 before | Expand all | Expand 10 after
1408 if (!IS_STRING(source) || %FunctionIsBuiltin(func)) { 1408 if (!IS_STRING(source) || %FunctionIsBuiltin(func)) {
1409 var name = %FunctionGetName(func); 1409 var name = %FunctionGetName(func);
1410 if (name) { 1410 if (name) {
1411 // Mimic what KJS does. 1411 // Mimic what KJS does.
1412 return 'function ' + name + '() { [native code] }'; 1412 return 'function ' + name + '() { [native code] }';
1413 } else { 1413 } else {
1414 return 'function () { [native code] }'; 1414 return 'function () { [native code] }';
1415 } 1415 }
1416 } 1416 }
1417 1417
1418 var name = %FunctionGetName(func); 1418 var name = %FunctionNameShouldPrintAsAnonymous(func)
1419 ? 'anonymous'
1420 : %FunctionGetName(func);
1419 return 'function ' + name + source; 1421 return 'function ' + name + source;
1420 } 1422 }
1421 1423
1422 1424
1423 function FunctionToString() { 1425 function FunctionToString() {
1424 return FunctionSourceString(this); 1426 return FunctionSourceString(this);
1425 } 1427 }
1426 1428
1427 1429
1428 // ES5 15.3.4.5 1430 // ES5 15.3.4.5
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1503 // character - it may make the combined function expression 1505 // character - it may make the combined function expression
1504 // compile. We avoid this problem by checking for this early on. 1506 // compile. We avoid this problem by checking for this early on.
1505 if (p.indexOf(')') != -1) throw MakeSyntaxError('unable_to_parse',[]); 1507 if (p.indexOf(')') != -1) throw MakeSyntaxError('unable_to_parse',[]);
1506 } 1508 }
1507 var body = (n > 0) ? ToString(%_Arguments(n - 1)) : ''; 1509 var body = (n > 0) ? ToString(%_Arguments(n - 1)) : '';
1508 var source = '(function(' + p + ') {\n' + body + '\n})'; 1510 var source = '(function(' + p + ') {\n' + body + '\n})';
1509 1511
1510 // The call to SetNewFunctionAttributes will ensure the prototype 1512 // The call to SetNewFunctionAttributes will ensure the prototype
1511 // property of the resulting function is enumerable (ECMA262, 15.3.5.2). 1513 // property of the resulting function is enumerable (ECMA262, 15.3.5.2).
1512 var f = %CompileString(source)(); 1514 var f = %CompileString(source)();
1513 %FunctionSetName(f, "anonymous"); 1515 %FunctionMarkNameShouldPrintAsAnonymous(f);
1514 return %SetNewFunctionAttributes(f); 1516 return %SetNewFunctionAttributes(f);
1515 } 1517 }
1516 1518
1517 %SetCode($Function, NewFunction); 1519 %SetCode($Function, NewFunction);
1518 1520
1519 // ---------------------------------------------------------------------------- 1521 // ----------------------------------------------------------------------------
1520 1522
1521 function SetupFunction() { 1523 function SetupFunction() {
1522 InstallFunctions($Function.prototype, DONT_ENUM, $Array( 1524 InstallFunctions($Function.prototype, DONT_ENUM, $Array(
1523 "bind", FunctionBind, 1525 "bind", FunctionBind,
1524 "toString", FunctionToString 1526 "toString", FunctionToString
1525 )); 1527 ));
1526 } 1528 }
1527 1529
1528 SetupFunction(); 1530 SetupFunction();
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | src/version.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698