** Code 'not e', doing constant folding. */
| 1229 | ** Code 'not e', doing constant folding. |
| 1230 | */ |
| 1231 | static void codenot (FuncState *fs, expdesc *e) { |
| 1232 | switch (e->k) { |
| 1233 | case VNIL: case VFALSE: { |
| 1234 | e->k = VTRUE; /* true == not nil == not false */ |
| 1235 | break; |
| 1236 | } |
| 1237 | case VK: case VKFLT: case VKINT: case VKSTR: case VTRUE: { |
| 1238 | e->k = VFALSE; /* false == not "x" == not 0.5 == not 1 == not true */ |
| 1239 | break; |
| 1240 | } |
| 1241 | case VJMP: { |
| 1242 | negatecondition(fs, e); |
| 1243 | break; |
| 1244 | } |
| 1245 | case VRELOC: |
| 1246 | case VNONRELOC: { |
| 1247 | discharge2anyreg(fs, e); |
| 1248 | freeexp(fs, e); |
| 1249 | e->u.info = luaK_codeABC(fs, OP_NOT, 0, e->u.info, 0); |
| 1250 | e->k = VRELOC; |
| 1251 | break; |
| 1252 | } |
| 1253 | default: lua_assert(0); /* cannot happen */ |
| 1254 | } |
| 1255 | /* interchange true and false lists */ |
| 1256 | { int temp = e->f; e->f = e->t; e->t = temp; } |
| 1257 | removevalues(fs, e->f); /* values are useless when negated */ |
| 1258 | removevalues(fs, e->t); |
| 1259 | } |
| 1260 | |
| 1261 | |
| 1262 | /* |
no test coverage detected