** Code 'not e', doing constant folding. */
| 1167 | ** Code 'not e', doing constant folding. |
| 1168 | */ |
| 1169 | static void codenot (FuncState *fs, expdesc *e) { |
| 1170 | switch (e->k) { |
| 1171 | case VNIL: case VFALSE: { |
| 1172 | e->k = VTRUE; /* true == not nil == not false */ |
| 1173 | break; |
| 1174 | } |
| 1175 | case VK: case VKFLT: case VKINT: case VKSTR: case VTRUE: { |
| 1176 | e->k = VFALSE; /* false == not "x" == not 0.5 == not 1 == not true */ |
| 1177 | break; |
| 1178 | } |
| 1179 | case VJMP: { |
| 1180 | negatecondition(fs, e); |
| 1181 | break; |
| 1182 | } |
| 1183 | case VRELOC: |
| 1184 | case VNONRELOC: { |
| 1185 | discharge2anyreg(fs, e); |
| 1186 | freeexp(fs, e); |
| 1187 | e->u.info = luaK_codeABC(fs, OP_NOT, 0, e->u.info, 0); |
| 1188 | e->k = VRELOC; |
| 1189 | break; |
| 1190 | } |
| 1191 | default: lua_assert(0); /* cannot happen */ |
| 1192 | } |
| 1193 | /* interchange true and false lists */ |
| 1194 | { int temp = e->f; e->f = e->t; e->t = temp; } |
| 1195 | removevalues(fs, e->f); /* values are useless when negated */ |
| 1196 | removevalues(fs, e->t); |
| 1197 | } |
| 1198 | |
| 1199 | |
| 1200 | /* |
no test coverage detected