** 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. */
| 410 | ** an error if there is no '__call' metafield. |
| 411 | */ |
| 412 | static StkId tryfuncTM (lua_State *L, StkId func) { |
| 413 | const TValue *tm; |
| 414 | StkId p; |
| 415 | checkstackGCp(L, 1, func); /* space for metamethod */ |
| 416 | tm = luaT_gettmbyobj(L, s2v(func), TM_CALL); /* (after previous GC) */ |
| 417 | if (l_unlikely(ttisnil(tm))) |
| 418 | luaG_callerror(L, s2v(func)); /* nothing to call */ |
| 419 | for (p = L->top.p; p > func; p--) /* open space for metamethod */ |
| 420 | setobjs2s(L, p, p-1); |
| 421 | L->top.p++; /* stack space pre-allocated by the caller */ |
| 422 | setobj2s(L, func, tm); /* metamethod is the new function to be called */ |
| 423 | return func; |
| 424 | } |
| 425 | |
| 426 | |
| 427 | /* |
no test coverage detected