** 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. */
| 388 | ** an error if there is no '__call' metafield. |
| 389 | */ |
| 390 | void luaD_tryfuncTM (lua_State *L, StkId func) { |
| 391 | const TValue *tm = luaT_gettmbyobj(L, s2v(func), TM_CALL); |
| 392 | StkId p; |
| 393 | if (l_unlikely(ttisnil(tm))) |
| 394 | luaG_callerror(L, s2v(func)); /* nothing to call */ |
| 395 | for (p = L->top; p > func; p--) /* open space for metamethod */ |
| 396 | setobjs2s(L, p, p-1); |
| 397 | L->top++; /* stack space pre-allocated by the caller */ |
| 398 | setobj2s(L, func, tm); /* metamethod is the new function to be called */ |
| 399 | } |
| 400 | |
| 401 | |
| 402 | /* |
no test coverage detected