12#ifndef COMPILER_AST_OPTIMIZER_HPP
13#define COMPILER_AST_OPTIMIZER_HPP
16#include <unordered_map>
36 explicit Optimizer(
unsigned debug)
noexcept;
50 [[nodiscard]]
const Node&
ast()
const noexcept override;
AST node used by the parser, optimizer and compiler.
Interface for a compiler pass (take in an AST, output an AST)
A node of an Abstract Syntax Tree for ArkScript.
The ArkScript AST optimizer.
Optimizer(unsigned debug) noexcept
Construct a new Optimizer.
void pruneUnusedGlobalVariables(Node &node)
Remove unused global variables from the AST.
const Node & ast() const noexcept override
Returns the modified AST.
void countAndPruneDeadCode(Node &node)
Count the occurrences of each symbol in the AST, recursively, and prune if false/true,...
std::unordered_map< std::string, unsigned > m_sym_appearances
void process(const Node &ast) override
Send the AST to the optimizer, then run the different optimization strategies on it.
An interface to describe compiler passes.