format to 80 columns for terminal display

This commit is contained in:
2023-02-20 22:05:57 -03:00
parent 09925b567c
commit adc5042c6c
30 changed files with 412 additions and 194 deletions

View File

@@ -31,7 +31,8 @@ namespace obelisk
/**
* @brief Get the callee.
*
* @return std::string Returns the name of the function being called.
* @return std::string Returns the name of the function being
* called.
*/
std::string getCallee();
@@ -45,7 +46,8 @@ namespace obelisk
/**
* @brief Get the arguments being used by the function.
*
* @return std::vector<std::unique_ptr<ExpressionAST>> Returns an AST expression containing the args.
* @return std::vector<std::unique_ptr<ExpressionAST>> Returns an
* AST expression containing the args.
*/
std::vector<std::unique_ptr<ExpressionAST>> getArgs();
@@ -63,7 +65,8 @@ namespace obelisk
* @param[in] callee The function to call.
* @param[in] args The args to pass into the function.
*/
CallExpressionAST(const std::string &callee, std::vector<std::unique_ptr<ExpressionAST>> args) :
CallExpressionAST(const std::string &callee,
std::vector<std::unique_ptr<ExpressionAST>> args) :
callee_(callee),
args_(std::move(args))
{

View File

@@ -11,7 +11,8 @@ namespace obelisk
* @brief Log an AST expression error.
*
* @param[in] str The error message.
* @return std::unique_ptr<ExpressionAST> Returns the AST expression that caused the error.
* @return std::unique_ptr<ExpressionAST> Returns the AST expression that
* caused the error.
*/
std::unique_ptr<ExpressionAST> LogError(const char *str);

View File

@@ -21,7 +21,8 @@ namespace obelisk
/**
* @brief Generate LLVM IR code based on the AST expression.
*
* @return llvm::Value* Returns the LLVM code value from the expression.
* @return llvm::Value* Returns the LLVM code value from the
* expression.
*/
virtual llvm::Value *codegen() = 0;
};

View File

@@ -17,7 +17,8 @@ llvm::Function *obelisk::FunctionAST::codegen()
return nullptr;
}
llvm::BasicBlock *bB = llvm::BasicBlock::Create(*TheContext, "entry", theFunction);
llvm::BasicBlock *bB
= llvm::BasicBlock::Create(*TheContext, "entry", theFunction);
Builder->SetInsertPoint(bB);
NamedValues.clear();

View File

@@ -48,7 +48,8 @@ namespace obelisk
* @param[in] prototype The prototype of the function.
* @param[in] body The body of the function.
*/
FunctionAST(std::unique_ptr<PrototypeAST> prototype, std::unique_ptr<ExpressionAST> body) :
FunctionAST(std::unique_ptr<PrototypeAST> prototype,
std::unique_ptr<ExpressionAST> body) :
prototype_(std::move(prototype)),
body_(std::move(body))
{

View File

@@ -3,10 +3,17 @@
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);
std::vector<llvm::Type *> doubles(args_.size(),
llvm::Type::getDoubleTy(*TheContext));
llvm::FunctionType *FT
= llvm::FunctionType::get(llvm::Type::getDoubleTy(*TheContext),
doubles,
false);
llvm::Function *F = llvm::Function::Create(FT, llvm::Function::ExternalLinkage, name_, obelisk::TheModule.get());
llvm::Function *F = llvm::Function::Create(FT,
llvm::Function::ExternalLinkage,
name_,
obelisk::TheModule.get());
unsigned idx = 0;
for (auto &arg : F->args())

View File

@@ -54,7 +54,8 @@ namespace obelisk
* @param[in] name The name of the prototype.
* @param[in] args The arguments the prototype accepts.
*/
PrototypeAST(const std::string& name, std::vector<std::string> args) :
PrototypeAST(const std::string& name,
std::vector<std::string> args) :
name_(name),
args_(std::move(args))
{