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

Function codenot

3rd/lua-5.4.3/src/lcode.c:1168–1196  ·  view source on GitHub ↗

** Code 'not e', doing constant folding. */

Source from the content-addressed store, hash-verified

1166** Code 'not e', doing constant folding.
1167*/
1168static void codenot (FuncState *fs, expdesc *e) {
1169 switch (e->k) {
1170 case VNIL: case VFALSE: {
1171 e->k = VTRUE; /* true == not nil == not false */
1172 break;
1173 }
1174 case VK: case VKFLT: case VKINT: case VKSTR: case VTRUE: {
1175 e->k = VFALSE; /* false == not "x" == not 0.5 == not 1 == not true */
1176 break;
1177 }
1178 case VJMP: {
1179 negatecondition(fs, e);
1180 break;
1181 }
1182 case VRELOC:
1183 case VNONRELOC: {
1184 discharge2anyreg(fs, e);
1185 freeexp(fs, e);
1186 e->u.info = luaK_codeABC(fs, OP_NOT, 0, e->u.info, 0);
1187 e->k = VRELOC;
1188 break;
1189 }
1190 default: lua_assert(0); /* cannot happen */
1191 }
1192 /* interchange true and false lists */
1193 { int temp = e->f; e->f = e->t; e->t = temp; }
1194 removevalues(fs, e->f); /* values are useless when negated */
1195 removevalues(fs, e->t);
1196}
1197
1198
1199/*

Callers 1

luaK_prefixFunction · 0.85

Calls 4

negateconditionFunction · 0.85
discharge2anyregFunction · 0.85
freeexpFunction · 0.85
removevaluesFunction · 0.85

Tested by

no test coverage detected