** 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. */
| 292 | ** it. Raise an error if __call metafield is not a function. |
| 293 | */ |
| 294 | static void tryfuncTM (lua_State *L, StkId func) { |
| 295 | const TValue *tm = luaT_gettmbyobj(L, func, TM_CALL); |
| 296 | StkId p; |
| 297 | if (!ttisfunction(tm)) |
| 298 | luaG_typeerror(L, func, "call"); |
| 299 | /* Open a hole inside the stack at 'func' */ |
| 300 | for (p = L->top; p > func; p--) |
| 301 | setobjs2s(L, p, p-1); |
| 302 | L->top++; /* slot ensured by caller */ |
| 303 | setobj2s(L, func, tm); /* tag method is the new function to be called */ |
| 304 | } |
| 305 | |
| 306 | |
| 307 |
no test coverage detected