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

Function fx_agent_start_aux

xs/tools/xst.c:688–751  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

686unsigned int __stdcall fx_agent_start_aux(void* it)
687#else
688void* fx_agent_start_aux(void* it)
689#endif
690{
691 xsCreation creation = {
692 16 * 1024 * 1024, /* initialChunkSize */
693 16 * 1024 * 1024, /* incrementalChunkSize */
694 1 * 1024 * 1024, /* initialHeapCount */
695 1 * 1024 * 1024, /* incrementalHeapCount */
696 4096, /* stackCount */
697 1024, /* initialKeyCount */
698 1024, /* incrementalKeyCount */
699 1993, /* nameModulo */
700 127, /* symbolModulo */
701 64 * 1024, /* parserBufferSize */
702 1993, /* parserTableModulo */
703 };
704 txAgent* agent = it;
705 xsMachine* machine = xsCreateMachine(&creation, "xst-agent", NULL);
706 xsBeginHost(machine);
707 {
708 xsTry {
709 txSlot* slot;
710 txSlot* global;
711 txStringCStream stream;
712
713 mxPush(mxGlobal);
714 global = the->stack;
715
716 slot = fxLastProperty(the, fxNewHostObject(the, NULL));
717 slot = fxNextHostFunctionProperty(the, slot, fx_agent_leaving, 0, xsID("leaving"), XS_DONT_ENUM_FLAG);
718 slot = fxNextHostFunctionProperty(the, slot, fx_agent_monotonicNow, 0, xsID("monotonicNow"), XS_DONT_ENUM_FLAG);
719 slot = fxNextHostFunctionProperty(the, slot, fx_agent_receiveBroadcast, 1, xsID("receiveBroadcast"), XS_DONT_ENUM_FLAG);
720 slot = fxNextHostFunctionProperty(the, slot, fx_agent_report, 1, xsID("report"), XS_DONT_ENUM_FLAG);
721 slot = fxNextHostFunctionProperty(the, slot, fx_agent_sleep, 1, xsID("sleep"), XS_DONT_ENUM_FLAG);
722 fxSetHostData(the, the->stack, agent);
723
724 mxPush(mxObjectPrototype);
725 slot = fxLastProperty(the, fxNewObjectInstance(the));
726 slot = fxNextSlotProperty(the, slot, the->stack + 1, xsID("agent"), XS_GET_ONLY);
727
728 slot = fxLastProperty(the, fxToInstance(the, global));
729 slot = fxNextSlotProperty(the, slot, the->stack, xsID("$262"), XS_GET_ONLY);
730
731 mxPop();
732 mxPop();
733 mxPop();
734
735 stream.buffer = agent->script;
736 stream.offset = 0;
737 stream.size = agent->scriptLength;
738 fxRunScript(the, fxParseScript(the, &stream, fxStringCGetter, mxProgramFlag), mxThis, C_NULL, C_NULL, C_NULL, mxProgram.value.reference);
739 fxRunLoop(the);
740 }
741 xsCatch {
742 }
743 }
744 xsEndHost(the);
745 xsDeleteMachine(machine);

Callers

nothing calls this directly

Calls 10

fxLastPropertyFunction · 0.85
fxNewHostObjectFunction · 0.85
fxSetHostDataFunction · 0.85
fxNewObjectInstanceFunction · 0.85
fxNextSlotPropertyFunction · 0.85
fxToInstanceFunction · 0.85
fxRunScriptFunction · 0.85
fxRunLoopFunction · 0.85
fxParseScriptFunction · 0.70

Tested by

no test coverage detected