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 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 } | 580 } |
581 | 581 |
582 | 582 |
583 // ECMA-262, section 9.9, page 36. | 583 // ECMA-262, section 9.9, page 36. |
584 function ToObject(x) { | 584 function ToObject(x) { |
585 if (IS_STRING(x)) return new $String(x); | 585 if (IS_STRING(x)) return new $String(x); |
586 if (IS_SYMBOL(x)) return new $Symbol(x); | 586 if (IS_SYMBOL(x)) return new $Symbol(x); |
587 if (IS_NUMBER(x)) return new $Number(x); | 587 if (IS_NUMBER(x)) return new $Number(x); |
588 if (IS_BOOLEAN(x)) return new $Boolean(x); | 588 if (IS_BOOLEAN(x)) return new $Boolean(x); |
589 if (IS_NULL_OR_UNDEFINED(x) && !IS_UNDETECTABLE(x)) { | 589 if (IS_NULL_OR_UNDEFINED(x) && !IS_UNDETECTABLE(x)) { |
590 throw %MakeTypeError('null_to_object', []); | 590 throw %MakeTypeError('undefined_or_null_to_object', []); |
591 } | 591 } |
592 return x; | 592 return x; |
593 } | 593 } |
594 | 594 |
595 | 595 |
596 // ECMA-262, section 9.4, page 34. | 596 // ECMA-262, section 9.4, page 34. |
597 function ToInteger(x) { | 597 function ToInteger(x) { |
598 if (%_IsSmi(x)) return x; | 598 if (%_IsSmi(x)) return x; |
599 return %NumberToInteger(ToNumber(x)); | 599 return %NumberToInteger(ToNumber(x)); |
600 } | 600 } |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 return i; | 681 return i; |
682 } | 682 } |
683 | 683 |
684 | 684 |
685 // NOTE: Setting the prototype for Array must take place as early as | 685 // NOTE: Setting the prototype for Array must take place as early as |
686 // possible due to code generation for array literals. When | 686 // possible due to code generation for array literals. When |
687 // generating code for a array literal a boilerplate array is created | 687 // generating code for a array literal a boilerplate array is created |
688 // that is cloned when running the code. It is essential that the | 688 // that is cloned when running the code. It is essential that the |
689 // boilerplate gets the right prototype. | 689 // boilerplate gets the right prototype. |
690 %FunctionSetPrototype($Array, new $Array(0)); | 690 %FunctionSetPrototype($Array, new $Array(0)); |
OLD | NEW |