Mercurial > projects > ldc
diff gen/toir.cpp @ 339:385a18242485 trunk
[svn r360] Another mostly rewrite of DtoArrayInit. Should be much more robust now, and probably faster code generated for the most common cases too!
Fixed issues with slice initialization (!!!) of multidimensional static arrays.
Attempt to fix issue with referencing nested 'this' pointers introduced in DMD 1.033 merge.
author | lindquist |
---|---|
date | Sun, 13 Jul 2008 01:29:49 +0200 |
parents | aaade6ded589 |
children | 351c0077d0b3 |
line wrap: on
line diff
--- a/gen/toir.cpp Sat Jul 12 23:56:56 2008 +0200 +++ b/gen/toir.cpp Sun Jul 13 01:29:49 2008 +0200 @@ -234,7 +234,12 @@ // function parameter else if (vd->isParameter()) { Logger::println("function param"); - if (vd->isRef() || vd->isOut() || DtoIsPassedByRef(vd->type) || llvm::isa<llvm::AllocaInst>(vd->ir.getIrValue())) { + FuncDeclaration* fd = vd->toParent2()->isFuncDeclaration(); + if (fd && fd != p->func()->decl) { + Logger::println("nested parameter"); + return new DVarValue(vd, DtoNestedVariable(vd), true); + } + else if (vd->isRef() || vd->isOut() || DtoIsPassedByRef(vd->type) || llvm::isa<llvm::AllocaInst>(vd->ir.getIrValue())) { return new DVarValue(vd, vd->ir.getIrValue(), true); } else if (llvm::isa<llvm::Argument>(vd->ir.getIrValue())) { @@ -1543,7 +1548,19 @@ else { assert(e1->type->toBasetype()->ty != Tpointer); - elen = DtoArrayLen(e); + // if the sliceee is a static array, we use the length of that as DMD seems + // to give contrary inconsistent sizesin some multidimensional static array cases. + // (namely default initialization, int[16][16] arr; -> int[256] arr = 0;) + if (etype->ty == Tsarray) + { + TypeSArray* tsa = (TypeSArray*)etype; + elen = DtoConstSize_t(tsa->dim->toUInteger()); + } + // for normal code the actual array length is what we want! + else + { + elen = DtoArrayLen(e); + } } return new DSliceValue(type, elen, eptr);