diff sema/SymbolTableBuilder.d @ 24:2d28b21faad6 new_gen

New codegen! Rewritten codegen to use the llvm bindings Everything except struct are back to normal, and there a a few additions. 1. Correct code in more cases, return at the end of a while/if wont generate a "ret" followed by a "br". 2. Better scope, "int x = x" now illegal 3. Probably more
author Anders Halager <halager@gmail.com>
date Sat, 19 Apr 2008 18:29:42 +0200
parents e331e4e816e4
children b4dc2b2c0e38
line wrap: on
line diff
--- a/sema/SymbolTableBuilder.d	Sat Apr 19 11:40:20 2008 +0200
+++ b/sema/SymbolTableBuilder.d	Sat Apr 19 18:29:42 2008 +0200
@@ -56,17 +56,36 @@
 
     override void visitVarDecl(VarDecl d)
     {
+        if (d.init)
+            visitExp(d.init);
+
+        if (need_push > 0) {
+            push();
+            --need_push;
+        }
+
         auto sc = current();
         auto sym = sc.add(d.identifier);
         sym.type = d.type;
-        super.visitVarDecl(d);
+        d.env = sc;
+        visitExp(d.type);
+        visitExp(d.identifier);
+    }
+
+    override void visitStructDecl(StructDecl s)
+    {
+        auto sc = current();
+        auto sym = sc.add(s.identifier);
+//        sym.type = Tok.Struct;
+        super.visitStructDecl(s);
     }
 
     override void visitDeclStmt(DeclStmt d)
     {
+        ++need_push;
         super.visitDeclStmt(d);
-        push();
     }
+    private uint need_push = 0;
 
     override void visitIfStmt(IfStmt s)
     {