FE 0.13.1
Header-only C++ frontend library
Loading...
Searching...
No Matches
fe::Driver Struct Reference

Use/derive from this class for "global" variables that you need all over the place. More...

#include <fe/driver.h>

Inheritance diagram for fe::Driver:
[legend]

Public Member Functions

 Driver ()
 Driver (std::unique_ptr< Diag > diag)
 Installs diag right away, so Driver::error renders through it from the very first message.
 ~Driver ()
 Driver (const Driver &)=delete
 Driver (Driver &&)=delete
Driveroperator= (Driver)=delete
Diagnostics

Every frontend building block reports into Driver::error; Error::ack it before this Driver dies.

Errorerror ()
const Errorerror () const
template<class... Args>
Errorerror (Loc loc, std::format_string< Args... > fmt, Args &&... args)
template<class... Args>
Errorwarn (Loc loc, std::format_string< Args... > fmt, Args &&... args)
template<class... Args>
Errornote (std::format_string< Args... > fmt, Args &&... args)
template<class... Args>
Errornote (Loc loc, std::format_string< Args... > fmt, Args &&... args)
Diagdiag ()
const Diagdiag () const
std::unique_ptr< Diagdiag (std::unique_ptr< Diag > diag)
 Installs diag - a subclass of your own, typically - and yields the previous one.
Source Files

Register every file you lex here: a Loc is only as good as the SrcMap that keeps its Src alive.

SrcMapsrc ()
const SrcMapsrc () const
Dbg Interning

A node only has to store the DbgKey instead of a full Dbg.

Both halves of a Dbg are already owned here: Dbg::sym is interned in this Driver's SymPool and Dbg::loc points into Driver::src.

Dbg dbg (DbgKey key) const
DbgKey dbg (Dbg dbg)
 Interns dbg and yields its DbgKey.
Public Member Functions inherited from fe::SymPool
 SymPool (const SymPool &)=delete
 SymPool () noexcept
 SymPool (SymPool &&other) noexcept
SymPooloperator= (SymPool)=delete
Sym sym (std::string_view s)
Sym sym (const std::string &s)
constexpr Sym sym (const char *s)
 s is a null-terminated C-string.

Additional Inherited Members

Public Types inherited from fe::SymPool
using String = Sym::String

Detailed Description

Use/derive from this class for "global" variables that you need all over the place.

Well, there are not really global - that's the point of this class. It manages a SymPool, a SrcMap, the interned Dbgs, the Diag that lays out a diagnostic, and the Error they land in.

Note
Deliberately free of virtual functions - Driver::diag is where you plug in behavior of your own.
Warning
Not movable: Driver::error - and a Diag of your own - point back here.

Definition at line 22 of file driver.h.

Constructor & Destructor Documentation

◆ Driver() [1/4]

fe::Driver::Driver ( )

Referenced by Driver(), Driver(), and operator=().

◆ Driver() [2/4]

fe::Driver::Driver ( std::unique_ptr< Diag > diag)
explicit

Installs diag right away, so Driver::error renders through it from the very first message.

Warning
Never nullptr.

References diag().

◆ ~Driver()

fe::Driver::~Driver ( )

◆ Driver() [3/4]

fe::Driver::Driver ( const Driver & )
delete

References Driver().

◆ Driver() [4/4]

fe::Driver::Driver ( Driver && )
delete

References Driver().

Member Function Documentation

◆ dbg() [1/2]

DbgKey fe::Driver::dbg ( Dbg dbg)
inline

Interns dbg and yields its DbgKey.

Definition at line 74 of file driver.h.

References dbg(), and fe::DbgKey::DbgKey().

◆ dbg() [2/2]

Dbg fe::Driver::dbg ( DbgKey key) const
inline

Definition at line 71 of file driver.h.

Referenced by dbg().

◆ diag() [1/3]

Diag & fe::Driver::diag ( )
inline

Definition at line 48 of file driver.h.

Referenced by diag(), and Driver().

◆ diag() [2/3]

const Diag & fe::Driver::diag ( ) const
inline

Definition at line 49 of file driver.h.

◆ diag() [3/3]

std::unique_ptr< Diag > fe::Driver::diag ( std::unique_ptr< Diag > diag)
inline

Installs diag - a subclass of your own, typically - and yields the previous one.

Warning
Never nullptr.

Definition at line 53 of file driver.h.

References diag().

◆ error() [1/3]

Error & fe::Driver::error ( )
inline

Definition at line 38 of file driver.h.

◆ error() [2/3]

const Error & fe::Driver::error ( ) const
inline

Definition at line 39 of file driver.h.

◆ error() [3/3]

template<class... Args>
Error & fe::Driver::error ( Loc loc,
std::format_string< Args... > fmt,
Args &&... args )
inline

Definition at line 42 of file driver.h.

References fe::Error::error().

◆ note() [1/2]

template<class... Args>
Error & fe::Driver::note ( Loc loc,
std::format_string< Args... > fmt,
Args &&... args )
inline

Definition at line 45 of file driver.h.

References fe::Error::note().

◆ note() [2/2]

template<class... Args>
Error & fe::Driver::note ( std::format_string< Args... > fmt,
Args &&... args )
inline

Definition at line 44 of file driver.h.

References fe::Error::note().

◆ operator=()

Driver & fe::Driver::operator= ( Driver )
delete

References Driver().

◆ src() [1/2]

SrcMap & fe::Driver::src ( )
inline

Definition at line 62 of file driver.h.

◆ src() [2/2]

const SrcMap & fe::Driver::src ( ) const
inline

Definition at line 63 of file driver.h.

◆ warn()

template<class... Args>
Error & fe::Driver::warn ( Loc loc,
std::format_string< Args... > fmt,
Args &&... args )
inline

Definition at line 43 of file driver.h.

References fe::Error::warn().


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