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