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 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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; | 562 if (IS_NULL_OR_UNDEFINED(x)) return true; |
563 if (IS_NUMBER(x)) { | 563 if (IS_NUMBER(x)) { |
564 if (NUMBER_IS_NAN(x) && NUMBER_IS_NAN(y)) return true; | 564 if (NUMBER_IS_NAN(x) && NUMBER_IS_NAN(y)) return true; |
565 // x is +0 and y is -0 or vice versa | 565 // x is +0 and y is -0 or vice versa. |
566 if (x === 0 && y === 0 && !%_IsSmi(x) && !%_IsSmi(y) && | 566 if (x === 0 && y === 0 && (1 / x) != (1 / y)) { |
567 ((1 / x < 0 && 1 / y > 0) || (1 / x > 0 && 1 / y < 0))) { | |
568 return false; | 567 return false; |
569 } | 568 } |
570 return x == y; | 569 return x == y; |
571 } | 570 } |
572 if (IS_STRING(x)) return %StringEquals(x, y); | 571 if (IS_STRING(x)) return %StringEquals(x, y); |
573 if (IS_BOOLEAN(x))return %NumberEquals(%ToNumber(x),%ToNumber(y)); | 572 if (IS_BOOLEAN(x)) return y == x; |
574 | 573 |
575 return %_ObjectEquals(x, y); | 574 return %_ObjectEquals(x, y); |
576 } | 575 } |
577 | 576 |
578 | 577 |
579 /* --------------------------------- | 578 /* --------------------------------- |
580 - - - U t i l i t i e s - - - | 579 - - - U t i l i t i e s - - - |
581 --------------------------------- | 580 --------------------------------- |
582 */ | 581 */ |
583 | 582 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 throw %MakeTypeError('cannot_convert_to_primitive', []); | 624 throw %MakeTypeError('cannot_convert_to_primitive', []); |
626 } | 625 } |
627 | 626 |
628 | 627 |
629 // NOTE: Setting the prototype for Array must take place as early as | 628 // NOTE: Setting the prototype for Array must take place as early as |
630 // possible due to code generation for array literals. When | 629 // possible due to code generation for array literals. When |
631 // generating code for a array literal a boilerplate array is created | 630 // generating code for a array literal a boilerplate array is created |
632 // that is cloned when running the code. It is essiential that the | 631 // that is cloned when running the code. It is essiential that the |
633 // boilerplate gets the right prototype. | 632 // boilerplate gets the right prototype. |
634 %FunctionSetPrototype($Array, new $Array(0)); | 633 %FunctionSetPrototype($Array, new $Array(0)); |
OLD | NEW |