diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-07-07 13:34:32 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-07-07 13:34:32 -0300 |
commit | 4dff277255e3785b76b6b52fe2a98592e6cbc834 (patch) | |
tree | e3607d2aab29b6e0dbd46ac1acc81e9c6bf08dd7 /lvm.h | |
parent | 07db10813cb044252c18973688f63b5eac6a90a6 (diff) | |
download | lua-4dff277255e3785b76b6b52fe2a98592e6cbc834.tar.gz lua-4dff277255e3785b76b6b52fe2a98592e6cbc834.tar.bz2 lua-4dff277255e3785b76b6b52fe2a98592e6cbc834.zip |
coercion string->number in arithmetic operations moved to string
library
Diffstat (limited to 'lvm.h')
-rw-r--r-- | lvm.h | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lvm.h,v 2.44 2017/06/09 19:16:41 roberto Exp roberto $ | 2 | ** $Id: lvm.h,v 2.45 2017/06/29 15:06:44 roberto Exp roberto $ |
3 | ** Lua virtual machine | 3 | ** Lua virtual machine |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -37,12 +37,22 @@ | |||
37 | #endif | 37 | #endif |
38 | 38 | ||
39 | 39 | ||
40 | /* convert an object to a float (including string coercion) */ | ||
40 | #define tonumber(o,n) \ | 41 | #define tonumber(o,n) \ |
41 | (ttisfloat(o) ? (*(n) = fltvalue(o), 1) : luaV_tonumber_(o,n)) | 42 | (ttisfloat(o) ? (*(n) = fltvalue(o), 1) : luaV_tonumber_(o,n)) |
42 | 43 | ||
44 | |||
45 | /* convert an object to a float (without string coercion) */ | ||
46 | #define tonumberns(o,n) \ | ||
47 | (ttisfloat(o) ? ((n) = fltvalue(o), 1) : \ | ||
48 | (ttisinteger(o) ? ((n) = cast_num(ivalue(o)), 1) : 0)) | ||
49 | |||
50 | |||
51 | /* convert an object to an integer (including string coercion) */ | ||
43 | #define tointeger(o,i) \ | 52 | #define tointeger(o,i) \ |
44 | (ttisinteger(o) ? (*(i) = ivalue(o), 1) : luaV_tointeger(o,i,LUA_FLOORN2I)) | 53 | (ttisinteger(o) ? (*(i) = ivalue(o), 1) : luaV_tointeger(o,i,LUA_FLOORN2I)) |
45 | 54 | ||
55 | |||
46 | #define intop(op,v1,v2) l_castU2S(l_castS2U(v1) op l_castS2U(v2)) | 56 | #define intop(op,v1,v2) l_castU2S(l_castS2U(v1) op l_castS2U(v2)) |
47 | 57 | ||
48 | #define luaV_rawequalobj(t1,t2) luaV_equalobj(NULL,t1,t2) | 58 | #define luaV_rawequalobj(t1,t2) luaV_equalobj(NULL,t1,t2) |