From 9d991f46a25544651cdc636e3e6823bb40d73bd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Grodzi=C5=84ski?= Date: Tue, 15 Jul 2025 10:27:50 +0900 Subject: [PATCH] Renamed --- src/Compiler/ModuleBuilder.cpp | 20 ++++++++++---------- src/Compiler/ModuleBuilder.h | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Compiler/ModuleBuilder.cpp b/src/Compiler/ModuleBuilder.cpp index e06d831..36adc31 100644 --- a/src/Compiler/ModuleBuilder.cpp +++ b/src/Compiler/ModuleBuilder.cpp @@ -53,7 +53,7 @@ shared_ptr ModuleBuilder::getModule() { void ModuleBuilder::buildStatement(shared_ptr statement) { switch (statement->getKind()) { case StatementKind::FUNCTION: - buildFunctionDeclaration(dynamic_pointer_cast(statement)); + buildFunction(dynamic_pointer_cast(statement)); break; case StatementKind::RAW_FUNCTION: buildRawFunction(dynamic_pointer_cast(statement)); @@ -84,15 +84,15 @@ void ModuleBuilder::buildStatement(shared_ptr statement) { } } -void ModuleBuilder::buildFunctionDeclaration(shared_ptr statement) { - // get argument types - vector types; - for (pair> &arg : statement->getArguments()) { - types.push_back(typeForValueType(arg.second)); - } +void ModuleBuilder::buildFunction(shared_ptr statement) { + // function types + llvm::Type *returnType = typeForValueType(statement->getReturnValueType()); + vector argTypes; + for (pair> &arg : statement->getArguments()) + argTypes.push_back(typeForValueType(arg.second)); // build function declaration - llvm::FunctionType *funType = llvm::FunctionType::get(typeForValueType(statement->getReturnValueType()), types, false); + llvm::FunctionType *funType = llvm::FunctionType::get(returnType, argTypes, false); llvm::Function *fun = llvm::Function::Create(funType, llvm::GlobalValue::ExternalLinkage, statement->getName(), module.get()); if (!setFun(statement->getName(), fun)) return; @@ -107,7 +107,7 @@ void ModuleBuilder::buildFunctionDeclaration(shared_ptr state int i=0; for (auto &arg : fun->args()) { string name = statement->getArguments()[i].first; - llvm::Type *type = types[i]; + llvm::Type *type = argTypes[i]; arg.setName(name); llvm::AllocaInst *alloca = builder->CreateAlloca(type, nullptr, name); @@ -137,7 +137,7 @@ void ModuleBuilder::buildRawFunction(shared_ptr statement) for (pair> &arg : statement->getArguments()) argTypes.push_back(typeForValueType(arg.second)); - // function declaration & body + // build function declaration & body llvm::FunctionType *funType = llvm::FunctionType::get(returnType, argTypes, false); llvm::InlineAsm *rawFun = llvm::InlineAsm::get(funType, statement->getRawSource(), statement->getConstraints(), false, false, llvm::InlineAsm::AsmDialect::AD_Intel); if (!setRawFun(statement->getName(), rawFun)) diff --git a/src/Compiler/ModuleBuilder.h b/src/Compiler/ModuleBuilder.h index 6518f6e..3378856 100644 --- a/src/Compiler/ModuleBuilder.h +++ b/src/Compiler/ModuleBuilder.h @@ -63,7 +63,7 @@ private: stack scopes; void buildStatement(shared_ptr statement); - void buildFunctionDeclaration(shared_ptr statement); + void buildFunction(shared_ptr statement); void buildRawFunction(shared_ptr statement); void buildVarDeclaration(shared_ptr statement); void buildAssignment(shared_ptr statement);