OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 files contains runtime support implemented in JavaScript. | 5 // This files contains runtime support implemented in JavaScript. |
6 | 6 |
7 // CAUTION: Some of the functions specified in this file are called | 7 // CAUTION: Some of the functions specified in this file are called |
8 // directly from compiled code. These are the functions with names in | 8 // directly from compiled code. These are the functions with names in |
9 // ALL CAPS. The compiled code passes the first argument in 'this'. | 9 // ALL CAPS. The compiled code passes the first argument in 'this'. |
10 | 10 |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 return %ToNumber(this); | 461 return %ToNumber(this); |
462 } | 462 } |
463 | 463 |
464 | 464 |
465 // Convert the receiver to a string - forward to ToString. | 465 // Convert the receiver to a string - forward to ToString. |
466 function TO_STRING() { | 466 function TO_STRING() { |
467 return %ToString(this); | 467 return %ToString(this); |
468 } | 468 } |
469 | 469 |
470 | 470 |
| 471 // Convert the receiver to a string or symbol - forward to ToName. |
| 472 function TO_NAME() { |
| 473 return %ToName(this); |
| 474 } |
| 475 |
| 476 |
471 /* ------------------------------------- | 477 /* ------------------------------------- |
472 - - - C o n v e r s i o n s - - - | 478 - - - C o n v e r s i o n s - - - |
473 ------------------------------------- | 479 ------------------------------------- |
474 */ | 480 */ |
475 | 481 |
476 // ECMA-262, section 9.1, page 30. Use null/undefined for no hint, | 482 // ECMA-262, section 9.1, page 30. Use null/undefined for no hint, |
477 // (1) for number hint, and (2) for string hint. | 483 // (1) for number hint, and (2) for string hint. |
478 function ToPrimitive(x, hint) { | 484 function ToPrimitive(x, hint) { |
479 // Fast case check. | 485 // Fast case check. |
480 if (IS_STRING(x)) return x; | 486 if (IS_STRING(x)) return x; |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 return i; | 674 return i; |
669 } | 675 } |
670 | 676 |
671 | 677 |
672 // NOTE: Setting the prototype for Array must take place as early as | 678 // NOTE: Setting the prototype for Array must take place as early as |
673 // possible due to code generation for array literals. When | 679 // possible due to code generation for array literals. When |
674 // generating code for a array literal a boilerplate array is created | 680 // generating code for a array literal a boilerplate array is created |
675 // that is cloned when running the code. It is essential that the | 681 // that is cloned when running the code. It is essential that the |
676 // boilerplate gets the right prototype. | 682 // boilerplate gets the right prototype. |
677 %FunctionSetPrototype($Array, new $Array(0)); | 683 %FunctionSetPrototype($Array, new $Array(0)); |
OLD | NEW |