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

Function fx_WeakSet

xs/sources/xsMapSet.c:1607–1644  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1605}
1606
1607void fx_WeakSet(txMachine* the)
1608{
1609 txSlot *function, *iterable, *iterator, *next, *value;
1610 if (!mxHasTarget)
1611 mxTypeError("call: WeakSet");
1612 mxPushSlot(mxTarget);
1613 fxGetPrototypeFromConstructor(the, &mxWeakSetPrototype);
1614 fxNewWeakSetInstance(the);
1615 mxPullSlot(mxResult);
1616 if (mxArgc < 1)
1617 return;
1618 iterable = mxArgv(0);
1619 if ((iterable->kind == XS_UNDEFINED_KIND) || (iterable->kind == XS_NULL_KIND))
1620 return;
1621 mxPushSlot(mxResult);
1622 mxGetID(mxID(_add));
1623 function = the->stack;
1624 if (!fxIsCallable(the, function))
1625 mxTypeError("result.add: not a function");
1626 mxTemporary(iterator);
1627 mxTemporary(next);
1628 fxGetIterator(the, iterable, iterator, next, 0);
1629 mxTemporary(value);
1630 while (fxIteratorNext(the, iterator, next, value)) {
1631 mxTry(the) {
1632 mxPushSlot(mxResult);
1633 mxPushSlot(function);
1634 mxCall();
1635 mxPushSlot(value);
1636 mxRunCount(1);
1637 mxPop();
1638 }
1639 mxCatch(the) {
1640 fxIteratorReturn(the, iterator, 1);
1641 fxJump(the);
1642 }
1643 }
1644}
1645
1646void fx_WeakSet_prototype_add(txMachine* the)
1647{

Callers

nothing calls this directly

Calls 7

fxNewWeakSetInstanceFunction · 0.85
fxIsCallableFunction · 0.85
fxGetIteratorFunction · 0.85
fxIteratorNextFunction · 0.85
fxIteratorReturnFunction · 0.85
fxJumpFunction · 0.85

Tested by

no test coverage detected