** 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. */
| 313 | ** it. Raise an error if __call metafield is not a function. |
| 314 | */ |
| 315 | static void tryfuncTM (lua_State *L, StkId func) { |
| 316 | const TValue *tm = luaT_gettmbyobj(L, func, TM_CALL); |
| 317 | StkId p; |
| 318 | if (!ttisfunction(tm)) |
| 319 | luaG_typeerror(L, func, "call"); |
| 320 | /* Open a hole inside the stack at 'func' */ |
| 321 | for (p = L->top; p > func; p--) |
| 322 | setobjs2s(L, p, p-1); |
| 323 | L->top++; /* slot ensured by caller */ |
| 324 | setobj2s(L, func, tm); /* tag method is the new function to be called */ |
| 325 | } |
| 326 | |
| 327 | |
| 328 | /* |
no test coverage detected