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

Function fxBundleLoad

xs/tools/xstBundle.c:117–140  ·  view source on GitHub ↗

Called from xst.c's fxLoadModule. Returns 1 if the module ID was found in the bundle map (and resolved), 0 to fall through to filesystem loading. Non-bundle usage: the map is empty, so this returns 0 immediately.

Source from the content-addressed store, hash-verified

115// the bundle map (and resolved), 0 to fall through to filesystem loading.
116// Non-bundle usage: the map is empty, so this returns 0 immediately.
117int fxBundleLoad(txMachine *the, txSlot *module, txID moduleID)
118{
119 if (gBundleMapCount == 0)
120 return 0;
121 const char *name = fxGetKeyName(the, moduleID);
122 if (!name)
123 return 0;
124 const txBundleEntry *entry = fxBundleMapGet(name);
125 if (!entry)
126 return 0;
127 txStringCStream stream;
128 stream.buffer = (char *)entry->source;
129 stream.offset = 0;
130 stream.size = entry->sourceLen;
131#ifdef mxDebug
132 txUnsigned flags = mxDebugFlag;
133#else
134 txUnsigned flags = 0;
135#endif
136 txScript *script = fxParseScript(the, &stream, fxStringCGetter, flags);
137 if (script)
138 fxResolveModule(the, module, moduleID, script, C_NULL, C_NULL);
139 return 1;
140}
141
142void fxBundleRun(txMachine *the, char *buffer, size_t size)
143{

Callers 1

fxLoadModuleFunction · 0.85

Calls 4

fxGetKeyNameFunction · 0.85
fxBundleMapGetFunction · 0.85
fxResolveModuleFunction · 0.85
fxParseScriptFunction · 0.70

Tested by

no test coverage detected