** 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. */
| 1258 | ** values in registers. |
| 1259 | */ |
| 1260 | void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) { |
| 1261 | if (k->k == VKSTR) |
| 1262 | str2K(fs, k); |
| 1263 | lua_assert(!hasjumps(t) && |
| 1264 | (t->k == VLOCAL || t->k == VNONRELOC || t->k == VUPVAL)); |
| 1265 | if (t->k == VUPVAL && !isKstr(fs, k)) /* upvalue indexed by non 'Kstr'? */ |
| 1266 | luaK_exp2anyreg(fs, t); /* put it in a register */ |
| 1267 | if (t->k == VUPVAL) { |
| 1268 | t->u.ind.t = t->u.info; /* upvalue index */ |
| 1269 | t->u.ind.idx = k->u.info; /* literal string */ |
| 1270 | t->k = VINDEXUP; |
| 1271 | } |
| 1272 | else { |
| 1273 | /* register index of the table */ |
| 1274 | t->u.ind.t = (t->k == VLOCAL) ? t->u.var.ridx: t->u.info; |
| 1275 | if (isKstr(fs, k)) { |
| 1276 | t->u.ind.idx = k->u.info; /* literal string */ |
| 1277 | t->k = VINDEXSTR; |
| 1278 | } |
| 1279 | else if (isCint(k)) { |
| 1280 | t->u.ind.idx = cast_int(k->u.ival); /* int. constant in proper range */ |
| 1281 | t->k = VINDEXI; |
| 1282 | } |
| 1283 | else { |
| 1284 | t->u.ind.idx = luaK_exp2anyreg(fs, k); /* register */ |
| 1285 | t->k = VINDEXED; |
| 1286 | } |
| 1287 | } |
| 1288 | } |
| 1289 | |
| 1290 | |
| 1291 | /* |
no test coverage detected