MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / luaD_tryfuncTM

Function luaD_tryfuncTM

xrepo/packages/l/lua/port/lua/src/ldo.c:390–402  ·  view source on GitHub ↗

** Check whether 'func' has a '__call' metafield. If so, put it in the ** stack, below original 'func', so that 'luaD_precall' can call it. Raise ** an error if there is no '__call' metafield. */

Source from the content-addressed store, hash-verified

388** an error if there is no '__call' metafield.
389*/
390StkId luaD_tryfuncTM (lua_State *L, StkId func) {
391 const TValue *tm;
392 StkId p;
393 checkstackGCp(L, 1, func); /* space for metamethod */
394 tm = luaT_gettmbyobj(L, s2v(func), TM_CALL); /* (after previous GC) */
395 if (l_unlikely(ttisnil(tm)))
396 luaG_callerror(L, s2v(func)); /* nothing to call */
397 for (p = L->top; p > func; p--) /* open space for metamethod */
398 setobjs2s(L, p, p-1);
399 L->top++; /* stack space pre-allocated by the caller */
400 setobj2s(L, func, tm); /* metamethod is the new function to be called */
401 return func;
402}
403
404
405/*

Callers 2

luaD_pretailcallFunction · 0.85
luaD_precallFunction · 0.85

Calls 2

luaG_callerrorFunction · 0.85
luaT_gettmbyobjFunction · 0.70

Tested by

no test coverage detected