Skip to content

Commit

Permalink
New macros for arithmetic/bitwise operations in 'luaV_execute'
Browse files Browse the repository at this point in the history
The repetitive code of the arithmetic and bitwise operators in
the main iterpreter loop was moved to appropriate macros.
(As a detail, the function 'luaV_div' was renamed 'luaV_idiv',
as it does an "integer division" (floor division).
  • Loading branch information
roberto-ieru committed Nov 5, 2018
1 parent e8c7797 commit 5e76a4f
Show file tree
Hide file tree
Showing 5 changed files with 156 additions and 220 deletions.
2 changes: 1 addition & 1 deletion lobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ static lua_Integer intarith (lua_State *L, int op, lua_Integer v1,
case LUA_OPSUB:return intop(-, v1, v2);
case LUA_OPMUL:return intop(*, v1, v2);
case LUA_OPMOD: return luaV_mod(L, v1, v2);
case LUA_OPIDIV: return luaV_div(L, v1, v2);
case LUA_OPIDIV: return luaV_idiv(L, v1, v2);
case LUA_OPBAND: return intop(&, v1, v2);
case LUA_OPBOR: return intop(|, v1, v2);
case LUA_OPBXOR: return intop(^, v1, v2);
Expand Down
2 changes: 1 addition & 1 deletion ltm.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ void luaT_trybinassocTM (lua_State *L, const TValue *p1, const TValue *p2,
}


void luaT_trybiniTM (lua_State *L, const TValue *p1, int i2,
void luaT_trybiniTM (lua_State *L, const TValue *p1, lua_Integer i2,
int inv, StkId res, TMS event) {
TValue aux;
setivalue(&aux, i2);
Expand Down
2 changes: 1 addition & 1 deletion ltm.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ LUAI_FUNC void luaT_trybinTM (lua_State *L, const TValue *p1, const TValue *p2,
StkId res, TMS event);
LUAI_FUNC void luaT_trybinassocTM (lua_State *L, const TValue *p1,
const TValue *p2, StkId res, int inv, TMS event);
LUAI_FUNC void luaT_trybiniTM (lua_State *L, const TValue *p1, int i2,
LUAI_FUNC void luaT_trybiniTM (lua_State *L, const TValue *p1, lua_Integer i2,
int inv, StkId res, TMS event);
LUAI_FUNC int luaT_callorderTM (lua_State *L, const TValue *p1,
const TValue *p2, TMS event);
Expand Down
Loading

0 comments on commit 5e76a4f

Please sign in to comment.