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

Function fx_ModuleSource

xs/sources/xsModule.c:3267–3302  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3265}
3266
3267void fx_ModuleSource(txMachine* the)
3268{
3269 txSlot* instance;
3270 txUnsigned flags = mxDebugFlag;
3271 txSlot* slot;
3272 txStringStream stream;
3273 txScript* script;
3274 if (!mxHasTarget)
3275 mxTypeError("call: ModuleSource");
3276 mxPushSlot(mxTarget);
3277 fxGetPrototypeFromConstructor(the, &mxModuleSourcePrototype);
3278 instance = fxNewModuleSourceInstance(the);
3279 mxPullSlot(mxResult);
3280 if (mxArgc > 0)
3281 mxPushSlot(mxArgv(0));
3282 else
3283 mxPushUndefined();
3284 if (mxArgc > 1) {
3285 if (fxCheckModuleOptions(the, mxArgv(1))) {
3286 instance->next->flag |= XS_JSON_MODULE_FLAG;
3287 flags |= mxJSONModuleFlag;
3288 }
3289 }
3290 slot = the->stack;
3291 stream.slot = slot;
3292 stream.offset = 0;
3293 stream.size = mxStringLength(fxToString(the, slot));
3294 script = fxParseScript(the, &stream, fxStringGetter, flags);
3295// mxPushClosure(mxResult);
3296 fxRunScript(the, script, mxResult, C_NULL, C_NULL, C_NULL, instance);
3297 mxPop();
3298 if (mxModuleInstanceExecute(instance)->kind == XS_NULL_KIND)
3299 mxTypeError("no module");
3300 mxPop();
3301 mxPop();
3302}
3303
3304void fx_ModuleSource_prototype_get_bindings(txMachine* the)
3305{

Callers

nothing calls this directly

Calls 6

fxCheckModuleOptionsFunction · 0.85
fxToStringFunction · 0.85
fxRunScriptFunction · 0.85
fxParseScriptFunction · 0.70

Tested by

no test coverage detected