Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::Compiler_HIR_Context Class Reference

Arena-backed ownership context for HIR nodes. More...

#include <Compiler_HIR_Model.H>

Collaboration diagram for Aleph::Compiler_HIR_Context:
[legend]

Classes

struct  Owned_Object
 

Public Member Functions

 Compiler_HIR_Context (const size_t arena_size=AhArenaAllocator::DEFAULT_SIZE)
 Constructs a context with arena_size bytes.
 
 Compiler_HIR_Context (const Compiler_HIR_Context &)=delete
 
Compiler_HIR_Context & operator= (const Compiler_HIR_Context &)=delete
 
 ~Compiler_HIR_Context () noexcept
 
template<typename T , typename... Args>
T * make (Args &&...args)
 Allocates and constructs one HIR object.
 
void reset () noexcept
 Destroys all tracked objects and rewinds the arena.
 
size_t allocated_size () const noexcept
 Returns bytes currently consumed in the arena.
 
size_t capacity () const noexcept
 Returns total arena capacity in bytes.
 

Private Attributes

AhArenaAllocator arena
 
DynArray< Owned_Object > owned
 

Detailed Description

Arena-backed ownership context for HIR nodes.

Definition at line 186 of file Compiler_HIR_Model.H.

Constructor & Destructor Documentation

◆ Compiler_HIR_Context() [1/2]

Aleph::Compiler_HIR_Context::Compiler_HIR_Context ( const size_t  arena_size = AhArenaAllocator::DEFAULT_SIZE)
inlineexplicit

Constructs a context with arena_size bytes.

Parameters
arena_sizeArena capacity in bytes.
Exceptions
std::runtime_errorIf the arena cannot be created.

Definition at line 203 of file Compiler_HIR_Model.H.

◆ Compiler_HIR_Context() [2/2]

Aleph::Compiler_HIR_Context::Compiler_HIR_Context ( const Compiler_HIR_Context &  )
delete

◆ ~Compiler_HIR_Context()

Aleph::Compiler_HIR_Context::~Compiler_HIR_Context ( )
inlinenoexcept

Definition at line 210 of file Compiler_HIR_Model.H.

References reset().

Member Function Documentation

◆ allocated_size()

size_t Aleph::Compiler_HIR_Context::allocated_size ( ) const
inlinenoexcept

Returns bytes currently consumed in the arena.

Definition at line 250 of file Compiler_HIR_Model.H.

References Aleph::AhArenaAllocator::allocated_size(), and arena.

◆ capacity()

size_t Aleph::Compiler_HIR_Context::capacity ( ) const
inlinenoexcept

Returns total arena capacity in bytes.

Definition at line 256 of file Compiler_HIR_Model.H.

References arena, and Aleph::AhArenaAllocator::capacity().

◆ make()

template<typename T , typename... Args>
T * Aleph::Compiler_HIR_Context::make ( Args &&...  args)
inline

Allocates and constructs one HIR object.

Template Parameters
TObject type to create.
Parameters
argsConstructor arguments forwarded to T.
Returns
Pointer stable until reset() or destruction.
Exceptions
std::runtime_errorIf arena allocation fails.

Definition at line 223 of file Compiler_HIR_Model.H.

References ah_runtime_error_unless, arena, Aleph::blossom_maximum_cardinality_matching(), and owned.

Referenced by Aleph::Compiler_HIR_Lowering::lower_expr(), Aleph::Compiler_HIR_Lowering::lower_function(), Aleph::Compiler_HIR_Lowering::lower_module(), and Aleph::Compiler_HIR_Lowering::lower_stmt().

◆ operator=()

Compiler_HIR_Context & Aleph::Compiler_HIR_Context::operator= ( const Compiler_HIR_Context &  )
delete

◆ reset()

void Aleph::Compiler_HIR_Context::reset ( )
inlinenoexcept

Member Data Documentation

◆ arena

AhArenaAllocator Aleph::Compiler_HIR_Context::arena
private

Definition at line 194 of file Compiler_HIR_Model.H.

Referenced by allocated_size(), capacity(), make(), and reset().

◆ owned

DynArray<Owned_Object> Aleph::Compiler_HIR_Context::owned
private

Definition at line 195 of file Compiler_HIR_Model.H.

Referenced by make(), and reset().


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