diff ir/irstruct.cpp @ 1262:ec1d9dc1d32a

Fixed struct default initializers.
author Tomas Lindquist Olsen <tomas.l.olsen gmail com>
date Sat, 25 Apr 2009 18:26:54 +0200
parents 747fdd9245d7
children dd135ff697fa
line wrap: on
line diff
--- a/ir/irstruct.cpp	Wed Apr 22 14:49:49 2009 -0600
+++ b/ir/irstruct.cpp	Sat Apr 25 18:26:54 2009 +0200
@@ -142,6 +142,9 @@
 
     assert(type->ty == Tstruct && "cannot build struct default initializer for non struct type");
 
+    IrTypeStruct* ts = type->irtype->isStruct();
+    assert(ts);
+
     // start at offset zero
     size_t offset = 0;
 
@@ -149,10 +152,10 @@
     std::vector<llvm::Constant*> constants;
 
     // go through fields
-    ArrayIter<VarDeclaration> it(aggrdecl->fields);
-    for (; !it.done(); it.next())
+    IrTypeAggr::iterator it;
+    for (it = ts->def_begin(); it != ts->def_end(); ++it)
     {
-        VarDeclaration* vd = it.get();
+        VarDeclaration* vd = *it;
 
         if (vd->offset < offset)
         {
@@ -195,12 +198,6 @@
     IF_LOG Logger::cout() << "final default initializer: " << *definit << std::endl;
 #endif
 
-    // sanity check
-    if (definit->getType() != type->irtype->get())
-    {
-        assert(0 && "default initializer type does not match the default struct type");
-    }
-
     return definit;
 }