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

Function fx_Set

xs/sources/xsMapSet.c:696–733  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

694}
695
696void fx_Set(txMachine* the)
697{
698 txSlot *function, *iterable, *iterator, *next, *value;
699 if (!mxHasTarget)
700 mxTypeError("call: Set");
701 mxPushSlot(mxTarget);
702 fxGetPrototypeFromConstructor(the, &mxSetPrototype);
703 fxNewSetInstance(the, mxTableMinLength);
704 mxPullSlot(mxResult);
705 if (mxArgc < 1)
706 return;
707 iterable = mxArgv(0);
708 if ((iterable->kind == XS_UNDEFINED_KIND) || (iterable->kind == XS_NULL_KIND))
709 return;
710 mxPushSlot(mxResult);
711 mxGetID(mxID(_add));
712 function = the->stack;
713 if (!fxIsCallable(the, function))
714 mxTypeError("result.add: not a function");
715 mxTemporary(iterator);
716 mxTemporary(next);
717 fxGetIterator(the, iterable, iterator, next, 0);
718 mxTemporary(value);
719 while (fxIteratorNext(the, iterator, next, value)) {
720 mxTry(the) {
721 mxPushSlot(mxResult);
722 mxPushSlot(function);
723 mxCall();
724 mxPushSlot(value);
725 mxRunCount(1);
726 mxPop();
727 }
728 mxCatch(the) {
729 fxIteratorReturn(the, iterator, 1);
730 fxJump(the);
731 }
732 }
733}
734
735void fx_Set_prototype_add(txMachine* the)
736{

Callers

nothing calls this directly

Calls 7

fxNewSetInstanceFunction · 0.85
fxIsCallableFunction · 0.85
fxGetIteratorFunction · 0.85
fxIteratorNextFunction · 0.85
fxIteratorReturnFunction · 0.85
fxJumpFunction · 0.85

Tested by

no test coverage detected