MCPcopy Create free account
hub / github.com/Cubitect/cubiomes-viewer / luaK_indexed

Function luaK_indexed

lua/src/lcode.c:1278–1306  ·  view source on GitHub ↗

** 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. */

Source from the content-addressed store, hash-verified

1276** values in registers.
1277*/
1278void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) {
1279 if (k->k == VKSTR)
1280 str2K(fs, k);
1281 lua_assert(!hasjumps(t) &&
1282 (t->k == VLOCAL || t->k == VNONRELOC || t->k == VUPVAL));
1283 if (t->k == VUPVAL && !isKstr(fs, k)) /* upvalue indexed by non 'Kstr'? */
1284 luaK_exp2anyreg(fs, t); /* put it in a register */
1285 if (t->k == VUPVAL) {
1286 t->u.ind.t = t->u.info; /* upvalue index */
1287 t->u.ind.idx = k->u.info; /* literal string */
1288 t->k = VINDEXUP;
1289 }
1290 else {
1291 /* register index of the table */
1292 t->u.ind.t = (t->k == VLOCAL) ? t->u.var.ridx: t->u.info;
1293 if (isKstr(fs, k)) {
1294 t->u.ind.idx = k->u.info; /* literal string */
1295 t->k = VINDEXSTR;
1296 }
1297 else if (isCint(k)) {
1298 t->u.ind.idx = cast_int(k->u.ival); /* int. constant in proper range */
1299 t->k = VINDEXI;
1300 }
1301 else {
1302 t->u.ind.idx = luaK_exp2anyreg(fs, k); /* register */
1303 t->k = VINDEXED;
1304 }
1305 }
1306}
1307
1308
1309/*

Callers 4

singlevarFunction · 0.85
fieldselFunction · 0.85
recfieldFunction · 0.85
suffixedexpFunction · 0.85

Calls 4

str2KFunction · 0.85
isKstrFunction · 0.85
luaK_exp2anyregFunction · 0.85
isCintFunction · 0.85

Tested by

no test coverage detected