# HG changeset patch # User Tomas Lindquist Olsen # Date 1225068047 -3600 # Node ID cc8ba72c0350feec0030c06d8e28bfde6b0742a9 # Parent 6aeaef263289e3ed89e44e141ec526c8c9481d68 Nested access to with statement should work now. fixes #105 diff -r 6aeaef263289 -r cc8ba72c0350 gen/statements.cpp --- 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); diff -r 6aeaef263289 -r cc8ba72c0350 gen/toobj.cpp --- a/gen/toobj.cpp Mon Oct 27 01:11:41 2008 +0100 +++ b/gen/toobj.cpp Mon Oct 27 01:40:47 2008 +0100 @@ -923,6 +923,7 @@ for (int i=0; i < n; ++i) { DsymbolExp* exp = (DsymbolExp*)objects->data[i]; + assert(exp->op == TOKdsymbol); exp->s->toObjFile(multiobj); } }