diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-05-12 18:22:05 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-05-12 18:22:05 -0300 |
| commit | 27d9219cf3649a195fdf7a2211efcb704cf3bffc (patch) | |
| tree | c7dbf7d2ffdca97e0907fbd6083514e784f4dc0b /lobject.c | |
| parent | 12bd01c56710d957e28bea41aab9f9b98182e72b (diff) | |
| download | lua-27d9219cf3649a195fdf7a2211efcb704cf3bffc.tar.gz lua-27d9219cf3649a195fdf7a2211efcb704cf3bffc.tar.bz2 lua-27d9219cf3649a195fdf7a2211efcb704cf3bffc.zip | |
no more integer exponentiation
Diffstat (limited to 'lobject.c')
| -rw-r--r-- | lobject.c | 8 |
1 files changed, 3 insertions, 5 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lobject.c,v 2.83 2014/04/30 16:48:44 roberto Exp roberto $ | 2 | ** $Id: lobject.c,v 2.84 2014/05/01 18:18:06 roberto Exp roberto $ |
| 3 | ** Some generic functions over Lua objects | 3 | ** Some generic functions over Lua objects |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -77,7 +77,6 @@ static lua_Integer intarith (lua_State *L, int op, lua_Integer v1, | |||
| 77 | case LUA_OPSUB:return intop(-, v1, v2); | 77 | case LUA_OPSUB:return intop(-, v1, v2); |
| 78 | case LUA_OPMUL:return intop(*, v1, v2); | 78 | case LUA_OPMUL:return intop(*, v1, v2); |
| 79 | case LUA_OPMOD: return luaV_mod(L, v1, v2); | 79 | case LUA_OPMOD: return luaV_mod(L, v1, v2); |
| 80 | case LUA_OPPOW: return luaV_pow(v1, v2); | ||
| 81 | case LUA_OPIDIV: return luaV_div(L, v1, v2); | 80 | case LUA_OPIDIV: return luaV_div(L, v1, v2); |
| 82 | case LUA_OPBAND: return intop(&, v1, v2); | 81 | case LUA_OPBAND: return intop(&, v1, v2); |
| 83 | case LUA_OPBOR: return intop(|, v1, v2); | 82 | case LUA_OPBOR: return intop(|, v1, v2); |
| @@ -123,7 +122,7 @@ void luaO_arith (lua_State *L, int op, const TValue *p1, const TValue *p2, | |||
| 123 | } | 122 | } |
| 124 | else break; /* go to the end */ | 123 | else break; /* go to the end */ |
| 125 | } | 124 | } |
| 126 | case LUA_OPDIV: { /* operates only on floats */ | 125 | case LUA_OPDIV: case LUA_OPPOW: { /* operate only on floats */ |
| 127 | lua_Number n1; lua_Number n2; | 126 | lua_Number n1; lua_Number n2; |
| 128 | if (tonumber(p1, &n1) && tonumber(p2, &n2)) { | 127 | if (tonumber(p1, &n1) && tonumber(p2, &n2)) { |
| 129 | setfltvalue(res, numarith(L, op, n1, n2)); | 128 | setfltvalue(res, numarith(L, op, n1, n2)); |
| @@ -133,8 +132,7 @@ void luaO_arith (lua_State *L, int op, const TValue *p1, const TValue *p2, | |||
| 133 | } | 132 | } |
| 134 | default: { /* other operations */ | 133 | default: { /* other operations */ |
| 135 | lua_Number n1; lua_Number n2; | 134 | lua_Number n1; lua_Number n2; |
| 136 | if (ttisinteger(p1) && ttisinteger(p2) && | 135 | if (ttisinteger(p1) && ttisinteger(p2)) { |
| 137 | (op != LUA_OPPOW || ivalue(p2) >= 0)) { | ||
| 138 | setivalue(res, intarith(L, op, ivalue(p1), ivalue(p2))); | 136 | setivalue(res, intarith(L, op, ivalue(p1), ivalue(p2))); |
| 139 | return; | 137 | return; |
| 140 | } | 138 | } |
