** Ensures final expression result is in a valid R/K index ** (that is, it is either in a register or in 'k' with an index ** in the range of R/K indices). ** Returns R/K index. */
| 756 | ** Returns R/K index. |
| 757 | */ |
| 758 | int luaK_exp2RK (FuncState *fs, expdesc *e) { |
| 759 | luaK_exp2val(fs, e); |
| 760 | switch (e->k) { /* move constants to 'k' */ |
| 761 | case VTRUE: e->u.info = boolK(fs, 1); goto vk; |
| 762 | case VFALSE: e->u.info = boolK(fs, 0); goto vk; |
| 763 | case VNIL: e->u.info = nilK(fs); goto vk; |
| 764 | case VKINT: e->u.info = luaK_intK(fs, e->u.ival); goto vk; |
| 765 | case VKFLT: e->u.info = luaK_numberK(fs, e->u.nval); goto vk; |
| 766 | case VK: |
| 767 | vk: |
| 768 | e->k = VK; |
| 769 | if (e->u.info <= MAXINDEXRK) /* constant fits in 'argC'? */ |
| 770 | return RKASK(e->u.info); |
| 771 | else break; |
| 772 | default: break; |
| 773 | } |
| 774 | /* not a constant in the right range: put it in a register */ |
| 775 | return luaK_exp2anyreg(fs, e); |
| 776 | } |
| 777 | |
| 778 | |
| 779 | /* |
no test coverage detected