11#ifndef ARK_COMPILER_LOWERER_ASTLOWERER_HPP
12#define ARK_COMPILER_LOWERER_ASTLOWERER_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;
101 return m_code_pages[page.index];
102 return m_temp_pages[page.index];
111 static std::optional<Instruction> getOperator(
const std::string& name)
noexcept;
119 static std::optional<uint16_t> getBuiltin(
const std::string& name)
noexcept;
127 static std::optional<Instruction> getListInstruction(
const std::string& name)
noexcept;
135 static bool nodeProducesOutput(
const Node& node);
144 static bool isUnaryInst(
Instruction inst)
noexcept;
153 static bool isTernaryInst(
Instruction inst)
noexcept;
161 static void warning(
const std::string& message,
const Node& node);
169 [[noreturn]]
static void buildAndThrowError(
const std::string& message,
const Node& node);
180 void compileExpression(
const Node& x, Page p,
bool is_result_unused,
bool is_terminal,
const std::string& var_name =
"");
182 void compileSymbol(
const Node& x, Page p,
bool is_result_unused);
183 void compileListInstruction(
const Node& c0,
const Node& x, Page p,
bool is_result_unused);
184 void compileIf(
const Node& x, Page p,
bool is_result_unused,
bool is_terminal,
const std::string& var_name);
185 void compileFunction(
const Node& x, Page p,
bool is_result_unused,
const std::string& var_name);
186 void compileLetMutSet(
Keyword n,
const Node& x, Page p);
187 void compileWhile(
const Node& x, Page p);
188 void compilePluginImport(
const Node& x, Page p);
189 void handleCalls(
const Node& x, Page p,
bool is_result_unused,
bool is_terminal,
const std::string& var_name);
198 uint16_t addSymbol(
const Node& sym);
207 uint16_t addValue(
const Node& x);
217 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 AST to IR compiler.
std::vector< ValTableElem > m_values
std::vector< IR::Block > m_temp_pages
we need temporary code pages for some compilations passes
std::vector< IR::Block > m_code_pages
std::vector< std::string > m_symbols
LocalsLocator m_locals_locator
IR::Block & page(const Page page) noexcept
helper functions to get a temp or finalized code page
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.