[llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp

Alkis Evlogimenos alkis at cs.uiuc.edu
Mon Dec 6 00:10:40 PST 2004



Changes in directory llvm-java/lib/Compiler:

Compiler.cpp updated: 1.169 -> 1.170
---
Log message:

Make instanceof work.


---
Diffs of the changes:  (+13 -6)

Index: llvm-java/lib/Compiler/Compiler.cpp
diff -u llvm-java/lib/Compiler/Compiler.cpp:1.169 llvm-java/lib/Compiler/Compiler.cpp:1.170
--- llvm-java/lib/Compiler/Compiler.cpp:1.169	Mon Dec  6 01:57:18 2004
+++ llvm-java/lib/Compiler/Compiler.cpp	Mon Dec  6 02:10:29 2004
@@ -568,15 +568,22 @@
     /// the array.
     std::pair<unsigned,llvm::Constant*>
     buildSuperClassesVTables(ClassFile* cf, const VTableInfo& vi) const {
-      ArrayType* vtablesArrayTy =
+      std::vector<llvm::Constant*> superVtables(vi.superVtables.size());
+      for (unsigned i = 0, e = vi.superVtables.size(); i != e; ++i)
+        superVtables[i] = ConstantExpr::getCast(
+          vi.superVtables[i],
+          PointerType::get(VTableInfo::VTableTy));
+
+      llvm::Constant* init = ConstantArray::get(
         ArrayType::get(PointerType::get(VTableInfo::VTableTy),
-                       vi.superVtables.size());
+                       superVtables.size()),
+        superVtables);
 
       GlobalVariable* vtablesArray = new GlobalVariable(
-        vtablesArrayTy,
+        init->getType(),
         true,
         GlobalVariable::ExternalLinkage,
-        ConstantArray::get(vtablesArrayTy, vi.superVtables),
+        init,
         cf->getThisClass()->getName()->str() + "<superclassesvtables>",
         &module_);
 
@@ -610,8 +617,8 @@
         assert(classVI.m2iMap.find(i->first) != classVI.m2iMap.end() &&
                "Interface method not found in class definition!");
         unsigned classMethodIdx = classVI.m2iMap.find(i->first)->second;
-        init[i->second] =
-          cast<ConstantStruct>(classVI.vtable->getInitializer())->getElementAt(classMethodIdx);
+        init[i->second] = cast<ConstantStruct>(
+          classVI.vtable->getInitializer())->getElementAt(classMethodIdx);
       }
 
       llvm::Constant* vtable = ConstantStruct::get(init);






More information about the llvm-commits mailing list