** Ensures expression value is in register 'reg' (and therefore ** 'e' will become a non-relocatable expression). ** (Expression still may have jump lists.) */
| 810 | ** (Expression still may have jump lists.) |
| 811 | */ |
| 812 | static 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 | /* |
no test coverage detected