| 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 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 // A false value here means that access checks failed. | 622 // A false value here means that access checks failed. |
| 623 if (current_or_access === false) return void 0; | 623 if (current_or_access === false) return void 0; |
| 624 | 624 |
| 625 var current = ConvertDescriptorArrayToDescriptor(current_or_access); | 625 var current = ConvertDescriptorArrayToDescriptor(current_or_access); |
| 626 var extensible = %IsExtensible(ToObject(obj)); | 626 var extensible = %IsExtensible(ToObject(obj)); |
| 627 | 627 |
| 628 // Error handling according to spec. | 628 // Error handling according to spec. |
| 629 // Step 3 | 629 // Step 3 |
| 630 if (IS_UNDEFINED(current) && !extensible) { | 630 if (IS_UNDEFINED(current) && !extensible) { |
| 631 if (should_throw) { | 631 if (should_throw) { |
| 632 throw MakeTypeError("define_disallowed", [p]); | 632 throw MakeTypeError("define_disallowed", ["defineProperty"]); |
| 633 } else { | 633 } else { |
| 634 return; | 634 return; |
| 635 } | 635 } |
| 636 } | 636 } |
| 637 | 637 |
| 638 if (!IS_UNDEFINED(current)) { | 638 if (!IS_UNDEFINED(current)) { |
| 639 // Step 5 and 6 | 639 // Step 5 and 6 |
| 640 if ((IsGenericDescriptor(desc) || | 640 if ((IsGenericDescriptor(desc) || |
| 641 IsDataDescriptor(desc) == IsDataDescriptor(current)) && | 641 IsDataDescriptor(desc) == IsDataDescriptor(current)) && |
| 642 (!desc.hasEnumerable() || | 642 (!desc.hasEnumerable() || |
| 643 SameValue(desc.isEnumerable(), current.isEnumerable())) && | 643 SameValue(desc.isEnumerable(), current.isEnumerable())) && |
| 644 (!desc.hasConfigurable() || | 644 (!desc.hasConfigurable() || |
| 645 SameValue(desc.isConfigurable(), current.isConfigurable())) && | 645 SameValue(desc.isConfigurable(), current.isConfigurable())) && |
| 646 (!desc.hasWritable() || | 646 (!desc.hasWritable() || |
| 647 SameValue(desc.isWritable(), current.isWritable())) && | 647 SameValue(desc.isWritable(), current.isWritable())) && |
| 648 (!desc.hasValue() || | 648 (!desc.hasValue() || |
| 649 SameValue(desc.getValue(), current.getValue())) && | 649 SameValue(desc.getValue(), current.getValue())) && |
| 650 (!desc.hasGetter() || | 650 (!desc.hasGetter() || |
| 651 SameValue(desc.getGet(), current.getGet())) && | 651 SameValue(desc.getGet(), current.getGet())) && |
| 652 (!desc.hasSetter() || | 652 (!desc.hasSetter() || |
| 653 SameValue(desc.getSet(), current.getSet()))) { | 653 SameValue(desc.getSet(), current.getSet()))) { |
| 654 return true; | 654 return true; |
| 655 } | 655 } |
| 656 if (!current.isConfigurable()) { | 656 if (!current.isConfigurable()) { |
| 657 // Step 7 | 657 // Step 7 |
| 658 if (desc.isConfigurable() || | 658 if (desc.isConfigurable() || |
| 659 (desc.hasEnumerable() && | 659 (desc.hasEnumerable() && |
| 660 desc.isEnumerable() != current.isEnumerable())) { | 660 desc.isEnumerable() != current.isEnumerable())) { |
| 661 if (should_throw) { | 661 if (should_throw) { |
| 662 throw MakeTypeError("redefine_disallowed", [p]); | 662 throw MakeTypeError("redefine_disallowed", ["defineProperty"]); |
| 663 } else { | 663 } else { |
| 664 return; | 664 return; |
| 665 } | 665 } |
| 666 } | 666 } |
| 667 // Step 8 | 667 // Step 8 |
| 668 if (!IsGenericDescriptor(desc)) { | 668 if (!IsGenericDescriptor(desc)) { |
| 669 // Step 9a | 669 // Step 9a |
| 670 if (IsDataDescriptor(current) != IsDataDescriptor(desc)) { | 670 if (IsDataDescriptor(current) != IsDataDescriptor(desc)) { |
| 671 if (should_throw) { | 671 if (should_throw) { |
| 672 throw MakeTypeError("redefine_disallowed", [p]); | 672 throw MakeTypeError("redefine_disallowed", ["defineProperty"]); |
| 673 } else { | 673 } else { |
| 674 return; | 674 return; |
| 675 } | 675 } |
| 676 } | 676 } |
| 677 // Step 10a | 677 // Step 10a |
| 678 if (IsDataDescriptor(current) && IsDataDescriptor(desc)) { | 678 if (IsDataDescriptor(current) && IsDataDescriptor(desc)) { |
| 679 if (!current.isWritable() && desc.isWritable()) { | 679 if (!current.isWritable() && desc.isWritable()) { |
| 680 if (should_throw) { | 680 if (should_throw) { |
| 681 throw MakeTypeError("redefine_disallowed", [p]); | 681 throw MakeTypeError("redefine_disallowed", ["defineProperty"]); |
| 682 } else { | 682 } else { |
| 683 return; | 683 return; |
| 684 } | 684 } |
| 685 } | 685 } |
| 686 if (!current.isWritable() && desc.hasValue() && | 686 if (!current.isWritable() && desc.hasValue() && |
| 687 !SameValue(desc.getValue(), current.getValue())) { | 687 !SameValue(desc.getValue(), current.getValue())) { |
| 688 if (should_throw) { | 688 if (should_throw) { |
| 689 throw MakeTypeError("redefine_disallowed", [p]); | 689 throw MakeTypeError("redefine_disallowed", ["defineProperty"]); |
| 690 } else { | 690 } else { |
| 691 return; | 691 return; |
| 692 } | 692 } |
| 693 } | 693 } |
| 694 } | 694 } |
| 695 // Step 11 | 695 // Step 11 |
| 696 if (IsAccessorDescriptor(desc) && IsAccessorDescriptor(current)) { | 696 if (IsAccessorDescriptor(desc) && IsAccessorDescriptor(current)) { |
| 697 if (desc.hasSetter() && !SameValue(desc.getSet(), current.getSet())) { | 697 if (desc.hasSetter() && !SameValue(desc.getSet(), current.getSet())) { |
| 698 if (should_throw) { | 698 if (should_throw) { |
| 699 throw MakeTypeError("redefine_disallowed", [p]); | 699 throw MakeTypeError("redefine_disallowed", ["defineProperty"]); |
| 700 } else { | 700 } else { |
| 701 return; | 701 return; |
| 702 } | 702 } |
| 703 } | 703 } |
| 704 if (desc.hasGetter() && !SameValue(desc.getGet(),current.getGet())) { | 704 if (desc.hasGetter() && !SameValue(desc.getGet(),current.getGet())) { |
| 705 if (should_throw) { | 705 if (should_throw) { |
| 706 throw MakeTypeError("redefine_disallowed", [p]); | 706 throw MakeTypeError("redefine_disallowed", ["defineProperty"]); |
| 707 } else { | 707 } else { |
| 708 return; | 708 return; |
| 709 } | 709 } |
| 710 } | 710 } |
| 711 } | 711 } |
| 712 } | 712 } |
| 713 } | 713 } |
| 714 } | 714 } |
| 715 | 715 |
| 716 // Send flags - enumerable and configurable are common - writable is | 716 // Send flags - enumerable and configurable are common - writable is |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1009 if (!ObjectIsExtensible(obj)) { | 1009 if (!ObjectIsExtensible(obj)) { |
| 1010 return true; | 1010 return true; |
| 1011 } | 1011 } |
| 1012 return false; | 1012 return false; |
| 1013 } | 1013 } |
| 1014 | 1014 |
| 1015 | 1015 |
| 1016 // ES5 section 15.2.3.13 | 1016 // ES5 section 15.2.3.13 |
| 1017 function ObjectIsExtensible(obj) { | 1017 function ObjectIsExtensible(obj) { |
| 1018 if (!IS_SPEC_OBJECT(obj)) { | 1018 if (!IS_SPEC_OBJECT(obj)) { |
| 1019 throw MakeTypeError("obj_ctor_property_non_object", ["isExtensible"]); | 1019 throw MakeTypeError("obj_ctor_property_non_object", ["preventExtension"]); |
| 1020 } | 1020 } |
| 1021 return %IsExtensible(obj); | 1021 return %IsExtensible(obj); |
| 1022 } | 1022 } |
| 1023 | 1023 |
| 1024 | 1024 |
| 1025 %SetCode($Object, function(x) { | 1025 %SetCode($Object, function(x) { |
| 1026 if (%_IsConstructCall()) { | 1026 if (%_IsConstructCall()) { |
| 1027 if (x == null) return this; | 1027 if (x == null) return this; |
| 1028 return ToObject(x); | 1028 return ToObject(x); |
| 1029 } else { | 1029 } else { |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1391 // ---------------------------------------------------------------------------- | 1391 // ---------------------------------------------------------------------------- |
| 1392 | 1392 |
| 1393 function SetupFunction() { | 1393 function SetupFunction() { |
| 1394 InstallFunctions($Function.prototype, DONT_ENUM, $Array( | 1394 InstallFunctions($Function.prototype, DONT_ENUM, $Array( |
| 1395 "bind", FunctionBind, | 1395 "bind", FunctionBind, |
| 1396 "toString", FunctionToString | 1396 "toString", FunctionToString |
| 1397 )); | 1397 )); |
| 1398 } | 1398 } |
| 1399 | 1399 |
| 1400 SetupFunction(); | 1400 SetupFunction(); |
| OLD | NEW |