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

Function fxBuildModule

xs/sources/xsModule.c:176–236  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

174#endif
175
176void fxBuildModule(txMachine* the)
177{
178 txSlot* slot;
179
180 fxNewHostFunction(the, mxCallback(fxModuleGetter), 0, XS_NO_ID, XS_NO_ID);
181 mxPushUndefined();
182 the->stack->flag = XS_DONT_DELETE_FLAG;
183 the->stack->kind = XS_ACCESSOR_KIND;
184 the->stack->value.accessor.getter = (the->stack + 1)->value.reference;
185 the->stack->value.accessor.setter = C_NULL;
186 mxPull(mxModuleAccessor);
187 the->stack += 1;
188
189 mxPush(mxObjectPrototype);
190 slot = fxLastProperty(the, fxNewObjectInstance(the));
191 slot = fxNextStringXProperty(the, slot, "Module", mxID(_Symbol_toStringTag), XS_GET_ONLY);
192 mxModulePrototype = *the->stack;
193 mxPop();
194
195 mxPush(mxObjectPrototype);
196 fxNewObjectInstance(the);
197 mxTransferPrototype = *the->stack;
198 mxPop();
199
200 mxPush(mxObjectPrototype);
201 slot = fxLastProperty(the, fxNewObjectInstance(the));
202 slot = fxNextHostAccessorProperty(the, slot, mxCallback(fx_Compartment_prototype_get_globalThis), C_NULL, mxID(_globalThis), XS_DONT_ENUM_FLAG);
203 slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Compartment_prototype_evaluate), 1, mxID(_evaluate), XS_DONT_ENUM_FLAG);
204 slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Compartment_prototype_import), 1, mxID(_import), XS_DONT_ENUM_FLAG);
205 slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Compartment_prototype_importNow), 1, mxID(_importNow), XS_DONT_ENUM_FLAG);
206// slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Compartment_prototype_module), 1, mxID(_module), XS_DONT_ENUM_FLAG);
207 slot = fxNextStringXProperty(the, slot, "Compartment", mxID(_Symbol_toStringTag), XS_DONT_ENUM_FLAG | XS_DONT_SET_FLAG);
208 mxCompartmentPrototype = *the->stack;
209 slot = fxBuildHostConstructor(the, mxCallback(fx_Compartment), 1, mxID(_Compartment));
210 mxCompartmentConstructor = *the->stack;
211 mxPop();
212
213 mxPush(mxObjectPrototype);
214 slot = fxLastProperty(the, fxNewObjectInstance(the));
215 slot = fxNextHostAccessorProperty(the, slot, mxCallback(fx_ModuleSource_prototype_get_bindings), C_NULL, mxID(_bindings), XS_DONT_ENUM_FLAG);
216 slot = fxNextHostAccessorProperty(the, slot, mxCallback(fx_ModuleSource_prototype_get_needsImport), C_NULL, mxID(_needsImport), XS_DONT_ENUM_FLAG);
217 slot = fxNextHostAccessorProperty(the, slot, mxCallback(fx_ModuleSource_prototype_get_needsImportMeta), C_NULL, mxID(_needsImportMeta), XS_DONT_ENUM_FLAG);
218#if mxECMAScript2025
219 slot = fxNextHostAccessorProperty(the, slot, mxCallback(fx_ModuleSource_prototype_get_options), C_NULL, mxID(_options), XS_DONT_ENUM_FLAG);
220#endif
221 slot = fxNextStringXProperty(the, slot, "ModuleSource", mxID(_Symbol_toStringTag), XS_DONT_ENUM_FLAG | XS_DONT_SET_FLAG);
222 mxModuleSourcePrototype = *the->stack;
223 slot = fxBuildHostConstructor(the, mxCallback(fx_ModuleSource), 1, mxID(_ModuleSource));
224 mxModuleSourceConstructor = *the->stack;
225 mxPop();
226
227#if mxModuleStuff
228 mxPush(mxObjectPrototype);
229 slot = fxLastProperty(the, fxNewObjectInstance(the));
230 slot = fxNextStringXProperty(the, slot, "ModuleStuff", mxID(_Symbol_toStringTag), XS_DONT_ENUM_FLAG | XS_DONT_SET_FLAG);
231 mxModuleStuffPrototype = *the->stack;
232 slot = fxBuildHostConstructor(the, mxCallback(fx_ModuleStuff), 1, mxID(_ModuleStuff));
233 mxModuleStuffConstructor = *the->stack;

Callers 1

fxCreateMachineFunction · 0.85

Calls 7

fxNewHostFunctionFunction · 0.85
fxLastPropertyFunction · 0.85
fxNewObjectInstanceFunction · 0.85
fxNextStringXPropertyFunction · 0.85
fxBuildHostConstructorFunction · 0.85

Tested by

no test coverage detected