diff sema/SymbolTableBuilder.d @ 45:9bc660cbdbec new_gen

If statements are back Also fixed a bug in the codegen preventing return in the else branch, now it is optional. Also found an issue with the way we are generating our llvm from ifs - it doesn't mean anything but the code looks ugly. if (cond_1) if (cond_2) statement; return 0; Becomes: br cond_1, then, merge then: br cond_2 then2, merge2 merge: ret 0 then2: statements merge2: br merge This is because we use appendBasicBlock on the function
author Anders Halager <halager@gmail.com>
date Wed, 23 Apr 2008 16:43:42 +0200
parents 495188f9078e
children da551f90e03f
line wrap: on
line diff
--- a/sema/SymbolTableBuilder.d	Wed Apr 23 00:57:45 2008 +0200
+++ b/sema/SymbolTableBuilder.d	Wed Apr 23 16:43:42 2008 +0200
@@ -115,14 +115,15 @@
         s.env = current();
         visitExp(s.cond);
         auto sc = push();
-        foreach (stmt; s.then_body)
-            visitStmt(stmt);
+        visitStmt(s.then_body);
         pop(sc);
 
-        sc = push();
-        foreach (stmt; s.else_body)
-            visitStmt(stmt);
-        pop(sc);
+        if (s.else_body !is null)
+        {
+            sc = push();
+            visitStmt(s.else_body);
+            pop(sc);
+        }
     }
 
     override void visitWhileStmt(WhileStmt s)