Extracting method BitcodeEmitter::emitFunctionPrototype()

This commit is contained in:
Stefano Sanfilippo 2015-03-07 14:08:10 +01:00
parent c0bfd4757f
commit 287d543b34
2 changed files with 14 additions and 3 deletions

View File

@ -438,9 +438,7 @@ bool BitcodeEmitter::emit(Branch const& node) {
return true;
}
bool BitcodeEmitter::emit(Function const& node) {
d->scope.enter();
bool BitcodeEmitter::emitFunctionPrototype(Function const& node, llvm::Function **proto) {
std::vector<llvm::Type*> argTypes;
for (FunArg const* arg: node.getArgs()) {
@ -492,6 +490,17 @@ bool BitcodeEmitter::emit(Function const& node) {
++argToEmit;
}
*proto = func;
return true;
}
bool BitcodeEmitter::emit(Function const& node) {
llvm::Function *func = nullptr;
GUARDED(emitFunctionPrototype(node, &func));
d->scope.enter();
llvm::BasicBlock *bb = llvm::BasicBlock::Create(
getGlobalContext(), "entry", func
);

View File

@ -26,6 +26,7 @@
namespace llvm {
class Module;
class Function;
}
namespace monicelli {
@ -65,6 +66,7 @@ public:
private:
bool emitSemiExpression(Id const& left, SemiExpression const& right);
bool emitFunctionPrototype(Function const& node, llvm::Function **proto);
std::unique_ptr<llvm::Module> module;
Private *d;