Don't overwrite previous value, if it succeeded.
[oota-llvm.git] / lib / ExecutionEngine / Interpreter / Interpreter.cpp
index 60e2897b819c03c35b40d55331ef511f251ac819..43e34533c7ba014037e32bc18d3f8663575383cf 100644 (file)
 #include "llvm/CodeGen/IntrinsicLowering.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/Module.h"
-#include "llvm/ModuleProvider.h"
+#include <cstring>
 using namespace llvm;
 
+namespace {
+
 static struct RegisterInterp {
   RegisterInterp() { Interpreter::Register(); }
 } InterpRegistrator;
 
-namespace llvm {
-  void LinkInInterpreter() {
-  }
 }
 
+extern "C" void LLVMLinkInInterpreter() { }
+
 /// create - Create a new interpreter object.  This can never fail.
 ///
-ExecutionEngine *Interpreter::create(ModuleProvider *MP, std::string* ErrStr) {
-  // Tell this ModuleProvide to materialize and release the module
-  if (!MP->materializeModule(ErrStr))
+ExecutionEngine *Interpreter::create(Module *M, std::string* ErrStr) {
+  // Tell this Module to materialize everything and release the GVMaterializer.
+  if (M->MaterializeAllPermanently(ErrStr))
     // We got an error, just return 0
     return 0;
 
-  return new Interpreter(MP);
+  return new Interpreter(M);
 }
 
 //===----------------------------------------------------------------------===//
 // Interpreter ctor - Initialize stuff
 //
-Interpreter::Interpreter(ModuleProvider *M)
-  : ExecutionEngine(M), TD(M->getModule()) {
+Interpreter::Interpreter(Module *M)
+  : ExecutionEngine(M), TD(M) {
       
   memset(&ExitValue.Untyped, 0, sizeof(ExitValue.Untyped));
   setTargetData(&TD);
@@ -95,4 +96,3 @@ Interpreter::runFunction(Function *F,
 
   return ExitValue;
 }
-