| 100 | |
| 101 | |
| 102 | void luaT_callTM (lua_State *L, const TValue *f, const TValue *p1, |
| 103 | const TValue *p2, TValue *p3, int hasres) { |
| 104 | ptrdiff_t result = savestack(L, p3); |
| 105 | StkId func = L->top; |
| 106 | setobj2s(L, func, f); /* push function (assume EXTRA_STACK) */ |
| 107 | setobj2s(L, func + 1, p1); /* 1st argument */ |
| 108 | setobj2s(L, func + 2, p2); /* 2nd argument */ |
| 109 | L->top += 3; |
| 110 | if (!hasres) /* no result? 'p3' is third argument */ |
| 111 | setobj2s(L, L->top++, p3); /* 3rd argument */ |
| 112 | /* metamethod may yield only when called from Lua code */ |
| 113 | if (isLua(L->ci)) |
| 114 | luaD_call(L, func, hasres); |
| 115 | else |
| 116 | luaD_callnoyield(L, func, hasres); |
| 117 | if (hasres) { /* if has result, move it to its place */ |
| 118 | p3 = restorestack(L, result); |
| 119 | setobjs2s(L, p3, --L->top); |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | |
| 124 | int luaT_callbinTM (lua_State *L, const TValue *p1, const TValue *p2, |
no test coverage detected