MimIR
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
mim::ast::AST Class Reference

Owns the arena all AST nodes live in as well as the AnnexInfos of all plugins. More...

#include <mim/ast/ast.h>

Classes

struct  Files

Public Member Functions

 AST (const AST &)=delete
 AST (World &)
 AST (AST &&)
 ~AST ()
template<class T, class... Args>
auto ptr (Args &&... args)
 The VLA ranges of a fe::VLA node come last, in the order its VLA_Types declares them.
template<class R, class T = std::ranges::range_value_t<R>>
fe::View< T > copy (const R &range)
 An Arena-allocated copy of range - for the few lists that do not sit behind a node.
Scopescope ()
 A fresh Scope for a ModDecl; owned here, as an AST node never runs a destructor.
Getters
Worldworld () const
Driverdriver () const
Error & error () const
Sym
Sym sym (const char *s)
Sym sym (std::string_view s)
Sym sym (const std::string &s)
Sym sym_anon ()
 "_".
Sym sym_return ()
 "return".
Sym sym_error ()
 "_error_".
Manage Files

A file is parsed exactly once; AST::file hands out the File every Import of that file shares.

std::pair< Ptr< File > &, bool > file (const fe::Src *src)
Manage Annex
AnnexInfoname2annex (Scopes &s, Dbg dbg, sub_t *sub_id)
const auto & plugin2annexes (Sym plugin)
bootstrap
void bootstrap (Sym plugin, std::ostream &h)
void bootstrap_py (Sym plugin, std::ostream &h)

Friends

void swap (AST &a1, AST &a2) noexcept

Detailed Description

Owns the arena all AST nodes live in as well as the AnnexInfos of all plugins.

Definition at line 99 of file ast.h.

Constructor & Destructor Documentation

◆ AST() [1/3]

mim::ast::AST::AST ( const AST & )
delete

References AST().

Referenced by AST(), AST(), mim::ast::load_plugins(), and swap.

◆ AST() [2/3]

mim::ast::AST::AST ( World & world)

Definition at line 12 of file ast.cpp.

References world().

◆ AST() [3/3]

mim::ast::AST::AST ( AST && other)

Definition at line 16 of file ast.cpp.

References AST(), swap, and world().

◆ ~AST()

mim::ast::AST::~AST ( )
default

Member Function Documentation

◆ bootstrap()

void mim::ast::AST::bootstrap ( Sym plugin,
std::ostream & h )

Definition at line 28 of file ast.cpp.

References mim::Annex::mangle(), plugin2annexes(), and sym().

◆ bootstrap_py()

void mim::ast::AST::bootstrap_py ( Sym plugin,
std::ostream & h )

Definition at line 135 of file ast.cpp.

References mim::Annex::mangle(), plugin2annexes(), and sym().

◆ copy()

template<class R, class T = std::ranges::range_value_t<R>>
fe::View< T > mim::ast::AST::copy ( const R & range)
inline

An Arena-allocated copy of range - for the few lists that do not sit behind a node.

Definition at line 131 of file ast.h.

◆ driver()

Driver & mim::ast::AST::driver ( ) const
inline

Definition at line 109 of file ast.h.

References mim::World::driver(), and world().

Referenced by mim::ast::Parser::driver(), error(), sym(), sym(), and sym().

◆ error()

Error & mim::ast::AST::error ( ) const
inline

Definition at line 110 of file ast.h.

References driver().

Referenced by mim::ast::Scopes::error(), and name2annex().

◆ file()

std::pair< Ptr< File > &, bool > mim::ast::AST::file ( const fe::Src * src)

The slot of src and whether it is fresh; a fresh slot is nullptr until the caller fills it in. A nullptr slot that is not fresh is a file still being parsed further up the stack.

Definition at line 23 of file ast.cpp.

Referenced by mim::ast::Parser::import().

◆ name2annex()

AnnexInfo * mim::ast::AST::name2annex ( Scopes & s,
Dbg dbg,
sub_t * sub_id )

Registers dbg as an annex, deriving plugin/tag/sub from dbg's source file and s's current mod-nesting (Scopes::mod_depth/Scopes::enclosing_mod); sub_id receives dbg's sub index within its tag. nullptr if dbg is anonymous or nests more than one mod deep.

Definition at line 323 of file bind.cpp.

References error(), mim::Annex::mangle(), sym(), and sym_error().

◆ plugin2annexes()

const auto & mim::ast::AST::plugin2annexes ( Sym plugin)
inline

Definition at line 153 of file ast.h.

Referenced by bootstrap(), and bootstrap_py().

◆ ptr()

template<class T, class... Args>
auto mim::ast::AST::ptr ( Args &&... args)
inline

The VLA ranges of a fe::VLA node come last, in the order its VLA_Types declares them.

Definition at line 125 of file ast.h.

◆ scope()

Scope & mim::ast::AST::scope ( )
inline

A fresh Scope for a ModDecl; owned here, as an AST node never runs a destructor.

Definition at line 137 of file ast.h.

◆ sym() [1/3]

Sym mim::ast::AST::sym ( const char * s)
inline

Definition at line 115 of file ast.h.

References driver().

Referenced by bootstrap(), bootstrap_py(), name2annex(), sym_anon(), sym_error(), and sym_return().

◆ sym() [2/3]

Sym mim::ast::AST::sym ( const std::string & s)
inline

Definition at line 117 of file ast.h.

References driver().

◆ sym() [3/3]

Sym mim::ast::AST::sym ( std::string_view s)
inline

Definition at line 116 of file ast.h.

References driver().

◆ sym_anon()

Sym mim::ast::AST::sym_anon ( )
inline

"_".

Definition at line 118 of file ast.h.

References sym().

◆ sym_error()

Sym mim::ast::AST::sym_error ( )
inline

"_error_".

Definition at line 120 of file ast.h.

References sym().

Referenced by name2annex().

◆ sym_return()

Sym mim::ast::AST::sym_return ( )
inline

"return".

Definition at line 119 of file ast.h.

References sym().

◆ world()

World & mim::ast::AST::world ( ) const
inline

Definition at line 108 of file ast.h.

Referenced by AST(), AST(), driver(), and mim::ast::Emitter::world().

◆ swap

void swap ( AST & a1,
AST & a2 )
friend

Definition at line 162 of file ast.h.

References AST(), and swap.

Referenced by AST(), and swap.


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