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++

#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"
#include "Mod.hpp"
namespace wg
{
WG_ERROR(compile_error);
class Compiler
{
public:
explicit Compiler(Mod& mod);
virtual ~Compiler();
void gen(std::filesystem::path obj);
void execute(std::shared_ptr<Node> node);
void imports(std::shared_ptr<Node> node);
void scan(std::shared_ptr<Node> node);
llvm::Value* compile(std::shared_ptr<Node> node);
private:
Mod& m_mod;
std::unordered_map<std::string, std::unique_ptr<Mod>> m_imports;
std::unique_ptr<llvm::IRBuilder<>> m_builder =
std::make_unique<llvm::IRBuilder<>>(m_mod.context());
};
}
#endif