Mercurial > projects > ldc
changeset 733:cc8ba72c0350
Nested access to with statement should work now. fixes #105
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Mon, 27 Oct 2008 01:40:47 +0100 |
parents | 6aeaef263289 |
children | 6dcab994ddc3 |
files | gen/statements.cpp gen/toobj.cpp |
diffstat | 2 files changed, 21 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/gen/statements.cpp Mon Oct 27 01:11:41 2008 +0100 +++ b/gen/statements.cpp Mon Oct 27 01:40:47 2008 +0100 @@ -1155,15 +1155,26 @@ DValue* e = exp->toElem(p); -#if 1 - // this doesn't handle the mini/with2.d test case ... - assert(!wthis->ir.isSet()); - wthis->ir.irLocal = new IrLocal(wthis); - wthis->ir.irLocal->value = DtoAlloca(DtoType(wthis->type), wthis->toChars()); -#else - // ... this does, but it also silently breaks MiniD!!! - DtoDeclarationExp(wthis); -#endif + if (wthis->ir.isSet()) + { + assert(wthis->nestedref); + assert(wthis->ir.irLocal); + assert(!wthis->ir.irLocal->value); + wthis->ir.irLocal->value = DtoAlloca(DtoType(wthis->type), wthis->toChars()); + + // store the address into the nested vars array + assert(wthis->ir.irLocal->nestedIndex >= 0); + LLValue* gep = DtoGEPi(gIR->func()->decl->ir.irFunc->nestedVar, 0, wthis->ir.irLocal->nestedIndex); + assert(isaPointer(wthis->ir.irLocal->value)); + LLValue* val = DtoBitCast(wthis->ir.irLocal->value, getVoidPtrType()); + DtoStore(val, gep); + } + else + { + assert(!wthis->nestedref); + wthis->ir.irLocal = new IrLocal(wthis); + wthis->ir.irLocal->value = DtoAlloca(DtoType(wthis->type), wthis->toChars()); + } DtoStore(e->getRVal(), wthis->ir.irLocal->value);