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

Function tryfuncTM

third-party/lua-5.4.6/src/ldo.c:419–431  ·  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

417** an error if there is no '__call' metafield.
418*/
419static StkId tryfuncTM (lua_State *L, StkId func) {
420 const TValue *tm;
421 StkId p;
422 checkstackGCp(L, 1, func); /* space for metamethod */
423 tm = luaT_gettmbyobj(L, s2v(func), TM_CALL); /* (after previous GC) */
424 if (l_unlikely(ttisnil(tm)))
425 luaG_callerror(L, s2v(func)); /* nothing to call */
426 for (p = L->top.p; p > func; p--) /* open space for metamethod */
427 setobjs2s(L, p, p-1);
428 L->top.p++; /* stack space pre-allocated by the caller */
429 setobj2s(L, func, tm); /* metamethod is the new function to be called */
430 return func;
431}
432
433
434/*

Callers 2

luaD_pretailcallFunction · 0.70
luaD_precallFunction · 0.70

Calls 2

luaT_gettmbyobjFunction · 0.70
luaG_callerrorFunction · 0.70

Tested by

no test coverage detected