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

Function fxAwaitImport

xs/sources/xsModule.c:2413–2453  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2411/* NOW */
2412
2413void fxAwaitImport(txMachine* the, txBoolean defaultFlag)
2414{
2415 txSlot* stack = the->stack;
2416 txSlot* realm = mxModuleInstanceInternal(mxProgram.value.reference)->value.module.realm;
2417 txID defaultID;
2418 txSlot* export;
2419 mxTry(the) {
2420 fxToString(the, stack);
2421 if (defaultFlag & XS_IMPORT_PREFLIGHT) {
2422 txID moduleID = fxFindModule(the, realm, XS_NO_ID, stack);
2423 stack->kind = XS_BOOLEAN_KIND;
2424 stack->value.boolean = moduleID != XS_NO_ID;
2425 }
2426 else {
2427 mxPushUndefined();
2428 if (defaultFlag & XS_IMPORT_ASYNC) {
2429 gxDefaults.runImport(the, realm, C_NULL);
2430 }
2431 else {
2432 fxRunImportNow(the, realm, C_NULL);
2433 if (defaultFlag & XS_IMPORT_DEFAULT) {
2434 defaultID = mxID(_default);
2435 export = mxModuleExports(stack)->value.reference->next;
2436 while (export) {
2437 mxCheck(the, export->kind == XS_EXPORT_KIND);
2438 if (export->ID == defaultID) {
2439 stack->kind = export->value.export.closure->kind;
2440 stack->value = export->value.export.closure->value;
2441 break;
2442 }
2443 export = export->next;
2444 }
2445 }
2446 }
2447 }
2448 }
2449 mxCatch(the) {
2450 fxJump(the);
2451 }
2452 the->stack = stack;
2453}
2454
2455void fxImportNow(txMachine* the)
2456{

Callers 4

xs_importNowFunction · 0.85
xs_importNowFunction · 0.85
xs_importNowFunction · 0.85
xs_importNowFunction · 0.85

Calls 4

fxToStringFunction · 0.85
fxRunImportNowFunction · 0.85
fxJumpFunction · 0.85
fxFindModuleFunction · 0.70

Tested by

no test coverage detected