FE 0.15.0
A C++23 toolkit for writing compiler/interpreter frontends.
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
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)
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 67 of file driver.h.

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

◆ dbg() [2/2]

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

Definition at line 64 of file driver.h.

Referenced by dbg().

◆ diag() [1/3]

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

Definition at line 41 of file driver.h.

Referenced by diag(), and Driver().

◆ diag() [2/3]

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

Definition at line 42 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 46 of file driver.h.

References diag().

◆ error() [1/2]

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

Definition at line 38 of file driver.h.

◆ error() [2/2]

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

Definition at line 39 of file driver.h.

◆ operator=()

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

References Driver().

◆ src() [1/2]

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

Definition at line 55 of file driver.h.

◆ src() [2/2]

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

Definition at line 56 of file driver.h.


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