Mercurial > projects > ldc
changeset 820:bb4a81e68ddb
Implemented allocating storage for a slice if its address is taken, fixes #115
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Tue, 02 Dec 2008 01:20:22 +0100 |
parents | 446263a8a30d |
children | 8f0b24bc55f0 |
files | gen/toir.cpp tests/mini/slices2.d |
diffstat | 2 files changed, 20 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/gen/toir.cpp Tue Dec 02 01:07:22 2008 +0100 +++ b/gen/toir.cpp Tue Dec 02 01:20:22 2008 +0100 @@ -888,10 +888,23 @@ return v; } Logger::println("is nothing special"); - LLValue* lval = v->getLVal(); + + // we special case here, since apparently taking the address of a slice is ok + LLValue* lval; + if (v->isLVal()) + lval = v->getLVal(); + else + { + assert(v->isSlice()); + LLValue* rval = v->getRVal(); + lval = DtoAlloca(rval->getType(), ".tmp_slice_storage"); + DtoStore(rval, lval); + } + if (Logger::enabled()) Logger::cout() << "lval: " << *lval << '\n'; - return new DImValue(type, DtoBitCast(v->getLVal(), DtoType(type))); + + return new DImValue(type, DtoBitCast(lval, DtoType(type))); } LLConstant* AddrExp::toConstElem(IRState* p)