LLVM Module is now managed by BitcodeEmitter.

This commit is contained in:
Stefano Sanfilippo 2015-03-06 13:42:47 +01:00
parent 68004b3f49
commit 4e883d148c
2 changed files with 11 additions and 4 deletions

View File

@ -39,7 +39,8 @@ struct BitcodeEmitter::Private {
Scope<Id const*, llvm::Value*> scope; Scope<Id const*, llvm::Value*> scope;
}; };
BitcodeEmitter::BitcodeEmitter(llvm::Module *module): module(module) { BitcodeEmitter::BitcodeEmitter() {
module = std::unique_ptr<llvm::Module>(new llvm::Module("monicelli", getGlobalContext()));
d = new Private; d = new Private;
} }

View File

@ -21,6 +21,8 @@
*/ */
#include "Emitter.hpp" #include "Emitter.hpp"
#include <memory>
namespace llvm { namespace llvm {
class Module; class Module;
@ -30,7 +32,7 @@ namespace monicelli {
class BitcodeEmitter: public Emitter { class BitcodeEmitter: public Emitter {
public: public:
BitcodeEmitter(llvm::Module *module); BitcodeEmitter();
BitcodeEmitter(BitcodeEmitter &) = delete; BitcodeEmitter(BitcodeEmitter &) = delete;
virtual ~BitcodeEmitter(); virtual ~BitcodeEmitter();
@ -53,10 +55,14 @@ public:
virtual void emit(FunctionCall const&) override; virtual void emit(FunctionCall const&) override;
virtual void emit(BinaryExpression const&) override; virtual void emit(BinaryExpression const&) override;
private: llvm::Module const& getModule() const {
return *module;
}
struct Private; struct Private;
llvm::Module *module; private:
std::unique_ptr<llvm::Module> module;
Private *d; Private *d;
}; };