MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / discharge2reg

Function discharge2reg

extlibs/lua/src/lcode.c:812–859  ·  view source on GitHub ↗

** Ensures expression value is in register 'reg' (and therefore ** 'e' will become a non-relocatable expression). ** (Expression still may have jump lists.) */

Source from the content-addressed store, hash-verified

810** (Expression still may have jump lists.)
811*/
812static void discharge2reg (FuncState *fs, expdesc *e, int reg) {
813 luaK_dischargevars(fs, e);
814 switch (e->k) {
815 case VNIL: {
816 luaK_nil(fs, reg, 1);
817 break;
818 }
819 case VFALSE: {
820 luaK_codeABC(fs, OP_LOADFALSE, reg, 0, 0);
821 break;
822 }
823 case VTRUE: {
824 luaK_codeABC(fs, OP_LOADTRUE, reg, 0, 0);
825 break;
826 }
827 case VKSTR: {
828 str2K(fs, e);
829 } /* FALLTHROUGH */
830 case VK: {
831 luaK_codek(fs, reg, e->u.info);
832 break;
833 }
834 case VKFLT: {
835 luaK_float(fs, reg, e->u.nval);
836 break;
837 }
838 case VKINT: {
839 luaK_int(fs, reg, e->u.ival);
840 break;
841 }
842 case VRELOC: {
843 Instruction *pc = &getinstruction(fs, e);
844 SETARG_A(*pc, reg); /* instruction will put result in 'reg' */
845 break;
846 }
847 case VNONRELOC: {
848 if (reg != e->u.info)
849 luaK_codeABC(fs, OP_MOVE, reg, e->u.info, 0);
850 break;
851 }
852 default: {
853 lua_assert(e->k == VJMP);
854 return; /* nothing to do... */
855 }
856 }
857 e->u.info = reg;
858 e->k = VNONRELOC;
859}
860
861
862/*

Callers 2

discharge2anyregFunction · 0.85
exp2regFunction · 0.85

Calls 6

luaK_dischargevarsFunction · 0.85
luaK_nilFunction · 0.85
str2KFunction · 0.85
luaK_codekFunction · 0.85
luaK_floatFunction · 0.85
luaK_intFunction · 0.85

Tested by

no test coverage detected