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

Function fxLoadModules

xs/sources/xsModule.c:1068–1166  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1066}
1067
1068void fxLoadModules(txMachine* the, txSlot* queue)
1069{
1070 txSlot* module = queue->next;
1071 txBoolean done = 1;
1072 if (queue->flag & XS_LEVEL_FLAG)
1073 return;
1074 queue->flag |= XS_LEVEL_FLAG;
1075 mxReportModuleQueue("LOAD");
1076 while (module) {
1077 if (mxModuleStatus(module) == XS_MODULE_STATUS_NEW) {
1078 txSlot* loader = mxModuleLoader(module);
1079 txID moduleID = loader->value.module.id;
1080 txSlot* realm = loader->value.module.realm;
1081 mxTry(the) {
1082 if (fxMapModule(the, realm, moduleID, module, queue, C_NULL)) {
1083 module = queue;
1084 done = 0;
1085 }
1086 else {
1087 txSlot* loadHook = mxLoadHook(realm);
1088 mxModuleStatus(module) = XS_MODULE_STATUS_LOADING;
1089 if (mxIsUndefined(loadHook)) {
1090 if (realm != mxModuleInstanceInternal(mxProgram.value.reference)->value.module.realm)
1091 mxTypeError("no loadHook");
1092 fxLoadModule(the, module, moduleID);
1093 if (mxModuleExecute(module)->kind == XS_NULL_KIND)
1094 mxTypeError("no module");
1095 mxModuleStatus(module) = XS_MODULE_STATUS_LOADED;
1096 module = queue;
1097 done = 1;
1098 mxReportModuleQueue("LOAD");
1099 }
1100 else {
1101 done = 0;
1102 mxModuleStatus(module) = XS_MODULE_STATUS_LOADING;
1103
1104 mxPushUndefined();
1105 mxPushSlot(loadHook);
1106 mxCall();
1107 fxPushKeyString(the, moduleID, C_NULL);
1108 fxPushModuleOptions(the, loader->flag);
1109 mxRunCount(2);
1110
1111 fxLoadModulesPromise(the, queue, module, the->stack, fxLoadModulesFulfilled, fxLoadModulesRejected);
1112
1113 mxPop();
1114 }
1115 }
1116 }
1117 mxCatch(the) {
1118 mxPush(mxException);
1119 mxException = mxUndefined;
1120 fxCompleteModule(the, module->value.reference, the->stack);
1121 fxRunImportRejected(the, module->value.reference, module->value.reference);
1122 }
1123 }
1124 else if (mxModuleStatus(module) == XS_MODULE_STATUS_LOADING) {
1125 done = 0;

Callers 5

fxLoadModulesFulfilledFunction · 0.85
fxLoadModulesRejectedFunction · 0.85
fxRunImportFunction · 0.85

Calls 11

fxMapModuleFunction · 0.85
fxPushKeyStringFunction · 0.85
fxPushModuleOptionsFunction · 0.85
fxLoadModulesPromiseFunction · 0.85
fxCompleteModuleFunction · 0.85
fxRunImportRejectedFunction · 0.85
fxLoadModuleStuffFromFunction · 0.85
fxLoadModulesFromFunction · 0.85
fxLinkModulesFunction · 0.85
fxExecuteModulesFunction · 0.85
fxLoadModuleFunction · 0.70

Tested by

no test coverage detected