diff gen/toir.cpp @ 1248:01909bd1132c

Merge.
author Tomas Lindquist Olsen <tomas.l.olsen gmail com>
date Tue, 21 Apr 2009 17:54:43 +0200
parents 837f48560863 465a77c904d4
children 9014d7f0433f
line wrap: on
line diff
--- a/gen/toir.cpp	Mon Apr 20 00:04:35 2009 +0200
+++ b/gen/toir.cpp	Tue Apr 21 17:54:43 2009 +0200
@@ -131,8 +131,7 @@
         {
             Logger::println("ClassInfoDeclaration: %s", cid->cd->toChars());
             cid->cd->codegen(Type::sir);;
-            assert(cid->cd->ir.irStruct->classInfo);
-            return new DVarValue(type, vd, cid->cd->ir.irStruct->classInfo);
+            return new DVarValue(type, vd, cid->cd->ir.irStruct->getClassInfoSymbol());
         }
         // nested variable
     #if DMDV2
@@ -216,8 +215,8 @@
         TypeStruct* ts = (TypeStruct*)sdecltype;
         assert(ts->sym);
         ts->sym->codegen(Type::sir);
-        assert(ts->sym->ir.irStruct->init);
-        return new DVarValue(type, ts->sym->ir.irStruct->init);
+
+        return new DVarValue(type, ts->sym->ir.irStruct->getInitSymbol());
     }
     else
     {
@@ -242,8 +241,8 @@
         assert(sdecltype->ty == Tstruct);
         TypeStruct* ts = (TypeStruct*)sdecltype;
         ts->sym->codegen(Type::sir);
-        assert(ts->sym->ir.irStruct->constInit);
-        return ts->sym->ir.irStruct->constInit;
+
+        return ts->sym->ir.irStruct->getDefaultInit();
     }
 
     if (TypeInfoDeclaration* ti = var->isTypeInfoDeclaration())
@@ -983,6 +982,7 @@
     }
     else if (e1->op == TOKstructliteral)
     {
+        // FIXME: is this right?
         StructLiteralExp* slexp = (StructLiteralExp*)e1;
         LLConstant* lit = slexp->toConstElem(p);
         return lit;
@@ -1134,9 +1134,7 @@
             size_t vtblidx = fdecl->vtblIndex;
             if (Logger::enabled())
                 Logger::cout() << "vthis: " << *vthis << '\n';
-            funcval = vthis;
-            if (!fdecl->isMember2()->isInterfaceDeclaration())
-                funcval = DtoGEP(funcval, zero, zero);
+            funcval = DtoGEP(vthis, zero, zero);
             funcval = DtoLoad(funcval);
             Logger::println("vtblidx = %lu", vtblidx);
             funcval = DtoGEP(funcval, zero, DtoConstUint(vtblidx), toChars());
@@ -1646,7 +1644,7 @@
         else {
             assert(ts->sym);
             ts->sym->codegen(Type::sir);
-            DtoAggrCopy(mem,ts->sym->ir.irStruct->init);
+            DtoAggrCopy(mem,ts->sym->ir.irStruct->getInitSymbol());
         }
         return new DImValue(type, mem);
     }
@@ -1658,8 +1656,7 @@
         DVarValue tmpvar(newtype, mem);
 
         // default initialize
-        // FIXME: should this use DtoConstExpInit instead ?
-        // or is static arrays the only troublemaker?
+        // static arrays never appear here, so using the defaultInit is ok!
         Expression* exp = newtype->defaultInit(loc);
         DValue* iv = exp->toElem(gIR);
         DtoAssign(loc, &tmpvar, iv);
@@ -2412,6 +2409,9 @@
     Logger::print("StructLiteralExp::toElem: %s @ %s\n", toChars(), type->toChars());
     LOG_SCOPE;
 
+    // make sure the struct is resolved
+    sd->codegen(Type::sir);
+
     // get inits
     std::vector<LLValue*> inits(sd->fields.dim, NULL);
 
@@ -2470,6 +2470,9 @@
     Logger::print("StructLiteralExp::toConstElem: %s @ %s\n", toChars(), type->toChars());
     LOG_SCOPE;
 
+    // make sure the struct is resolved
+    sd->codegen(Type::sir);
+
     // get inits
     std::vector<LLValue*> inits(sd->fields.dim, NULL);