MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / luaK_indexed

Function luaK_indexed

3rd/lua-5.4.3/src/lcode.c:1260–1288  ·  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

1258** values in registers.
1259*/
1260void 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/*

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