** Try to make 'e' a K expression with an index in the range of R/K ** indices. Return true iff succeeded. */
| 1053 | ** indices. Return true iff succeeded. |
| 1054 | */ |
| 1055 | static int luaK_exp2K (FuncState *fs, expdesc *e) { |
| 1056 | if (!hasjumps(e)) { |
| 1057 | int info; |
| 1058 | switch (e->k) { /* move constants to 'k' */ |
| 1059 | case VTRUE: info = boolT(fs); break; |
| 1060 | case VFALSE: info = boolF(fs); break; |
| 1061 | case VNIL: info = nilK(fs); break; |
| 1062 | case VKINT: info = luaK_intK(fs, e->u.ival); break; |
| 1063 | case VKFLT: info = luaK_numberK(fs, e->u.nval); break; |
| 1064 | case VKSTR: info = stringK(fs, e->u.strval); break; |
| 1065 | case VK: info = e->u.info; break; |
| 1066 | default: return 0; /* not a constant */ |
| 1067 | } |
| 1068 | if (info <= MAXINDEXRK) { /* does constant fit in 'argC'? */ |
| 1069 | e->k = VK; /* make expression a 'K' expression */ |
| 1070 | e->u.info = info; |
| 1071 | return 1; |
| 1072 | } |
| 1073 | } |
| 1074 | /* else, expression doesn't fit; leave it unchanged */ |
| 1075 | return 0; |
| 1076 | } |
| 1077 | |
| 1078 | |
| 1079 | /* |
no test coverage detected