** 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. */
| 763 | ** Returns R/K index. |
| 764 | */ |
| 765 | int luaK_exp2RK (FuncState *fs, expdesc *e) { |
| 766 | luaK_exp2val(fs, e); |
| 767 | switch (e->k) { /* move constants to 'k' */ |
| 768 | case VTRUE: e->u.info = boolK(fs, 1); goto vk; |
| 769 | case VFALSE: e->u.info = boolK(fs, 0); goto vk; |
| 770 | case VNIL: e->u.info = nilK(fs); goto vk; |
| 771 | case VKINT: e->u.info = luaK_intK(fs, e->u.ival); goto vk; |
| 772 | case VKFLT: e->u.info = luaK_numberK(fs, e->u.nval); goto vk; |
| 773 | case VK: |
| 774 | vk: |
| 775 | e->k = VK; |
| 776 | if (e->u.info <= MAXINDEXRK) /* constant fits in 'argC'? */ |
| 777 | return RKASK(e->u.info); |
| 778 | else break; |
| 779 | default: break; |
| 780 | } |
| 781 | /* not a constant in the right range: put it in a register */ |
| 782 | return luaK_exp2anyreg(fs, e); |
| 783 | } |
| 784 | |
| 785 | |
| 786 | /* |
no test coverage detected