| 641 | } |
| 642 | |
| 643 | void fxReviveJSON(txMachine* the, txJSONParser* theParser, txSlot* reviver) |
| 644 | { |
| 645 | txSlot* valueReference = the->stack + 1; |
| 646 | txSlot* sourceReference = the->stack; |
| 647 | mxCheckCStack(); |
| 648 | if (mxIsReference(valueReference)) { |
| 649 | txSlot* instance = valueReference->value.reference; |
| 650 | if (fxIsArray(the, instance)) { |
| 651 | txIndex length, index; |
| 652 | mxPushSlot(valueReference); |
| 653 | mxGetID(mxID(_length)); |
| 654 | length = (txIndex)fxToLength(the, the->stack); |
| 655 | mxPop(); |
| 656 | index = 0; |
| 657 | while (index < length) { |
| 658 | mxPushSlot(valueReference); |
| 659 | mxPushSlot(reviver); |
| 660 | mxCall(); |
| 661 | mxPushUndefined(); |
| 662 | fxKeyAt(the, 0, index, the->stack); |
| 663 | mxPushSlot(valueReference); |
| 664 | mxGetIndex(index); |
| 665 | if (mxIsReference(sourceReference)) { |
| 666 | mxPushSlot(sourceReference); |
| 667 | mxGetIndex(index); |
| 668 | } |
| 669 | else |
| 670 | mxPushUndefined(); |
| 671 | fxReviveJSON(the, theParser, reviver); |
| 672 | if (mxIsUndefined(the->stack)) { |
| 673 | mxBehaviorDeleteProperty(the, valueReference->value.reference, 0, index); |
| 674 | } |
| 675 | else { |
| 676 | mxBehaviorDefineOwnProperty(the, valueReference->value.reference, 0, index, the->stack, XS_GET_ONLY); |
| 677 | } |
| 678 | mxPop(); |
| 679 | index++; |
| 680 | } |
| 681 | } |
| 682 | else { |
| 683 | txSlot* at = fxNewInstance(the); |
| 684 | mxBehaviorOwnKeys(the, instance, XS_EACH_NAME_FLAG, at); |
| 685 | while ((at = at->next)) { |
| 686 | mxPushSlot(valueReference); |
| 687 | mxPushSlot(reviver); |
| 688 | mxCall(); |
| 689 | mxPushUndefined(); |
| 690 | fxKeyAt(the, at->value.at.id, at->value.at.index, the->stack); |
| 691 | mxPushSlot(valueReference); |
| 692 | mxGetAll(at->value.at.id, at->value.at.index); |
| 693 | if (mxIsReference(sourceReference)) { |
| 694 | mxPushSlot(sourceReference); |
| 695 | mxGetAll(at->value.at.id, at->value.at.index); |
| 696 | } |
| 697 | else |
| 698 | mxPushUndefined(); |
| 699 | fxReviveJSON(the, theParser, reviver); |
| 700 | if (mxIsUndefined(the->stack)) { |
no test coverage detected