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

Function fx_Function

xs/sources/xsFunction.c:262–297  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

260}
261
262void fx_Function(txMachine* the)
263{
264 txInteger c, i;
265 txStringStream stream;
266 txSlot* module = mxFunctionInstanceHome(mxFunction->value.reference)->value.home.module;
267 if (!module) module = mxProgram.value.reference;
268
269 c = mxArgc;
270 i = 0;
271 mxPushStringX("(function anonymous(");
272 while (c > 1) {
273 fxToString(the, mxArgv(i));
274 fxConcatString(the, the->stack, mxArgv(i));
275 if (c > 2)
276 fxConcatStringC(the, the->stack, ", ");
277 c--;
278 i++;
279 }
280 fxConcatStringC(the, the->stack, "\n){");
281 if (c > 0) {
282 fxToString(the, mxArgv(i));
283 fxConcatString(the, the->stack, mxArgv(i));
284 }
285 fxConcatStringC(the, the->stack, "\n})");
286 stream.slot = the->stack;
287 stream.offset = 0;
288 stream.size = mxStringLength(the->stack->value.string);
289 fxRunScript(the, fxParseScript(the, &stream, fxStringGetter, mxProgramFlag | mxFunctionFlag), C_NULL, C_NULL, C_NULL, C_NULL, module);
290 mxPullSlot(mxResult);
291 if (mxHasTarget && !fxIsSameSlot(the, mxTarget, mxFunction)) {
292 mxPushSlot(mxTarget);
293 fxGetPrototypeFromConstructor(the, &mxFunctionPrototype);
294 mxResult->value.reference->value.instance.prototype = the->stack->value.reference;
295 mxPop();
296 }
297}
298
299void fx_Function_prototype_apply(txMachine* the)
300{

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