2022-11-21 21:24:44 -03:00
|
|
|
#include "ast/ast.h"
|
|
|
|
#include "ast/prototype_ast.h"
|
|
|
|
|
|
|
|
llvm::Function *obelisk::PrototypeAST::codegen()
|
|
|
|
{
|
2023-02-20 22:05:57 -03:00
|
|
|
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
|
|
|
|
2023-02-20 22:05:57 -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;
|
|
|
|
}
|