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 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 } | 570 } |
571 | 571 |
572 | 572 |
573 // ES5, section 9.12 | 573 // ES5, section 9.12 |
574 function SameValue(x, y) { | 574 function SameValue(x, y) { |
575 if (typeof x != typeof y) return false; | 575 if (typeof x != typeof y) return false; |
576 if (IS_NULL_OR_UNDEFINED(x)) return true; | 576 if (IS_NULL_OR_UNDEFINED(x)) return true; |
577 if (IS_NUMBER(x)) { | 577 if (IS_NUMBER(x)) { |
578 if (NUMBER_IS_NAN(x) && NUMBER_IS_NAN(y)) return true; | 578 if (NUMBER_IS_NAN(x) && NUMBER_IS_NAN(y)) return true; |
579 // x is +0 and y is -0 or vice versa | 579 // x is +0 and y is -0 or vice versa |
580 if (x === 0 && y === 0 && !%_IsSmi(x) && !%_IsSmi(y) && | 580 if (x === 0 && y === 0 && !%_IsSmi(x) && !%_IsSmi(y) && |
581 ((1 / x < 0 && 1 / y > 0) || (1 / x > 0 && 1 / y < 0))) { | 581 ((1 / x < 0 && 1 / y > 0) || (1 / x > 0 && 1 / y < 0))) { |
582 return false; | 582 return false; |
583 } | 583 } |
584 return x == y; | 584 return x == y; |
585 } | 585 } |
586 if (IS_STRING(x)) return %StringEquals(x, y); | 586 if (IS_STRING(x)) return %StringEquals(x, y); |
587 if (IS_BOOLEAN(x))return %NumberEquals(%ToNumber(x),%ToNumber(y)); | 587 if (IS_BOOLEAN(x))return %NumberEquals(%ToNumber(x),%ToNumber(y)); |
588 | 588 |
589 return %_ObjectEquals(x, y); | 589 return %_ObjectEquals(x, y); |
590 } | 590 } |
591 | 591 |
592 | 592 |
593 /* --------------------------------- | 593 /* --------------------------------- |
594 - - - U t i l i t i e s - - - | 594 - - - U t i l i t i e s - - - |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 throw %MakeTypeError('cannot_convert_to_primitive', []); | 639 throw %MakeTypeError('cannot_convert_to_primitive', []); |
640 } | 640 } |
641 | 641 |
642 | 642 |
643 // NOTE: Setting the prototype for Array must take place as early as | 643 // NOTE: Setting the prototype for Array must take place as early as |
644 // possible due to code generation for array literals. When | 644 // possible due to code generation for array literals. When |
645 // generating code for a array literal a boilerplate array is created | 645 // generating code for a array literal a boilerplate array is created |
646 // that is cloned when running the code. It is essiential that the | 646 // that is cloned when running the code. It is essiential that the |
647 // boilerplate gets the right prototype. | 647 // boilerplate gets the right prototype. |
648 %FunctionSetPrototype($Array, new $Array(0)); | 648 %FunctionSetPrototype($Array, new $Array(0)); |
OLD | NEW |