Mercurial > projects > ldc
comparison gen/arrays.cpp @ 328:7086a84ab3d6 trunk
[svn r349] Fixed problems with static arrays of void as well as a static arrays with zero length.
Fixed issues with DMD generated assert statements when using class invariants, generally due to incomplete ASTs.
Removed some dead code.
Added a few comments.
author | lindquist |
---|---|
date | Fri, 11 Jul 2008 00:17:00 +0200 |
parents | a9697749e898 |
children | 20446d22f832 |
comparison
equal
deleted
inserted
replaced
327:781af50846b2 | 328:7086a84ab3d6 |
---|---|
32 | 32 |
33 ////////////////////////////////////////////////////////////////////////////////////////// | 33 ////////////////////////////////////////////////////////////////////////////////////////// |
34 | 34 |
35 const LLArrayType* DtoStaticArrayType(Type* t) | 35 const LLArrayType* DtoStaticArrayType(Type* t) |
36 { | 36 { |
37 if (t->ir.type) | 37 t = t->toBasetype(); |
38 return isaArray(t->ir.type->get()); | |
39 | |
40 assert(t->ty == Tsarray); | 38 assert(t->ty == Tsarray); |
41 assert(t->next); | |
42 | |
43 const LLType* at = DtoType(t->next); | |
44 | |
45 TypeSArray* tsa = (TypeSArray*)t; | 39 TypeSArray* tsa = (TypeSArray*)t; |
46 assert(tsa->dim->type->isintegral()); | 40 Type* tnext = tsa->next; |
47 const LLArrayType* arrty = LLArrayType::get(at,tsa->dim->toUInteger()); | 41 |
48 | 42 const LLType* elemty = DtoType(tnext); |
49 assert(!tsa->ir.type); | 43 if (elemty == LLType::VoidTy) |
50 tsa->ir.type = new LLPATypeHolder(arrty); | 44 elemty = LLType::Int8Ty; |
51 return arrty; | 45 |
46 return LLArrayType::get(elemty, tsa->dim->toUInteger()); | |
52 } | 47 } |
53 | 48 |
54 ////////////////////////////////////////////////////////////////////////////////////////// | 49 ////////////////////////////////////////////////////////////////////////////////////////// |
55 | 50 |
56 void DtoSetArrayToNull(LLValue* v) | 51 void DtoSetArrayToNull(LLValue* v) |
972 if (rval->getType() != tolltype) | 967 if (rval->getType() != tolltype) |
973 rval = gIR->ir->CreateBitCast(rval, tolltype, "tmp"); | 968 rval = gIR->ir->CreateBitCast(rval, tolltype, "tmp"); |
974 } | 969 } |
975 else if (totype->ty == Tarray) { | 970 else if (totype->ty == Tarray) { |
976 Logger::cout() << "to array" << '\n'; | 971 Logger::cout() << "to array" << '\n'; |
977 const LLType* ptrty = DtoType(totype->next); | 972 const LLType* ptrty = DtoArrayType(totype)->getContainedType(1); |
978 if (ptrty == LLType::VoidTy) | 973 const LLType* ety = DtoTypeNotVoid(fromtype->next); |
979 ptrty = LLType::Int8Ty; | |
980 ptrty = getPtrToType(ptrty); | |
981 | |
982 const LLType* ety = DtoType(fromtype->next); | |
983 if (ety == LLType::VoidTy) | |
984 ety = LLType::Int8Ty; | |
985 | 974 |
986 if (DSliceValue* usl = u->isSlice()) { | 975 if (DSliceValue* usl = u->isSlice()) { |
987 Logger::println("from slice"); | 976 Logger::println("from slice"); |
988 Logger::cout() << "from: " << *usl->ptr << " to: " << *ptrty << '\n'; | 977 Logger::cout() << "from: " << *usl->ptr << " to: " << *ptrty << '\n'; |
989 rval = DtoBitCast(usl->ptr, ptrty); | 978 rval = DtoBitCast(usl->ptr, ptrty); |