diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2016-06-20 16:12:46 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2016-06-20 16:12:46 -0300 |
commit | 6487fb11fcae97b6cb7d06e32063fd786b35874c (patch) | |
tree | 9c1803808b807210e9ff1bb2888b343ec801945c | |
parent | 644799537fede7892b2d7f705661e39246fce796 (diff) | |
download | lua-6487fb11fcae97b6cb7d06e32063fd786b35874c.tar.gz lua-6487fb11fcae97b6cb7d06e32063fd786b35874c.tar.bz2 lua-6487fb11fcae97b6cb7d06e32063fd786b35874c.zip |
all 'static' variables should be 'const'
-rw-r--r-- | lcode.c | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lcode.c,v 2.108 2016/01/05 16:22:37 roberto Exp roberto $ | 2 | ** $Id: lcode.c,v 2.109 2016/05/13 19:09:21 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 | */ |
@@ -40,7 +40,7 @@ | |||
40 | ** If expression is a numeric constant, fills 'v' with its value | 40 | ** If expression is a numeric constant, fills 'v' with its value |
41 | ** and returns 1. Otherwise, returns 0. | 41 | ** and returns 1. Otherwise, returns 0. |
42 | */ | 42 | */ |
43 | static int tonumeral(expdesc *e, TValue *v) { | 43 | static int tonumeral(const expdesc *e, TValue *v) { |
44 | if (hasjumps(e)) | 44 | if (hasjumps(e)) |
45 | return 0; /* not a numeral */ | 45 | return 0; /* not a numeral */ |
46 | switch (e->k) { | 46 | switch (e->k) { |
@@ -975,7 +975,8 @@ static int validop (int op, TValue *v1, TValue *v2) { | |||
975 | ** Try to "constant-fold" an operation; return 1 iff successful. | 975 | ** Try to "constant-fold" an operation; return 1 iff successful. |
976 | ** (In this case, 'e1' has the final result.) | 976 | ** (In this case, 'e1' has the final result.) |
977 | */ | 977 | */ |
978 | static int constfolding (FuncState *fs, int op, expdesc *e1, expdesc *e2) { | 978 | static int constfolding (FuncState *fs, int op, expdesc *e1, |
979 | const expdesc *e2) { | ||
979 | TValue v1, v2, res; | 980 | TValue v1, v2, res; |
980 | if (!tonumeral(e1, &v1) || !tonumeral(e2, &v2) || !validop(op, &v1, &v2)) | 981 | if (!tonumeral(e1, &v1) || !tonumeral(e2, &v2) || !validop(op, &v1, &v2)) |
981 | return 0; /* non-numeric operands or not safe to fold */ | 982 | return 0; /* non-numeric operands or not safe to fold */ |
@@ -1060,9 +1061,9 @@ static void codecomp (FuncState *fs, BinOpr opr, expdesc *e1, expdesc *e2) { | |||
1060 | ** Aplly prefix operation 'op' to expression 'e'. | 1061 | ** Aplly prefix operation 'op' to expression 'e'. |
1061 | */ | 1062 | */ |
1062 | void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e, int line) { | 1063 | void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e, int line) { |
1063 | static expdesc ef = {VKINT, {0}, NO_JUMP, NO_JUMP}; /* fake 2nd operand */ | 1064 | static const expdesc ef = {VKINT, {0}, NO_JUMP, NO_JUMP}; |
1064 | switch (op) { | 1065 | switch (op) { |
1065 | case OPR_MINUS: case OPR_BNOT: | 1066 | case OPR_MINUS: case OPR_BNOT: /* use 'ef' as fake 2nd operand */ |
1066 | if (constfolding(fs, op + LUA_OPUNM, e, &ef)) | 1067 | if (constfolding(fs, op + LUA_OPUNM, e, &ef)) |
1067 | break; | 1068 | break; |
1068 | /* FALLTHROUGH */ | 1069 | /* FALLTHROUGH */ |