| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 } | 111 } |
| 112 | 112 |
| 113 | 113 |
| 114 // ECMA-262, section 11.8.5, page 53. The 'ncr' parameter is used as | 114 // ECMA-262, section 11.8.5, page 53. The 'ncr' parameter is used as |
| 115 // the result when either (or both) the operands are NaN. | 115 // the result when either (or both) the operands are NaN. |
| 116 function COMPARE(x, ncr) { | 116 function COMPARE(x, ncr) { |
| 117 var left; | 117 var left; |
| 118 | 118 |
| 119 // Fast cases for string, numbers and undefined compares. | 119 // Fast cases for string, numbers and undefined compares. |
| 120 if (IS_STRING(this)) { | 120 if (IS_STRING(this)) { |
| 121 if (IS_STRING(x)) return %StringCompare(this, x); | 121 if (IS_STRING(x)) return %_StringCompare(this, x); |
| 122 if (IS_UNDEFINED(x)) return ncr; | 122 if (IS_UNDEFINED(x)) return ncr; |
| 123 left = this; | 123 left = this; |
| 124 } else if (IS_NUMBER(this)) { | 124 } else if (IS_NUMBER(this)) { |
| 125 if (IS_NUMBER(x)) return %NumberCompare(this, x, ncr); | 125 if (IS_NUMBER(x)) return %NumberCompare(this, x, ncr); |
| 126 if (IS_UNDEFINED(x)) return ncr; | 126 if (IS_UNDEFINED(x)) return ncr; |
| 127 left = this; | 127 left = this; |
| 128 } else if (IS_UNDEFINED(this)) { | 128 } else if (IS_UNDEFINED(this)) { |
| 129 return ncr; | 129 return ncr; |
| 130 } else { | 130 } else { |
| 131 if (IS_UNDEFINED(x)) return ncr; | 131 if (IS_UNDEFINED(x)) return ncr; |
| 132 left = %ToPrimitive(this, NUMBER_HINT); | 132 left = %ToPrimitive(this, NUMBER_HINT); |
| 133 } | 133 } |
| 134 | 134 |
| 135 // Default implementation. | 135 // Default implementation. |
| 136 var right = %ToPrimitive(x, NUMBER_HINT); | 136 var right = %ToPrimitive(x, NUMBER_HINT); |
| 137 if (IS_STRING(left) && IS_STRING(right)) { | 137 if (IS_STRING(left) && IS_STRING(right)) { |
| 138 return %StringCompare(left, right); | 138 return %_StringCompare(left, right); |
| 139 } else { | 139 } else { |
| 140 var left_number = %ToNumber(left); | 140 var left_number = %ToNumber(left); |
| 141 var right_number = %ToNumber(right); | 141 var right_number = %ToNumber(right); |
| 142 if (NUMBER_IS_NAN(left_number) || NUMBER_IS_NAN(right_number)) return ncr; | 142 if (NUMBER_IS_NAN(left_number) || NUMBER_IS_NAN(right_number)) return ncr; |
| 143 return %NumberCompare(left_number, right_number, ncr); | 143 return %NumberCompare(left_number, right_number, ncr); |
| 144 } | 144 } |
| 145 } | 145 } |
| 146 | 146 |
| 147 | 147 |
| 148 | 148 |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 throw %MakeTypeError('cannot_convert_to_primitive', []); | 617 throw %MakeTypeError('cannot_convert_to_primitive', []); |
| 618 } | 618 } |
| 619 | 619 |
| 620 | 620 |
| 621 // NOTE: Setting the prototype for Array must take place as early as | 621 // NOTE: Setting the prototype for Array must take place as early as |
| 622 // possible due to code generation for array literals. When | 622 // possible due to code generation for array literals. When |
| 623 // generating code for a array literal a boilerplate array is created | 623 // generating code for a array literal a boilerplate array is created |
| 624 // that is cloned when running the code. It is essiential that the | 624 // that is cloned when running the code. It is essiential that the |
| 625 // boilerplate gets the right prototype. | 625 // boilerplate gets the right prototype. |
| 626 %FunctionSetPrototype($Array, new $Array(0)); | 626 %FunctionSetPrototype($Array, new $Array(0)); |
| OLD | NEW |