diff options
Diffstat (limited to 'ltm.c')
-rw-r--r-- | ltm.c | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltm.c,v 2.33 2014/11/21 12:15:57 roberto Exp roberto $ | 2 | ** $Id: ltm.c,v 2.34 2015/03/30 15:42:27 roberto Exp roberto $ |
3 | ** Tag methods | 3 | ** Tag methods |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -86,13 +86,18 @@ const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, TMS event) { | |||
86 | void luaT_callTM (lua_State *L, const TValue *f, const TValue *p1, | 86 | void luaT_callTM (lua_State *L, const TValue *f, const TValue *p1, |
87 | const TValue *p2, TValue *p3, int hasres) { | 87 | const TValue *p2, TValue *p3, int hasres) { |
88 | ptrdiff_t result = savestack(L, p3); | 88 | ptrdiff_t result = savestack(L, p3); |
89 | setobj2s(L, L->top++, f); /* push function (assume EXTRA_STACK) */ | 89 | StkId func = L->top; |
90 | setobj2s(L, L->top++, p1); /* 1st argument */ | 90 | setobj2s(L, func, f); /* push function (assume EXTRA_STACK) */ |
91 | setobj2s(L, L->top++, p2); /* 2nd argument */ | 91 | setobj2s(L, func + 1, p1); /* 1st argument */ |
92 | setobj2s(L, func + 2, p2); /* 2nd argument */ | ||
93 | L->top += 3; | ||
92 | if (!hasres) /* no result? 'p3' is third argument */ | 94 | if (!hasres) /* no result? 'p3' is third argument */ |
93 | setobj2s(L, L->top++, p3); /* 3rd argument */ | 95 | setobj2s(L, L->top++, p3); /* 3rd argument */ |
94 | /* metamethod may yield only when called from Lua code */ | 96 | /* metamethod may yield only when called from Lua code */ |
95 | luaD_call(L, L->top - (4 - hasres), hasres, isLua(L->ci)); | 97 | if (isLua(L->ci)) |
98 | luaD_call(L, func, hasres); | ||
99 | else | ||
100 | luaD_callnoyield(L, func, hasres); | ||
96 | if (hasres) { /* if has result, move it to its place */ | 101 | if (hasres) { /* if has result, move it to its place */ |
97 | p3 = restorestack(L, result); | 102 | p3 = restorestack(L, result); |
98 | setobjs2s(L, p3, --L->top); | 103 | setobjs2s(L, p3, --L->top); |