diff ir/irclass.cpp @ 1253:752bed475b75

Fixed classinfo.interfaces for .. interfaces!
author Tomas Lindquist Olsen <tomas.l.olsen gmail com>
date Tue, 21 Apr 2009 20:19:53 +0200
parents 871ae029ff49
children 854e86eaa022 ec1d9dc1d32a
line wrap: on
line diff
--- a/ir/irclass.cpp	Tue Apr 21 19:32:22 2009 +0200
+++ b/ir/irclass.cpp	Tue Apr 21 20:19:53 2009 +0200
@@ -424,11 +424,20 @@
         ci = DtoBitCast(ci, classinfo_type);
 
         // vtbl
-        ClassGlobalMap::iterator itv = interfaceVtblMap.find(it->base);
-        assert(itv != interfaceVtblMap.end() && "interface vtbl not found");
-        LLConstant* vtb = itv->second;
-        vtb = DtoBitCast(vtb, voidptrptr_type);
-        vtb = DtoConstSlice(DtoConstSize_t(itc->getVtblSize()), vtb);
+        LLConstant* vtb;
+        // interface get a null
+        if (cd->isInterfaceDeclaration())
+        {
+            vtb = DtoConstSlice(DtoConstSize_t(0), getNullValue(voidptrptr_type));
+        }
+        else
+        {
+            ClassGlobalMap::iterator itv = interfaceVtblMap.find(it->base);
+            assert(itv != interfaceVtblMap.end() && "interface vtbl not found");
+            vtb = itv->second;
+            vtb = DtoBitCast(vtb, voidptrptr_type);
+            vtb = DtoConstSlice(DtoConstSize_t(itc->getVtblSize()), vtb);
+        }
 
         // offset
         LLConstant* off = DtoConstSize_t(it->offset);
@@ -473,3 +482,22 @@
 }
 
 //////////////////////////////////////////////////////////////////////////////
+
+void IrStruct::initializeInterface()
+{
+    InterfaceDeclaration* base = aggrdecl->isInterfaceDeclaration();
+    assert(base && "not interface");
+
+    // has interface vtbls?
+    if (!base->vtblInterfaces)
+        return;
+
+    ArrayIter<BaseClass> it(*base->vtblInterfaces);
+    for (; !it.done(); it.next())
+    {
+        // add to the interface list
+        interfacesWithVtbls.push_back(it.get());
+    }
+}
+
+//////////////////////////////////////////////////////////////////////////////