12#ifndef ARK_COMPILER_COMPILER_HPP
13#define ARK_COMPILER_COMPILER_HPP
51 void process(
const Node& ast);
58 [[nodiscard]]
const std::vector<IR::Block>& intermediateRepresentation()
const noexcept;
65 [[nodiscard]]
const std::vector<std::string>& symbols()
const noexcept;
72 [[nodiscard]]
const std::vector<ValTableElem>& values()
const noexcept;
100 return m_code_pages[page.index];
101 return m_temp_pages[page.index];
110 static std::optional<Instruction> getOperator(
const std::string& name)
noexcept;
118 static std::optional<uint16_t> getBuiltin(
const std::string& name)
noexcept;
126 static std::optional<Instruction> getListInstruction(
const std::string& name)
noexcept;
134 static bool nodeProducesOutput(
const Node& node);
143 static bool isUnaryInst(
Instruction inst)
noexcept;
152 static bool isTernaryInst(
Instruction inst)
noexcept;
160 static void compilerWarning(
const std::string& message,
const Node& node);
168 [[noreturn]]
static void throwCompilerError(
const std::string& message,
const Node& node);
179 void compileExpression(
const Node& x, Page p,
bool is_result_unused,
bool is_terminal,
const std::string& var_name =
"");
181 void compileSymbol(
const Node& x, Page p,
bool is_result_unused);
182 void compileListInstruction(
const Node& c0,
const Node& x, Page p,
bool is_result_unused);
183 void compileIf(
const Node& x, Page p,
bool is_result_unused,
bool is_terminal,
const std::string& var_name);
184 void compileFunction(
const Node& x, Page p,
bool is_result_unused,
const std::string& var_name);
185 void compileLetMutSet(
Keyword n,
const Node& x, Page p);
186 void compileWhile(
const Node& x, Page p);
187 void compilePluginImport(
const Node& x, Page p);
188 void handleCalls(
const Node& x, Page p,
bool is_result_unused,
bool is_terminal,
const std::string& var_name);
197 uint16_t addSymbol(
const Node& sym);
206 uint16_t addValue(
const Node& x);
216 uint16_t addValue(std::size_t page_id,
const Node& current);
An entity in the IR is a bundle of information.
The different instructions used by the compiler and virtual machine.
AST node used by the parser, optimizer and compiler.
The basic value type handled by the compiler.
The ArkScript bytecode compiler.
unsigned m_debug
the debug level of the compiler
std::vector< IR::Block > m_code_pages
std::vector< IR::Block > m_temp_pages
we need temporary code pages for some compilations passes
std::vector< ValTableElem > m_values
IR::Block & page(const Page page) noexcept
helper functions to get a temp or finalized code page
std::vector< std::string > m_symbols
A node of an Abstract Syntax Tree for ArkScript.
std::vector< Entity > Block
Keyword
The different keywords available.
Instruction
The different bytecodes are stored here.