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

Function fxLoadModule

xs/platforms/mc/xsHosts.c:345–390  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

343}
344
345void fxLoadModule(txMachine* the, txSlot* module, txID moduleID)
346{
347 txPreparation* preparation = the->preparation;
348 txString path = fxGetKeyName(the, moduleID);
349 txInteger c = preparation->scriptCount;
350 txScript* script = preparation->scripts;
351#if MODDEF_XS_MODS
352 uint8_t *mod;
353 int modSize;
354
355 mod = findMod(the, path, &modSize);
356 if (mod) {
357 txScript aScript;
358
359 aScript.callback = NULL;
360 aScript.symbolsBuffer = NULL;
361 aScript.symbolsSize = 0;
362 aScript.codeBuffer = mod;
363 aScript.codeSize = modSize;
364 aScript.hostsBuffer = NULL;
365 aScript.hostsSize = 0;
366 aScript.path = path;
367 aScript.version[0] = XS_MAJOR_VERSION;
368 aScript.version[1] = XS_MINOR_VERSION;
369 aScript.version[2] = XS_PATCH_VERSION;
370 aScript.version[3] = 0;
371
372 fxResolveModule(the, module, moduleID, &aScript, C_NULL, C_NULL);
373 return;
374 }
375#endif
376
377 while (c > 0) {
378 if (!c_strcmp(path, script->path)) {
379 fxResolveModule(the, module, moduleID, script, C_NULL, C_NULL);
380 return;
381 }
382 c--;
383 script++;
384 }
385
386#if defined(mxDebug) && MODDEF_XS_TEST
387 if (!c_strncmp(path, "xsbug://", 8))
388 fxDebugImport(the, module, path);
389#endif
390}
391
392txScript* fxParseScript(txMachine* the, void* stream, txGetter getter, txUnsigned flags)
393{

Callers

nothing calls this directly

Calls 4

fxGetKeyNameFunction · 0.85
fxResolveModuleFunction · 0.85
fxDebugImportFunction · 0.85
findModFunction · 0.70

Tested by

no test coverage detected