** Ensure expression value is in register 'reg', making 'e' a ** non-relocatable expression. ** (Expression still may have jump lists.) */
| 880 | ** (Expression still may have jump lists.) |
| 881 | */ |
| 882 | static 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 | /* |
no test coverage detected