MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / luaK_exp2K

Function luaK_exp2K

3rd/lua-5.4.3/src/lcode.c:980–1001  ·  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

978** indices. Return true iff succeeded.
979*/
980static int luaK_exp2K (FuncState *fs, expdesc *e) {
981 if (!hasjumps(e)) {
982 int info;
983 switch (e->k) { /* move constants to 'k' */
984 case VTRUE: info = boolT(fs); break;
985 case VFALSE: info = boolF(fs); break;
986 case VNIL: info = nilK(fs); break;
987 case VKINT: info = luaK_intK(fs, e->u.ival); break;
988 case VKFLT: info = luaK_numberK(fs, e->u.nval); break;
989 case VKSTR: info = stringK(fs, e->u.strval); break;
990 case VK: info = e->u.info; break;
991 default: return 0; /* not a constant */
992 }
993 if (info <= MAXINDEXRK) { /* does constant fit in 'argC'? */
994 e->k = VK; /* make expression a 'K' expression */
995 e->u.info = info;
996 return 1;
997 }
998 }
999 /* else, expression doesn't fit; leave it unchanged */
1000 return 0;
1001}
1002
1003
1004/*

Callers 2

luaK_exp2RKFunction · 0.85
codearithFunction · 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