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

Function fx_Promise_resolveAux

xs/sources/xsPromise.c:912–950  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

910}
911
912void fx_Promise_resolveAux(txMachine* the)
913{
914 txSlot* argument = the->stack;
915 txSlot* constructor = the->stack + 1;
916 txSlot* result = the->stack + 2;
917 txSlot* resolveFunction;
918 txSlot* rejectFunction;
919 if (mxIsReference(argument)) {
920 txSlot* promise = argument->value.reference;
921 if (mxIsPromise(promise)) {
922 mxPushReference(promise);
923 mxGetID(mxID(_constructor));
924 if (fxIsSameValue(the, constructor, the->stack, 0)) {
925 *result = *argument;
926 mxPop();
927 return;
928 }
929 mxPop();
930 }
931 }
932 mxTemporary(resolveFunction);
933 mxTemporary(rejectFunction);
934 mxPushSlot(constructor);
935 fxNewPromiseCapability(the, resolveFunction, rejectFunction);
936 *result = *the->stack;
937 mxPop();
938 /* THIS */
939 mxPushUndefined();
940 /* FUNCTION */
941 mxPushSlot(resolveFunction);
942 mxCall();
943 /* ARGUMENTS */
944 mxPushSlot(argument);
945 /* COUNT */
946 mxRunCount(1);
947 mxPop();
948 mxPop(); // rejectFunction
949 mxPop(); // resolveFunction
950}
951
952#if mxECMAScript2025
953void fx_Promise_try(txMachine* the)

Calls 2

fxIsSameValueFunction · 0.85
fxNewPromiseCapabilityFunction · 0.85

Tested by

no test coverage detected