aboutsummaryrefslogtreecommitdiff
path: root/lcode.c
diff options
context:
space:
mode:
Diffstat (limited to 'lcode.c')
-rw-r--r--lcode.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/lcode.c b/lcode.c
index 1edf08aa..f7bc2140 100644
--- a/lcode.c
+++ b/lcode.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lcode.c,v 2.121 2017/06/29 15:06:44 roberto Exp roberto $ 2** $Id: lcode.c,v 2.122 2017/09/13 19:50:08 roberto Exp roberto $
3** Code generator for Lua 3** Code generator for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -579,6 +579,18 @@ void luaK_int (FuncState *fs, int reg, lua_Integer i) {
579} 579}
580 580
581 581
582static void luaK_float (FuncState *fs, int reg, lua_Number f) {
583 TValue v;
584 lua_Integer fi;
585 setfltvalue(&v, f);
586 if (luaV_tointeger(&v, &fi, 0) &&
587 l_castS2U(fi) + MAXARG_sBx <= l_castS2U(MAXARG_Bx))
588 luaK_codeAsBx(fs, OP_LOADF, reg, cast_int(fi));
589 else
590 luaK_codek(fs, reg, luaK_numberK(fs, f));
591}
592
593
582/* 594/*
583** Fix an expression to return the number of results 'nresults'. 595** Fix an expression to return the number of results 'nresults'.
584** Either 'e' is a multi-ret expression (function call or vararg) 596** Either 'e' is a multi-ret expression (function call or vararg)
@@ -688,7 +700,7 @@ static void discharge2reg (FuncState *fs, expdesc *e, int reg) {
688 break; 700 break;
689 } 701 }
690 case VKFLT: { 702 case VKFLT: {
691 luaK_codek(fs, reg, luaK_numberK(fs, e->u.nval)); 703 luaK_float(fs, reg, e->u.nval);
692 break; 704 break;
693 } 705 }
694 case VKINT: { 706 case VKINT: {