MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / luaK_exp2K

Function luaK_exp2K

lib/lua/src/lcode.c:999–1020  ·  view source on GitHub ↗

** Try to make 'e' a K expression with an index in the range of R/K ** indices. Return true iff succeeded. */

Source from the content-addressed store, hash-verified

997** indices. Return true iff succeeded.
998*/
999static int luaK_exp2K (FuncState *fs, expdesc *e) {
1000 if (!hasjumps(e)) {
1001 int info;
1002 switch (e->k) { /* move constants to 'k' */
1003 case VTRUE: info = boolT(fs); break;
1004 case VFALSE: info = boolF(fs); break;
1005 case VNIL: info = nilK(fs); break;
1006 case VKINT: info = luaK_intK(fs, e->u.ival); break;
1007 case VKFLT: info = luaK_numberK(fs, e->u.nval); break;
1008 case VKSTR: info = stringK(fs, e->u.strval); break;
1009 case VK: info = e->u.info; break;
1010 default: return 0; /* not a constant */
1011 }
1012 if (info <= MAXINDEXRK) { /* does constant fit in 'argC'? */
1013 e->k = VK; /* make expression a 'K' expression */
1014 e->u.info = info;
1015 return 1;
1016 }
1017 }
1018 /* else, expression doesn't fit; leave it unchanged */
1019 return 0;
1020}
1021
1022
1023/*

Callers 3

exp2RKFunction · 0.85
codearithFunction · 0.85
codebitwiseFunction · 0.85

Calls 6

boolTFunction · 0.85
boolFFunction · 0.85
nilKFunction · 0.85
luaK_intKFunction · 0.85
luaK_numberKFunction · 0.85
stringKFunction · 0.85

Tested by

no test coverage detected