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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 } else if (IS_BOOLEAN(x)) { | 71 } else if (IS_BOOLEAN(x)) { |
72 if (IS_BOOLEAN(y)) { | 72 if (IS_BOOLEAN(y)) { |
73 return %_ObjectEquals(x, y) ? 0 : 1; | 73 return %_ObjectEquals(x, y) ? 0 : 1; |
74 } | 74 } |
75 if (y == null) return 1; // not equal | 75 if (y == null) return 1; // not equal |
76 return %NumberEquals(%ToNumber(x), %ToNumber(y)); | 76 return %NumberEquals(%ToNumber(x), %ToNumber(y)); |
77 } else if (x == null) { | 77 } else if (x == null) { |
78 // NOTE: This checks for both null and undefined. | 78 // NOTE: This checks for both null and undefined. |
79 return (y == null) ? 0 : 1; | 79 return (y == null) ? 0 : 1; |
80 } else { | 80 } else { |
| 81 // x is not a number, boolean, null or undefined. |
| 82 if (IS_UNDEFINED(y)) return 1; // not equal |
| 83 |
81 if (IS_OBJECT(y)) { | 84 if (IS_OBJECT(y)) { |
82 return %_ObjectEquals(x, y) ? 0 : 1; | 85 return %_ObjectEquals(x, y) ? 0 : 1; |
83 } | 86 } |
84 if (IS_FUNCTION(y)) { | 87 if (IS_FUNCTION(y)) { |
85 return %_ObjectEquals(x, y) ? 0 : 1; | 88 return %_ObjectEquals(x, y) ? 0 : 1; |
86 } | 89 } |
| 90 |
87 x = %ToPrimitive(x, NO_HINT); | 91 x = %ToPrimitive(x, NO_HINT); |
88 } | 92 } |
89 } | 93 } |
90 } | 94 } |
91 | 95 |
92 // ECMA-262, section 11.9.4, page 56. | 96 // ECMA-262, section 11.9.4, page 56. |
93 function STRICT_EQUALS(x) { | 97 function STRICT_EQUALS(x) { |
94 if (IS_STRING(this)) { | 98 if (IS_STRING(this)) { |
95 if (!IS_STRING(x)) return 1; // not equal | 99 if (!IS_STRING(x)) return 1; // not equal |
96 return %StringEquals(this, x); | 100 return %StringEquals(this, x); |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 throw %MakeTypeError('cannot_convert_to_primitive', []); | 519 throw %MakeTypeError('cannot_convert_to_primitive', []); |
516 } | 520 } |
517 | 521 |
518 | 522 |
519 // NOTE: Setting the prototype for Array must take place as early as | 523 // NOTE: Setting the prototype for Array must take place as early as |
520 // possible due to code generation for array literals. When | 524 // possible due to code generation for array literals. When |
521 // generating code for a array literal a boilerplate array is created | 525 // generating code for a array literal a boilerplate array is created |
522 // that is cloned when running the code. It is essiential that the | 526 // that is cloned when running the code. It is essiential that the |
523 // boilerplate gets the right prototype. | 527 // boilerplate gets the right prototype. |
524 %FunctionSetPrototype($Array, new $Array(0)); | 528 %FunctionSetPrototype($Array, new $Array(0)); |
OLD | NEW |