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

Function fx_AsyncFunction

xs/sources/xsFunction.c:726–761  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

724}
725
726void fx_AsyncFunction(txMachine* the)
727{
728 txInteger c, i;
729 txStringStream stream;
730 txSlot* module = mxFunctionInstanceHome(mxFunction->value.reference)->value.home.module;
731 if (!module) module = mxProgram.value.reference;
732
733 c = mxArgc;
734 i = 0;
735 mxPushStringX("(async function anonymous(");
736 while (c > 1) {
737 fxToString(the, mxArgv(i));
738 fxConcatString(the, the->stack, mxArgv(i));
739 if (c > 2)
740 fxConcatStringC(the, the->stack, ", ");
741 c--;
742 i++;
743 }
744 fxConcatStringC(the, the->stack, "\n){");
745 if (c > 0) {
746 fxToString(the, mxArgv(i));
747 fxConcatString(the, the->stack, mxArgv(i));
748 }
749 fxConcatStringC(the, the->stack, "\n})");
750 stream.slot = the->stack;
751 stream.offset = 0;
752 stream.size = mxStringLength(the->stack->value.string);
753 fxRunScript(the, fxParseScript(the, &stream, fxStringGetter, mxProgramFlag | mxFunctionFlag), C_NULL, C_NULL, C_NULL, C_NULL, module);
754 mxPullSlot(mxResult);
755 if (mxHasTarget && !fxIsSameSlot(the, mxTarget, mxFunction)) {
756 mxPushSlot(mxTarget);
757 fxGetPrototypeFromConstructor(the, &mxAsyncFunctionPrototype);
758 mxResult->value.reference->value.instance.prototype = the->stack->value.reference;
759 mxPop();
760 }
761}

Callers

nothing calls this directly

Calls 7

fxToStringFunction · 0.85
fxConcatStringFunction · 0.85
fxConcatStringCFunction · 0.85
fxRunScriptFunction · 0.85
fxIsSameSlotFunction · 0.85
fxParseScriptFunction · 0.70

Tested by

no test coverage detected