Genericize the ReversePostOrderIterator.
[oota-llvm.git] / tools / lli / lli.cpp
index 818931c5f79ba029f2a32d8846e9872cbc394896..f4145c169c5cffc03e8e49f9da195ae9ade7d5fe 100644 (file)
@@ -8,23 +8,27 @@
 //===----------------------------------------------------------------------===//
 
 #include "Interpreter.h"
-#include "llvm/Support/CommandLine.h"
+#include "Support/CommandLine.h"
 
-cl::String InputFilename(""       , "Input filename", cl::NoFlags, "-");
+cl::StringList InputArgv(""   , "Input command line", cl::ConsumeAfter);
 cl::String MainFunction ("f"      , "Function to execute", cl::NoFlags, "main");
 cl::Flag   DebugMode    ("debug"  , "Start program in debugger");
 cl::Alias  DebugModeA   ("d"      , "Alias for -debug", cl::NoFlags, DebugMode);
+cl::Flag   TraceMode    ("trace"  , "Enable Tracing");
 cl::Flag   ProfileMode  ("profile", "Enable Profiling [unimp]");
 
+
 //===----------------------------------------------------------------------===//
 // Interpreter ctor - Initialize stuff
 //
-Interpreter::Interpreter() : ExitCode(0), Profile(ProfileMode), CurFrame(-1) {
+Interpreter::Interpreter() : ExitCode(0), Profile(ProfileMode), 
+                             Trace(TraceMode), CurFrame(-1) {
   CurMod = 0;
-  loadModule(InputFilename);
+  loadModule(InputArgv.size() ? InputArgv[0] : "-");
 
   // Initialize the "backend"
   initializeExecutionEngine();
+  initializeExternalMethods();
 }
 
 //===----------------------------------------------------------------------===//
@@ -46,10 +50,18 @@ int main(int argc, char** argv) {
 
   // If running with the profiler, enable it now...
   if (ProfileMode) I.enableProfiling();
+  if (TraceMode) I.enableTracing();
+
+  // Ensure that there is at least one argument... the name of the program.
+  // This is only unavailable if the program was read from stdin, instead of a
+  // file.
+  //
+  if (InputArgv.empty())
+    InputArgv.push_back("from-stdin-prog");
 
   // Start interpreter into the main function...
   //
-  if (!I.callMainMethod(MainFunction, InputFilename) && !DebugMode) {
+  if (!I.callMainMethod(MainFunction, InputArgv) && !DebugMode) {
     // If not in debug mode and if the call succeeded, run the code now...
     I.run();
   }