** 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. */
| 353 | ** an error if there is no '__call' metafield. |
| 354 | */ |
| 355 | void 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 | /* |
no test coverage detected