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

Function fxRejectPromise

xs/sources/xsPromise.c:677–718  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

675}
676
677void fxRejectPromise(txMachine* the)
678{
679 txSlot* slot;
680 txSlot* promise;
681 txSlot* argument;
682 txSlot* result;
683 slot = mxFunctionInstanceHome(mxFunction->value.reference)->value.home.object->next;
684 if (slot->value.boolean)
685 return;
686 slot->value.boolean = 1;
687 mxPushSlot(slot->next);
688 promise = the->stack->value.reference;
689 slot->next = C_NULL;
690 if (mxArgc > 0)
691 mxPushSlot(mxArgv(0));
692 else
693 mxPushUndefined();
694 argument = the->stack;
695#ifdef mxPromisePrint
696 fprintf(stderr, "fxRejectPromise %d\n", promise->next->ID);
697#endif
698 result = mxPromiseResult(promise);
699 result->kind = argument->kind;
700 result->value = argument->value;
701 slot = mxPromiseThens(promise)->value.reference->next;
702 if (slot) {
703 while (slot) {
704 mxPushReference(slot->value.reference);
705 mxPush(mxOnRejectedPromiseFunction);
706 mxCall();
707 mxPushSlot(argument);
708 fxQueueJob(the, 1, promise);
709 slot = slot->next;
710 }
711 mxPromiseThens(promise)->value.reference->next = C_NULL;
712 }
713 else {
714 fxAddUnhandledRejection(the, promise);
715 }
716 slot = mxPromiseStatus(promise);
717 slot->value.integer = mxRejectedStatus;
718}
719
720void fxResolvePromise(txMachine* the)
721{

Callers

nothing calls this directly

Calls 2

fxQueueJobFunction · 0.85
fxAddUnhandledRejectionFunction · 0.85

Tested by

no test coverage detected