diff gen/toir.cpp @ 452:30ef3c7bddca

Fixed problems with nested 'this'. Fixes #39 . Fixed problem with debug info order of intrinsic calls (func.start after declare).
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Sat, 02 Aug 2008 00:50:39 +0200
parents cc40db549aea
children 121624c14053 9db9099583ca
line wrap: on
line diff
--- a/gen/toir.cpp	Fri Aug 01 21:56:13 2008 +0200
+++ b/gen/toir.cpp	Sat Aug 02 00:50:39 2008 +0200
@@ -969,6 +969,7 @@
 
     // this seems to happen for dmd generated assert statements like:
     //      assert(this, "null this");
+    // FIXME: check for TOKthis in AssertExp instead
     if (!var)
     {
         LLValue* v = p->func()->thisVar;
@@ -978,9 +979,16 @@
     // regular this expr
     else if (VarDeclaration* vd = var->isVarDeclaration()) {
         LLValue* v;
-        v = p->func()->decl->ir.irFunc->thisVar;
-        if (llvm::isa<llvm::AllocaInst>(v))
-            v = DtoLoad(v);
+        if (vd->toParent2() != p->func()->decl) {
+            Logger::println("nested this exp");
+            v = DtoLoad(DtoNestedVariable(vd));
+        }
+        else {
+            Logger::println("normal this exp");
+            v = p->func()->decl->ir.irFunc->thisVar;
+            if (llvm::isa<llvm::AllocaInst>(v))
+                v = DtoLoad(v);
+        }
         const LLType* t = DtoType(type);
         if (v->getType() != t)
             v = DtoBitCast(v, t);