MCPcopy Create free account
hub / github.com/Achain-Dev/Achain / tryfuncTM

Function tryfuncTM

src/Chain/libraries/glua/ldo.cpp:336–351  ·  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

334** it. Raise an error if __call metafield is not a function.
335*/
336static void tryfuncTM(lua_State *L, StkId func) {
337 const TValue *tm = luaT_gettmbyobj(L, func, TM_CALL);
338 StkId p;
339 if (!ttisfunction(tm))
340 {
341 global_glua_chain_api->throw_exception(L, THINKYOUNG_API_LVM_ERROR, "Can't find __call method");
342 luaG_typeerror(L, func, "call");
343 }
344 if (L->force_stopping)
345 return;
346 /* Open a hole inside the stack at 'func' */
347 for (p = L->top; p > func; p--)
348 setobjs2s(L, p, p - 1);
349 L->top++; /* slot ensured by caller */
350 setobj2s(L, func, tm); /* tag method is the new function to be called */
351}
352
353
354

Callers 1

ldo.cppFile · 0.85

Calls 3

luaT_gettmbyobjFunction · 0.85
luaG_typeerrorFunction · 0.85
throw_exceptionMethod · 0.45

Tested by

no test coverage detected