47 lines
1.1 KiB
C++
47 lines
1.1 KiB
C++
#ifndef fk_MODULE_HPP
|
|
#define fk_MODULE_HPP
|
|
|
|
#include "commons.hpp"
|
|
#include "Lexer.hpp"
|
|
#include "Parser.hpp"
|
|
#include "Compiler.hpp"
|
|
#include "VM.hpp"
|
|
#include "SymTable.hpp"
|
|
|
|
namespace fk
|
|
{
|
|
FK_ERROR(module_error);
|
|
|
|
class Module
|
|
{
|
|
public:
|
|
explicit Module(std::filesystem::path source_path);
|
|
virtual ~Module();
|
|
|
|
std::shared_ptr<VM> vm() const { return m_vm; }
|
|
|
|
void build();
|
|
|
|
void import_std();
|
|
void import_library(std::filesystem::path lib_path);
|
|
|
|
void register_function(std::string const& name, native_t native);
|
|
void register_macro(std::string const& name, macro_t macro);
|
|
|
|
private:
|
|
std::filesystem::path m_source_path;
|
|
std::string m_source;
|
|
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);
|
|
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
|