changeset 1236:57db55766118

Fixed ClassInfo.interfaces. mini/s.d now runs again.
author Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
date Thu, 16 Apr 2009 21:10:51 +0200
parents ded6a557220a
children 73b56541152c
files ir/irclass.cpp
diffstat 1 files changed, 16 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/ir/irclass.cpp	Thu Apr 16 21:00:49 2009 +0200
+++ b/ir/irclass.cpp	Thu Apr 16 21:10:51 2009 +0200
@@ -384,11 +384,10 @@
     assert(type->irtype->isClass()->getNumInterfaceVtbls() == n &&
         "inconsistent number of interface vtables in this class");
 
+    VarDeclarationIter interfaces_idx(ClassDeclaration::classinfo->fields, 3);
+
     if (n == 0)
-    {
-        VarDeclarationIter idx(ClassDeclaration::classinfo->fields, 3);
-        return getNullValue(DtoType(idx->type));
-    }
+        return getNullValue(DtoType(interfaces_idx->type));
 
 // Build array of:
 //
@@ -447,22 +446,29 @@
     LLConstant* arr = llvm::ConstantArray::get(
         array_type,
         &constants[0],
-        constants.size());
+        n);
 
     // apply the initializer
     classInterfacesArray->setInitializer(arr);
 
+    // return null, only baseclass provide interfaces
+    if (cd->vtblInterfaces->dim == 0)
+    {
+        return getNullValue(DtoType(interfaces_idx->type));
+    }
+
+    // only the interface explicitly implemented by this class
+    // (not super classes) should show in ClassInfo
     LLConstant* idxs[2] = {
         DtoConstSize_t(0),
-        // only the interface explicitly implemented by this class
-        // (not super classes) should show in ClassInfo
         DtoConstSize_t(n - cd->vtblInterfaces->dim)
     };
 
+    LLConstant* ptr = llvm::ConstantExpr::getGetElementPtr(
+        classInterfacesArray, idxs, 2);
+
     // return as a slice
-    return DtoConstSlice(
-        DtoConstSize_t(n),
-        llvm::ConstantExpr::getGetElementPtr(classInterfacesArray, idxs, 2));
+    return DtoConstSlice( DtoConstSize_t(cd->vtblInterfaces->dim), ptr );
 }
 
 //////////////////////////////////////////////////////////////////////////////