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

Function fxRunImportAux

xs/sources/xsModule.c:2268–2319  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2266}
2267
2268txSlot* fxRunImportAux(txMachine* the, txSlot* realm, txSlot* referrer, txSlot* specifier, txSlot* options, txBoolean now)
2269{
2270 txSlot* module;
2271 txID moduleID;
2272 txFlag moduleFlag = fxCheckModuleOptions(the, options);
2273#if mxModuleStuff
2274 if (mxIsReference(specifier)) {
2275 txSlot* internal = specifier->value.reference->next;
2276 if (internal && (internal->kind == XS_MODULE_STUFF_KIND)) {
2277 module = mxModuleStuffModule(specifier);
2278 if (mxIsNull(module)) {
2279 txSlot* source = mxModuleStuffSource(specifier);
2280 fxNewModule(the, realm, XS_NO_ID, XS_NO_FLAG, module);
2281 if (mxIsModuleSource(source->value.reference))
2282 fxDuplicateModuleTransfers(the, source, module);
2283 else
2284 fxLoadVirtualModuleSource(the, source, module->value.reference);
2285 internal = mxModuleHook(module);
2286 internal->kind = specifier->kind;
2287 internal->value = specifier->value;
2288 mxModuleStatus(module) = XS_MODULE_STATUS_LOADED;
2289 }
2290 return module;
2291 }
2292 }
2293#endif
2294 fxToString(the, specifier);
2295 if (referrer) {
2296#if mxModuleStuff
2297 if (referrer->next->kind == XS_MODULE_KIND) {
2298 txSlot* reference = mxModuleInstanceHook(referrer);
2299 if (mxIsReference(reference)) {
2300 txSlot* handler = mxModuleStuffHandler(reference);
2301 txSlot* importHook = (now) ? mxModuleStuffImportNowHook(reference) : mxModuleStuffImportHook(reference);
2302 if (mxIsReference(handler) && mxIsReference(importHook)) {
2303 module = fxImportModuleStuff(the, realm, mxModuleQueue.value.reference, reference, specifier, now);
2304 return module;
2305 }
2306 }
2307 }
2308#endif
2309 moduleID = fxResolveSpecifier(the, realm, mxModuleInstanceInternal(referrer)->value.module.id, specifier);
2310 }
2311 else
2312 moduleID = fxResolveSpecifier(the, realm, XS_NO_ID, specifier);
2313 module = fxGetModule(the, realm, moduleID, moduleFlag);
2314 if (!module) {
2315 module = mxBehaviorSetProperty(the, mxOwnModules(realm)->value.reference, moduleID, 0, XS_OWN);
2316 fxNewModule(the, realm, moduleID, moduleFlag, module);
2317 }
2318 return module;
2319}
2320
2321void fxRunImportFulfilled(txMachine* the, txSlot* module, txSlot* with)
2322{

Callers 2

fxRunImportFunction · 0.85
fxRunImportNowFunction · 0.85

Calls 8

fxCheckModuleOptionsFunction · 0.85
fxNewModuleFunction · 0.85
fxToStringFunction · 0.85
fxImportModuleStuffFunction · 0.85
fxResolveSpecifierFunction · 0.85
fxGetModuleFunction · 0.85

Tested by

no test coverage detected