D1: Fixed accessing parameters in contracts.

This reverts the changes from commit f7e5245 and implements the
proper fix – in D1, contracts are treated as normal nested functions.

GitHub: Fix #138.
This commit is contained in:
David Nadlinger
2012-10-20 17:08:51 +02:00
parent ece5176aa9
commit 07888f95e4
2 changed files with 17 additions and 9 deletions

View File

@@ -1562,11 +1562,16 @@ DValue* ThisExp::toElem(IRState* p)
LLValue* v;
Dsymbol* vdparent = vd->toParent2();
Identifier *ident = p->func()->decl->ident;
#if DMDV2
// In D1, contracts are treated as normal nested methods, 'this' is
// just passed in the context struct along with any used parameters.
if (ident == Id::ensure || ident == Id::require) {
Logger::println("contract this exp");
v = p->func()->nestArg;
v = DtoBitCast(v, DtoType(type)->getPointerTo());
} else if (vdparent != p->func()->decl) {
} else
#endif
if (vdparent != p->func()->decl) {
Logger::println("nested this exp");
#if STRUCTTHISREF
return DtoNestedVariable(loc, type, vd, type->ty == Tstruct);