comparison tools/AstPrinter.d @ 101:fea8d61a2451 new_gen

First step(the other first was a bad one) toward imports. You can now compile two files that use eachother - given that they both are in the command line. Right now it's only root sturcts and methods you can use(i guess...?)
author Anders Johnsen <skabet@gmail.com>
date Wed, 07 May 2008 19:58:13 +0200
parents 48bb2287c035
children cd066f3b539a
comparison
equal deleted inserted replaced
100:5f258eaf9517 101:fea8d61a2451
19 this.sm = sm; 19 this.sm = sm;
20 } 20 }
21 21
22 void print(Module m) 22 void print(Module m)
23 { 23 {
24 printBeginLine("module ");
25 printEndLine(m.moduleName);
26 printEndLine();
24 foreach(decl ; m.decls) 27 foreach(decl ; m.decls)
25 { 28 {
26 printDecl(decl); 29 printDecl(decl);
27 } 30 }
31 printEndLine();
28 } 32 }
29 33
30 void printDecl(Decl decl) 34 void printDecl(Decl decl)
31 { 35 {
32 switch(decl.declType) 36 switch(decl.declType)
66 printOpenBrace; 70 printOpenBrace;
67 foreach( var ; structDecl.vars) 71 foreach( var ; structDecl.vars)
68 printDecl(var); 72 printDecl(var);
69 printCloseBrace; 73 printCloseBrace;
70 break; 74 break;
71 } 75
76 case DeclType.ImportDecl:
77 auto i = cast(ImportDecl)decl;
78 printBeginLine("import ");
79 printEndLine(i.get);
80 break;
81 }
82 printEndLine();
72 } 83 }
73 84
74 void printStatement(Stmt stmt) 85 void printStatement(Stmt stmt)
75 { 86 {
76 switch(stmt.stmtType) 87 switch(stmt.stmtType)