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

Function fx_Enumerator

xs/sources/xsGenerator.c:1434–1476  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1432}
1433
1434void fx_Enumerator(txMachine* the)
1435{
1436 txSlot* iterator;
1437 txSlot* result;
1438 txSlot* slot;
1439 txSlot* keys;
1440 txSlot* visited;
1441
1442 mxPush(mxEnumeratorFunction);
1443 mxGetID(mxID(_prototype));
1444 iterator = fxNewObjectInstance(the);
1445 mxPullSlot(mxResult);
1446 mxPush(mxObjectPrototype);
1447 result = fxNewObjectInstance(the);
1448 slot = fxNextUndefinedProperty(the, result, mxID(_value), XS_DONT_DELETE_FLAG | XS_DONT_SET_FLAG);
1449 slot = fxNextBooleanProperty(the, slot, 0, mxID(_done), XS_DONT_DELETE_FLAG | XS_DONT_SET_FLAG);
1450 slot = fxNextSlotProperty(the, iterator, the->stack, mxID(_result), XS_GET_ONLY);
1451 mxPop();
1452
1453 slot = slot->next = fxNewSlot(the);
1454 slot->flag = XS_GET_ONLY;
1455 slot->ID = mxID(_iterable);
1456 slot->kind = mxThis->kind;
1457 slot->value = mxThis->value;
1458 if (mxIsUndefined(slot) || mxIsNull(slot))
1459 return;
1460 fxToInstance(the, slot);
1461
1462 keys = fxNewInstance(the);
1463 mxBehaviorOwnKeys(the, slot->value.reference, XS_EACH_NAME_FLAG, keys);
1464 slot = slot->next = fxNewSlot(the);
1465 slot->flag = XS_GET_ONLY;
1466 slot->kind = XS_REFERENCE_KIND;
1467 slot->value.reference = keys;
1468 mxPop();
1469
1470 visited = fxNewInstance(the);
1471 slot = slot->next = fxNewSlot(the);
1472 slot->flag = XS_GET_ONLY;
1473 slot->kind = XS_REFERENCE_KIND;
1474 slot->value.reference = visited;
1475 mxPop();
1476}
1477
1478void fx_Enumerator_prototype_next(txMachine* the)
1479{

Callers

nothing calls this directly

Calls 7

fxNewObjectInstanceFunction · 0.85
fxNextUndefinedPropertyFunction · 0.85
fxNextBooleanPropertyFunction · 0.85
fxNextSlotPropertyFunction · 0.85
fxNewSlotFunction · 0.85
fxToInstanceFunction · 0.85
fxNewInstanceFunction · 0.85

Tested by

no test coverage detected