| 2203 | |
| 2204 | |
| 2205 | void fxRunImport(txMachine* the, txSlot* realm, txSlot* referrer) |
| 2206 | { |
| 2207 | txSlot* stack = the->stack + 1; |
| 2208 | txSlot* promise; |
| 2209 | txSlot* fulfillFunction; |
| 2210 | txSlot* rejectFunction; |
| 2211 | txSlot* module; |
| 2212 | txID status; |
| 2213 | txSlot* slot; |
| 2214 | |
| 2215 | fxBeginHost(the); |
| 2216 | mxPush(mxPromisePrototype); |
| 2217 | promise = fxNewPromiseInstance(the); |
| 2218 | mxPromiseStatus(promise)->value.integer = mxPendingStatus; |
| 2219 | fxPushPromiseFunctions(the, promise); |
| 2220 | fulfillFunction = the->stack + 1; |
| 2221 | rejectFunction = the->stack; |
| 2222 | { |
| 2223 | mxTry(the) { |
| 2224 | module = fxRunImportAux(the, realm, referrer, stack, stack - 1, 0); |
| 2225 | status = mxModuleStatus(module); |
| 2226 | if (status == XS_MODULE_STATUS_ERROR) { |
| 2227 | /* THIS */ |
| 2228 | mxPushUndefined(); |
| 2229 | /* FUNCTION */ |
| 2230 | mxPushSlot(rejectFunction); |
| 2231 | mxCall(); |
| 2232 | /* ARGUMENTS */ |
| 2233 | mxPushSlot(mxModuleMeta(module)); |
| 2234 | mxRunCount(1); |
| 2235 | } |
| 2236 | else if (status == XS_MODULE_STATUS_EXECUTED) { |
| 2237 | /* THIS */ |
| 2238 | mxPushUndefined(); |
| 2239 | /* FUNCTION */ |
| 2240 | mxPushSlot(fulfillFunction); |
| 2241 | mxCall(); |
| 2242 | /* ARGUMENTS */ |
| 2243 | mxPushSlot(module); |
| 2244 | mxRunCount(1); |
| 2245 | } |
| 2246 | else { |
| 2247 | txSlot* queue = mxModuleQueue.value.reference; |
| 2248 | slot = fxLastProperty(the, module->value.reference); |
| 2249 | slot = fxNextSlotProperty(the, slot, fulfillFunction, XS_NO_ID, XS_NO_FLAG); |
| 2250 | slot = fxNextSlotProperty(the, slot, rejectFunction, XS_NO_ID, XS_NO_FLAG); |
| 2251 | // if ((status == XS_MODULE_STATUS_NEW) || (status == XS_MODULE_STATUS_LOADED)) { |
| 2252 | // txSlot* queue = fxNewInstance(the); |
| 2253 | if (fxQueueModule(the, queue, module)) |
| 2254 | fxLoadModules(the, queue); |
| 2255 | // } |
| 2256 | } |
| 2257 | } |
| 2258 | mxCatch(the) { |
| 2259 | fxRejectException(the, rejectFunction); |
| 2260 | } |
| 2261 | } |
| 2262 | fxEndHost(the); |
no test coverage detected