aboutsummaryrefslogtreecommitdiff
path: root/lobject.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-07-26 14:59:39 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-07-26 14:59:39 -0300
commitb80077b8f3e27a94c6afa895b41a9f8b52c42e61 (patch)
tree8a7c21ee0acfed553ef1d92bdfd7b1f728f35a91 /lobject.c
parente70f275f32a5339a86be6f8b9d08c20cb874b205 (diff)
downloadlua-b80077b8f3e27a94c6afa895b41a9f8b52c42e61.tar.gz
lua-b80077b8f3e27a94c6afa895b41a9f8b52c42e61.tar.bz2
lua-b80077b8f3e27a94c6afa895b41a9f8b52c42e61.zip
Change in the handling of 'L->top' when calling metamethods
Instead of updating 'L->top' in every place that may call a metamethod, the metamethod functions themselves (luaT_trybinTM and luaT_callorderTM) correct the top. (When calling metamethods from the C API, however, the callers must preserve 'L->top'.)
Diffstat (limited to 'lobject.c')
-rw-r--r--lobject.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/lobject.c b/lobject.c
index b4efae4f..b376ab15 100644
--- a/lobject.c
+++ b/lobject.c
@@ -127,7 +127,9 @@ void luaO_arith (lua_State *L, int op, const TValue *p1, const TValue *p2,
127 StkId res) { 127 StkId res) {
128 if (!luaO_rawarith(L, op, p1, p2, s2v(res))) { 128 if (!luaO_rawarith(L, op, p1, p2, s2v(res))) {
129 /* could not perform raw operation; try metamethod */ 129 /* could not perform raw operation; try metamethod */
130 ptrdiff_t top = savestack(L, L->top);
130 luaT_trybinTM(L, p1, p2, res, cast(TMS, (op - LUA_OPADD) + TM_ADD)); 131 luaT_trybinTM(L, p1, p2, res, cast(TMS, (op - LUA_OPADD) + TM_ADD));
132 L->top = restorestack(L, top);
131 } 133 }
132} 134}
133 135