MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / discharge2reg

Function discharge2reg

lib/lua/src/lcode.c:826–873  ·  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

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

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