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

Function fxBuildPromise

xs/sources/xsPromise.c:56–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54};
55
56void fxBuildPromise(txMachine* the)
57{
58 txSlot* slot;
59 mxPush(mxObjectPrototype);
60 slot = fxLastProperty(the, fxNewObjectInstance(the));
61 slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Promise_prototype_catch), 1, mxID(_catch), XS_DONT_ENUM_FLAG);
62 slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Promise_prototype_finally), 1, mxID(_finally_), XS_DONT_ENUM_FLAG);
63 slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Promise_prototype_then), 2, mxID(_then), XS_DONT_ENUM_FLAG);
64 slot = fxNextStringXProperty(the, slot, "Promise", mxID(_Symbol_toStringTag), XS_DONT_ENUM_FLAG | XS_DONT_SET_FLAG);
65 mxPromisePrototype = *the->stack;
66 slot = fxBuildHostConstructor(the, mxCallback(fx_Promise), 1, mxID(_Promise));
67 mxPromiseConstructor = *the->stack;
68 slot = fxLastProperty(the, slot);
69 slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Promise_all), 1, mxID(_all), XS_DONT_ENUM_FLAG);
70 slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Promise_allSettled), 1, mxID(_allSettled), XS_DONT_ENUM_FLAG);
71 slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Promise_any), 1, mxID(_any), XS_DONT_ENUM_FLAG);
72 slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Promise_race), 1, mxID(_race), XS_DONT_ENUM_FLAG);
73 slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Promise_reject), 1, mxID(_reject), XS_DONT_ENUM_FLAG);
74 slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Promise_resolve), 1, mxID(_resolve), XS_DONT_ENUM_FLAG);
75#if mxECMAScript2025
76 slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Promise_try), 1, mxID(_try_), XS_DONT_ENUM_FLAG);
77#endif
78#if mxECMAScript2024
79 slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Promise_withResolvers), 0, mxID(_withResolvers), XS_DONT_ENUM_FLAG);
80#endif
81 slot = fxNextHostAccessorProperty(the, slot, mxCallback(fx_species_get), C_NULL, mxID(_Symbol_species), XS_DONT_ENUM_FLAG);
82 mxPop();
83 fxNewHostFunction(the, mxCallback(fxOnRejectedPromise), 1, XS_NO_ID, XS_NO_ID);
84 mxOnRejectedPromiseFunction = *the->stack;
85 mxPop();
86 fxNewHostFunction(the, mxCallback(fxOnResolvedPromise), 1, XS_NO_ID, XS_NO_ID);
87 mxOnResolvedPromiseFunction = *the->stack;
88 mxPop();
89 fxNewHostFunction(the, mxCallback(fxOnThenable), 1, XS_NO_ID, XS_NO_ID);
90 mxOnThenableFunction = *the->stack;
91 mxPop();
92}
93
94txSlot* fxNewPromiseInstance(txMachine* the)
95{

Callers 1

fxCreateMachineFunction · 0.85

Calls 7

fxLastPropertyFunction · 0.85
fxNewObjectInstanceFunction · 0.85
fxNextStringXPropertyFunction · 0.85
fxBuildHostConstructorFunction · 0.85
fxNewHostFunctionFunction · 0.85

Tested by

no test coverage detected