commit 1b100335839e13021b4731f0407b87e4f7544dc0
parent 00e728af885d2781e365071557530a6685110d7e
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Wed, 27 Sep 2017 15:58:41 -0300
new function 'luaT_trybiniTM'
to handle tag methods for instructions with immediate integer arguments
Diffstat:
3 files changed, 19 insertions(+), 12 deletions(-)
diff --git a/ltm.c b/ltm.c
@@ -1,5 +1,5 @@
/*
-** $Id: ltm.c,v 2.42 2017/06/29 15:06:44 roberto Exp roberto $
+** $Id: ltm.c,v 2.43 2017/07/27 13:50:16 roberto Exp roberto $
** Tag methods
** See Copyright Notice in lua.h
*/
@@ -167,6 +167,18 @@ void luaT_trybinTM (lua_State *L, const TValue *p1, const TValue *p2,
}
+void luaT_trybiniTM (lua_State *L, const TValue *p1, int i2,
+ int inv, StkId res, TMS event) {
+ TValue aux; TValue *p2;
+ setivalue(&aux, i2);
+ if (inv) { /* arguments were exchanged? */
+ p2 = p1; p1 = &aux; /* correct them */
+ }
+ else p2 = &aux;
+ luaT_trybinTM(L, p1, p2, res, event);
+}
+
+
int luaT_callorderTM (lua_State *L, const TValue *p1, const TValue *p2,
TMS event) {
if (!callbinTM(L, p1, p2, L->top, event))
diff --git a/ltm.h b/ltm.h
@@ -1,5 +1,5 @@
/*
-** $Id: ltm.h,v 2.24 2017/05/13 12:57:20 roberto Exp roberto $
+** $Id: ltm.h,v 2.25 2017/06/29 15:06:44 roberto Exp roberto $
** Tag methods
** See Copyright Notice in lua.h
*/
@@ -68,6 +68,8 @@ LUAI_FUNC void luaT_callTMres (lua_State *L, const TValue *f,
const TValue *p1, const TValue *p2, StkId p3);
LUAI_FUNC void luaT_trybinTM (lua_State *L, const TValue *p1, const TValue *p2,
StkId res, TMS event);
+LUAI_FUNC void luaT_trybiniTM (lua_State *L, const TValue *p1, int i2,
+ int inv, StkId res, TMS event);
LUAI_FUNC int luaT_callorderTM (lua_State *L, const TValue *p1,
const TValue *p2, TMS event);
diff --git a/lvm.c b/lvm.c
@@ -1,5 +1,5 @@
/*
-** $Id: lvm.c,v 2.293 2017/09/19 18:38:14 roberto Exp roberto $
+** $Id: lvm.c,v 2.294 2017/09/26 18:14:45 roberto Exp roberto $
** Lua virtual machine
** See Copyright Notice in lua.h
*/
@@ -999,15 +999,8 @@ void luaV_execute (lua_State *L) {
else if (tonumberns(rb, nb)) {
setfltvalue(s2v(ra), luai_numadd(L, nb, cast_num(ic)));
}
- else {
- TValue aux; TValue *rc;
- setivalue(&aux, ic);
- if (GETARG_Bk(i)) { /* arguments were exchanged? */
- rc = rb; rb = &aux; /* correct them */
- }
- else rc = &aux;
- Protect(luaT_trybinTM(L, rb, rc, ra, TM_ADD));
- }
+ else
+ Protect(luaT_trybiniTM(L, rb, ic, GETARG_Bk(i), ra, TM_ADD));
vmbreak;
}
vmcase(OP_ADD) {