12#ifndef COMPILER_AST_OPTIMIZER_HPP
13#define COMPILER_AST_OPTIMIZER_HPP
16#include <unordered_map>
38 explicit Optimizer(uint16_t options)
noexcept;
52 const Node&
ast()
const noexcept;
Constants used by ArkScript.
ArkScript homemade exceptions.
AST node used by the parser, optimizer and compiler.
A node of an Abstract Syntax Tree for ArkScript.
The ArkScript AST optimizer.
void feed(const Node &ast)
Send the AST to the optimizer, then run the different optimization strategies on it.
void throwOptimizerError(const std::string &message, const Node &node)
Generate a fancy error message.
void remove_unused()
Iterate over the AST and remove unused top level functions and constants.
const Node & ast() const noexcept
Returns the modified AST.
void countOccurences(Node &node)
Count the occurences of each symbol in the AST, recursively.
void runOnGlobalScopeVars(Node &node, const std::function< void(Node &, Node &, int)> &func)
Run a given functor on the global scope symbols.
std::unordered_map< std::string, unsigned > m_sym_appearances
Create string error context for AST errors.