Mercurial > projects > dang
comparison gen/CodeGen.d @ 114:3a0cd42de9cc
Removed misc/Error.d and is now using the error system all way through.
author | Anders Johnsen <skabet@gmail.com> |
---|---|
date | Sun, 25 May 2008 16:40:38 +0200 |
parents | 189c049cbfcc |
children | e89c42733e10 |
comparison
equal
deleted
inserted
replaced
112:d03b011c50e9 | 114:3a0cd42de9cc |
---|---|
9 import ast.Decl, | 9 import ast.Decl, |
10 ast.Stmt, | 10 ast.Stmt, |
11 ast.Exp, | 11 ast.Exp, |
12 ast.Module : DModule = Module; | 12 ast.Module : DModule = Module; |
13 | 13 |
14 import misc.Error, | 14 import basic.SmallArray; |
15 basic.SmallArray; | |
16 | 15 |
17 import lexer.Token; | 16 import lexer.Token; |
18 | 17 |
19 import sema.Scope, | 18 import sema.Scope, |
20 sema.Visitor; | 19 sema.Visitor; |
280 { | 279 { |
281 // try to find a convertion - only works for iX | 280 // try to find a convertion - only works for iX |
282 IntegerType l = cast(IntegerType) left.type; | 281 IntegerType l = cast(IntegerType) left.type; |
283 IntegerType r = cast(IntegerType) right.type; | 282 IntegerType r = cast(IntegerType) right.type; |
284 if (l is null || r is null) | 283 if (l is null || r is null) |
285 throw error(__LINE__, PE.NoImplicitConversion) | 284 assert(0, PE.NoImplicitConversion); |
285 /* | |
286 .arg(left.type.toString) | 286 .arg(left.type.toString) |
287 .arg(right.type.toString); | 287 .arg(right.type.toString);*/ |
288 | 288 |
289 if (l.numBits() < r.numBits()) | 289 if (l.numBits() < r.numBits()) |
290 left = b.buildSExt(left, r, ".cast"); | 290 left = b.buildSExt(left, r, ".cast"); |
291 else | 291 else |
292 right = b.buildSExt(right, l, ".cast"); | 292 right = b.buildSExt(right, l, ".cast"); |
458 { | 458 { |
459 b.buildRetVoid(); | 459 b.buildRetVoid(); |
460 return; | 460 return; |
461 } | 461 } |
462 else | 462 else |
463 throw error(__LINE__, PE.VoidRetInNonVoidFunc); | 463 assert(0, PE.VoidRetInNonVoidFunc); |
464 | 464 |
465 RValue v = genExpression(ret.exp); | 465 RValue v = genExpression(ret.exp); |
466 /* if (v.type != t) | 466 /* if (v.type != t) |
467 { | 467 { |
468 IntegerType v_t = cast(IntegerType) v.type; | 468 IntegerType v_t = cast(IntegerType) v.type; |
722 args[2] = ConstantInt.GetS(Type.Int32, t.byteSize()); | 722 args[2] = ConstantInt.GetS(Type.Int32, t.byteSize()); |
723 args[3] = ConstantInt.GetS(Type.Int32, 32); | 723 args[3] = ConstantInt.GetS(Type.Int32, 32); |
724 b.buildCall(llvm_memcpy, args[], null); | 724 b.buildCall(llvm_memcpy, args[], null); |
725 } | 725 } |
726 | 726 |
727 Error error(uint line, char[] msg) | |
728 { | |
729 return new Error(msg); | |
730 } | |
731 | |
732 /** | 727 /** |
733 Get the LLVM Type corresponding to a DType. | 728 Get the LLVM Type corresponding to a DType. |
734 | 729 |
735 Currently using the built-in associative array - not sure if it works | 730 Currently using the built-in associative array - not sure if it works |
736 well when the hashes are so uniform. | 731 well when the hashes are so uniform. |