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

Function fxExecuteModules

xs/sources/xsModule.c:384–463  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

382}
383
384void fxExecuteModules(txMachine* the, txSlot* queue)
385{
386 txBoolean done = 1;
387 txSlot* module = queue->next;
388 mxReportModuleQueue("INIT");
389 while (module) {
390 txID status = mxModuleStatus(module);
391 if (status == XS_MODULE_STATUS_LINKED) {
392 txSlot* exception;
393 txID fromStatus = fxExecuteModulesFrom(the, queue, module, &exception);
394 if (fromStatus == XS_MODULE_STATUS_ERROR) {
395 fxCompleteModule(the, module->value.reference, exception);
396 fxRunImportRejected(the, module->value.reference, module->value.reference);
397 }
398 else if (fromStatus == XS_MODULE_STATUS_LINKED) {
399 mxModuleStatus(module) = XS_MODULE_STATUS_EXECUTING;
400 mxPushSlot(mxModuleHosts(module));
401 mxPull(mxHosts);
402 {
403 mxTry(the) {
404 txSlot* result;
405 mxPushUndefined();
406 mxPushSlot(mxModuleExecute(module));
407 mxCall();
408 mxRunCount(0);
409 result = the->stack;
410 if (mxIsReference(result) && mxIsPromise(result->value.reference)) {
411 txSlot* function;
412 txSlot* home;
413 txSlot* resolveExecuteFunction;
414 txSlot* rejectExecuteFunction;
415
416 function = fxNewHostFunction(the, fxExecuteModulesFulfilled, 1, XS_NO_ID, mxExecuteModulesFulfilledProfileID);
417 home = mxFunctionInstanceHome(function);
418 home->value.home.object = queue;
419 home->value.home.module = module->value.reference;
420 resolveExecuteFunction = the->stack;
421
422 function = fxNewHostFunction(the, fxExecuteModulesRejected, 1, XS_NO_ID, mxExecuteModulesRejectedProfileID);
423 home = mxFunctionInstanceHome(function);
424 home->value.home.object = queue;
425 home->value.home.module = module->value.reference;
426 rejectExecuteFunction = the->stack;
427
428 fxPromiseThen(the, result->value.reference, resolveExecuteFunction, rejectExecuteFunction, C_NULL, C_NULL);
429
430 mxPop();
431 mxPop();
432 mxPop();
433 done = 0;
434 }
435 else {
436 mxPop();
437 fxCompleteModule(the, module->value.reference, C_NULL);
438 fxRunImportFulfilled(the, module->value.reference, module->value.reference);
439 }
440 }
441 mxCatch(the) {

Callers 3

fxExecuteModulesRejectedFunction · 0.85
fxLoadModulesFunction · 0.85

Calls 6

fxExecuteModulesFromFunction · 0.85
fxCompleteModuleFunction · 0.85
fxRunImportRejectedFunction · 0.85
fxNewHostFunctionFunction · 0.85
fxPromiseThenFunction · 0.85
fxRunImportFulfilledFunction · 0.85

Tested by

no test coverage detected