[llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp
Alkis Evlogimenos
alkis at cs.uiuc.edu
Sat Nov 6 09:54:29 PST 2004
Changes in directory llvm-java/lib/Compiler:
Compiler.cpp updated: 1.139 -> 1.140
---
Log message:
Lookup static fields in super classes as well.
---
Diffs of the changes: (+21 -13)
Index: llvm-java/lib/Compiler/Compiler.cpp
diff -u llvm-java/lib/Compiler/Compiler.cpp:1.139 llvm-java/lib/Compiler/Compiler.cpp:1.140
--- llvm-java/lib/Compiler/Compiler.cpp:1.139 Sat Nov 6 11:52:44 2004
+++ llvm-java/lib/Compiler/Compiler.cpp Sat Nov 6 11:54:19 2004
@@ -1017,20 +1017,28 @@
ConstantFieldRef* fieldRef = cf_->getConstantFieldRef(index);
ConstantNameAndType* nameAndType = fieldRef->getNameAndType();
- // Get ClassInfo for class owning the field - this will force
- // the globals to be initialized.
- getClassInfo(ClassFile::get(fieldRef->getClass()->getName()->str()));
-
- std::string globalName =
- fieldRef->getClass()->getName()->str() + '/' +
- nameAndType->getName()->str();
-
- DEBUG(std::cerr << "Looking up global: " << globalName << '\n');
- GlobalVariable* global = module_.getGlobalVariable
- (globalName, getType(nameAndType->getDescriptor()));
- assert(global && "Got NULL global variable!");
+ std::string className = fieldRef->getClass()->getName()->str();
- return global;
+ while (true) {
+ // Get ClassInfo for class owning the field - this will force
+ // the globals to be initialized.
+ ClassFile* cf = ClassFile::get(className);
+ getClassInfo(cf);
+
+ std::string globalName =
+ className + '/' + nameAndType->getName()->str();
+
+ DEBUG(std::cerr << "Looking up global: " << globalName << '\n');
+ GlobalVariable* global = module_.getGlobalVariable
+ (globalName, getType(nameAndType->getDescriptor()));
+ if (global)
+ return global;
+
+ assert(cf->getSuperClass() && "Cannot find global for static field!");
+ className = cf->getSuperClass()->getName()->str();
+ }
+
+ return NULL; // never reached
}
/// Emits the necessary code to get a field from the passed
More information about the llvm-commits
mailing list