Moving convertAndStore to preamble of BitcodeEmitter.cpp

This commit is contained in:
Stefano Sanfilippo 2015-03-08 12:47:15 +01:00
parent 9d2413857d
commit b1aff41ce9

View File

@ -192,6 +192,15 @@ llvm::Value* coerce(BitcodeEmitter::Private *d, llvm::Value *val, llvm::Type *to
return nullptr;
}
static
bool convertAndStore(BitcodeEmitter::Private *d, llvm::AllocaInst *dest, llvm::Value *expression) {
llvm::Type *varType = dest->getAllocatedType();
expression = coerce(d, expression, varType);
if (expression == nullptr) return false;
d->builder.CreateStore(expression, dest);
return true;
}
BitcodeEmitter::BitcodeEmitter() {
module = std::unique_ptr<llvm::Module>(
new llvm::Module("monicelli", getGlobalContext())
@ -244,15 +253,6 @@ bool BitcodeEmitter::emit(Loop const& node) {
return true;
}
static
bool convertAndStore(BitcodeEmitter::Private *d, llvm::AllocaInst *dest, llvm::Value *expression) {
llvm::Type *varType = dest->getAllocatedType();
expression = coerce(d, expression, varType);
if (expression == nullptr) return false;
d->builder.CreateStore(expression, dest);
return true;
}
bool BitcodeEmitter::emit(VarDeclaration const& node) {
llvm::Function *father = d->builder.GetInsertBlock()->getParent();
llvm::Type *varType = LLVMType(node.getType());