aboutsummaryrefslogtreecommitdiff
path: root/lcode.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2023-05-15 10:07:25 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2023-05-15 10:07:25 -0300
commit934e77a286aeb97ca02badf56956ccc78217e9d0 (patch)
tree6994a5bc3d625d1d37156895a5b21bebb46f36a8 /lcode.c
parent6443185167c77adcc8552a3fee7edab7895db1a9 (diff)
downloadlua-934e77a286aeb97ca02badf56956ccc78217e9d0.tar.gz
lua-934e77a286aeb97ca02badf56956ccc78217e9d0.tar.bz2
lua-934e77a286aeb97ca02badf56956ccc78217e9d0.zip
Details
- Better comments about short strings in opcodes. - luaH_newkey made static.
Diffstat (limited to 'lcode.c')
-rw-r--r--lcode.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/lcode.c b/lcode.c
index 1a371ca9..eade2806 100644
--- a/lcode.c
+++ b/lcode.c
@@ -1215,7 +1215,7 @@ static void codenot (FuncState *fs, expdesc *e) {
1215 1215
1216 1216
1217/* 1217/*
1218** Check whether expression 'e' is a small literal string 1218** Check whether expression 'e' is a short literal string
1219*/ 1219*/
1220static int isKstr (FuncState *fs, expdesc *e) { 1220static int isKstr (FuncState *fs, expdesc *e) {
1221 return (e->k == VK && !hasjumps(e) && e->u.info <= MAXARG_B && 1221 return (e->k == VK && !hasjumps(e) && e->u.info <= MAXARG_B &&
@@ -1283,15 +1283,16 @@ void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) {
1283 if (t->k == VUPVAL && !isKstr(fs, k)) /* upvalue indexed by non 'Kstr'? */ 1283 if (t->k == VUPVAL && !isKstr(fs, k)) /* upvalue indexed by non 'Kstr'? */
1284 luaK_exp2anyreg(fs, t); /* put it in a register */ 1284 luaK_exp2anyreg(fs, t); /* put it in a register */
1285 if (t->k == VUPVAL) { 1285 if (t->k == VUPVAL) {
1286 lua_assert(isKstr(fs, k));
1286 t->u.ind.t = t->u.info; /* upvalue index */ 1287 t->u.ind.t = t->u.info; /* upvalue index */
1287 t->u.ind.idx = k->u.info; /* literal string */ 1288 t->u.ind.idx = k->u.info; /* literal short string */
1288 t->k = VINDEXUP; 1289 t->k = VINDEXUP;
1289 } 1290 }
1290 else { 1291 else {
1291 /* register index of the table */ 1292 /* register index of the table */
1292 t->u.ind.t = (t->k == VLOCAL) ? t->u.var.ridx: t->u.info; 1293 t->u.ind.t = (t->k == VLOCAL) ? t->u.var.ridx: t->u.info;
1293 if (isKstr(fs, k)) { 1294 if (isKstr(fs, k)) {
1294 t->u.ind.idx = k->u.info; /* literal string */ 1295 t->u.ind.idx = k->u.info; /* literal short string */
1295 t->k = VINDEXSTR; 1296 t->k = VINDEXSTR;
1296 } 1297 }
1297 else if (isCint(k)) { 1298 else if (isCint(k)) {