| 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 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 if (IS_NUMBER(x)) return !((x == 0) || NUMBER_IS_NAN(x)); | 534 if (IS_NUMBER(x)) return !((x == 0) || NUMBER_IS_NAN(x)); |
| 535 return true; | 535 return true; |
| 536 } | 536 } |
| 537 | 537 |
| 538 | 538 |
| 539 // ECMA-262, section 9.9, page 36. | 539 // ECMA-262, section 9.9, page 36. |
| 540 function ToObject(x) { | 540 function ToObject(x) { |
| 541 if (IS_STRING(x)) return new $String(x); | 541 if (IS_STRING(x)) return new $String(x); |
| 542 if (IS_NUMBER(x)) return new $Number(x); | 542 if (IS_NUMBER(x)) return new $Number(x); |
| 543 if (IS_BOOLEAN(x)) return new $Boolean(x); | 543 if (IS_BOOLEAN(x)) return new $Boolean(x); |
| 544 if (x == null) throw %MakeTypeError('null_to_object', []); | 544 if (IS_NULL_OR_UNDEFINED(x) && !IS_UNDETECTABLE(x)) { |
| 545 throw %MakeTypeError('null_to_object', []); |
| 546 } |
| 545 return x; | 547 return x; |
| 546 } | 548 } |
| 547 | 549 |
| 548 | 550 |
| 549 // ECMA-262, section 9.4, page 34. | 551 // ECMA-262, section 9.4, page 34. |
| 550 function ToInteger(x) { | 552 function ToInteger(x) { |
| 551 if (%_IsSmi(x)) return x; | 553 if (%_IsSmi(x)) return x; |
| 552 return %NumberToInteger(ToNumber(x)); | 554 return %NumberToInteger(ToNumber(x)); |
| 553 } | 555 } |
| 554 | 556 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 throw %MakeTypeError('cannot_convert_to_primitive', []); | 619 throw %MakeTypeError('cannot_convert_to_primitive', []); |
| 618 } | 620 } |
| 619 | 621 |
| 620 | 622 |
| 621 // NOTE: Setting the prototype for Array must take place as early as | 623 // NOTE: Setting the prototype for Array must take place as early as |
| 622 // possible due to code generation for array literals. When | 624 // possible due to code generation for array literals. When |
| 623 // generating code for a array literal a boilerplate array is created | 625 // generating code for a array literal a boilerplate array is created |
| 624 // that is cloned when running the code. It is essiential that the | 626 // that is cloned when running the code. It is essiential that the |
| 625 // boilerplate gets the right prototype. | 627 // boilerplate gets the right prototype. |
| 626 %FunctionSetPrototype($Array, new $Array(0)); | 628 %FunctionSetPrototype($Array, new $Array(0)); |
| OLD | NEW |