MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / luaK_indexed

Function luaK_indexed

lib/lua/src/lcode.c:1279–1309  ·  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

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

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