diff options
Diffstat (limited to 'lapi.c')
-rw-r--r-- | lapi.c | 15 |
1 files changed, 4 insertions, 11 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lapi.c,v 2.177 2013/04/26 19:51:17 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 2.178 2013/04/29 17:12:50 roberto Exp roberto $ |
3 | ** Lua API | 3 | ** Lua API |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -297,9 +297,6 @@ LUA_API int lua_rawequal (lua_State *L, int index1, int index2) { | |||
297 | 297 | ||
298 | 298 | ||
299 | LUA_API void lua_arith (lua_State *L, int op) { | 299 | LUA_API void lua_arith (lua_State *L, int op) { |
300 | StkId o1; /* 1st operand */ | ||
301 | StkId o2; /* 2nd operand */ | ||
302 | lua_Number n1, n2; | ||
303 | lua_lock(L); | 300 | lua_lock(L); |
304 | if (op != LUA_OPUNM) /* all other operations expect two operands */ | 301 | if (op != LUA_OPUNM) /* all other operations expect two operands */ |
305 | api_checknelems(L, 2); | 302 | api_checknelems(L, 2); |
@@ -308,13 +305,9 @@ LUA_API void lua_arith (lua_State *L, int op) { | |||
308 | setobjs2s(L, L->top, L->top - 1); | 305 | setobjs2s(L, L->top, L->top - 1); |
309 | L->top++; | 306 | L->top++; |
310 | } | 307 | } |
311 | o1 = L->top - 2; | 308 | /* first operand at top - 2, second at top - 1; result go to top - 2 */ |
312 | o2 = L->top - 1; | 309 | luaO_arith(L, op, L->top - 2, L->top - 1, L->top - 2); |
313 | if (tonumber(o1, &n1) && tonumber(o2, &n2)) { | 310 | L->top--; /* remove second operand */ |
314 | setnvalue(o1, luaO_numarith(op, n1, n2)); | ||
315 | } | ||
316 | else luaT_trybinTM(L, o1, o2, o1, cast(TMS, op - LUA_OPADD + TM_ADD)); | ||
317 | L->top--; | ||
318 | lua_unlock(L); | 311 | lua_unlock(L); |
319 | } | 312 | } |
320 | 313 | ||