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

Function fxNewAsyncInstance

xs/sources/xsFunction.c:579–632  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

577}
578
579txSlot* fxNewAsyncInstance(txMachine* the)
580{
581 txSlot* instance;
582 txSlot* property;
583 txSlot* promise;
584 txSlot* status;
585 txSlot* function;
586 txSlot* home;
587
588 mxPushUndefined();
589
590 instance = fxNewSlot(the);
591 instance->kind = XS_INSTANCE_KIND;
592 instance->value.instance.garbage = C_NULL;
593 instance->value.instance.prototype = C_NULL;
594 the->stack->value.reference = instance;
595 the->stack->kind = XS_REFERENCE_KIND;
596
597 property = instance->next = fxNewSlot(the);
598 property->flag = XS_INTERNAL_FLAG;
599 property->kind = XS_STACK_KIND;
600 property->ID = XS_NO_ID;
601 property->value.stack.length = 0;
602 property->value.stack.address = C_NULL;
603
604 property = fxNextIntegerProperty(the, property, XS_CODE_START_ASYNC, XS_NO_ID, XS_INTERNAL_FLAG);
605
606 mxPush(mxPromisePrototype);
607 promise = fxNewPromiseInstance(the);
608 status = mxPromiseStatus(promise);
609 status->value.integer = mxPendingStatus;
610 property = fxNextSlotProperty(the, property, the->stack, XS_NO_ID, XS_INTERNAL_FLAG);
611 mxPop();
612
613 fxPushPromiseFunctions(the, promise);
614 property = fxNextSlotProperty(the, property, the->stack + 1, XS_NO_ID, XS_INTERNAL_FLAG);
615 property = fxNextSlotProperty(the, property, the->stack, XS_NO_ID, XS_INTERNAL_FLAG);
616 mxPop();
617 mxPop();
618
619 function = fxNewHostFunction(the, fxResolveAwait, 1, XS_NO_ID, mxResolveAwaitProfileID);
620 home = mxFunctionInstanceHome(function);
621 home->value.home.object = instance;
622 property = fxNextSlotProperty(the, property, the->stack, XS_NO_ID, XS_INTERNAL_FLAG);
623 mxPop();
624
625 function = fxNewHostFunction(the, fxRejectAwait, 1, XS_NO_ID, mxRejectAwaitProfileID);
626 home = mxFunctionInstanceHome(function);
627 home->value.home.object = instance;
628 property = fxNextSlotProperty(the, property, the->stack, XS_NO_ID, XS_INTERNAL_FLAG);
629 mxPop();
630
631 return instance;
632}
633
634void fxResolveAwait(txMachine* the)
635{

Callers

nothing calls this directly

Calls 6

fxNewSlotFunction · 0.85
fxNextIntegerPropertyFunction · 0.85
fxNewPromiseInstanceFunction · 0.85
fxNextSlotPropertyFunction · 0.85
fxPushPromiseFunctionsFunction · 0.85
fxNewHostFunctionFunction · 0.85

Tested by

no test coverage detected