[llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp
Alkis Evlogimenos
alkis at cs.uiuc.edu
Tue Jul 13 03:47:01 PDT 2004
Changes in directory llvm-java/lib/Compiler:
Compiler.cpp updated: 1.53 -> 1.54
---
Log message:
Simplify inceamental method compilation.
---
Diffs of the changes: (+23 -25)
Index: llvm-java/lib/Compiler/Compiler.cpp
diff -u llvm-java/lib/Compiler/Compiler.cpp:1.53 llvm-java/lib/Compiler/Compiler.cpp:1.54
--- llvm-java/lib/Compiler/Compiler.cpp:1.53 Fri Jul 9 05:48:38 2004
+++ llvm-java/lib/Compiler/Compiler.cpp Tue Jul 13 05:46:51 2004
@@ -24,6 +24,7 @@
#include <llvm/Type.h>
#include <Support/Debug.h>
#include <Support/SetVector.h>
+#include <Support/STLExtras.h>
#include <Support/StringExtras.h>
#include <iostream>
#include <stack>
@@ -215,31 +216,29 @@
}
void compileMethodOnly(Module& module,
- const ClassFile& cf,
- const Method& method) {
-
- DEBUG(std::cerr << "Compiling method: "
- << method.getName()->str() << '\n');
+ const std::string& classMethodDesc) {
+ DEBUG(std::cerr << "Compiling method: " << classMethodDesc << '\n');
module_ = &module;
- cf_ = &cf;
+ const Method* method;
+ tie(cf_, method) = findClassAndMethod(classMethodDesc);
std::string name = cf_->getThisClass()->getName()->str();
name += '/';
- name += method.getName()->str();
- name += method.getDescriptor()->str();
+ name += method->getName()->str();
+ name += method->getDescriptor()->str();
Function* function =
new Function(
- cast<FunctionType>(getType(method.getDescriptor())),
- (method.isPrivate() ?
+ cast<FunctionType>(getType(method->getDescriptor())),
+ (method->isPrivate() ?
Function::InternalLinkage :
Function::ExternalLinkage),
name,
&module);
const Java::CodeAttribute* codeAttr =
- Java::getCodeAttribute(method.getAttributes());
+ Java::getCodeAttribute(method->getAttributes());
while (!opStack_.empty())
opStack_.pop();
@@ -264,19 +263,8 @@
}
}
- public:
- void compileMethod(Module& module,
- const ClassFile& cf,
- const Method& method) {
- compileMethodOnly(module, cf, method);
-
- for (unsigned i = 0; i != toCompileFunctions_.size(); ++i) {
- Function* f = toCompileFunctions_[i];
- compileMethod(module, f->getName());
- }
- }
-
- void compileMethod(Module& module, const std::string& classMethodDesc) {
+ std::pair<const ClassFile*, const Method*>
+ findClassAndMethod(const std::string& classMethodDesc) {
unsigned slash = classMethodDesc.find('/');
std::string className = classMethodDesc.substr(0, slash);
std::string methodNameAndDescr = classMethodDesc.substr(slash+1);
@@ -288,7 +276,17 @@
"Method " + methodNameAndDescr +
" not found in class " + className);
- compileMethod(module, *classfile, *method);
+
+ return std::make_pair(classfile, method);
+ }
+
+ public:
+ void compileMethod(Module& module, const std::string& classMethodDesc) {
+ compileMethodOnly(module, classMethodDesc);
+ for (unsigned i = 0; i != toCompileFunctions_.size(); ++i) {
+ Function* f = toCompileFunctions_[i];
+ compileMethodOnly(module, f->getName());
+ }
}
void do_aconst_null(unsigned bcI) {
More information about the llvm-commits
mailing list