** Create expression 't[k]'. 't' must have its final result already in a ** register or upvalue. Upvalues can only be indexed by literal strings. ** Keys can be literal strings in the constant table or arbitrary ** values in registers. */
| 1259 | ** values in registers. |
| 1260 | */ |
| 1261 | void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) { |
| 1262 | if (k->k == VKSTR) |
| 1263 | str2K(fs, k); |
| 1264 | lua_assert(!hasjumps(t) && |
| 1265 | (t->k == VLOCAL || t->k == VNONRELOC || t->k == VUPVAL)); |
| 1266 | if (t->k == VUPVAL && !isKstr(fs, k)) /* upvalue indexed by non 'Kstr'? */ |
| 1267 | luaK_exp2anyreg(fs, t); /* put it in a register */ |
| 1268 | if (t->k == VUPVAL) { |
| 1269 | t->u.ind.t = t->u.info; /* upvalue index */ |
| 1270 | t->u.ind.idx = k->u.info; /* literal string */ |
| 1271 | t->k = VINDEXUP; |
| 1272 | } |
| 1273 | else { |
| 1274 | /* register index of the table */ |
| 1275 | t->u.ind.t = (t->k == VLOCAL) ? t->u.var.sidx: t->u.info; |
| 1276 | if (isKstr(fs, k)) { |
| 1277 | t->u.ind.idx = k->u.info; /* literal string */ |
| 1278 | t->k = VINDEXSTR; |
| 1279 | } |
| 1280 | else if (isCint(k)) { |
| 1281 | t->u.ind.idx = cast_int(k->u.ival); /* int. constant in proper range */ |
| 1282 | t->k = VINDEXI; |
| 1283 | } |
| 1284 | else { |
| 1285 | t->u.ind.idx = luaK_exp2anyreg(fs, k); /* register */ |
| 1286 | t->k = VINDEXED; |
| 1287 | } |
| 1288 | } |
| 1289 | } |
| 1290 | |
| 1291 | |
| 1292 | /* |
no test coverage detected