diff gen/declarations.cpp @ 1228:79758fd2f48a

Added Doxygen file. Completely seperated type and symbol generation. Should fix a lot of bugs, but is not yet 100% complete.
author Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
date Wed, 15 Apr 2009 20:06:25 +0200
parents 5ebe8224988b
children 48747003a5de
line wrap: on
line diff
--- a/gen/declarations.cpp	Mon Apr 13 17:42:36 2009 +0200
+++ b/gen/declarations.cpp	Wed Apr 15 20:06:25 2009 +0200
@@ -14,6 +14,8 @@
 
 #include "ir/ir.h"
 #include "ir/irvar.h"
+#include "ir/irtype.h"
+#include "ir/irtypestruct.h"
 
 /* ================================================================== */
 
@@ -72,11 +74,14 @@
 
 /* ================================================================== */
 
+// FIXME: this is horrible!!!
+
 void VarDeclaration::codegen(Ir* p)
 {
     Logger::print("VarDeclaration::toObjFile(): %s | %s\n", toChars(), type->toChars());
     LOG_SCOPE;
 
+    // just forward aliases
     if (aliassym)
     {
         Logger::println("alias sym");
@@ -84,10 +89,11 @@
         return;
     }
 
+    // output the parent aggregate first
     if (AggregateDeclaration* ad = isMember())
         ad->codegen(p);
 
-    // global variable or magic
+    // global variable
 #if DMDV2
     // taken from dmd2/structs
     if (isDataseg() || (storage_class & (STCconst | STCinvariant) && init))
@@ -138,25 +144,8 @@
         if (nakedUse)
             gIR->usedArray.push_back(DtoBitCast(gvar, getVoidPtrType()));
 
-        // don't initialize static struct members yet, they might be of the struct type
-        // which doesn't have a static initializer yet.
-        if (AggregateDeclaration* ad = isMember())
-            ad->ir.irStruct->staticVars.push_back(this);
-        else
-            DtoConstInitGlobal(this);
-    }
-    else
-    {
-        // might already have its irField, as classes derive each other without getting copies of the VarDeclaration
-        if (!ir.irField)
-        {
-            assert(!ir.isSet());
-            ir.irField = new IrField(this);
-        }
-        IrStruct* irstruct = gIR->topstruct();
-        irstruct->addVar(this);
-
-        Logger::println("added offset %u", offset);
+        // initialize
+        DtoConstInitGlobal(this);
     }
 }
 
@@ -164,8 +153,7 @@
 
 void TypedefDeclaration::codegen(Ir*)
 {
-    static int tdi = 0;
-    Logger::print("TypedefDeclaration::toObjFile(%d): %s\n", tdi++, toChars());
+    Logger::print("TypedefDeclaration::toObjFile: %s\n", toChars());
     LOG_SCOPE;
 
     // generate typeinfo
@@ -181,33 +169,12 @@
 
 /* ================================================================== */
 
-void FuncDeclaration::codegen(Ir*)
+void FuncDeclaration::codegen(Ir* p)
 {
-    DtoResolveDsymbol(this);
-}
-
-/* ================================================================== */
-
-void AnonDeclaration::codegen(Ir* p)
-{
-    Array *d = include(NULL, NULL);
-
-    if (d)
+    // don't touch function aliases, they don't contribute any new symbols
+    if (!isFuncAliasDeclaration())
     {
-        // get real aggregate parent
-        IrStruct* irstruct = gIR->topstruct();
-
-        // push a block on the stack
-        irstruct->pushAnon(isunion);
-
-        // go over children
-        for (unsigned i = 0; i < d->dim; i++)
-        {   Dsymbol *s = (Dsymbol *)d->data[i];
-            s->codegen(p);
-        }
-
-        // finish
-        irstruct->popAnon();
+        DtoResolveDsymbol(this);
     }
 }