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

Function fxRunImportNow

xs/sources/xsModule.c:2463–2586  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2461}
2462
2463void fxRunImportNow(txMachine* the, txSlot* realm, txSlot* referrer)
2464{
2465 txSlot* stack = the->stack + 1;
2466 txSlot* module = fxRunImportAux(the, realm, referrer, stack, stack - 1, 1);
2467 txID status = mxModuleStatus(module);
2468 if ((status == XS_MODULE_STATUS_NEW) || (status == XS_MODULE_STATUS_LOADED)) {
2469 txSlot* result = stack;
2470 txSlot* queue = fxNewInstance(the);
2471 mxTry(the) {
2472 txBoolean done = 1;
2473 result->kind = module->kind;
2474 result->value = module->value;
2475
2476 fxQueueModule(the, queue, module);
2477// slot = mxBehaviorSetProperty(the, queue, moduleID, 0, XS_OWN);;
2478// slot->flag |= XS_BASE_FLAG;
2479// slot->kind = XS_REFERENCE_KIND;
2480// slot->value.reference = module->value.reference;
2481
2482 mxReportModuleQueue("LOAD");
2483 module = queue->next;
2484 while (module) {
2485 if (mxModuleStatus(module) == XS_MODULE_STATUS_NEW) {
2486 txSlot* loader = mxModuleLoader(module);
2487 txID moduleID = loader->value.module.id;
2488 txSlot* realm = loader->value.module.realm;
2489 if (!fxMapModule(the, realm, moduleID, module, queue, result)) {
2490 txSlot* loadNowHook = mxLoadNowHook(realm);
2491 if (mxIsUndefined(loadNowHook)) {
2492 if (realm != mxModuleInstanceInternal(mxProgram.value.reference)->value.module.realm)
2493 mxTypeError("no loadNowHook");
2494 fxLoadModule(the, module, moduleID);
2495 if (mxModuleExecute(module)->kind == XS_NULL_KIND)
2496 mxTypeError("no module");
2497 mxModuleStatus(module) = XS_MODULE_STATUS_LOADED;
2498 }
2499 else {
2500 txSlot* descriptor;
2501 done = 0;
2502 mxModuleStatus(module) = XS_MODULE_STATUS_LOADING;
2503 mxPushUndefined();
2504 mxPushSlot(loadNowHook);
2505 mxCall();
2506 fxPushKeyString(the, moduleID, C_NULL);
2507 fxPushModuleOptions(the, loader->flag);
2508 mxRunCount(2);
2509 descriptor = the->stack;
2510 fxMapModuleDescriptor(the, realm, moduleID, module, queue, result, descriptor);
2511 mxPop(); // descriptor
2512 }
2513 }
2514 module = queue;
2515 done = 1;
2516 mxReportModuleQueue("LOAD");
2517 }
2518 else if (mxModuleStatus(module) == XS_MODULE_STATUS_LOADING) {
2519 done = 0;
2520 }

Callers 3

fxAwaitImportFunction · 0.85
fxImportNowFunction · 0.85

Calls 13

fxRunImportAuxFunction · 0.85
fxNewInstanceFunction · 0.85
fxQueueModuleFunction · 0.85
fxMapModuleFunction · 0.85
fxPushKeyStringFunction · 0.85
fxPushModuleOptionsFunction · 0.85
fxMapModuleDescriptorFunction · 0.85
fxLoadModuleStuffFromFunction · 0.85
fxLoadModulesFromFunction · 0.85
fxLinkModulesFunction · 0.85
fxCompleteModuleFunction · 0.85
fxJumpFunction · 0.85

Tested by

no test coverage detected