diff gen/classes.cpp @ 737:041c1596d217

Removed warnings on ignored aligns. Only do aligment on packed structs, align(1) struct Packed { ... } Changed the way struct/class fields are added, first small part of cleaning up these... Make struct/class/union fields aware of any anonymous struct/union they might be part of, not yet really useful, but part of getting better union support.
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Tue, 28 Oct 2008 15:41:09 +0100
parents 635f91212b78
children f04dde6e882c
line wrap: on
line diff
--- a/gen/classes.cpp	Mon Oct 27 17:42:38 2008 +0100
+++ b/gen/classes.cpp	Tue Oct 28 15:41:09 2008 +0100
@@ -57,7 +57,7 @@
 
 //////////////////////////////////////////////////////////////////////////////////////////
 
-static void LLVM_AddBaseClassData(BaseClasses* bcs)
+static void LLVM_AddBaseClassData(IrStruct* irstruct, BaseClasses* bcs)
 {
     // add base class data members first
     for (int j=0; j<bcs->dim; j++)
@@ -69,7 +69,7 @@
             continue;
 
         // recursively add baseclass data
-        LLVM_AddBaseClassData(&bc->base->baseclasses);
+        LLVM_AddBaseClassData(irstruct, &bc->base->baseclasses);
 
         Array* arr = &bc->base->fields;
         if (arr->dim == 0)
@@ -80,7 +80,9 @@
 
         for (int k=0; k < arr->dim; k++) {
             VarDeclaration* v = (VarDeclaration*)(arr->data[k]);
-            v->toObjFile(0); // TODO: multiobj
+            Logger::println("Adding field: %s %s", v->type->toChars(), v->toChars());
+            // init fields, used to happen in VarDeclaration::toObjFile
+            irstruct->addField(v);
         }
     }
 }
@@ -143,9 +145,19 @@
     fieldtypes.push_back(getVoidPtrType());
 
     // add base class data fields first
-    LLVM_AddBaseClassData(&cd->baseclasses);
+    LLVM_AddBaseClassData(irstruct, &cd->baseclasses);
 
-    // then add own members, if any
+    // add own fields
+    Array* fields = &cd->fields;
+    for (int k=0; k < fields->dim; k++)
+    {
+        VarDeclaration* v = (VarDeclaration*)fields->data[k];
+        Logger::println("Adding field: %s %s", v->type->toChars(), v->toChars());
+        // init fields, used to happen in VarDeclaration::toObjFile
+        irstruct->addField(v);
+    }
+
+    // then add other members of us, if any
     if(cd->members) {
         for (int k=0; k < cd->members->dim; k++) {
             Dsymbol* dsym = (Dsymbol*)(cd->members->data[k]);