Mercurial > projects > dang
diff sema/Visitor.d @ 5:2c5a8f4c254a
Added very simple if support.
* No else
* Still no logical operators, always tests != 0
author | Anders Halager <halager@gmail.com> |
---|---|
date | Fri, 18 Apr 2008 11:46:00 +0200 |
parents | 2168f4cb73f1 |
children | 642c6a998fd9 |
line wrap: on
line diff
--- a/sema/Visitor.d Fri Apr 18 11:07:46 2008 +0200 +++ b/sema/Visitor.d Fri Apr 18 11:46:00 2008 +0200 @@ -45,6 +45,8 @@ return visitDeclStmt(cast(DeclStmt)stmt); case StmtType.Exp: return visitExpStmt(cast(ExpStmt)stmt); + case StmtType.If: + return visitIfStmt(cast(IfStmt)stmt); default: throw new Exception("Unknown statement type"); } @@ -119,6 +121,17 @@ return StmtT.init; } + StmtT visitIfStmt(IfStmt s) + { + visitExp(s.cond); + foreach (stmt; s.then) + visitStmt(stmt); + static if (is(StmtT == void)) + return; + else + return StmtT.init; + } + StmtT visitExpStmt(ExpStmt s) { visitExp(s.exp);