| 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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 return i; | 683 return i; |
| 678 } | 684 } |
| 679 | 685 |
| 680 | 686 |
| 681 // NOTE: Setting the prototype for Array must take place as early as | 687 // NOTE: Setting the prototype for Array must take place as early as |
| 682 // possible due to code generation for array literals. When | 688 // possible due to code generation for array literals. When |
| 683 // generating code for a array literal a boilerplate array is created | 689 // generating code for a array literal a boilerplate array is created |
| 684 // that is cloned when running the code. It is essential that the | 690 // that is cloned when running the code. It is essential that the |
| 685 // boilerplate gets the right prototype. | 691 // boilerplate gets the right prototype. |
| 686 %FunctionSetPrototype($Array, new $Array(0)); | 692 %FunctionSetPrototype($Array, new $Array(0)); |
| OLD | NEW |