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

Function fxImportModuleStuff

xs/sources/xsModule.c:3469–3504  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3467}
3468
3469txSlot* fxImportModuleStuff(txMachine* the, txSlot* realm, txSlot* queue, txSlot* reference, txSlot* name, txBoolean now)
3470{
3471 txID moduleID = (name->kind == XS_STRING_X_KIND) ? fxNewNameX(the, name->value.string) : fxNewName(the, name);
3472 txSlot* list = mxModuleStuffModules(reference)->value.reference;
3473 txSlot* module = mxBehaviorGetProperty(the, list, moduleID, 0, XS_ANY);
3474 if (!module) {
3475 txSlot* handler = mxModuleStuffHandler(reference);
3476 txSlot* importHook = (now) ? mxModuleStuffImportNowHook(reference) : mxModuleStuffImportHook(reference);
3477 txSlot* loader;
3478
3479 module = mxBehaviorSetProperty(the, list, moduleID, 0, XS_OWN);
3480 fxNewModule(the, realm, XS_NO_ID, XS_NO_FLAG, module);
3481 mxModuleStatus(module) = XS_MODULE_STATUS_LOADING;
3482 fxQueueModule(the, queue, module);
3483
3484 loader = mxModuleLoader(module);
3485 loader->kind = reference->kind;
3486 loader->value = reference->value;
3487
3488 mxPushSlot(handler);
3489 mxPushSlot(importHook);
3490 mxCall();
3491 mxPushSlot(name);
3492 fxPushModuleOptions(the, name->flag);
3493 mxRunCount(2);
3494
3495 if (now) {
3496 fxLoadModuleStuff(the, queue, module, the->stack);
3497 }
3498 else {
3499 fxLoadModulesPromise(the, queue, module, the->stack, fxLoadModuleStuffFulfilled, fxLoadModuleStuffRejected);
3500 }
3501 mxPop();
3502 }
3503 return module;
3504}
3505
3506void fxLoadModuleStuff(txMachine* the, txSlot* queue, txSlot* module, txSlot* stuff)
3507{

Callers 2

fxRunImportAuxFunction · 0.85
fxLoadModuleStuffFromFunction · 0.85

Calls 7

fxNewNameXFunction · 0.85
fxNewNameFunction · 0.85
fxNewModuleFunction · 0.85
fxQueueModuleFunction · 0.85
fxPushModuleOptionsFunction · 0.85
fxLoadModuleStuffFunction · 0.85
fxLoadModulesPromiseFunction · 0.85

Tested by

no test coverage detected