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

Function fx_ModuleStuff

xs/sources/xsModule.c:3612–3669  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3610}
3611
3612void fx_ModuleStuff(txMachine* the)
3613{
3614 txSlot* instance;
3615 txSlot* handler;
3616 txSlot* importHook;
3617 txSlot* importMetaHook;
3618 txSlot* importNowHook;
3619 txSlot* slot;
3620 if (!mxHasTarget)
3621 mxTypeError("call: ModuleStuff");
3622 if ((mxArgc < 1) || (!mxIsReference(mxArgv(0))))
3623 mxTypeError("source: not an object");
3624 if ((mxArgc < 2) || mxIsUndefined(mxArgv(1))) {
3625 mxPushUndefined();
3626 mxPushUndefined();
3627 mxPushUndefined();
3628 mxPushUndefined();
3629 }
3630 else if (mxIsReference(mxArgv(1))) {
3631 mxPushSlot(mxArgv(1));
3632 mxPushSlot(mxArgv(1));
3633 mxGetID(fxID(the, "importHook"));
3634 if (!mxIsUndefined(the->stack) && !fxIsCallable(the, the->stack))
3635 mxTypeError("handler.importHook: not a function");
3636 mxPushSlot(mxArgv(1));
3637 mxGetID(fxID(the, "importMetaHook"));
3638 if (!mxIsUndefined(the->stack) && !fxIsCallable(the, the->stack))
3639 mxTypeError("handler.importMetaHook: not a function");
3640 mxPushSlot(mxArgv(1));
3641 mxGetID(fxID(the, "importNowHook"));
3642 if (!mxIsUndefined(the->stack) && !fxIsCallable(the, the->stack))
3643 mxTypeError("handler.importNowHook: not a function");
3644 }
3645 else {
3646 mxTypeError("handler: not an object");
3647 }
3648 handler = the->stack + 3;
3649 importHook = the->stack + 2;
3650 importMetaHook = the->stack + 1;
3651 importNowHook = the->stack;
3652
3653 mxPushSlot(mxTarget);
3654 fxGetPrototypeFromConstructor(the, &mxModuleStuffPrototype);
3655 instance = fxNewModuleStuffInstance(the);
3656 mxPullSlot(mxResult);
3657
3658 slot = fxLastProperty(the, instance);
3659 slot = fxNextSlotProperty(the, slot, mxArgv(0), XS_NO_ID, XS_INTERNAL_FLAG);
3660 slot = fxNextSlotProperty(the, slot, handler, XS_NO_ID, XS_INTERNAL_FLAG);
3661 slot = fxNextSlotProperty(the, slot, importHook, XS_NO_ID, XS_INTERNAL_FLAG);
3662 slot = fxNextSlotProperty(the, slot, importMetaHook, XS_NO_ID, XS_INTERNAL_FLAG);
3663 slot = fxNextSlotProperty(the, slot, importNowHook, XS_NO_ID, XS_INTERNAL_FLAG);
3664
3665 mxPop();
3666 mxPop();
3667 mxPop();
3668 mxPop();
3669}

Callers

nothing calls this directly

Calls 6

fxIDFunction · 0.85
fxIsCallableFunction · 0.85
fxNewModuleStuffInstanceFunction · 0.85
fxLastPropertyFunction · 0.85
fxNextSlotPropertyFunction · 0.85

Tested by

no test coverage detected