MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / fx_Object_fromEntries

Function fx_Object_fromEntries

xs/sources/xsObject.c:745–776  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

743}
744
745void fx_Object_fromEntries(txMachine* the)
746{
747 txSlot *instance, *iterator, *next, *value, *at;
748 if ((mxArgc < 1) || (mxArgv(0)->kind == XS_UNDEFINED_KIND) || (mxArgv(0)->kind == XS_NULL_KIND))
749 mxTypeError("invalid iterable");
750 mxPush(mxObjectPrototype);
751 instance = fxNewObjectInstance(the);
752 mxPullSlot(mxResult);
753 mxTemporary(iterator);
754 mxTemporary(next);
755 fxGetIterator(the, mxArgv(0), iterator, next, 0);
756 mxTemporary(value);
757 while (fxIteratorNext(the, iterator, next, value)) {
758 mxTry(the) {
759 if (value->kind != XS_REFERENCE_KIND)
760 mxTypeError("item: not an object");
761 mxPushSlot(value);
762 mxGetIndex(0);
763 mxPushSlot(value);
764 mxGetIndex(1);
765 at = fxAt(the, the->stack + 1);
766 mxBehaviorDefineOwnProperty(the, instance, at->value.at.id, at->value.at.index, the->stack, XS_GET_ONLY);
767 mxPop();
768 mxPop();
769 }
770 mxCatch(the) {
771 fxIteratorReturn(the, iterator, 1);
772 fxJump(the);
773 }
774 }
775 mxPop();
776}
777
778void fx_Object_getOwnPropertyDescriptor(txMachine* the)
779{

Callers

nothing calls this directly

Calls 6

fxNewObjectInstanceFunction · 0.85
fxGetIteratorFunction · 0.85
fxIteratorNextFunction · 0.85
fxAtFunction · 0.85
fxIteratorReturnFunction · 0.85
fxJumpFunction · 0.85

Tested by

no test coverage detected