comparison 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
comparison
equal deleted inserted replaced
338:0c90d816394f 339:385a18242485
232 return new DVarValue(vd, DtoNestedVariable(vd), true); 232 return new DVarValue(vd, DtoNestedVariable(vd), true);
233 } 233 }
234 // function parameter 234 // function parameter
235 else if (vd->isParameter()) { 235 else if (vd->isParameter()) {
236 Logger::println("function param"); 236 Logger::println("function param");
237 if (vd->isRef() || vd->isOut() || DtoIsPassedByRef(vd->type) || llvm::isa<llvm::AllocaInst>(vd->ir.getIrValue())) { 237 FuncDeclaration* fd = vd->toParent2()->isFuncDeclaration();
238 if (fd && fd != p->func()->decl) {
239 Logger::println("nested parameter");
240 return new DVarValue(vd, DtoNestedVariable(vd), true);
241 }
242 else if (vd->isRef() || vd->isOut() || DtoIsPassedByRef(vd->type) || llvm::isa<llvm::AllocaInst>(vd->ir.getIrValue())) {
238 return new DVarValue(vd, vd->ir.getIrValue(), true); 243 return new DVarValue(vd, vd->ir.getIrValue(), true);
239 } 244 }
240 else if (llvm::isa<llvm::Argument>(vd->ir.getIrValue())) { 245 else if (llvm::isa<llvm::Argument>(vd->ir.getIrValue())) {
241 return new DImValue(type, vd->ir.getIrValue()); 246 return new DImValue(type, vd->ir.getIrValue());
242 } 247 }
1541 } 1546 }
1542 // no bounds or full slice -> just convert to slice 1547 // no bounds or full slice -> just convert to slice
1543 else 1548 else
1544 { 1549 {
1545 assert(e1->type->toBasetype()->ty != Tpointer); 1550 assert(e1->type->toBasetype()->ty != Tpointer);
1546 elen = DtoArrayLen(e); 1551 // if the sliceee is a static array, we use the length of that as DMD seems
1552 // to give contrary inconsistent sizesin some multidimensional static array cases.
1553 // (namely default initialization, int[16][16] arr; -> int[256] arr = 0;)
1554 if (etype->ty == Tsarray)
1555 {
1556 TypeSArray* tsa = (TypeSArray*)etype;
1557 elen = DtoConstSize_t(tsa->dim->toUInteger());
1558 }
1559 // for normal code the actual array length is what we want!
1560 else
1561 {
1562 elen = DtoArrayLen(e);
1563 }
1547 } 1564 }
1548 1565
1549 return new DSliceValue(type, elen, eptr); 1566 return new DSliceValue(type, elen, eptr);
1550 } 1567 }
1551 1568