Mercurial > projects > dang
comparison gen/CodeGen.d @ 89:a49bb982a7b0 new_gen
Using the new SourceLocation system to handle errors. Also, this is the first push for making the errors don't throw, but continue to check the source.
author | Anders Johnsen <skabet@gmail.com> |
---|---|
date | Sun, 04 May 2008 20:27:01 +0200 |
parents | eb5b2c719a39 |
children | 771ac63898e2 |
comparison
equal
deleted
inserted
replaced
88:eb5b2c719a39 | 89:a49bb982a7b0 |
---|---|
63 ~this() | 63 ~this() |
64 { | 64 { |
65 b.dispose(); | 65 b.dispose(); |
66 } | 66 } |
67 | 67 |
68 void gen(Decl[] decls, bool optimize, bool inline) | 68 void gen(Decl[] decls, uint handle, bool optimize, bool inline) |
69 { | 69 { |
70 // create module | 70 // create module |
71 m = new Module("main_module"); | 71 m = new Module("main_module"); |
72 scope(exit) m.dispose(); | 72 scope(exit) m.dispose(); |
73 | 73 |
87 if(auto st = t.asStruct) | 87 if(auto st = t.asStruct) |
88 { | 88 { |
89 Type pointer = PointerType.Get(llvm(st)); | 89 Type pointer = PointerType.Get(llvm(st)); |
90 param_types ~= pointer; | 90 param_types ~= pointer; |
91 } | 91 } |
92 if(auto ar = t.asArray) | 92 else if(auto ar = t.asArray) |
93 { | 93 { |
94 Type pointer = PointerType.Get(llvm(ar)); | 94 Type pointer = PointerType.Get(llvm(ar)); |
95 param_types ~= pointer; | 95 param_types ~= pointer; |
96 } | 96 } |
97 else | 97 else |
139 debug m.verify(); | 139 debug m.verify(); |
140 | 140 |
141 if(optimize) | 141 if(optimize) |
142 m.optimize(inline); | 142 m.optimize(inline); |
143 | 143 |
144 m.writeBitcodeToFile("out.bc"); | 144 m.writeBitcodeToFileHandle(handle); |
145 } | 145 } |
146 | 146 |
147 void genRootDecl(Decl decl) | 147 void genRootDecl(Decl decl) |
148 { | 148 { |
149 switch(decl.declType) | 149 switch(decl.declType) |
529 return b.buildGEP(array, gep_indices[1 .. 2], "index"); | 529 return b.buildGEP(array, gep_indices[1 .. 2], "index"); |
530 } | 530 } |
531 else assert(0, "Can only index pointers and arrays"); | 531 else assert(0, "Can only index pointers and arrays"); |
532 case ExpType.MemberReference: | 532 case ExpType.MemberReference: |
533 auto mem = cast(MemberReference)exp; | 533 auto mem = cast(MemberReference)exp; |
534 Stdout(mem.target).newline; | |
535 switch(mem.target.expType) | 534 switch(mem.target.expType) |
536 { | 535 { |
537 case ExpType.Identifier: | 536 case ExpType.Identifier: |
538 auto identifier = cast(Identifier)mem.target; | 537 auto identifier = cast(Identifier)mem.target; |
539 auto child = mem.child; | 538 auto child = mem.child; |