aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-12-18 13:44:44 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-12-18 13:44:44 -0200
commitab07005568a399f2e97996677472d9e6e69c9f4f (patch)
tree1ddfad16a7840d950db417eed1d2cce2b41aea4a
parent7024f49c422956259c620fe6673ac42b33398adb (diff)
downloadlua-ab07005568a399f2e97996677472d9e6e69c9f4f.tar.gz
lua-ab07005568a399f2e97996677472d9e6e69c9f4f.tar.bz2
lua-ab07005568a399f2e97996677472d9e6e69c9f4f.zip
new auxiliary function 'luaK_isKint' + removal of 'luaK_needclose',
which was not being used anywhere.
-rw-r--r--lcode.c26
-rw-r--r--lcode.h4
2 files changed, 12 insertions, 18 deletions
diff --git a/lcode.c b/lcode.c
index 162b732d..04b534e2 100644
--- a/lcode.c
+++ b/lcode.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lcode.c,v 2.144 2017/12/14 14:24:02 roberto Exp roberto $ 2** $Id: lcode.c,v 2.145 2017/12/15 18:53:48 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*/
@@ -260,18 +260,6 @@ void luaK_patchtohere (FuncState *fs, int list) {
260 260
261 261
262/* 262/*
263** Check whether some jump in given list needs a close instruction.
264*/
265int luaK_needclose (FuncState *fs, int list) {
266 for (; list != NO_JUMP; list = getjump(fs, list)) {
267 if (GETARG_A(fs->f->code[list])) /* needs close? */
268 return 1;
269 }
270 return 0;
271}
272
273
274/*
275** Correct a jump list to jump to 'target'. If 'hasclose' is true, 263** Correct a jump list to jump to 'target'. If 'hasclose' is true,
276** 'target' contains an OP_CLOSE instruction (see first assert). 264** 'target' contains an OP_CLOSE instruction (see first assert).
277** Only jumps with the 'k' arg true need that close; other jumps 265** Only jumps with the 'k' arg true need that close; other jumps
@@ -1090,14 +1078,20 @@ static int isKstr (FuncState *fs, expdesc *e) {
1090 ttisshrstring(&fs->f->k[e->u.info])); 1078 ttisshrstring(&fs->f->k[e->u.info]));
1091} 1079}
1092 1080
1081/*
1082** Check whether expression 'e' is a literal integer.
1083*/
1084int luaK_isKint (expdesc *e) {
1085 return (e->k == VKINT && !hasjumps(e));
1086}
1087
1093 1088
1094/* 1089/*
1095** Check whether expression 'e' is a literal integer in 1090** Check whether expression 'e' is a literal integer in
1096** proper range to fit in register C 1091** proper range to fit in register C
1097*/ 1092*/
1098static int isCint (expdesc *e) { 1093static int isCint (expdesc *e) {
1099 return (e->k == VKINT && !hasjumps(e) && 1094 return luaK_isKint(e) && (l_castS2U(e->u.ival) <= l_castS2U(MAXARG_C));
1100 l_castS2U(e->u.ival) <= l_castS2U(MAXARG_C));
1101} 1095}
1102 1096
1103 1097
@@ -1106,7 +1100,7 @@ static int isCint (expdesc *e) {
1106** proper range to fit in register sC 1100** proper range to fit in register sC
1107*/ 1101*/
1108static int isSCint (expdesc *e) { 1102static int isSCint (expdesc *e) {
1109 return (e->k == VKINT && !hasjumps(e) && fitsC(e->u.ival)); 1103 return luaK_isKint(e) && fitsC(e->u.ival);
1110} 1104}
1111 1105
1112 1106
diff --git a/lcode.h b/lcode.h
index a1fd735d..beeba54f 100644
--- a/lcode.h
+++ b/lcode.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lcode.h,v 1.68 2017/10/04 21:56:32 roberto Exp roberto $ 2** $Id: lcode.h,v 1.69 2017/11/30 13:29:18 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*/
@@ -55,6 +55,7 @@ LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx);
55LUAI_FUNC int luaK_codeAsBx (FuncState *fs, OpCode o, int A, int Bx); 55LUAI_FUNC int luaK_codeAsBx (FuncState *fs, OpCode o, int A, int Bx);
56LUAI_FUNC int luaK_codeABCk (FuncState *fs, OpCode o, int A, 56LUAI_FUNC int luaK_codeABCk (FuncState *fs, OpCode o, int A,
57 int B, int C, int k); 57 int B, int C, int k);
58LUAI_FUNC int luaK_isKint (expdesc *e);
58LUAI_FUNC void luaK_fixline (FuncState *fs, int line); 59LUAI_FUNC void luaK_fixline (FuncState *fs, int line);
59LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n); 60LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n);
60LUAI_FUNC void luaK_reserveregs (FuncState *fs, int n); 61LUAI_FUNC void luaK_reserveregs (FuncState *fs, int n);
@@ -80,7 +81,6 @@ LUAI_FUNC void luaK_patchlist (FuncState *fs, int list, int target);
80void luaK_patchgoto (FuncState *fs, int list, int target, int hasclose); 81void luaK_patchgoto (FuncState *fs, int list, int target, int hasclose);
81LUAI_FUNC void luaK_patchtohere (FuncState *fs, int list); 82LUAI_FUNC void luaK_patchtohere (FuncState *fs, int list);
82LUAI_FUNC void luaK_patchclose (FuncState *fs, int list); 83LUAI_FUNC void luaK_patchclose (FuncState *fs, int list);
83LUAI_FUNC int luaK_needclose (FuncState *fs, int list);
84LUAI_FUNC void luaK_concat (FuncState *fs, int *l1, int l2); 84LUAI_FUNC void luaK_concat (FuncState *fs, int *l1, int l2);
85LUAI_FUNC int luaK_getlabel (FuncState *fs); 85LUAI_FUNC int luaK_getlabel (FuncState *fs);
86LUAI_FUNC void luaK_prefix (FuncState *fs, UnOpr op, expdesc *v, int line); 86LUAI_FUNC void luaK_prefix (FuncState *fs, UnOpr op, expdesc *v, int line);