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

Function discharge2reg

third-party/lua-5.5.0/src/lcode.c:882–929  ·  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

880** (Expression still may have jump lists.)
881*/
882static void discharge2reg (FuncState *fs, expdesc *e, int reg) {
883 luaK_dischargevars(fs, e);
884 switch (e->k) {
885 case VNIL: {
886 luaK_nil(fs, reg, 1);
887 break;
888 }
889 case VFALSE: {
890 luaK_codeABC(fs, OP_LOADFALSE, reg, 0, 0);
891 break;
892 }
893 case VTRUE: {
894 luaK_codeABC(fs, OP_LOADTRUE, reg, 0, 0);
895 break;
896 }
897 case VKSTR: {
898 str2K(fs, e);
899 } /* FALLTHROUGH */
900 case VK: {
901 luaK_codek(fs, reg, e->u.info);
902 break;
903 }
904 case VKFLT: {
905 luaK_float(fs, reg, e->u.nval);
906 break;
907 }
908 case VKINT: {
909 luaK_int(fs, reg, e->u.ival);
910 break;
911 }
912 case VRELOC: {
913 Instruction *pc = &getinstruction(fs, e);
914 SETARG_A(*pc, reg); /* instruction will put result in 'reg' */
915 break;
916 }
917 case VNONRELOC: {
918 if (reg != e->u.info)
919 luaK_codeABC(fs, OP_MOVE, reg, e->u.info, 0);
920 break;
921 }
922 default: {
923 lua_assert(e->k == VJMP);
924 return; /* nothing to do... */
925 }
926 }
927 e->u.info = reg;
928 e->k = VNONRELOC;
929}
930
931
932/*

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