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

Function fx_Promise_try

xs/sources/xsPromise.c:953–1000  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

951
952#if mxECMAScript2025
953void fx_Promise_try(txMachine* the)
954{
955 txSlot* stack = the->stack;
956 txSlot* resolveFunction;
957 txSlot* rejectFunction;
958 if (!mxIsReference(mxThis))
959 mxTypeError("this: not an object");
960 mxTemporary(resolveFunction);
961 mxTemporary(rejectFunction);
962 mxPushSlot(mxThis);
963 fxNewPromiseCapability(the, resolveFunction, rejectFunction);
964 mxPullSlot(mxResult);
965 {
966 mxTry(the) {
967 txInteger c = mxArgc, i;
968 txSlot* value;
969 /* THIS */
970 mxPushUndefined();
971 /* FUNCTION */
972 if (c > 0)
973 mxPushSlot(mxArgv(0));
974 else
975 mxPushUndefined();
976 mxCall();
977 /* ARGUMENTS */
978 for (i = 1; i < c; i++)
979 mxPushSlot(mxArgv(i));
980 if (c > 0)
981 mxRunCount(c - 1);
982 else
983 mxRunCount(0);
984 value = the->stack;
985 /* THIS */
986 mxPushUndefined();
987 /* FUNCTION */
988 mxPushSlot(resolveFunction);
989 mxCall();
990 /* ARGUMENTS */
991 mxPushSlot(value);
992 /* COUNT */
993 mxRunCount(1);
994 }
995 mxCatch(the) {
996 fxRejectException(the, rejectFunction);
997 }
998 }
999 the->stack = stack;
1000}
1001#endif
1002
1003#if mxECMAScript2024

Callers

nothing calls this directly

Calls 2

fxNewPromiseCapabilityFunction · 0.85
fxRejectExceptionFunction · 0.85

Tested by

no test coverage detected