| 641 | } |
| 642 | |
| 643 | void fx_Object_freeze(txMachine* the) |
| 644 | { |
| 645 | if (mxArgc > 0) { |
| 646 | txSlot* slot = mxArgv(0); |
| 647 | if (slot->kind == XS_REFERENCE_KIND) { |
| 648 | txSlot* instance = slot->value.reference; |
| 649 | txBoolean deep = 0; |
| 650 | txSlot* at; |
| 651 | txSlot* property; |
| 652 | if (!mxBehaviorPreventExtensions(the, instance)) |
| 653 | mxTypeError("extensible object"); |
| 654 | if ((mxArgc > 1) && fxToBoolean(the, mxArgv(1))) |
| 655 | deep = 1; |
| 656 | at = fxNewInstance(the); |
| 657 | mxBehaviorOwnKeys(the, instance, XS_EACH_NAME_FLAG | XS_EACH_SYMBOL_FLAG, at); |
| 658 | mxPushUndefined(); |
| 659 | property = the->stack; |
| 660 | while ((at = at->next)) { |
| 661 | if (mxBehaviorGetOwnProperty(the, instance, at->value.at.id, at->value.at.index, property)) { |
| 662 | txFlag mask = XS_DONT_DELETE_FLAG; |
| 663 | property->flag |= XS_DONT_DELETE_FLAG; |
| 664 | if (property->kind != XS_ACCESSOR_KIND) { |
| 665 | mask |= XS_DONT_SET_FLAG; |
| 666 | property->flag |= XS_DONT_SET_FLAG; |
| 667 | } |
| 668 | property->kind = XS_UNINITIALIZED_KIND; |
| 669 | if (!mxBehaviorDefineOwnProperty(the, instance, at->value.at.id, at->value.at.index, property, mask)) { |
| 670 | if (!deep) |
| 671 | mxTypeError("cannot configure property"); |
| 672 | } |
| 673 | } |
| 674 | } |
| 675 | mxPop(); |
| 676 | if (deep) { |
| 677 | at = the->stack->value.reference; |
| 678 | mxPushUndefined(); |
| 679 | property = the->stack; |
| 680 | while ((at = at->next)) { |
| 681 | if (mxBehaviorGetOwnProperty(the, instance, at->value.at.id, at->value.at.index, property)) { |
| 682 | if (property->kind == XS_REFERENCE_KIND) { |
| 683 | mxPushSlot(mxThis); |
| 684 | mxDub(); |
| 685 | mxGetID(mxID(_isFrozen)); |
| 686 | mxCall(); |
| 687 | mxPushSlot(property); |
| 688 | mxRunCount(1); |
| 689 | if (!fxRunTest(the)) { |
| 690 | mxPushSlot(mxThis); |
| 691 | mxPushSlot(mxFunction); |
| 692 | mxCall(); |
| 693 | mxPushSlot(property); |
| 694 | mxPushBoolean(1); |
| 695 | mxRunCount(2); |
| 696 | mxPop(); |
| 697 | } |
| 698 | } |
| 699 | else if (property->kind == XS_ACCESSOR_KIND) { |
| 700 | if (property->value.accessor.getter) { |
nothing calls this directly
no test coverage detected