fakir/src/Module.hpp

45 lines
1.1 KiB
C++
Raw Normal View History

#ifndef fk_MODULE_HPP
#define fk_MODULE_HPP
#include "commons.hpp"
#include "Lexer.hpp"
#include "Parser.hpp"
#include "Compiler.hpp"
#include "VM.hpp"
2023-09-20 15:17:13 +00:00
#include "SymTable.hpp"
namespace fk
{
FK_ERROR(module_error);
class Module
{
public:
explicit Module(std::filesystem::path source_path);
virtual ~Module();
void build();
2023-09-20 15:17:13 +00:00
void import_std();
void import_library(std::filesystem::path lib_path);
void register_function(std::string const& name, native_t native);
2023-09-20 19:21:51 +00:00
void register_macro(std::string const& name, macro_t macro);
2023-09-20 15:17:13 +00:00
private:
std::filesystem::path m_source_path;
std::string m_source;
2023-09-21 20:26:13 +00:00
Loc m_loc {m_source_path, 1};
std::shared_ptr<Lexer> m_lexer = std::make_shared<Lexer>(m_loc);
std::shared_ptr<Parser> m_parser = std::make_shared<Parser>(*m_lexer);
2023-09-20 15:17:13 +00:00
std::shared_ptr<SymTable> m_sym = std::make_shared<SymTable>();
std::shared_ptr<Compiler> m_compiler = std::make_shared<Compiler>(m_sym);
std::shared_ptr<Node> m_ast;
std::shared_ptr<VM> m_vm = std::make_shared<VM>();
std::string load_sources();
};
}
#endif