** 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. */
| 334 | ** it. Raise an error if __call metafield is not a function. |
| 335 | */ |
| 336 | static void tryfuncTM(lua_State *L, StkId func) { |
| 337 | const TValue *tm = luaT_gettmbyobj(L, func, TM_CALL); |
| 338 | StkId p; |
| 339 | if (!ttisfunction(tm)) |
| 340 | { |
| 341 | global_glua_chain_api->throw_exception(L, THINKYOUNG_API_LVM_ERROR, "Can't find __call method"); |
| 342 | luaG_typeerror(L, func, "call"); |
| 343 | } |
| 344 | if (L->force_stopping) |
| 345 | return; |
| 346 | /* Open a hole inside the stack at 'func' */ |
| 347 | for (p = L->top; p > func; p--) |
| 348 | setobjs2s(L, p, p - 1); |
| 349 | L->top++; /* slot ensured by caller */ |
| 350 | setobj2s(L, func, tm); /* tag method is the new function to be called */ |
| 351 | } |
| 352 | |
| 353 | |
| 354 |
no test coverage detected