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 |
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 // Returns if the given x is a primitive value - not an object or a | 610 // Returns if the given x is a primitive value - not an object or a |
611 // function. | 611 // function. |
612 function IsPrimitive(x) { | 612 function IsPrimitive(x) { |
613 // Even though the type of null is "object", null is still | 613 // Even though the type of null is "object", null is still |
614 // considered a primitive value. IS_SPEC_OBJECT handles this correctly | 614 // considered a primitive value. IS_SPEC_OBJECT handles this correctly |
615 // (i.e., it will return false if x is null). | 615 // (i.e., it will return false if x is null). |
616 return !IS_SPEC_OBJECT(x); | 616 return !IS_SPEC_OBJECT(x); |
617 } | 617 } |
618 | 618 |
619 | 619 |
| 620 // ES6, draft 10-14-14, section 22.1.3.1.1 |
| 621 function IsConcatSpreadable(O) { |
| 622 if (!IS_SPEC_OBJECT(O)) return false; |
| 623 var spreadable = O[symbolIsConcatSpreadable]; |
| 624 if (IS_UNDEFINED(spreadable)) return IS_ARRAY(O); |
| 625 return ToBoolean(spreadable); |
| 626 } |
| 627 |
| 628 |
620 // ECMA-262, section 8.6.2.6, page 28. | 629 // ECMA-262, section 8.6.2.6, page 28. |
621 function DefaultNumber(x) { | 630 function DefaultNumber(x) { |
622 if (!IS_SYMBOL_WRAPPER(x)) { | 631 if (!IS_SYMBOL_WRAPPER(x)) { |
623 var valueOf = x.valueOf; | 632 var valueOf = x.valueOf; |
624 if (IS_SPEC_FUNCTION(valueOf)) { | 633 if (IS_SPEC_FUNCTION(valueOf)) { |
625 var v = %_CallFunction(x, valueOf); | 634 var v = %_CallFunction(x, valueOf); |
626 if (%IsPrimitive(v)) return v; | 635 if (%IsPrimitive(v)) return v; |
627 } | 636 } |
628 | 637 |
629 var toString = x.toString; | 638 var toString = x.toString; |
(...skipping 29 matching lines...) Expand all Loading... |
659 return i; | 668 return i; |
660 } | 669 } |
661 | 670 |
662 | 671 |
663 // NOTE: Setting the prototype for Array must take place as early as | 672 // NOTE: Setting the prototype for Array must take place as early as |
664 // possible due to code generation for array literals. When | 673 // possible due to code generation for array literals. When |
665 // generating code for a array literal a boilerplate array is created | 674 // generating code for a array literal a boilerplate array is created |
666 // that is cloned when running the code. It is essential that the | 675 // that is cloned when running the code. It is essential that the |
667 // boilerplate gets the right prototype. | 676 // boilerplate gets the right prototype. |
668 %FunctionSetPrototype($Array, new $Array(0)); | 677 %FunctionSetPrototype($Array, new $Array(0)); |
OLD | NEW |