aboutsummaryrefslogtreecommitdiff
path: root/lcode.c
diff options
context:
space:
mode:
Diffstat (limited to 'lcode.c')
-rw-r--r--lcode.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/lcode.c b/lcode.c
index aca0256d..f48221cf 100644
--- a/lcode.c
+++ b/lcode.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lcode.c,v 2.111 2016/07/19 17:12:07 roberto Exp roberto $ 2** $Id: lcode.c,v 2.112 2016/12/22 13:08:50 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*/
@@ -343,7 +343,7 @@ static int codeextraarg (FuncState *fs, int a) {
343** (if constant index 'k' fits in 18 bits) or an 'OP_LOADKX' 343** (if constant index 'k' fits in 18 bits) or an 'OP_LOADKX'
344** instruction with "extra argument". 344** instruction with "extra argument".
345*/ 345*/
346int luaK_codek (FuncState *fs, int reg, int k) { 346static int luaK_codek (FuncState *fs, int reg, int k) {
347 if (k <= MAXARG_Bx) 347 if (k <= MAXARG_Bx)
348 return luaK_codeABx(fs, OP_LOADK, reg, k); 348 return luaK_codeABx(fs, OP_LOADK, reg, k);
349 else { 349 else {
@@ -468,7 +468,7 @@ int luaK_stringK (FuncState *fs, TString *s) {
468** same value; conversion to 'void*' is used only for hashing, so there 468** same value; conversion to 'void*' is used only for hashing, so there
469** are no "precision" problems. 469** are no "precision" problems.
470*/ 470*/
471int luaK_intK (FuncState *fs, lua_Integer n) { 471static int luaK_intK (FuncState *fs, lua_Integer n) {
472 TValue k, o; 472 TValue k, o;
473 setpvalue(&k, cast(void*, cast(size_t, n))); 473 setpvalue(&k, cast(void*, cast(size_t, n)));
474 setivalue(&o, n); 474 setivalue(&o, n);
@@ -507,6 +507,14 @@ static int nilK (FuncState *fs) {
507} 507}
508 508
509 509
510void luaK_int (FuncState *fs, int reg, lua_Integer i) {
511 if (-MAXARG_sBx <= i && i <= MAXARG_sBx)
512 luaK_codeAsBx(fs, OP_LOADI, reg, cast_int(i));
513 else
514 luaK_codek(fs, reg, luaK_intK(fs, i));
515}
516
517
510/* 518/*
511** Fix an expression to return the number of results 'nresults'. 519** Fix an expression to return the number of results 'nresults'.
512** Either 'e' is a multi-ret expression (function call or vararg) 520** Either 'e' is a multi-ret expression (function call or vararg)
@@ -612,7 +620,7 @@ static void discharge2reg (FuncState *fs, expdesc *e, int reg) {
612 break; 620 break;
613 } 621 }
614 case VKINT: { 622 case VKINT: {
615 luaK_codek(fs, reg, luaK_intK(fs, e->u.ival)); 623 luaK_int(fs, reg, e->u.ival);
616 break; 624 break;
617 } 625 }
618 case VRELOCABLE: { 626 case VRELOCABLE: {