From d0cd74c697b9016b8c8f14b73cb1a2c9015b08fe Mon Sep 17 00:00:00 2001 From: servostar Date: Sun, 26 May 2024 17:23:08 +0200 Subject: [PATCH] modified codegen backend to use set module --- src/codegen/backend.c | 3 ++- src/codegen/backend.h | 5 +++-- src/llvm/backend.c | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/codegen/backend.c b/src/codegen/backend.c index d2eccac..8e6f5ca 100644 --- a/src/codegen/backend.c +++ b/src/codegen/backend.c @@ -1,4 +1,5 @@ +#include "set/types.h" #include #include @@ -67,7 +68,7 @@ BackendError set_backend(const codegen_init init_func, const codegen_deinit dein return new_backend_error(Success); } -BackendError generate_code(const AST_NODE_PTR root, void** output) { +BackendError generate_code(const Module* root, void** output) { DEBUG("generating code with backend: %s", CodegenBackend.name); if (CodegenBackend.codegen_func == NULL) { diff --git a/src/codegen/backend.h b/src/codegen/backend.h index c00859b..ad3613d 100644 --- a/src/codegen/backend.h +++ b/src/codegen/backend.h @@ -2,6 +2,7 @@ #ifndef CODEGN_BACKEND_H_ #define CODEGN_BACKEND_H_ +#include #include typedef struct BackendImplError_t { @@ -29,7 +30,7 @@ typedef struct BackendError_t { * @brief Function called by the compiler backend to generate an intermediate format * from AST. Returns a custom container for its intermediate language. */ -typedef BackendError (*codegen)(const AST_NODE_PTR, void**); +typedef BackendError (*codegen)(const Module*, void**); /** * @brief Initialize the code generation backend. @@ -77,7 +78,7 @@ BackendError deinit_backend(void); * @return BackendError */ [[nodiscard]] -BackendError generate_code(const AST_NODE_PTR root, void** code); +BackendError generate_code(const Module* root, void** code); /** * @brief Create a new backend error diff --git a/src/llvm/backend.c b/src/llvm/backend.c index 30a248d..5bf2b21 100644 --- a/src/llvm/backend.c +++ b/src/llvm/backend.c @@ -10,7 +10,7 @@ typedef enum LLVMBackendError_t { UnresolvedImport } LLVMBackendError; -static BackendError llvm_backend_codegen(const AST_NODE_PTR module_node, void**) { +static BackendError llvm_backend_codegen(const Module* unit, void**) { // we start with a LLVM module LLVMContextRef context = LLVMContextCreate(); LLVMModuleRef module = LLVMModuleCreateWithNameInContext("gemstone application", context);