diff gen/tocall.cpp @ 486:a34078905d01

Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in. Reimplemented support for nested functions/class using a new approach. Added error on taking address of intrinsic. Fixed problems with the ->syntaxCopy of TypeFunction delegate exp. Removed DtoDType and replaced all uses with ->toBasetype() instead. Removed unused inplace stuff. Fixed a bunch of issues in the runtime unittests, not complete yet. Added mini tests.
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Sun, 10 Aug 2008 08:37:38 +0200
parents 672eb4893b55
children 993b217af574
line wrap: on
line diff
--- a/gen/tocall.cpp	Sat Aug 09 09:03:52 2008 +0200
+++ b/gen/tocall.cpp	Sun Aug 10 08:37:38 2008 +0200
@@ -71,6 +71,7 @@
     else if (type->ty == Tdelegate)
     {
         LLValue* dg = fn->getRVal();
+        Logger::cout() << "delegate: " << *dg << '\n';
         LLValue* funcptr = DtoGEPi(dg, 0, 1);
         return DtoLoad(funcptr);
     }
@@ -200,10 +201,10 @@
     TypeFunction* tf = DtoTypeFunction(fnval);
 
     // misc
-    bool retinptr = tf->llvmRetInPtr;
-    bool usesthis = tf->llvmUsesThis;
+    bool retinptr = tf->retInPtr;
+    bool thiscall = tf->usesThis;
     bool delegatecall = (calleeType->toBasetype()->ty == Tdelegate);
-    bool nestedcall = (dfnval && dfnval->func && dfnval->func->isNested());
+    bool nestedcall = tf->usesNest;
     bool dvarargs = (tf->linkage == LINKd && tf->varargs == 1);
 
     unsigned callconv = DtoCallingConv(tf->linkage);
@@ -221,8 +222,8 @@
     llvm::PAListPtr palist;
 
     // return attrs
-    if (tf->llvmRetAttrs)
-        palist = palist.addAttr(0, tf->llvmRetAttrs);
+    if (tf->retAttrs)
+        palist = palist.addAttr(0, tf->retAttrs);
 
     // handle implicit arguments
     std::vector<LLValue*> args;
@@ -237,11 +238,12 @@
     }
 
     // then comes a context argument...
-    if(usesthis || delegatecall || nestedcall)
+    if(thiscall || delegatecall || nestedcall)
     {
         // ... which can be a 'this' argument
-        if (dfnval && dfnval->vthis)
+        if (thiscall)
         {
+            assert(dfnval && dfnval->vthis);
             LLValue* thisarg = DtoBitCast(dfnval->vthis, argiter->get());
             ++argiter;
             args.push_back(thisarg);
@@ -257,11 +259,8 @@
         // ... or a nested function context arg
         else if (nestedcall)
         {
-            LLValue* contextptr = DtoNestedContext(dfnval->func->toParent2()->isFuncDeclaration());
-            if (!contextptr)
-                contextptr = getNullPtr(getVoidPtrType());
-            else
-                contextptr = DtoBitCast(contextptr, getVoidPtrType());
+            LLValue* contextptr = DtoNestedContext(loc, dfnval->func);
+            contextptr = DtoBitCast(contextptr, getVoidPtrType());
             ++argiter;
             args.push_back(contextptr);
         }
@@ -354,7 +353,7 @@
         call->setCallingConv(callconv);
     call->setParamAttrs(palist);
 
-    return new DImValue(resulttype, retllval, false);
+    return new DImValue(resulttype, retllval);
 }