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

Function discharge2reg

xrepo/packages/l/lua/port/lua/src/lcode.c:825–872  ·  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

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

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