MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / codenot

Function codenot

xrepo/packages/l/lua/port/lua/src/lcode.c:1186–1214  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1184** Code 'not e', doing constant folding.
1185*/
1186static void codenot (FuncState *fs, expdesc *e) {
1187 switch (e->k) {
1188 case VNIL: case VFALSE: {
1189 e->k = VTRUE; /* true == not nil == not false */
1190 break;
1191 }
1192 case VK: case VKFLT: case VKINT: case VKSTR: case VTRUE: {
1193 e->k = VFALSE; /* false == not "x" == not 0.5 == not 1 == not true */
1194 break;
1195 }
1196 case VJMP: {
1197 negatecondition(fs, e);
1198 break;
1199 }
1200 case VRELOC:
1201 case VNONRELOC: {
1202 discharge2anyreg(fs, e);
1203 freeexp(fs, e);
1204 e->u.info = luaK_codeABC(fs, OP_NOT, 0, e->u.info, 0);
1205 e->k = VRELOC;
1206 break;
1207 }
1208 default: lua_assert(0); /* cannot happen */
1209 }
1210 /* interchange true and false lists */
1211 { int temp = e->f; e->f = e->t; e->t = temp; }
1212 removevalues(fs, e->f); /* values are useless when negated */
1213 removevalues(fs, e->t);
1214}
1215
1216
1217/*

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