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

Function fx_Array_fromAsync_onIterated

xs/sources/xsArray.c:1416–1479  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1414}
1415
1416void fx_Array_fromAsync_onIterated(txMachine* the)
1417{
1418 txSlot* slot = mxFunctionInstanceHome(mxFunction->value.reference);
1419 txSlot* closure = slot->value.home.object;
1420 txSlot* resolveFunction = closure->next;
1421 txSlot* rejectFunction = resolveFunction->next;
1422 txSlot* onIteratedFunction = rejectFunction->next;
1423 txSlot* onRejectedFunction = onIteratedFunction->next;
1424 txSlot* result = onRejectedFunction->next;
1425 txSlot* index = result->next;
1426 txSlot* iterator = index->next;
1427 txSlot* mapFunction = iterator->next;
1428 txSlot* mapThis = mapFunction->next;
1429 txSlot* onMappedFunction = mapThis->next;
1430
1431 mxTry(the) {
1432 mxPushSlot(mxArgv(0));
1433 mxGetID(mxID(_done));
1434 if (fxToBoolean(the, the->stack)) {
1435 mxPushSlot(index);
1436 mxPushSlot(result);
1437 mxSetID(mxID(_length));
1438 mxPop();
1439
1440 mxPushUndefined();
1441 mxPushSlot(resolveFunction);
1442 mxCall();
1443 mxPushSlot(result);
1444 mxRunCount(1);
1445 mxPop();
1446 return;
1447 }
1448 if (!mxIsUndefined(mapFunction)) {
1449 mxPushUndefined();
1450 mxPush(mxPromiseConstructor);
1451
1452 mxPushSlot(mapThis);
1453 mxPushSlot(mapFunction);
1454 mxCall();
1455 mxPushSlot(mxArgv(0));
1456 mxGetID(mxID(_value));
1457 mxPushSlot(index);
1458 mxRunCount(2);
1459
1460 fx_Promise_resolveAux(the);
1461 mxPop();
1462 mxPop();
1463 fxPromiseThen(the, the->stack->value.reference, onMappedFunction, onRejectedFunction, C_NULL, rejectFunction);
1464 }
1465 else {
1466 mxPushSlot(mxArgv(0));
1467 mxGetID(mxID(_value));
1468 mxPushSlot(result);
1469 mxDefineIndex(index->value.integer, 0, XS_GET_ONLY);
1470 mxPop();
1471 index->value.integer++;
1472 fx_Array_fromAsync_aux(the, closure);
1473 }

Callers

nothing calls this directly

Calls 6

fxToBooleanFunction · 0.85
fx_Promise_resolveAuxFunction · 0.85
fxPromiseThenFunction · 0.85
fx_Array_fromAsync_auxFunction · 0.85
fxIteratorReturnFunction · 0.85
fxThrowFunction · 0.85

Tested by

no test coverage detected