** Ensure expression value is in register 'reg', making 'e' a ** non-relocatable expression. ** (Expression still may have jump lists.) */
| 805 | ** (Expression still may have jump lists.) |
| 806 | */ |
| 807 | static void discharge2reg (FuncState *fs, expdesc *e, int reg) { |
| 808 | luaK_dischargevars(fs, e); |
| 809 | switch (e->k) { |
| 810 | case VNIL: { |
| 811 | luaK_nil(fs, reg, 1); |
| 812 | break; |
| 813 | } |
| 814 | case VFALSE: { |
| 815 | luaK_codeABC(fs, OP_LOADFALSE, reg, 0, 0); |
| 816 | break; |
| 817 | } |
| 818 | case VTRUE: { |
| 819 | luaK_codeABC(fs, OP_LOADTRUE, reg, 0, 0); |
| 820 | break; |
| 821 | } |
| 822 | case VKSTR: { |
| 823 | str2K(fs, e); |
| 824 | } /* FALLTHROUGH */ |
| 825 | case VK: { |
| 826 | luaK_codek(fs, reg, e->u.info); |
| 827 | break; |
| 828 | } |
| 829 | case VKFLT: { |
| 830 | luaK_float(fs, reg, e->u.nval); |
| 831 | break; |
| 832 | } |
| 833 | case VKINT: { |
| 834 | luaK_int(fs, reg, e->u.ival); |
| 835 | break; |
| 836 | } |
| 837 | case VRELOC: { |
| 838 | Instruction *pc = &getinstruction(fs, e); |
| 839 | SETARG_A(*pc, reg); /* instruction will put result in 'reg' */ |
| 840 | break; |
| 841 | } |
| 842 | case VNONRELOC: { |
| 843 | if (reg != e->u.info) |
| 844 | luaK_codeABC(fs, OP_MOVE, reg, e->u.info, 0); |
| 845 | break; |
| 846 | } |
| 847 | default: { |
| 848 | lua_assert(e->k == VJMP); |
| 849 | return; /* nothing to do... */ |
| 850 | } |
| 851 | } |
| 852 | e->u.info = reg; |
| 853 | e->k = VNONRELOC; |
| 854 | } |
| 855 | |
| 856 | |
| 857 | /* |
no test coverage detected