This repository has been archived on 2024-03-07. You can view files and clone it, but cannot push or open issues/pull-requests.
wongola/lib/Compiler.hpp

39 lines
816 B
C++
Raw Permalink Normal View History

#ifndef wg_COMPILER_HPP
#define wg_COMPILER_HPP
#include <llvm/IR/LLVMContext.h>
#include <llvm/IR/IRBuilder.h>
#include <llvm/IR/Module.h>
#include "commons.hpp"
#include "Node.hpp"
#include "SymTable.hpp"
2023-09-29 16:26:05 +00:00
#include "Mod.hpp"
namespace wg
{
2023-09-29 16:26:05 +00:00
WG_ERROR(compile_error);
class Compiler
{
public:
2023-09-29 16:26:05 +00:00
explicit Compiler(Mod& mod);
virtual ~Compiler();
2023-09-28 20:18:03 +00:00
void gen(std::filesystem::path obj);
2023-09-29 16:26:05 +00:00
void execute(std::shared_ptr<Node> node);
void imports(std::shared_ptr<Node> node);
void scan(std::shared_ptr<Node> node);
2023-09-27 21:05:04 +00:00
llvm::Value* compile(std::shared_ptr<Node> node);
2023-09-29 16:26:05 +00:00
private:
Mod& m_mod;
std::unordered_map<std::string, std::unique_ptr<Mod>> m_imports;
std::unique_ptr<llvm::IRBuilder<>> m_builder =
2023-09-29 16:26:05 +00:00
std::make_unique<llvm::IRBuilder<>>(m_mod.context());
};
}
#endif