| 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 // 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 |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 } | 532 } |
| 533 | 533 |
| 534 function NonNumberToNumber(x) { | 534 function NonNumberToNumber(x) { |
| 535 if (IS_STRING(x)) { | 535 if (IS_STRING(x)) { |
| 536 return %_HasCachedArrayIndex(x) ? %_GetCachedArrayIndex(x) | 536 return %_HasCachedArrayIndex(x) ? %_GetCachedArrayIndex(x) |
| 537 : %StringToNumber(x); | 537 : %StringToNumber(x); |
| 538 } | 538 } |
| 539 if (IS_BOOLEAN(x)) return x ? 1 : 0; | 539 if (IS_BOOLEAN(x)) return x ? 1 : 0; |
| 540 if (IS_UNDEFINED(x)) return NAN; | 540 if (IS_UNDEFINED(x)) return NAN; |
| 541 if (IS_SYMBOL(x)) return NAN; | 541 if (IS_SYMBOL(x)) return NAN; |
| 542 if (IS_FLOAT32x4(x)) return NaN; |
| 543 if (IS_INT32x4(x)) return NaN; |
| 542 return (IS_NULL(x)) ? 0 : ToNumber(%DefaultNumber(x)); | 544 return (IS_NULL(x)) ? 0 : ToNumber(%DefaultNumber(x)); |
| 543 } | 545 } |
| 544 | 546 |
| 545 | 547 |
| 546 // ECMA-262, section 9.8, page 35. | 548 // ECMA-262, section 9.8, page 35. |
| 547 function ToString(x) { | 549 function ToString(x) { |
| 548 if (IS_STRING(x)) return x; | 550 if (IS_STRING(x)) return x; |
| 549 if (IS_NUMBER(x)) return %_NumberToString(x); | 551 if (IS_NUMBER(x)) return %_NumberToString(x); |
| 550 if (IS_BOOLEAN(x)) return x ? 'true' : 'false'; | 552 if (IS_BOOLEAN(x)) return x ? 'true' : 'false'; |
| 551 if (IS_UNDEFINED(x)) return 'undefined'; | 553 if (IS_UNDEFINED(x)) return 'undefined'; |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 return i; | 671 return i; |
| 670 } | 672 } |
| 671 | 673 |
| 672 | 674 |
| 673 // NOTE: Setting the prototype for Array must take place as early as | 675 // NOTE: Setting the prototype for Array must take place as early as |
| 674 // possible due to code generation for array literals. When | 676 // possible due to code generation for array literals. When |
| 675 // generating code for a array literal a boilerplate array is created | 677 // generating code for a array literal a boilerplate array is created |
| 676 // that is cloned when running the code. It is essential that the | 678 // that is cloned when running the code. It is essential that the |
| 677 // boilerplate gets the right prototype. | 679 // boilerplate gets the right prototype. |
| 678 %FunctionSetPrototype($Array, new $Array(0)); | 680 %FunctionSetPrototype($Array, new $Array(0)); |
| OLD | NEW |