diff gen/classes.cpp @ 812:6c2ff06c4201

Fixed a nasty bug with how interface vtables for class initializers were output, causing some class fields to be skipped. Fixed a problem in definition of ClassInfos where an invalid constant was potentially used. This needs to be looked into proper as it might happen again in the future.
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Mon, 01 Dec 2008 04:37:54 +0100
parents 69a5e4a6fc0f
children 7d16ce7ad19d
line wrap: on
line diff
--- a/gen/classes.cpp	Mon Dec 01 02:10:16 2008 +0100
+++ b/gen/classes.cpp	Mon Dec 01 04:37:54 2008 +0100
@@ -435,7 +435,7 @@
         offsetbegin = init_class_initializer(inits, target, cd->baseClass, offsetbegin);
     }
 
-    Logger::println("adding data of %s to %s", cd->toChars(), target->toChars());
+    Logger::println("adding data of %s to %s starting at %lu", cd->toChars(), target->toChars(), offsetbegin);
     LOG_SCOPE;
 
     // add default fields
@@ -464,7 +464,7 @@
         }
         else
         {
-            Logger::println("  skipped %s", var->toChars());
+            Logger::println("  skipped %s at offset %u, current pos is %lu", var->toChars(), var->offset, lastoffset+lastsize);
         }
     }
 
@@ -519,7 +519,7 @@
         else // abstract impl
             inits.push_back(getNullPtr(getVoidPtrType()));
 
-        lastoffset += PTRSIZE;
+        lastoffset += lastsize;
         lastsize = PTRSIZE;
     }
 
@@ -749,6 +749,7 @@
     init_class_interface_vtbl_initializers(cd);
 
     // build constant from inits
+    assert(!irstruct->constInit);
     irstruct->constInit = LLConstantStruct::get(inits); // classes are never packed
 
     // refine __initZ global type to the one of the initializer
@@ -1437,7 +1438,7 @@
     assert(ir->classInfo);
 
     TypeClass* cdty = (TypeClass*)cd->type;
-    if (!cd->isInterfaceDeclaration() && !cd->isAbstract())
+    if (!cd->isInterfaceDeclaration())
     {
         assert(ir->init);
         assert(ir->constInit);
@@ -1450,7 +1451,6 @@
 
     ClassDeclaration* cinfo = ClassDeclaration::classinfo;
     DtoForceConstInitDsymbol(cinfo);
-    assert(cinfo->ir.irStruct->constInit);
 
     LLConstant* c;
 
@@ -1473,7 +1473,7 @@
     {
         c = DtoBitCast(ir->init, voidPtr);
         //Logger::cout() << *ir->constInit->getType() << std::endl;
-        size_t initsz = getABITypeSize(ir->constInit->getType());
+        size_t initsz = getABITypeSize(ir->init->getType()->getContainedType(0));
         c = DtoConstSlice(DtoConstSize_t(initsz), c);
     }
     inits.push_back(c);