MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / tryfuncTM

Function tryfuncTM

third-party/lua-5.3.5/src/ldo.c:315–325  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

313** it. Raise an error if __call metafield is not a function.
314*/
315static void tryfuncTM (lua_State *L, StkId func) {
316 const TValue *tm = luaT_gettmbyobj(L, func, TM_CALL);
317 StkId p;
318 if (!ttisfunction(tm))
319 luaG_typeerror(L, func, "call");
320 /* Open a hole inside the stack at 'func' */
321 for (p = L->top; p > func; p--)
322 setobjs2s(L, p, p-1);
323 L->top++; /* slot ensured by caller */
324 setobj2s(L, func, tm); /* tag method is the new function to be called */
325}
326
327
328/*

Callers 1

luaD_precallFunction · 0.70

Calls 2

luaT_gettmbyobjFunction · 0.70
luaG_typeerrorFunction · 0.70

Tested by

no test coverage detected