diff gen/toir.c @ 68:c4b3f5d2cd9b trunk

[svn r72] Calling a nested function that is not a delegate was not working.
author lindquist
date Sun, 28 Oct 2007 03:14:29 +0100
parents f918f3e2e99e
children 2b5a2eaa88be
line wrap: on
line diff
--- a/gen/toir.c	Sun Oct 28 02:46:06 2007 +0200
+++ b/gen/toir.c	Sun Oct 28 03:14:29 2007 +0100
@@ -1036,6 +1036,7 @@
     if (fn->arg || delegateCall) n++;
     if (retinptr) n++;
     if (tf->linkage == LINKd && tf->varargs == 1) n+=2;
+    if (fn->funcdecl && fn->funcdecl->isNested()) n++;
 
     llvm::Value* funcval = fn->getValue();
     assert(funcval != 0);
@@ -1127,6 +1128,15 @@
         ++j;
         ++argiter;
     }
+    // nested call
+    else if (fn->funcdecl && fn->funcdecl->isNested()) {
+        Logger::println("Nested Call");
+        llvm::Value* contextptr = p->func().decl->llvmNested;
+        assert(contextptr);
+        llargs[j] = p->ir->CreateBitCast(contextptr, llvm::PointerType::get(llvm::Type::Int8Ty), "tmp");
+        ++j;
+        ++argiter;
+    }
 
     // va arg function special argument passing
     if (va_magic) {