Materialize the module before releasing it.
[oota-llvm.git] / include / llvm / ModuleProvider.h
1 //===-- llvm/ModuleProvider.h - Interface for module providers --*- C++ -*-===//
2 //
3 // Abstract interface for providing a module.
4 //
5 //===----------------------------------------------------------------------===//
6
7 #ifndef MODULEPROVIDER_H
8 #define MODULEPROVIDER_H
9
10 class Function;
11 class Module;
12
13 class AbstractModuleProvider {
14 protected:
15   Module *TheModule;
16   AbstractModuleProvider();
17
18 public:
19   virtual ~AbstractModuleProvider();
20
21   /// getModule - returns the module this provider is encapsulating.
22   ///
23   Module* getModule() { return TheModule; }
24
25   /// materializeFunction - make sure the given function is fully read.
26   ///
27   virtual void materializeFunction(Function *F) = 0;
28
29   /// materializeModule - make sure the entire Module has been completely read.
30   ///
31   void materializeModule();
32
33   /// releaseModule - no longer delete the Module* when provider is destroyed.
34   ///
35   virtual Module* releaseModule() { 
36     // Since we're losing control of this Module, we must hand it back complete
37     materializeModule();
38     Module *tempM = TheModule; 
39     TheModule = 0; 
40     return tempM; 
41   }
42
43 };
44
45 #endif