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 | |
477 /* ------------------------------------- | 471 /* ------------------------------------- |
478 - - - C o n v e r s i o n s - - - | 472 - - - C o n v e r s i o n s - - - |
479 ------------------------------------- | 473 ------------------------------------- |
480 */ | 474 */ |
481 | 475 |
482 // ECMA-262, section 9.1, page 30. Use null/undefined for no hint, | 476 // ECMA-262, section 9.1, page 30. Use null/undefined for no hint, |
483 // (1) for number hint, and (2) for string hint. | 477 // (1) for number hint, and (2) for string hint. |
484 function ToPrimitive(x, hint) { | 478 function ToPrimitive(x, hint) { |
485 // Fast case check. | 479 // Fast case check. |
486 if (IS_STRING(x)) return x; | 480 if (IS_STRING(x)) return x; |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 return i; | 668 return i; |
675 } | 669 } |
676 | 670 |
677 | 671 |
678 // NOTE: Setting the prototype for Array must take place as early as | 672 // NOTE: Setting the prototype for Array must take place as early as |
679 // possible due to code generation for array literals. When | 673 // possible due to code generation for array literals. When |
680 // generating code for a array literal a boilerplate array is created | 674 // generating code for a array literal a boilerplate array is created |
681 // that is cloned when running the code. It is essential that the | 675 // that is cloned when running the code. It is essential that the |
682 // boilerplate gets the right prototype. | 676 // boilerplate gets the right prototype. |
683 %FunctionSetPrototype($Array, new $Array(0)); | 677 %FunctionSetPrototype($Array, new $Array(0)); |
OLD | NEW |