obelisk/src/ast/prototype_ast.cpp

26 lines
605 B
C++
Raw Normal View History

2022-11-21 21:24:44 -03:00
#include "ast/ast.h"
#include "ast/prototype_ast.h"
llvm::Function *obelisk::PrototypeAST::codegen()
{
std::vector<llvm::Type *> doubles(args_.size(),
llvm::Type::getDoubleTy(*TheContext));
llvm::FunctionType *FT
= llvm::FunctionType::get(llvm::Type::getDoubleTy(*TheContext),
doubles,
false);
2022-11-21 21:24:44 -03:00
llvm::Function *F = llvm::Function::Create(FT,
llvm::Function::ExternalLinkage,
name_,
obelisk::TheModule.get());
2022-11-21 21:24:44 -03:00
unsigned idx = 0;
for (auto &arg : F->args())
{
arg.setName(args_[idx++]);
}
return F;
}