]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - ir.c
Make unary - operator act as an ast_unary node. This allows for consistency (no sense...
[xonotic/gmqcc.git] / ir.c
diff --git a/ir.c b/ir.c
index f92d5524eb12281e4d13fe1044f906e150718e41..49d4b2f02e26354024e1db26da4765bbb639c78f 100644 (file)
--- a/ir.c
+++ b/ir.c
@@ -1878,16 +1878,22 @@ ir_value* ir_block_create_unary(ir_block *self, lex_ctx_t ctx,
         case INSTR_NOT_V:
         case INSTR_NOT_S:
         case INSTR_NOT_ENT:
-        case INSTR_NOT_FNC:
-#if 0
-        case INSTR_NOT_I:
-#endif
+        case INSTR_NOT_FNC: /*
+        case INSTR_NOT_I:   */
             ot = TYPE_FLOAT;
             break;
-        /* QC doesn't have other unary operations. We expect extensions to fill
-         * the above list, otherwise we assume out-type = in-type, eg for an
-         * unary minus
+
+        /*
+         * Negation for virtual instructions is emulated with 0-value. Thankfully
+         * the operand for 0 already exists so we just source it from here.
          */
+        case VINSTR_NEG_F:
+            return ir_block_create_general_instr(self, ctx, label, INSTR_SUB_F, NULL, operand, ot);
+            break;
+        case VINSTR_NEG_V:
+            return ir_block_create_general_instr(self, ctx, label, INSTR_SUB_V, NULL, operand, ot);
+            break;
+
         default:
             ot = operand->vtype;
             break;