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 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 // ECMA-262, section 9.5, page 34 | 552 // ECMA-262, section 9.5, page 34 |
553 function ToInt32(x) { | 553 function ToInt32(x) { |
554 if (%_IsSmi(x)) return x; | 554 if (%_IsSmi(x)) return x; |
555 return %NumberToJSInt32(ToNumber(x)); | 555 return %NumberToJSInt32(ToNumber(x)); |
556 } | 556 } |
557 | 557 |
558 | 558 |
559 // ES5, section 9.12 | 559 // ES5, section 9.12 |
560 function SameValue(x, y) { | 560 function SameValue(x, y) { |
561 if (typeof x != typeof y) return false; | 561 if (typeof x != typeof y) return false; |
562 if (IS_NULL_OR_UNDEFINED(x)) return true; | |
563 if (IS_NUMBER(x)) { | 562 if (IS_NUMBER(x)) { |
564 if (NUMBER_IS_NAN(x) && NUMBER_IS_NAN(y)) return true; | 563 if (NUMBER_IS_NAN(x) && NUMBER_IS_NAN(y)) return true; |
565 // x is +0 and y is -0 or vice versa. | 564 // x is +0 and y is -0 or vice versa. |
566 if (x === 0 && y === 0 && (1 / x) != (1 / y)) { | 565 if (x === 0 && y === 0 && (1 / x) != (1 / y)) { |
567 return false; | 566 return false; |
568 } | 567 } |
569 return x == y; | 568 return x === y; |
570 } | 569 } |
571 if (IS_STRING(x)) return %StringEquals(x, y); | 570 return x === y |
572 if (IS_BOOLEAN(x)) return y == x; | |
573 | |
574 return %_ObjectEquals(x, y); | |
575 } | 571 } |
576 | 572 |
577 | 573 |
578 /* --------------------------------- | 574 /* --------------------------------- |
579 - - - U t i l i t i e s - - - | 575 - - - U t i l i t i e s - - - |
580 --------------------------------- | 576 --------------------------------- |
581 */ | 577 */ |
582 | 578 |
583 // Returns if the given x is a primitive value - not an object or a | 579 // Returns if the given x is a primitive value - not an object or a |
584 // function. | 580 // function. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 throw %MakeTypeError('cannot_convert_to_primitive', []); | 620 throw %MakeTypeError('cannot_convert_to_primitive', []); |
625 } | 621 } |
626 | 622 |
627 | 623 |
628 // NOTE: Setting the prototype for Array must take place as early as | 624 // NOTE: Setting the prototype for Array must take place as early as |
629 // possible due to code generation for array literals. When | 625 // possible due to code generation for array literals. When |
630 // generating code for a array literal a boilerplate array is created | 626 // generating code for a array literal a boilerplate array is created |
631 // that is cloned when running the code. It is essiential that the | 627 // that is cloned when running the code. It is essiential that the |
632 // boilerplate gets the right prototype. | 628 // boilerplate gets the right prototype. |
633 %FunctionSetPrototype($Array, new $Array(0)); | 629 %FunctionSetPrototype($Array, new $Array(0)); |
OLD | NEW |