diff dang/compiler.d @ 94:48bb2287c035 new_gen

Added Modules. Right now it's very simple - will grow with time and need.
author Anders Johnsen <skabet@gmail.com>
date Tue, 06 May 2008 16:24:14 +0200
parents 771ac63898e2
children 198ad05f3ace
line wrap: on
line diff
--- a/dang/compiler.d	Mon May 05 20:53:13 2008 +0200
+++ b/dang/compiler.d	Tue May 06 16:24:14 2008 +0200
@@ -15,7 +15,7 @@
 
 import basic.Message;
 
-import ast.Decl;
+import ast.Module;
 
 import tools.AstPrinter,
        tools.DotPrinter;
@@ -82,7 +82,7 @@
     Signal!(Lexer) postLex;
 
     Signal!(Lexer) preParse;
-    Signal!(Decl[], SourceManager) postParse;
+    Signal!(Module, SourceManager) postParse;
 
     preStart.attach(&checkFiles);
 
@@ -140,36 +140,36 @@
     auto what = options["what-to-do"];
     if (what == "" || what == "gen-llvm")
         postParse.attach(
-            (Decl[] decls, SourceManager sm) {
+            (Module m, SourceManager sm) {
                 StopWatch w; w.start;
                 auto llvmGen = new CodeGen();
                 auto file = new FileConduit("out.bc", FileConduit.WriteCreate);
-                llvmGen.gen(decls, file.fileHandle, optimize, inline);
+                llvmGen.gen(m, file.fileHandle, optimize, inline);
                 timings ~= Measurement("Generating LLVM bytecode", w.stop);
             });
     else if (what == "compile")
         postParse.attach(
-            (Decl[] decls, SourceManager sm) {
+            (Module m, SourceManager sm) {
                 StopWatch w; w.start;
                 auto llvmGen = new CodeGen();
                 auto llc = new Process("llc");
-                llvmGen.gen(decls, llc.stdin.fileHandle, optimize, inline);
+                llvmGen.gen(m, llc.stdin.fileHandle, optimize, inline);
                 timings ~= Measurement("Generating assemble bytecode", w.stop);
             });
     else if (what == "dot")
         postParse.attach(
-            (Decl[] decls, SourceManager sm) {
+            (Module m, SourceManager sm) {
                 StopWatch w; w.start;
                 auto print = new DotPrinter();
-                print.print(decls);
+                print.print(m);
                 timings ~= Measurement("Generating dot output", w.stop);
             });
     else if (what == "code")
         postParse.attach(
-            (Decl[] decls, SourceManager sm) {
+            (Module m, SourceManager sm) {
                 StopWatch w; w.start;
                 auto print = new AstPrinter(sm);
-                print.print(decls);
+                print.print(m);
                 timings ~= Measurement("Converting AST to text", w.stop);
             });
     StopWatch total;
@@ -188,24 +188,24 @@
         watch.start;
         auto parser = new Parser(messages);
         auto action = new AstAction(src_mgr);
-        auto decls = cast(Decl[])parser.parse(src_mgr, lexer, action);
+        auto m = cast(Module)parser.parse(src_mgr, lexer, action);
         timings ~= Measurement("Lex + Parse", watch.stop);
         messages.checkErrors(ExitLevel.Parser);
 
         StopWatch watch2;
         watch.start;
         watch2.start;
-        (new ScopeBuilder).visit(decls);
+        (new ScopeBuilder).visit(m);
         auto scope_builder = watch2.stop;
         watch2.start;
-        (new ScopeCheck).visit(decls);
+        (new ScopeCheck).visit(m);
         auto scope_check = watch2.stop;
         watch2.start;
-        (new TypeCheck).visit(decls);
+        (new TypeCheck).visit(m);
         auto type_check = watch2.stop;
         watch2.start;
 
-        foreach (decl; decls)
+        foreach (decl; m.decls)
             decl.simplify();
         auto simplify = watch2.stop;
         auto extra_stuff = watch.stop;
@@ -214,7 +214,7 @@
         timings ~= Measurement("  - Checking scopes", scope_check);
         timings ~= Measurement("  - Checking types", type_check);
 
-        postParse(decls, src_mgr);
+        postParse(m, src_mgr);
     }
     timings ~= Measurement("Total", total.stop);