diff gen/toobj.cpp @ 102:027b8d8b71ec trunk

[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up. Basically it tries to do the following in order: Resolve types, Declare symbols, Create constant initializers, Apply initializers, Generate functions bodies. ClassInfo is now has the most useful(biased?) members working. Probably other stuf...
author lindquist
date Sun, 18 Nov 2007 06:52:57 +0100
parents 5071469303d4
children 855adfdb8d38
line wrap: on
line diff
--- a/gen/toobj.cpp	Fri Nov 16 10:01:24 2007 +0100
+++ b/gen/toobj.cpp	Sun Nov 18 06:52:57 2007 +0100
@@ -92,14 +92,33 @@
         dsym->toObjFile();
     }
 
-    // process deferred const initializers
-    for (size_t i=0; i<ir.constInitQueue.size(); ++i) {
-        DtoConstInitDsymbol(ir.constInitQueue[i]);
-    }
-
-    // process deferred definitions
-    for (size_t i=0; i<ir.defineQueue.size(); ++i) {
-        DtoDefineDsymbol(ir.defineQueue[i]);
+    // main driver loop
+    for(;;)
+    {
+        Dsymbol* dsym;
+        if (!ir.resolveList.empty()) {
+            dsym = ir.resolveList.front();
+            ir.resolveList.pop_front();
+            DtoResolveDsymbol(dsym);
+        }
+        else if (!ir.declareList.empty()) {
+            dsym = ir.declareList.front();
+            ir.declareList.pop_front();
+            DtoDeclareDsymbol(dsym);
+        }
+        else if (!ir.constInitList.empty()) {
+            dsym = ir.constInitList.front();
+            ir.constInitList.pop_front();
+            DtoConstInitDsymbol(dsym);
+        }
+        else if (!ir.defineList.empty()) {
+            dsym = ir.defineList.front();
+            ir.defineList.pop_front();
+            DtoDefineDsymbol(dsym);
+        }
+        else {
+            break;
+        }
     }
 
     // generate ModuleInfo
@@ -326,7 +345,7 @@
 
 void StructDeclaration::toObjFile()
 {
-    DtoDeclareStruct(this);
+    gIR->resolveList.push_back(this);
 }
 
 /* ================================================================== */
@@ -364,7 +383,7 @@
 
 void ClassDeclaration::toObjFile()
 {
-    DtoDeclareClass(this);
+    gIR->resolveList.push_back(this);
 }
 
 /******************************************
@@ -394,8 +413,9 @@
     // global variable or magic
     if (isDataseg())
     {
-        if (llvmTouched) return;
-        else llvmTouched = true;
+        if (llvmResolved) return;
+        llvmResolved = true;
+        llvmDeclared = true;
 
         llvmIRGlobal = new IRGlobal(this);
 
@@ -430,7 +450,7 @@
         if (static_local)
             DtoConstInitGlobal(this);
         else
-            gIR->constInitQueue.push_back(this);
+            gIR->constInitList.push_back(this);
 
         //if (storage_class & STCprivate)
         //    gvar->setVisibility(llvm::GlobalValue::ProtectedVisibility);
@@ -473,5 +493,5 @@
 
 void FuncDeclaration::toObjFile()
 {
-    DtoDeclareFunction(this);
+    gIR->resolveList.push_back(this);
 }