Mercurial > projects > ldc
diff 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 |
line wrap: on
line diff
--- a/gen/arrays.cpp Thu Jul 10 22:00:27 2008 +0200 +++ b/gen/arrays.cpp Fri Jul 11 00:17:00 2008 +0200 @@ -34,21 +34,16 @@ const LLArrayType* DtoStaticArrayType(Type* t) { - if (t->ir.type) - return isaArray(t->ir.type->get()); - + t = t->toBasetype(); assert(t->ty == Tsarray); - assert(t->next); - - const LLType* at = DtoType(t->next); + TypeSArray* tsa = (TypeSArray*)t; + Type* tnext = tsa->next; - TypeSArray* tsa = (TypeSArray*)t; - assert(tsa->dim->type->isintegral()); - const LLArrayType* arrty = LLArrayType::get(at,tsa->dim->toUInteger()); + const LLType* elemty = DtoType(tnext); + if (elemty == LLType::VoidTy) + elemty = LLType::Int8Ty; - assert(!tsa->ir.type); - tsa->ir.type = new LLPATypeHolder(arrty); - return arrty; + return LLArrayType::get(elemty, tsa->dim->toUInteger()); } ////////////////////////////////////////////////////////////////////////////////////////// @@ -974,14 +969,8 @@ } else if (totype->ty == Tarray) { Logger::cout() << "to array" << '\n'; - const LLType* ptrty = DtoType(totype->next); - if (ptrty == LLType::VoidTy) - ptrty = LLType::Int8Ty; - ptrty = getPtrToType(ptrty); - - const LLType* ety = DtoType(fromtype->next); - if (ety == LLType::VoidTy) - ety = LLType::Int8Ty; + const LLType* ptrty = DtoArrayType(totype)->getContainedType(1); + const LLType* ety = DtoTypeNotVoid(fromtype->next); if (DSliceValue* usl = u->isSlice()) { Logger::println("from slice");