mirror of https://github.com/rusefi/lua.git
new function 'luaT_trybiniTM'
to handle tag methods for instructions with immediate integer arguments
This commit is contained in:
parent
00e728af88
commit
1b10033583
14
ltm.c
14
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
|
** Tag methods
|
||||||
** See Copyright Notice in lua.h
|
** 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,
|
int luaT_callorderTM (lua_State *L, const TValue *p1, const TValue *p2,
|
||||||
TMS event) {
|
TMS event) {
|
||||||
if (!callbinTM(L, p1, p2, L->top, event))
|
if (!callbinTM(L, p1, p2, L->top, event))
|
||||||
|
|
4
ltm.h
4
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
|
** Tag methods
|
||||||
** See Copyright Notice in lua.h
|
** 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);
|
const TValue *p1, const TValue *p2, StkId p3);
|
||||||
LUAI_FUNC void luaT_trybinTM (lua_State *L, const TValue *p1, const TValue *p2,
|
LUAI_FUNC void luaT_trybinTM (lua_State *L, const TValue *p1, const TValue *p2,
|
||||||
StkId res, TMS event);
|
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,
|
LUAI_FUNC int luaT_callorderTM (lua_State *L, const TValue *p1,
|
||||||
const TValue *p2, TMS event);
|
const TValue *p2, TMS event);
|
||||||
|
|
||||||
|
|
13
lvm.c
13
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
|
** Lua virtual machine
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -999,15 +999,8 @@ void luaV_execute (lua_State *L) {
|
||||||
else if (tonumberns(rb, nb)) {
|
else if (tonumberns(rb, nb)) {
|
||||||
setfltvalue(s2v(ra), luai_numadd(L, nb, cast_num(ic)));
|
setfltvalue(s2v(ra), luai_numadd(L, nb, cast_num(ic)));
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
TValue aux; TValue *rc;
|
Protect(luaT_trybiniTM(L, rb, ic, GETARG_Bk(i), ra, TM_ADD));
|
||||||
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));
|
|
||||||
}
|
|
||||||
vmbreak;
|
vmbreak;
|
||||||
}
|
}
|
||||||
vmcase(OP_ADD) {
|
vmcase(OP_ADD) {
|
||||||
|
|
Loading…
Reference in New Issue