[llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp
Alkis Evlogimenos
alkis at cs.uiuc.edu
Fri Aug 6 08:19:13 PDT 2004
Changes in directory llvm-java/lib/Compiler:
Compiler.cpp updated: 1.83 -> 1.84
---
Log message:
Implement constructor calls through the invokespecial
bytecode. Calling the superclass' method (another use of
invokespecial) is yet unimplemented.
---
Diffs of the changes: (+22 -1)
Index: llvm-java/lib/Compiler/Compiler.cpp
diff -u llvm-java/lib/Compiler/Compiler.cpp:1.83 llvm-java/lib/Compiler/Compiler.cpp:1.84
--- llvm-java/lib/Compiler/Compiler.cpp:1.83 Fri Aug 6 10:16:14 2004
+++ llvm-java/lib/Compiler/Compiler.cpp Fri Aug 6 10:19:03 2004
@@ -961,7 +961,28 @@
}
void do_invokespecial(unsigned bcI, unsigned index) {
- assert(0 && "not implemented");
+ ConstantMethodRef* methodRef = cf_->getConstantMethodRef(index);
+ ConstantNameAndType* nameAndType = methodRef->getNameAndType();
+
+ const std::string& className = methodRef->getClass()->getName()->str();
+ const std::string& methodName = nameAndType->getName()->str();
+ const std::string& methodDescr =
+ methodName + nameAndType->getDescriptor()->str();
+ std::string funcName = className + '/' + methodDescr;
+
+ const ClassInfo& ci = getClassInfo(className);
+ // constructor calls are statically bound
+ if (methodName == "<init>") {
+ FunctionType* funcType =
+ cast<FunctionType>(getType(nameAndType->getDescriptor(), ci.type));
+ Function* function = module_->getOrInsertFunction(funcName, funcType);
+ toCompileFunctions_.insert(function);
+ makeCall(function, getBBAt(bcI));
+ }
+ // otherwise we call the superclass' implementation of the method
+ else {
+ assert(0 && "not implemented");
+ }
}
void do_invokestatic(unsigned bcI, unsigned index) {
More information about the llvm-commits
mailing list