MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / luaD_tryfuncTM

Function luaD_tryfuncTM

3rd/lua-5.4.3/src/ldo.c:390–399  ·  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*/
390void luaD_tryfuncTM (lua_State *L, StkId func) {
391 const TValue *tm = luaT_gettmbyobj(L, s2v(func), TM_CALL);
392 StkId p;
393 if (l_unlikely(ttisnil(tm)))
394 luaG_callerror(L, s2v(func)); /* nothing to call */
395 for (p = L->top; p > func; p--) /* open space for metamethod */
396 setobjs2s(L, p, p-1);
397 L->top++; /* stack space pre-allocated by the caller */
398 setobj2s(L, func, tm); /* metamethod is the new function to be called */
399}
400
401
402/*

Callers 2

luaV_executeFunction · 0.85
luaD_precallFunction · 0.85

Calls 2

luaT_gettmbyobjFunction · 0.85
luaG_callerrorFunction · 0.85

Tested by

no test coverage detected