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

import "file"|name [as alias|*];, plugin name [as alias|*];, or use path [as alias|*]; as * splices instead of naming; a use without an as is sugar for as *. More...

#include <mim/ast/ast.h>

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

Public Member Functions

 UseDecl (Loc loc, Mods mods, Ptr< Path > path, Dbg alias)
 use path [as alias|*];; no alias means as *.
 UseDecl (Loc loc, Mods mods, Tok::Tag tag, Ptr< Path > path, Sym file_path, Dbg alias, bool splice, const File *file)
 import/plugin; name is the module name, derived from file_path if there is one.
Tok::Tag tag () const
 import, plugin, or use.
bool is_import () const
const Pathpath () const
 Module path of a use; module name of an import/plugin.
Dbg alias () const
 Empty, unless the source spelled as I.
Sym file_path () const
 Spelling of an import "..."; empty otherwise.
bool is_file_path () const
const Filefile () const
bool is_splice () const
 as *: splice the module's public members, bind no name.
Dbg dbg () const override
 The name this decl introduces; anonymous if it splices instead.
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::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

import "file"|name [as alias|*];, plugin name [as alias|*];, or use path [as alias|*]; as * splices instead of naming; a use without an as is sugar for as *.

Makes another module available here: import/plugin pull in a File, use walks a Path. Either that module is bound under UseDecl::dbg, or its public members are spliced into the current scope. Defaults to priv; whatever it binds or splices carries this decl's own Vis, so only pub re-exports.

Definition at line 893 of file ast.h.

Constructor & Destructor Documentation

◆ UseDecl() [1/2]

mim::ast::UseDecl::UseDecl ( Loc loc,
Mods mods,
Ptr< Path > path,
Dbg alias )
inline

use path [as alias|*];; no alias means as *.

Definition at line 896 of file ast.h.

References alias(), mim::ast::Node::loc(), mim::ast::ValDecl::mods(), path(), and mim::ast::ValDecl::ValDecl().

Referenced by bind().

◆ UseDecl() [2/2]

mim::ast::UseDecl::UseDecl ( Loc loc,
Mods mods,
Tok::Tag tag,
Ptr< Path > path,
Sym file_path,
Dbg alias,
bool splice,
const File * file )
inline

import/plugin; name is the module name, derived from file_path if there is one.

The File itself is owned by the AST and shared by all its importers.

Definition at line 905 of file ast.h.

References alias(), file(), file_path(), mim::ast::Node::loc(), mim::ast::ValDecl::mods(), path(), tag(), and mim::ast::ValDecl::ValDecl().

Member Function Documentation

◆ alias()

Dbg mim::ast::UseDecl::alias ( ) const
inline

Empty, unless the source spelled as I.

Definition at line 917 of file ast.h.

Referenced by stream(), UseDecl(), and UseDecl().

◆ bind()

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

◆ dbg()

Dbg mim::ast::UseDecl::dbg ( ) const
inlineoverridevirtual

The name this decl introduces; anonymous if it splices instead.

Reimplemented from mim::ast::Decl.

Definition at line 924 of file ast.h.

References is_splice().

Referenced by bind().

◆ emit()

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

Implements mim::ast::ValDecl.

Definition at line 58 of file emit.cpp.

References mim::ast::File::emit(), and file().

◆ file()

const File * mim::ast::UseDecl::file ( ) const
inline

Definition at line 920 of file ast.h.

Referenced by bind(), emit(), and UseDecl().

◆ file_path()

Sym mim::ast::UseDecl::file_path ( ) const
inline

Spelling of an import "..."; empty otherwise.

Definition at line 918 of file ast.h.

Referenced by stream(), and UseDecl().

◆ is_file_path()

bool mim::ast::UseDecl::is_file_path ( ) const
inline

Definition at line 919 of file ast.h.

Referenced by stream().

◆ is_import()

bool mim::ast::UseDecl::is_import ( ) const
inline

Definition at line 915 of file ast.h.

Referenced by stream().

◆ is_splice()

bool mim::ast::UseDecl::is_splice ( ) const
inline

as *: splice the module's public members, bind no name.

Definition at line 921 of file ast.h.

Referenced by bind(), dbg(), and stream().

◆ path()

const Path * mim::ast::UseDecl::path ( ) const
inline

Module path of a use; module name of an import/plugin.

Definition at line 916 of file ast.h.

Referenced by stream(), UseDecl(), and UseDecl().

◆ scope()

const Scope * mim::ast::UseDecl::scope ( ) const
inlineoverridevirtual

Non-nullptr if this Decl is a module whose members a Path may walk into.

Reimplemented from mim::ast::Decl.

Definition at line 926 of file ast.h.

◆ stream()

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

◆ tag()

Tok::Tag mim::ast::UseDecl::tag ( ) const
inline

import, plugin, or use.

Definition at line 914 of file ast.h.

Referenced by stream(), and UseDecl().


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