[llvm-commits] CVS: llvm-java/tools/class2llvm/class2llvm.cpp
Alkis Evlogimenos
alkis at cs.uiuc.edu
Fri Jul 2 05:50:02 PDT 2004
Changes in directory llvm-java/tools/class2llvm:
class2llvm.cpp updated: 1.6 -> 1.7
---
Log message:
Make class2llvm accept a classfile in std::cin as well as a filename.
---
Diffs of the changes: (+14 -2)
Index: llvm-java/tools/class2llvm/class2llvm.cpp
diff -u llvm-java/tools/class2llvm/class2llvm.cpp:1.6 llvm-java/tools/class2llvm/class2llvm.cpp:1.7
--- llvm-java/tools/class2llvm/class2llvm.cpp:1.6 Fri Jul 2 05:44:48 2004
+++ llvm-java/tools/class2llvm/class2llvm.cpp Fri Jul 2 05:49:01 2004
@@ -29,6 +29,18 @@
static cl::opt<std::string>
InputFilename(cl::Positional, cl::desc("<input bytecode>"), cl::init("-"));
+namespace {
+
+ std::auto_ptr<std::istream> getInputStream(const std::string& fn) {
+ std::auto_ptr<std::istream> in;
+ if (fn == "-") in.reset(new std::istream(std::cin.rdbuf()));
+ else in.reset(new std::ifstream(fn.c_str()));
+
+ return in;
+ }
+
+}
+
int main(int argc, char* argv[])
{
PrintStackTraceOnErrorSignal();
@@ -36,9 +48,9 @@
"classfile to llvm utility");
try {
- std::ifstream in(InputFilename.c_str());
+ std::auto_ptr<std::istream> in(getInputStream(InputFilename));
- std::auto_ptr<Java::ClassFile> cf(Java::ClassFile::readClassFile(in));
+ std::auto_ptr<Java::ClassFile> cf(Java::ClassFile::readClassFile(*in));
Java::Compiler compiler;
More information about the llvm-commits
mailing list