MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / luaK_indexed

Function luaK_indexed

third-party/lua-5.4.6/src/lcode.c:1280–1310  ·  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

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

Callers 4

singlevarFunction · 0.70
fieldselFunction · 0.70
recfieldFunction · 0.70
suffixedexpFunction · 0.70

Calls 4

str2KFunction · 0.70
isKstrFunction · 0.70
luaK_exp2anyregFunction · 0.70
isCintFunction · 0.70

Tested by

no test coverage detected