ArkScript
A small, fast, functional and scripting language for video games
Ark::internal::Optimizer Class Referencefinal

The ArkScript AST optimizer. More...

#include <Optimizer.hpp>

Inheritance diagram for Ark::internal::Optimizer:
[legend]
Collaboration diagram for Ark::internal::Optimizer:
[legend]

Public Member Functions

 Optimizer (unsigned debug) noexcept
 Construct a new Optimizer.
 
void process (const Node &ast) override
 Send the AST to the optimizer, then run the different optimization strategies on it.
 
const Nodeast () const noexcept override
 Returns the modified AST.
 
- Public Member Functions inherited from Ark::internal::Pass
 Pass (std::string name, unsigned debug_level)
 Construct a new Pass object.
 
virtual ~Pass ()=default
 

Private Member Functions

void countAndPruneDeadCode (Node &node)
 Count the occurrences of each symbol in the AST, recursively, and prune if false/true, while false/true.
 
void pruneUnusedGlobalVariables (Node &node)
 Remove unused global variables from the AST.
 

Private Attributes

Node m_ast
 
std::unordered_map< std::string, unsigned > m_sym_appearances
 

Additional Inherited Members

- Protected Attributes inherited from Ark::internal::Pass
Logger m_logger
 

Detailed Description

The ArkScript AST optimizer.

Definition at line 28 of file Optimizer.hpp.

Constructor & Destructor Documentation

◆ Optimizer()

Ark::internal::Optimizer::Optimizer ( unsigned debug)
explicitnoexcept

Construct a new Optimizer.

Parameters
debuglevel of debug

Definition at line 5 of file Optimizer.cpp.

Member Function Documentation

◆ ast()

const Node & Ark::internal::Optimizer::ast ( ) const
nodiscardoverridevirtualnoexcept

Returns the modified AST.

Returns
const Node&

Implements Ark::internal::Pass.

Definition at line 28 of file Optimizer.cpp.

References m_ast.

Referenced by Ark::Welder::computeAST(), and process().

◆ countAndPruneDeadCode()

◆ process()

void Ark::internal::Optimizer::process ( const Node & ast)
overridevirtual

◆ pruneUnusedGlobalVariables()

void Ark::internal::Optimizer::pruneUnusedGlobalVariables ( Node & node)
private

Member Data Documentation

◆ m_ast

Node Ark::internal::Optimizer::m_ast
private

Definition at line 53 of file Optimizer.hpp.

Referenced by ast(), and process().

◆ m_sym_appearances

std::unordered_map<std::string, unsigned> Ark::internal::Optimizer::m_sym_appearances
private

Definition at line 54 of file Optimizer.hpp.

Referenced by countAndPruneDeadCode(), and pruneUnusedGlobalVariables().


The documentation for this class was generated from the following files: