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

The AST of one source file: an anonymous ModDecl that a UseDecl binds under a name of its own. More...

#include <mim/ast/ast.h>

Inheritance diagram for mim::ast::File:
[legend]

Public Member Functions

 File (Loc loc, Scope &members, fe::View< Ptr< ValDecl > > decls)
auto implicit_imports () const
 Imports the driver was told about via -p; they precede everything the file itself declares.
void add_implicit_imports (fe::View< Ptr< UseDecl > > imports) const
void compile (AST &) const
void bind (AST &) const
void bind (Scopes &) const override
void emit (AST &) const
void emit (Emitter &) const override
void stream (fe::Tab &, std::ostream &) const override
Public Member Functions inherited from mim::ast::ModDecl
 ModDecl (Loc loc, Vis vis, Dbg dbg, Scope &members, fe::View< Ptr< ValDecl > > decls)
Dbg dbg () const override
 The name this Decl introduces; anonymous if it has none.
auto decls () const
const Scopescope () const override
 Non-nullptr if this Decl is a module whose members a Path may walk into.
void bind (Scopes &) const override
void emit (Emitter &) const override
void stream (fe::Tab &, std::ostream &) const override
Public Member Functions inherited from mim::ast::ValDecl
Vis vis () const override
 A ValDecl's own Vis; Pub for anything else (Ptrn, Import, ...), which the priv/pub system ignores.
bool is_extern () const override
 Whether this decl crosses the Mim/native boundary (extern); body presence picks which side supplies it.
bool is_anx () const override
 Whether this decl is registered as a compiler-exposed annex (anx).
const Modsmods () const
Public Member Functions inherited from mim::ast::Decl
const Defdef () const
virtual std::pair< AnnexInfo *, sub_tannex_sub () const
 The (AnnexInfo, sub) slot this decl registered itself under as an annex; {nullptr, 0} if it isn't one.
Public Member Functions inherited from mim::ast::Node
Loc loc () const
void dump () const

Additional Inherited Members

Protected Member Functions inherited from mim::ast::ModDecl
Scopemembers () const
void bind_decls (Scopes &) const
void emit_decls (Emitter &) const
Protected Member Functions inherited from mim::ast::ValDecl
 ValDecl (Loc loc, Mods mods={})
Protected Member Functions inherited from mim::ast::Decl
 Decl (Loc loc)
Protected Member Functions inherited from mim::ast::Node
 Node (Loc loc)
Protected Attributes inherited from mim::ast::Decl
const Defdef_ = nullptr

Detailed Description

The AST of one source file: an anonymous ModDecl that a UseDecl binds under a name of its own.

Unlike a nested ModDecl, its Scope is a barrier: a file must not see whoever imports it.

Definition at line 1204 of file ast.h.

Constructor & Destructor Documentation

◆ File()

mim::ast::File::File ( Loc loc,
Scope & members,
fe::View< Ptr< ValDecl > > decls )
inline

Member Function Documentation

◆ add_implicit_imports()

void mim::ast::File::add_implicit_imports ( fe::View< Ptr< UseDecl > > imports) const
inline

Definition at line 1212 of file ast.h.

◆ bind() [1/2]

void mim::ast::File::bind ( AST & ast) const

Definition at line 140 of file bind.cpp.

References bind(), and mim::ast::Scopes::Scopes().

Referenced by bind(), and compile().

◆ bind() [2/2]

void mim::ast::File::bind ( Scopes & s) const
overridevirtual

◆ compile()

void mim::ast::File::compile ( AST & ast) const

Definition at line 201 of file ast.cpp.

References bind(), and emit().

Referenced by mim::ast::load_plugins().

◆ emit() [1/2]

void mim::ast::File::emit ( AST & ast) const

Definition at line 43 of file emit.cpp.

References emit(), and mim::ast::Emitter::Emitter().

Referenced by compile(), emit(), and mim::ast::UseDecl::emit().

◆ emit() [2/2]

void mim::ast::File::emit ( Emitter & e) const
overridevirtual

Implements mim::ast::ValDecl.

Definition at line 48 of file emit.cpp.

References mim::ast::ModDecl::emit_decls(), implicit_imports(), and mim::ast::Node::loc().

◆ implicit_imports()

auto mim::ast::File::implicit_imports ( ) const
inline

Imports the driver was told about via -p; they precede everything the file itself declares.

Definition at line 1210 of file ast.h.

Referenced by bind(), and emit().

◆ stream()

void mim::ast::File::stream ( fe::Tab & tab,
std::ostream & os ) const
overridevirtual

Implements mim::ast::Node.

Definition at line 76 of file stream.cpp.

References mim::ast::ModDecl::decls(), and mim::ast::stream_decls().


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