MCPcopy Create free account
hub / github.com/DFHack/dfhack / luaK_exp2RK

Function luaK_exp2RK

depends/lua/src/lcode.c:758–776  ·  view source on GitHub ↗

** Ensures final expression result is in a valid R/K index ** (that is, it is either in a register or in 'k' with an index ** in the range of R/K indices). ** Returns R/K index. */

Source from the content-addressed store, hash-verified

756** Returns R/K index.
757*/
758int luaK_exp2RK (FuncState *fs, expdesc *e) {
759 luaK_exp2val(fs, e);
760 switch (e->k) { /* move constants to 'k' */
761 case VTRUE: e->u.info = boolK(fs, 1); goto vk;
762 case VFALSE: e->u.info = boolK(fs, 0); goto vk;
763 case VNIL: e->u.info = nilK(fs); goto vk;
764 case VKINT: e->u.info = luaK_intK(fs, e->u.ival); goto vk;
765 case VKFLT: e->u.info = luaK_numberK(fs, e->u.nval); goto vk;
766 case VK:
767 vk:
768 e->k = VK;
769 if (e->u.info <= MAXINDEXRK) /* constant fits in 'argC'? */
770 return RKASK(e->u.info);
771 else break;
772 default: break;
773 }
774 /* not a constant in the right range: put it in a register */
775 return luaK_exp2anyreg(fs, e);
776}
777
778
779/*

Callers 7

recfieldFunction · 0.85
luaK_storevarFunction · 0.85
luaK_selfFunction · 0.85
luaK_indexedFunction · 0.85
codebinexpvalFunction · 0.85
codecompFunction · 0.85
luaK_infixFunction · 0.85

Calls 6

luaK_exp2valFunction · 0.85
boolKFunction · 0.85
nilKFunction · 0.85
luaK_intKFunction · 0.85
luaK_numberKFunction · 0.85
luaK_exp2anyregFunction · 0.85

Tested by

no test coverage detected