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

Function tryfuncTM

third-party/lua-5.5.0/src/ldo.c:523–536  ·  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. ** Bits CIST_CCMT in status count how many _call metamethods were ** invoked and how many corresponding extra arguments were pushed. ** (This count will be saved in the 'callstatus' of the call). ** Raise a

Source from the content-addressed store, hash-verified

521** Raise an error if this counter overflows.
522*/
523static unsigned tryfuncTM (lua_State *L, StkId func, unsigned status) {
524 const TValue *tm;
525 StkId p;
526 tm = luaT_gettmbyobj(L, s2v(func), TM_CALL);
527 if (l_unlikely(ttisnil(tm))) /* no metamethod? */
528 luaG_callerror(L, s2v(func));
529 for (p = L->top.p; p > func; p--) /* open space for metamethod */
530 setobjs2s(L, p, p-1);
531 L->top.p++; /* stack space pre-allocated by the caller */
532 setobj2s(L, func, tm); /* metamethod is the new function to be called */
533 if ((status & MAX_CCMT) == MAX_CCMT) /* is counter full? */
534 luaG_runerror(L, "'__call' chain too long");
535 return status + (1u << CIST_CCMT); /* increment counter */
536}
537
538
539/* Generic case for 'moveresult' */

Callers 2

luaD_pretailcallFunction · 0.70
luaD_precallFunction · 0.70

Calls 3

luaT_gettmbyobjFunction · 0.70
luaG_callerrorFunction · 0.70
luaG_runerrorFunction · 0.70

Tested by

no test coverage detected