modified codegen backend to use set module

This commit is contained in:
Sven Vogel 2024-05-26 17:23:08 +02:00
parent 932e1fa961
commit d0cd74c697
3 changed files with 6 additions and 4 deletions

View File

@ -1,4 +1,5 @@
#include "set/types.h"
#include <codegen/backend.h>
#include <sys/log.h>
@ -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) {

View File

@ -2,6 +2,7 @@
#ifndef CODEGN_BACKEND_H_
#define CODEGN_BACKEND_H_
#include <set/types.h>
#include <ast/ast.h>
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

View File

@ -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);