diff gen/toir.cpp @ 259:2e652b8ad1fd trunk

[svn r277] Fixed a nasty bug in delegate expressions. Context pointers to nested functions of the parent, from inside a nested function were invalid.
author lindquist
date Fri, 13 Jun 2008 05:47:28 +0200
parents 8dbddae09152
children 88252a1af660
line wrap: on
line diff
--- a/gen/toir.cpp	Thu Jun 12 19:59:19 2008 +0200
+++ b/gen/toir.cpp	Fri Jun 13 05:47:28 2008 +0200
@@ -2230,13 +2230,12 @@
     DValue* u = e1->toElem(p);
     LLValue* uval;
     if (DFuncValue* f = u->isFunc()) {
-        //assert(f->vthis);
-        //uval = f->vthis;
-        LLValue* nestvar = p->func()->decl->ir.irFunc->nestedVar;
-        if (nestvar)
-            uval = nestvar;
+        assert(f->func);
+        LLValue* contextptr = DtoNestedContext(f->func->toParent2()->isFuncDeclaration());
+        if (!contextptr)
+            uval = LLConstant::getNullValue(getVoidPtrType());
         else
-            uval = llvm::ConstantPointerNull::get(int8ptrty);
+            uval = DtoBitCast(contextptr, getVoidPtrType());
     }
     else {
         DValue* src = u;