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

Function luaD_tryfuncTM

extlibs/lua/src/ldo.c:355–364  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

353** an error if there is no '__call' metafield.
354*/
355void luaD_tryfuncTM (lua_State *L, StkId func) {
356 const TValue *tm = luaT_gettmbyobj(L, s2v(func), TM_CALL);
357 StkId p;
358 if (unlikely(ttisnil(tm)))
359 luaG_typeerror(L, s2v(func), "call"); /* nothing to call */
360 for (p = L->top; p > func; p--) /* open space for metamethod */
361 setobjs2s(L, p, p-1);
362 L->top++; /* stack space pre-allocated by the caller */
363 setobj2s(L, func, tm); /* metamethod is the new function to be called */
364}
365
366
367/*

Callers 2

luaV_executeFunction · 0.85
luaD_callFunction · 0.85

Calls 2

luaT_gettmbyobjFunction · 0.85
luaG_typeerrorFunction · 0.85

Tested by

no test coverage detected