]> de.git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - ast.c
Fix util_endianswap; and endianswap the LNO data as well
[xonotic/gmqcc.git] / ast.c
diff --git a/ast.c b/ast.c
index 79a74c0cc0176fce28f91ddc18cc4021f79b33e3..04e13b8e6d5f96eca84bdedb14b494776989ca3c 100644 (file)
--- a/ast.c
+++ b/ast.c
@@ -709,8 +709,8 @@ void ast_ternary_delete(ast_ternary *self)
 
 ast_loop* ast_loop_new(lex_ctx ctx,
                        ast_expression *initexpr,
-                       ast_expression *precond,
-                       ast_expression *postcond,
+                       ast_expression *precond, bool pre_not,
+                       ast_expression *postcond, bool post_not,
                        ast_expression *increment,
                        ast_expression *body)
 {
@@ -723,6 +723,9 @@ ast_loop* ast_loop_new(lex_ctx ctx,
     self->increment = increment;
     self->body      = body;
 
+    self->pre_not   = pre_not;
+    self->post_not  = post_not;
+
     if (initexpr)
         ast_propagate_effects(self, initexpr);
     if (precond)
@@ -1502,7 +1505,7 @@ bool ast_function_codegen(ast_function *self, ir_builder *ir)
     }
 
     /* TODO: check return types */
-    if (!self->curblock->is_return)
+    if (!self->curblock->final)
     {
         if (!self->vtype->expression.next ||
             self->vtype->expression.next->expression.vtype == TYPE_VOID)
@@ -2546,6 +2549,11 @@ bool ast_loop_codegen(ast_loop *self, ast_function *func, bool lvalue, ir_value
         else if (bpostcond)  ontrue = bpostcond;
         else                 ontrue = bprecond;
         onfalse = bout;
+        if (self->pre_not) {
+            tmpblock = ontrue;
+            ontrue   = onfalse;
+            onfalse  = tmpblock;
+        }
         if (!ir_block_create_if(end_bprecond, ast_ctx(self), precond, ontrue, onfalse))
             return false;
     }
@@ -2581,6 +2589,11 @@ bool ast_loop_codegen(ast_loop *self, ast_function *func, bool lvalue, ir_value
         else if (bincrement) ontrue = bincrement;
         else                 ontrue = bpostcond;
         onfalse = bout;
+        if (self->post_not) {
+            tmpblock = ontrue;
+            ontrue   = onfalse;
+            onfalse  = tmpblock;
+        }
         if (!ir_block_create_if(end_bpostcond, ast_ctx(self), postcond, ontrue, onfalse))
             return false;
     }