diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-12-05 14:14:29 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-12-05 14:14:29 -0300 |
commit | d30569c06407529cc6e99f4a35ae5f9bfe6fa940 (patch) | |
tree | 51e560713cb01203d94d792a1e80f38ba7f84c52 /lcode.c | |
parent | 2d92102dee88a81711dca8e8ea3ef0ea9d732283 (diff) | |
download | lua-d30569c06407529cc6e99f4a35ae5f9bfe6fa940.tar.gz lua-d30569c06407529cc6e99f4a35ae5f9bfe6fa940.tar.bz2 lua-d30569c06407529cc6e99f4a35ae5f9bfe6fa940.zip |
Using an enumeration for float->integer coercion modes
Diffstat (limited to 'lcode.c')
-rw-r--r-- | lcode.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -653,7 +653,7 @@ void luaK_int (FuncState *fs, int reg, lua_Integer i) { | |||
653 | 653 | ||
654 | static void luaK_float (FuncState *fs, int reg, lua_Number f) { | 654 | static void luaK_float (FuncState *fs, int reg, lua_Number f) { |
655 | lua_Integer fi; | 655 | lua_Integer fi; |
656 | if (luaV_flttointeger(f, &fi, 0) && fitsBx(fi)) | 656 | if (luaV_flttointeger(f, &fi, F2Ieq) && fitsBx(fi)) |
657 | luaK_codeAsBx(fs, OP_LOADF, reg, cast_int(fi)); | 657 | luaK_codeAsBx(fs, OP_LOADF, reg, cast_int(fi)); |
658 | else | 658 | else |
659 | luaK_codek(fs, reg, luaK_numberK(fs, f)); | 659 | luaK_codek(fs, reg, luaK_numberK(fs, f)); |
@@ -1220,7 +1220,7 @@ static int isSCnumber (expdesc *e, int *pi, int *isfloat) { | |||
1220 | lua_Integer i; | 1220 | lua_Integer i; |
1221 | if (e->k == VKINT) | 1221 | if (e->k == VKINT) |
1222 | i = e->u.ival; | 1222 | i = e->u.ival; |
1223 | else if (e->k == VKFLT && luaV_flttointeger(e->u.nval, &i, 0)) | 1223 | else if (e->k == VKFLT && luaV_flttointeger(e->u.nval, &i, F2Ieq)) |
1224 | *isfloat = 1; | 1224 | *isfloat = 1; |
1225 | else | 1225 | else |
1226 | return 0; /* not a number */ | 1226 | return 0; /* not a number */ |