This repository has been archived on 2023-09-10. You can view files and clone it, but cannot push or open issues/pull-requests.
2023-09-09 22:03:28 +00:00
|
|
|
#ifndef jk_COMPILER_HPP
|
|
|
|
#define jk_COMPILER_HPP
|
|
|
|
|
|
|
|
#include "commons.hpp"
|
|
|
|
#include "SymTable.hpp"
|
|
|
|
#include "Logger.hpp"
|
|
|
|
#include "Node.hpp"
|
|
|
|
#include "Program.hpp"
|
|
|
|
#include "VM.hpp"
|
|
|
|
|
|
|
|
namespace jk
|
|
|
|
{
|
|
|
|
JK_ERROR(compile_error);
|
|
|
|
|
2023-09-10 14:16:20 +00:00
|
|
|
class StaticFunction;
|
|
|
|
|
2023-09-09 22:03:28 +00:00
|
|
|
class Compiler
|
|
|
|
{
|
|
|
|
public:
|
2023-09-10 07:59:51 +00:00
|
|
|
explicit Compiler(Logger& logger);
|
2023-09-09 22:03:28 +00:00
|
|
|
virtual ~Compiler();
|
|
|
|
|
|
|
|
void compile(std::shared_ptr<Node> node,
|
2023-09-10 07:59:51 +00:00
|
|
|
std::shared_ptr<Program> program,
|
|
|
|
std::shared_ptr<SymTable> sym);
|
2023-09-09 22:03:28 +00:00
|
|
|
|
2023-09-10 14:16:20 +00:00
|
|
|
void declare_static(std::string const& name,
|
|
|
|
std::shared_ptr<StaticFunction> fun);
|
|
|
|
|
2023-09-09 22:03:28 +00:00
|
|
|
private:
|
|
|
|
Logger& m_logger;
|
2023-09-10 14:16:20 +00:00
|
|
|
std::unordered_map<std::string,
|
|
|
|
std::shared_ptr<StaticFunction>> m_statics;
|
2023-09-09 22:03:28 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|