Mercurial > projects > dang
diff sema/Visitor.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 | 90fb4fdfefdd |
line wrap: on
line diff
--- a/sema/Visitor.d Wed Apr 23 00:57:45 2008 +0200 +++ b/sema/Visitor.d Wed Apr 23 16:43:42 2008 +0200 @@ -158,10 +158,9 @@ StmtT visitIfStmt(IfStmt s) { visitExp(s.cond); - foreach (stmt; s.then_body) - visitStmt(stmt); - foreach (stmt; s.else_body) - visitStmt(stmt); + visitStmt(s.then_body); + if (s.else_body !is null) + visitStmt(s.else_body); static if (is(StmtT == void)) return; else