Chromium Code Reviews| 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 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // This files contains runtime support implemented in JavaScript. | 5 // This files contains runtime support implemented in JavaScript. |
| 6 | 6 |
| 7 // CAUTION: Some of the functions specified in this file are called | 7 // CAUTION: Some of the functions specified in this file are called |
| 8 // directly from compiled code. These are the functions with names in | 8 // directly from compiled code. These are the functions with names in |
| 9 // ALL CAPS. The compiled code passes the first argument in 'this'. | 9 // ALL CAPS. The compiled code passes the first argument in 'this'. |
| 10 | 10 |
| 11 | 11 |
| 12 /* ----------------------------------- | 12 /* ----------------------------------- |
| 13 - - - C o m p a r i s o n - - - | 13 - - - C o m p a r i s o n - - - |
| 14 ----------------------------------- | 14 ----------------------------------- |
| 15 */ | 15 */ |
| 16 | 16 |
| 17 // The following declarations are shared with other native JS files. | 17 // The following declarations are shared with other native JS files. |
| 18 // They are all declared at this one spot to avoid redeclaration errors. | 18 // They are all declared at this one spot to avoid redeclaration errors. |
| 19 var EQUALS; | 19 var EQUALS; |
| 20 var STRICT_EQUALS; | 20 var STRICT_EQUALS; |
| 21 var COMPARE; | 21 var COMPARE; |
|
rossberg
2015/05/08 13:54:36
Declare COMPARE_STRONG here
conradw
2015/05/08 14:08:21
Done.
| |
| 22 var ADD; | 22 var ADD; |
| 23 var ADD_STRONG; | 23 var ADD_STRONG; |
| 24 var STRING_ADD_LEFT; | 24 var STRING_ADD_LEFT; |
| 25 var STRING_ADD_LEFT_STRONG; | 25 var STRING_ADD_LEFT_STRONG; |
| 26 var STRING_ADD_RIGHT; | 26 var STRING_ADD_RIGHT; |
| 27 var STRING_ADD_RIGHT_STRONG; | 27 var STRING_ADD_RIGHT_STRONG; |
| 28 var SUB; | 28 var SUB; |
| 29 var SUB_STRONG; | 29 var SUB_STRONG; |
| 30 var MUL; | 30 var MUL; |
| 31 var MUL_STRONG; | 31 var MUL_STRONG; |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 196 if (IS_STRING(left) && IS_STRING(right)) { | 196 if (IS_STRING(left) && IS_STRING(right)) { |
| 197 return %_StringCompare(left, right); | 197 return %_StringCompare(left, right); |
| 198 } else { | 198 } else { |
| 199 var left_number = %$toNumber(left); | 199 var left_number = %$toNumber(left); |
| 200 var right_number = %$toNumber(right); | 200 var right_number = %$toNumber(right); |
| 201 if (NUMBER_IS_NAN(left_number) || NUMBER_IS_NAN(right_number)) return ncr; | 201 if (NUMBER_IS_NAN(left_number) || NUMBER_IS_NAN(right_number)) return ncr; |
| 202 return %NumberCompare(left_number, right_number, ncr); | 202 return %NumberCompare(left_number, right_number, ncr); |
| 203 } | 203 } |
| 204 } | 204 } |
| 205 | 205 |
| 206 //Strong mode COMPARE throws if an implicit conversion would be performed | |
|
rossberg
2015/05/08 13:54:36
Nit: space
conradw
2015/05/08 14:08:21
Done.
| |
| 207 COMPARE_STRONG = function COMPARE_STRONG(x, ncr) { | |
| 208 if (IS_STRING(this) && IS_STRING(x)) return %_StringCompare(this, x); | |
| 209 if (IS_NUMBER(this) && IS_NUMBER(x)) return %NumberCompare(this, x, ncr); | |
| 210 | |
| 211 throw %MakeTypeError('strong_implicit_cast'); | |
| 212 } | |
| 213 | |
| 206 | 214 |
| 207 | 215 |
| 208 /* ----------------------------------- | 216 /* ----------------------------------- |
| 209 - - - A r i t h m e t i c - - - | 217 - - - A r i t h m e t i c - - - |
| 210 ----------------------------------- | 218 ----------------------------------- |
| 211 */ | 219 */ |
| 212 | 220 |
| 213 // ECMA-262, section 11.6.1, page 50. | 221 // ECMA-262, section 11.6.1, page 50. |
| 214 ADD = function ADD(x) { | 222 ADD = function ADD(x) { |
| 215 // Fast case: Check for number operands and do the addition. | 223 // Fast case: Check for number operands and do the addition. |
| (...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 991 $toLength = ToLength; | 999 $toLength = ToLength; |
| 992 $toName = ToName; | 1000 $toName = ToName; |
| 993 $toNumber = ToNumber; | 1001 $toNumber = ToNumber; |
| 994 $toObject = ToObject; | 1002 $toObject = ToObject; |
| 995 $toPositiveInteger = ToPositiveInteger; | 1003 $toPositiveInteger = ToPositiveInteger; |
| 996 $toPrimitive = ToPrimitive; | 1004 $toPrimitive = ToPrimitive; |
| 997 $toString = ToString; | 1005 $toString = ToString; |
| 998 $toUint32 = ToUint32; | 1006 $toUint32 = ToUint32; |
| 999 | 1007 |
| 1000 })(); | 1008 })(); |
| OLD | NEW |