MCPcopy Create free account
hub / github.com/ArduPilot/ardupilot / codenot

Function codenot

libraries/AP_Scripting/lua/src/lcode.c:917–946  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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

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