diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-12-18 13:44:44 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-12-18 13:44:44 -0200 |
commit | ab07005568a399f2e97996677472d9e6e69c9f4f (patch) | |
tree | 1ddfad16a7840d950db417eed1d2cce2b41aea4a /lcode.c | |
parent | 7024f49c422956259c620fe6673ac42b33398adb (diff) | |
download | lua-github-ab07005568a399f2e97996677472d9e6e69c9f4f.tar.gz |
new auxiliary function 'luaK_isKint' + removal of 'luaK_needclose',
which was not being used anywhere.
Diffstat (limited to 'lcode.c')
-rw-r--r-- | lcode.c | 26 |
1 files changed, 10 insertions, 16 deletions
@@ -1,5 +1,5 @@ /* -** $Id: lcode.c,v 2.144 2017/12/14 14:24:02 roberto Exp roberto $ +** $Id: lcode.c,v 2.145 2017/12/15 18:53:48 roberto Exp roberto $ ** Code generator for Lua ** See Copyright Notice in lua.h */ @@ -260,18 +260,6 @@ void luaK_patchtohere (FuncState *fs, int list) { /* -** Check whether some jump in given list needs a close instruction. -*/ -int luaK_needclose (FuncState *fs, int list) { - for (; list != NO_JUMP; list = getjump(fs, list)) { - if (GETARG_A(fs->f->code[list])) /* needs close? */ - return 1; - } - return 0; -} - - -/* ** Correct a jump list to jump to 'target'. If 'hasclose' is true, ** 'target' contains an OP_CLOSE instruction (see first assert). ** Only jumps with the 'k' arg true need that close; other jumps @@ -1090,14 +1078,20 @@ static int isKstr (FuncState *fs, expdesc *e) { ttisshrstring(&fs->f->k[e->u.info])); } +/* +** Check whether expression 'e' is a literal integer. +*/ +int luaK_isKint (expdesc *e) { + return (e->k == VKINT && !hasjumps(e)); +} + /* ** Check whether expression 'e' is a literal integer in ** proper range to fit in register C */ static int isCint (expdesc *e) { - return (e->k == VKINT && !hasjumps(e) && - l_castS2U(e->u.ival) <= l_castS2U(MAXARG_C)); + return luaK_isKint(e) && (l_castS2U(e->u.ival) <= l_castS2U(MAXARG_C)); } @@ -1106,7 +1100,7 @@ static int isCint (expdesc *e) { ** proper range to fit in register sC */ static int isSCint (expdesc *e) { - return (e->k == VKINT && !hasjumps(e) && fitsC(e->u.ival)); + return luaK_isKint(e) && fitsC(e->u.ival); } |