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

Function fxNewPromiseCapability

xs/sources/xsPromise.c:145–176  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

143}
144
145txSlot* fxNewPromiseCapability(txMachine* the, txSlot* resolveFunction, txSlot* rejectFunction)
146{
147 txSlot* capability;
148 txSlot* slot;
149 txSlot* function;
150 mxNew();
151 resolveFunction->value.reference = fxNewHostFunction(the, fxNewPromiseCapabilityCallback, 2, XS_NO_ID, mxNewPromiseCapabilityCallbackProfileID);
152 resolveFunction->kind = XS_REFERENCE_KIND;
153 mxRunCount(1);
154 capability = resolveFunction->value.reference;
155 resolveFunction->kind = XS_UNDEFINED_KIND;
156 slot = mxFunctionInstanceHome(capability)->value.home.object;
157 if (!slot)
158 mxTypeError("executor not called");
159 slot = slot->next;
160 if (!mxIsReference(slot))
161 mxTypeError("resolve: not an object");
162 function = slot->value.reference;
163 if (!mxIsFunction(function))
164 mxTypeError("resolve: not a function");
165 resolveFunction->kind = XS_REFERENCE_KIND;
166 resolveFunction->value.reference = function;
167 slot = slot->next;
168 if (!mxIsReference(slot))
169 mxTypeError("reject: not an object");
170 function = slot->value.reference;
171 if (!mxIsFunction(function))
172 mxTypeError("reject: not a function");
173 rejectFunction->kind = XS_REFERENCE_KIND;
174 rejectFunction->value.reference = function;
175 return the->stack->value.reference;
176}
177
178void fxNewPromiseCapabilityCallback(txMachine* the)
179{

Callers 13

fxAsyncGeneratorStepFunction · 0.85
fxStepAsyncFunction · 0.85
fx_Array_fromAsyncFunction · 0.85
fx_Atomics_waitAsyncFunction · 0.85
fxCombinePromisesFunction · 0.85
fx_Promise_rejectFunction · 0.85
fx_Promise_resolveAuxFunction · 0.85
fx_Promise_tryFunction · 0.85
fx_Promise_withResolversFunction · 0.85

Calls 1

fxNewHostFunctionFunction · 0.85

Tested by

no test coverage detected