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

Classes

struct  NomInfo

Public Member Functions

 Emitter (AST &ast)
AST & ast () const
World & world ()
Driver & driver ()
fe::Error & error ()
void attach (AnnexInfo *annex, sub_t sub, Sym name, const Def *def)
 name is this registration's own (unqualified) Dbg::sym; AnnexInfo::qualified turns it into the full plugin.tag[.sub] name.
void attach_alias (AnnexInfo *annex, sub_t sub, Sym name)
Names

Field and constructor names live on the Def, so same-shaped types share one table.

void add_names (const Def *def, const fe::SymMap< size_t > &sym2idx)
void adopt_names (const Nom *nom)
 Copies the names of nom's declaration onto the corresponding parts of nom - an instance of it.
auto variant_str (const Def *variant)
 A declared variant prints under its name; an anonymous one spells out its cases, named as source does.
std::optional< size_t > find_name (const Def *def, Dbg dbg)
void add_ctors (const Def *variant, const VariantExpr *expr)
size_t ctor (const Def *variant, Dbg dbg)
std::string ctor_names (const Def *variant, size_t i)
 Every name case i goes by, sorted for a deterministic diagnostic; its index if it has none.
Nominal scope

Only the mod declaring a private nom - or one nested in it - may access its representation.

void push_mod (const ModDecl *mod)
void pop_mod ()
fe::Vector< const ModDecl * > reset_mods ()
void restore_mods (fe::Vector< const ModDecl * > mods)
void add_nom (const Nom *nom, const NomDecl *decl)
NomInfo nom_decl (const Nom *nom) const
 The declared nom that nom instantiates and, if its representation is private, the mod owning it.
bool within (const ModDecl *mod) const

Detailed Description

Definition at line 14 of file emit.cpp.


Class Documentation

◆ mim::ast::Emitter::NomInfo

struct mim::ast::Emitter::NomInfo

Definition at line 130 of file emit.cpp.

Class Members
const Nom * decl
const ModDecl * owner

Constructor & Destructor Documentation

◆ Emitter()

mim::ast::Emitter::Emitter ( AST & ast)
inline

Definition at line 16 of file emit.cpp.

References ast().

Referenced by mim::ast::File::emit().

Member Function Documentation

◆ add_ctors()

void mim::ast::Emitter::add_ctors ( const Def * variant,
const VariantExpr * expr )
inline

◆ add_names()

void mim::ast::Emitter::add_names ( const Def * def,
const fe::SymMap< size_t > & sym2idx )
inline

Definition at line 40 of file emit.cpp.

Referenced by add_ctors().

◆ add_nom()

void mim::ast::Emitter::add_nom ( const Nom * nom,
const NomDecl * decl )
inline

Definition at line 135 of file emit.cpp.

References mim::Nom::key(), mim::ast::Priv, and mim::ast::NomDecl::rep_vis().

◆ adopt_names()

void mim::ast::Emitter::adopt_names ( const Nom * nom)
inline

Copies the names of nom's declaration onto the corresponding parts of nom - an instance of it.

Definition at line 47 of file emit.cpp.

References adopt_names(), mim::ast::Emitter::NomInfo::decl, nom_decl(), and mim::Nom::op().

Referenced by adopt_names().

◆ ast()

AST & mim::ast::Emitter::ast ( ) const
inline

Definition at line 19 of file emit.cpp.

Referenced by Emitter(), and world().

◆ attach()

void mim::ast::Emitter::attach ( AnnexInfo * annex,
sub_t sub,
Sym name,
const Def * def )
inline

name is this registration's own (unqualified) Dbg::sym; AnnexInfo::qualified turns it into the full plugin.tag[.sub] name.

We must take it from the declaration rather than from Def::sym, since hash-consing can make several annexes share a single Def (e.g. mod foo anx let bar = 23; anx let baz = 23; end).

Definition at line 28 of file emit.cpp.

References mim::World::annexes(), mim::World::Annexes::attach(), driver(), mim::ast::AnnexInfo::id, mim::ast::AnnexInfo::plugin_id(), mim::ast::AnnexInfo::qualified(), and world().

◆ attach_alias()

void mim::ast::Emitter::attach_alias ( AnnexInfo * annex,
sub_t sub,
Sym name )
inline

◆ ctor()

size_t mim::ast::Emitter::ctor ( const Def * variant,
Dbg dbg )
inline

Definition at line 107 of file emit.cpp.

References error(), find_name(), and variant_str().

◆ ctor_names()

std::string mim::ast::Emitter::ctor_names ( const Def * variant,
size_t i )
inline

Every name case i goes by, sorted for a deterministic diagnostic; its index if it has none.

Definition at line 113 of file emit.cpp.

◆ driver()

Driver & mim::ast::Emitter::driver ( )
inline

Definition at line 21 of file emit.cpp.

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

Referenced by attach(), attach_alias(), and error().

◆ error()

fe::Error & mim::ast::Emitter::error ( )
inline

Definition at line 22 of file emit.cpp.

References driver().

Referenced by add_ctors(), ctor(), and find_name().

◆ find_name()

std::optional< size_t > mim::ast::Emitter::find_name ( const Def * def,
Dbg dbg )
inline

Definition at line 75 of file emit.cpp.

References error(), and variant_str().

Referenced by ctor().

◆ nom_decl()

NomInfo mim::ast::Emitter::nom_decl ( const Nom * nom) const
inline

The declared nom that nom instantiates and, if its representation is private, the mod owning it.

Definition at line 140 of file emit.cpp.

References mim::Nom::key().

Referenced by adopt_names().

◆ pop_mod()

void mim::ast::Emitter::pop_mod ( )
inline

Definition at line 126 of file emit.cpp.

◆ push_mod()

void mim::ast::Emitter::push_mod ( const ModDecl * mod)
inline

Definition at line 125 of file emit.cpp.

◆ reset_mods()

fe::Vector< const ModDecl * > mim::ast::Emitter::reset_mods ( )
inline

Definition at line 127 of file emit.cpp.

◆ restore_mods()

void mim::ast::Emitter::restore_mods ( fe::Vector< const ModDecl * > mods)
inline

Definition at line 128 of file emit.cpp.

◆ variant_str()

auto mim::ast::Emitter::variant_str ( const Def * variant)
inline

A declared variant prints under its name; an anonymous one spells out its cases, named as source does.

Streams lazily so that it still renders under the PlainNames guard Error::msg formats within.

Definition at line 56 of file emit.cpp.

References mim::Def::num_ops(), mim::Def::op(), mim::World::sigma(), mim::Def::sym(), and mim::Def::world().

Referenced by ctor(), and find_name().

◆ within()

bool mim::ast::Emitter::within ( const ModDecl * mod) const
inline

Definition at line 145 of file emit.cpp.

◆ world()

World & mim::ast::Emitter::world ( )
inline

Definition at line 20 of file emit.cpp.

References ast(), and mim::ast::AST::world().

Referenced by attach(), attach_alias(), and driver().


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