MCPcopy Create free account
hub / github.com/DFHack/dfhack / codenot

Function codenot

depends/lua/src/lcode.c:910–939  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

908** Code 'not e', doing constant folding.
909*/
910static void codenot (FuncState *fs, expdesc *e) {
911 luaK_dischargevars(fs, e);
912 switch (e->k) {
913 case VNIL: case VFALSE: {
914 e->k = VTRUE; /* true == not nil == not false */
915 break;
916 }
917 case VK: case VKFLT: case VKINT: case VTRUE: {
918 e->k = VFALSE; /* false == not "x" == not 0.5 == not 1 == not true */
919 break;
920 }
921 case VJMP: {
922 negatecondition(fs, e);
923 break;
924 }
925 case VRELOCABLE:
926 case VNONRELOC: {
927 discharge2anyreg(fs, e);
928 freeexp(fs, e);
929 e->u.info = luaK_codeABC(fs, OP_NOT, 0, e->u.info, 0);
930 e->k = VRELOCABLE;
931 break;
932 }
933 default: lua_assert(0); /* cannot happen */
934 }
935 /* interchange true and false lists */
936 { int temp = e->f; e->f = e->t; e->t = temp; }
937 removevalues(fs, e->f); /* values are useless when negated */
938 removevalues(fs, e->t);
939}
940
941
942/*

Callers 1

luaK_prefixFunction · 0.85

Calls 6

luaK_dischargevarsFunction · 0.85
negateconditionFunction · 0.85
discharge2anyregFunction · 0.85
freeexpFunction · 0.85
luaK_codeABCFunction · 0.85
removevaluesFunction · 0.85

Tested by

no test coverage detected