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

Function discharge2reg

third-party/lua-5.4.6/src/lcode.c:827–874  ·  view source on GitHub ↗

** Ensure expression value is in register 'reg', making 'e' a ** non-relocatable expression. ** (Expression still may have jump lists.) */

Source from the content-addressed store, hash-verified

825** (Expression still may have jump lists.)
826*/
827static void discharge2reg (FuncState *fs, expdesc *e, int reg) {
828 luaK_dischargevars(fs, e);
829 switch (e->k) {
830 case VNIL: {
831 luaK_nil(fs, reg, 1);
832 break;
833 }
834 case VFALSE: {
835 luaK_codeABC(fs, OP_LOADFALSE, reg, 0, 0);
836 break;
837 }
838 case VTRUE: {
839 luaK_codeABC(fs, OP_LOADTRUE, reg, 0, 0);
840 break;
841 }
842 case VKSTR: {
843 str2K(fs, e);
844 } /* FALLTHROUGH */
845 case VK: {
846 luaK_codek(fs, reg, e->u.info);
847 break;
848 }
849 case VKFLT: {
850 luaK_float(fs, reg, e->u.nval);
851 break;
852 }
853 case VKINT: {
854 luaK_int(fs, reg, e->u.ival);
855 break;
856 }
857 case VRELOC: {
858 Instruction *pc = &getinstruction(fs, e);
859 SETARG_A(*pc, reg); /* instruction will put result in 'reg' */
860 break;
861 }
862 case VNONRELOC: {
863 if (reg != e->u.info)
864 luaK_codeABC(fs, OP_MOVE, reg, e->u.info, 0);
865 break;
866 }
867 default: {
868 lua_assert(e->k == VJMP);
869 return; /* nothing to do... */
870 }
871 }
872 e->u.info = reg;
873 e->k = VNONRELOC;
874}
875
876
877/*

Callers 2

discharge2anyregFunction · 0.70
exp2regFunction · 0.70

Calls 7

luaK_dischargevarsFunction · 0.70
luaK_nilFunction · 0.70
str2KFunction · 0.70
luaK_codekFunction · 0.70
luaK_floatFunction · 0.70
luaK_intFunction · 0.70
luaK_codeABCFunction · 0.50

Tested by

no test coverage detected